From: Guenter Roeck <linux@roeck-us.net>
To: Andrew Jeffery <andrew@aj.id.au>
Cc: linux-hwmon@vger.kernel.org, jdelvare@suse.com, corbet@lwn.net,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, joel@jms.id.au,
openbmc@lists.ozlabs.org
Subject: Re: [v6,3/4] pmbus (core): Add virtual page config bit
Date: Wed, 29 Nov 2017 13:15:18 -0800 [thread overview]
Message-ID: <20171129211518.GA22235@roeck-us.net> (raw)
In-Reply-To: <57d31e056da37bab946a42c30c1aa4f0a0a595f1.1511152748.git-series.andrew@aj.id.au>
On Mon, Nov 20, 2017 at 03:12:05PM +1030, 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. An example of this is the Maxim MAX31785 controller,
> which extends the READ_FAN_SPEED_1 PMBus register from two to four bytes
> to support tach readings for both rotors of a dual rotor fan. This extended
> register contains two word-sized values, one reporting the rate of the
> fastest rotor, the other the rate of the slowest. The concept of virtual
> pages aids this situation by mapping the page number onto the value to be
> selected from the vectored result.
>
> We should not try to set virtual pages on the device as such a page
> explicitly doesn't exist; add a flag so we can avoid doing so.
>
> Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/pmbus/pmbus.h | 2 ++
> drivers/hwmon/pmbus/pmbus_core.c | 27 ++++++++++++++++++---------
> 2 files changed, 20 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
> index b54d7604d3ef..d39d506aa63e 100644
> --- a/drivers/hwmon/pmbus/pmbus.h
> +++ b/drivers/hwmon/pmbus/pmbus.h
> @@ -372,6 +372,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, vr13 };
>
> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> index edc25efe7552..e215bbd403a5 100644
> --- a/drivers/hwmon/pmbus/pmbus_core.c
> +++ b/drivers/hwmon/pmbus/pmbus_core.c
> @@ -161,18 +161,27 @@ EXPORT_SYMBOL_GPL(pmbus_clear_cache);
> int pmbus_set_page(struct i2c_client *client, int page)
> {
> struct pmbus_data *data = i2c_get_clientdata(client);
> - int rv = 0;
> - int newpage;
> + int rv;
> +
> + if (page < 0 || page == data->currpage)
> + return 0;
>
> - if (page >= 0 && page != data->currpage) {
> + 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;
> + if (rv < 0)
> + return rv;
> +
> + rv = i2c_smbus_read_byte_data(client, PMBUS_PAGE);
> + if (rv < 0)
> + return rv;
> +
> + if (rv != page)
> + return -EIO;
> }
> - return rv;
> +
> + data->currpage = page;
> +
> + return 0;
> }
> EXPORT_SYMBOL_GPL(pmbus_set_page);
>
next prev parent reply other threads:[~2017-11-29 21:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-20 4:42 [PATCH v6 0/4] pmbus: Expand fan support and add MAX31785 driver Andrew Jeffery
2017-11-20 4:42 ` [PATCH v6 1/4] pmbus (core): Add fan control support Andrew Jeffery
2017-11-29 21:10 ` [v6,1/4] " Guenter Roeck
2017-11-20 4:42 ` [PATCH v6 2/4] pmbus (max31785): Add fan control Andrew Jeffery
2017-11-29 21:13 ` [v6,2/4] " Guenter Roeck
2017-11-20 4:42 ` [PATCH v6 3/4] pmbus (core): Add virtual page config bit Andrew Jeffery
2017-11-29 21:15 ` Guenter Roeck [this message]
2017-11-20 4:42 ` [PATCH v6 4/4] pmbus (max31785): Add dual tachometer support Andrew Jeffery
2017-11-29 21:17 ` [v6,4/4] " Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171129211518.GA22235@roeck-us.net \
--to=linux@roeck-us.net \
--cc=andrew@aj.id.au \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=joel@jms.id.au \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=openbmc@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox