All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Eddie James <eajames@linux.ibm.com>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	jdelvare@suse.com
Subject: Re: [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Fix LED blink behavior
Date: Wed, 6 Nov 2019 14:38:08 -0800	[thread overview]
Message-ID: <20191106223808.GA20956@roeck-us.net> (raw)
In-Reply-To: <20191106200106.29519-3-eajames@linux.ibm.com>

On Wed, Nov 06, 2019 at 02:01:06PM -0600, Eddie James wrote:
> The LED blink_set function incorrectly did not tell the PSU LED to blink
> if brightness was LED_OFF. Fix this, and also correct the LED_OFF
> command data, which should give control of the LED back to the PSU
> firmware. Also prevent I2C failures from getting the driver LED state
> out of sync and add some dev_dbg statements.
> 
> Signed-off-by: Eddie James <eajames@linux.ibm.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/pmbus/ibm-cffps.c | 27 +++++++++++++++++++--------
>  1 file changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
> index c6a00e83aac6..d359b76bcb36 100644
> --- a/drivers/hwmon/pmbus/ibm-cffps.c
> +++ b/drivers/hwmon/pmbus/ibm-cffps.c
> @@ -44,9 +44,13 @@
>  #define CFFPS_MFR_VAUX_FAULT			BIT(6)
>  #define CFFPS_MFR_CURRENT_SHARE_WARNING		BIT(7)
>  
> +/*
> + * LED off state actually relinquishes LED control to PSU firmware, so it can
> + * turn on the LED for faults.
> + */
> +#define CFFPS_LED_OFF				0
>  #define CFFPS_LED_BLINK				BIT(0)
>  #define CFFPS_LED_ON				BIT(1)
> -#define CFFPS_LED_OFF				BIT(2)
>  #define CFFPS_BLINK_RATE_MS			250
>  
>  enum {
> @@ -301,23 +305,31 @@ static int ibm_cffps_led_brightness_set(struct led_classdev *led_cdev,
>  					enum led_brightness brightness)
>  {
>  	int rc;
> +	u8 next_led_state;
>  	struct ibm_cffps *psu = container_of(led_cdev, struct ibm_cffps, led);
>  
>  	if (brightness == LED_OFF) {
> -		psu->led_state = CFFPS_LED_OFF;
> +		next_led_state = CFFPS_LED_OFF;
>  	} else {
>  		brightness = LED_FULL;
> +
>  		if (psu->led_state != CFFPS_LED_BLINK)
> -			psu->led_state = CFFPS_LED_ON;
> +			next_led_state = CFFPS_LED_ON;
> +		else
> +			next_led_state = CFFPS_LED_BLINK;
>  	}
>  
> +	dev_dbg(&psu->client->dev, "LED brightness set: %d. Command: %d.\n",
> +		brightness, next_led_state);
> +
>  	pmbus_set_page(psu->client, 0);
>  
>  	rc = i2c_smbus_write_byte_data(psu->client, CFFPS_SYS_CONFIG_CMD,
> -				       psu->led_state);
> +				       next_led_state);
>  	if (rc < 0)
>  		return rc;
>  
> +	psu->led_state = next_led_state;
>  	led_cdev->brightness = brightness;
>  
>  	return 0;
> @@ -330,10 +342,7 @@ static int ibm_cffps_led_blink_set(struct led_classdev *led_cdev,
>  	int rc;
>  	struct ibm_cffps *psu = container_of(led_cdev, struct ibm_cffps, led);
>  
> -	psu->led_state = CFFPS_LED_BLINK;
> -
> -	if (led_cdev->brightness == LED_OFF)
> -		return 0;
> +	dev_dbg(&psu->client->dev, "LED blink set.\n");
>  
>  	pmbus_set_page(psu->client, 0);
>  
> @@ -342,6 +351,8 @@ static int ibm_cffps_led_blink_set(struct led_classdev *led_cdev,
>  	if (rc < 0)
>  		return rc;
>  
> +	psu->led_state = CFFPS_LED_BLINK;
> +	led_cdev->brightness = LED_FULL;
>  	*delay_on = CFFPS_BLINK_RATE_MS;
>  	*delay_off = CFFPS_BLINK_RATE_MS;
>  

      reply	other threads:[~2019-11-06 22:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06 20:01 [PATCH 0/2] hwmon: (pmbus/ibm-cffps) Fixes for the LED subsystem Eddie James
2019-11-06 20:01 ` [PATCH 1/2] hwmon: (pmbus/ibm-cffps) Switch LEDs to blocking brightness call Eddie James
2019-11-06 22:35   ` Guenter Roeck
2019-11-06 20:01 ` [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Fix LED blink behavior Eddie James
2019-11-06 22:38   ` Guenter Roeck [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=20191106223808.GA20956@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=eajames@linux.ibm.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.