[PATCH linux dev-4.10 1/3] hwmon: pmbus: core: Add virtual page config bit

Matt Spinler mspinler at linux.vnet.ibm.com
Fri Oct 27 07:58:44 AEDT 2017


Reviewed-by: Matt Spinler mspinler at linux.vnet.ibm.com


On 10/26/2017 1:19 AM, Andrew Jeffery wrote:
> Some circumstances call for virtual pages to expose multiple values
> packed into an extended PMBus register in a manner non-compliant with
> the PMBus standard. We should not try to set virtual pages on the
> device; add a flag so we can avoid doing so.
>
> Cc: Eddie James <eajames at linux.vnet.ibm.com>
> Cc: Matt Spinler <mspinler at linux.vnet.ibm.com>
> Signed-off-by: Andrew Jeffery <andrew at aj.id.au>
> ---
>   drivers/hwmon/pmbus/pmbus.h      |  2 ++
>   drivers/hwmon/pmbus/pmbus_core.c | 12 ++++++++----
>   2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
> index a863b8fed16f..fd422cd76452 100644
> --- a/drivers/hwmon/pmbus/pmbus.h
> +++ b/drivers/hwmon/pmbus/pmbus.h
> @@ -367,6 +367,8 @@ enum pmbus_sensor_classes {
>   #define PMBUS_HAVE_PWM12	BIT(20)
>   #define PMBUS_HAVE_PWM34	BIT(21)
>
> +#define PMBUS_PAGE_VIRTUAL	BIT(31)
> +
>   enum pmbus_data_format { linear = 0, direct, vid };
>   enum vrm_version { vr11 = 0, vr12 };
>
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index f72f966f5251..390a7b02b836 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -164,14 +164,18 @@ int pmbus_set_page(struct i2c_client *client, u8 page)
>   	int rv = 0;
>   	int newpage;
>
> -	if (page != data->currpage) {
> +	if (page == data->currpage)
> +		return 0;
> +
> +	if (!(data->info->func[page] & PMBUS_PAGE_VIRTUAL)) {
>   		rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
>   		newpage = i2c_smbus_read_byte_data(client, PMBUS_PAGE);
>   		if (newpage != page)
> -			rv = -EIO;
> -		else
> -			data->currpage = page;
> +			return -EIO;
>   	}
> +
> +	data->currpage = page;
> +
>   	return rv;
>   }
>   EXPORT_SYMBOL_GPL(pmbus_set_page);



More information about the openbmc mailing list