mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Naresh Solanki <naresh.solanki@9elements.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org, Jean Delvare <jdelvare@suse.com>,
	Patrick Rudolph <patrick.rudolph@9elements.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6] hwmon: (pmbus/core): Implement regulator get_status
Date: Fri, 25 Nov 2022 21:23:47 +0530	[thread overview]
Message-ID: <8765db57-3de8-60c1-895c-4a01322df1bd@9elements.com> (raw)
In-Reply-To: <20221125155146.GA1169995@roeck-us.net>



On 25-11-2022 09:21 pm, Guenter Roeck wrote:
> On Thu, Nov 24, 2022 at 08:36:42PM +0100, Naresh Solanki wrote:
>> From: Patrick Rudolph <patrick.rudolph@9elements.com>
>>
>> Add get_status for pmbus_regulator_ops.
>> ---
> 
> Adding "---" into the commit description causes everything afterwards
> to get lost when applying the patch, including the signatures.
> I fixed it up and applied it, but please don't do that in the future.
Sure. Thanks
> 
> Guenter
> 
>> Changes:
>> - use lock throughout the function
>> - Avoid line continuation upto 100 column
>> - Optimize use of & and | operator
>> - Check for VOUT, IOUT, TEMPERATURE bit in status word before checking
>>    respective status register for fault.
>> - Report regulator current status.
>> - Utilize get_error_flag to check for regulator errors.
>> - Check for return value of function get_error_flag
>> - Use function pmbus_regulator_get_error_flags directly
>>
>> Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
>> Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
>> ---
>>   drivers/hwmon/pmbus/pmbus_core.c | 44 ++++++++++++++++++++++++++++++++
>>   1 file changed, 44 insertions(+)
>>
>>
>> base-commit: 2c71b3246ec3246522e8cb7c8191dc7a5d62cc70
>>
>> diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
>> index 20ca26e19db7..95e95783972a 100644
>> --- a/drivers/hwmon/pmbus/pmbus_core.c
>> +++ b/drivers/hwmon/pmbus/pmbus_core.c
>> @@ -2855,6 +2855,49 @@ static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned
>>   	return 0;
>>   }
>>   
>> +static int pmbus_regulator_get_status(struct regulator_dev *rdev)
>> +{
>> +	struct device *dev = rdev_get_dev(rdev);
>> +	struct i2c_client *client = to_i2c_client(dev->parent);
>> +	struct pmbus_data *data = i2c_get_clientdata(client);
>> +	u8 page = rdev_get_id(rdev);
>> +	int status, ret;
>> +
>> +	mutex_lock(&data->update_lock);
>> +	status = pmbus_get_status(client, page, PMBUS_STATUS_WORD);
>> +	if (status < 0) {
>> +		ret = status;
>> +		goto unlock;
>> +	}
>> +
>> +	if (status & PB_STATUS_OFF) {
>> +		ret = REGULATOR_STATUS_OFF;
>> +		goto unlock;
>> +	}
>> +
>> +	/* If regulator is ON & reports power good then return ON */
>> +	if (!(status & PB_STATUS_POWER_GOOD_N)) {
>> +		ret = REGULATOR_STATUS_ON;
>> +		goto unlock;
>> +	}
>> +
>> +	ret = pmbus_regulator_get_error_flags(rdev, &status);
>> +	if (ret)
>> +		goto unlock;
>> +
>> +	if (status & (REGULATOR_ERROR_UNDER_VOLTAGE | REGULATOR_ERROR_OVER_CURRENT |
>> +	   REGULATOR_ERROR_REGULATION_OUT | REGULATOR_ERROR_FAIL | REGULATOR_ERROR_OVER_TEMP)) {
>> +		ret = REGULATOR_STATUS_ERROR;
>> +		goto unlock;
>> +	}
>> +
>> +	ret = REGULATOR_STATUS_UNDEFINED;
>> +
>> +unlock:
>> +	mutex_unlock(&data->update_lock);
>> +	return ret;
>> +}
>> +
>>   static int pmbus_regulator_get_low_margin(struct i2c_client *client, int page)
>>   {
>>   	struct pmbus_data *data = i2c_get_clientdata(client);
>> @@ -2995,6 +3038,7 @@ const struct regulator_ops pmbus_regulator_ops = {
>>   	.disable = pmbus_regulator_disable,
>>   	.is_enabled = pmbus_regulator_is_enabled,
>>   	.get_error_flags = pmbus_regulator_get_error_flags,
>> +	.get_status = pmbus_regulator_get_status,
>>   	.get_voltage = pmbus_regulator_get_voltage,
>>   	.set_voltage = pmbus_regulator_set_voltage,
>>   	.list_voltage = pmbus_regulator_list_voltage,

Naresh

      reply	other threads:[~2022-11-25 15:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 19:36 Naresh Solanki
2022-11-25 15:51 ` Guenter Roeck
2022-11-25 15:53   ` Naresh Solanki [this message]

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=8765db57-3de8-60c1-895c-4a01322df1bd@9elements.com \
    --to=naresh.solanki@9elements.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=patrick.rudolph@9elements.com \
    /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

all inboxes | Powered by JetHome®