Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4827338ybl; Wed, 22 Jan 2020 05:29:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzIXIqagN/mJLkR4mcXeRSjLyYxcVMTYt032cZGY7lLhtwdrsq9xP1p5F/q+0Sn7CBjptgO X-Received: by 2002:a05:6808:9a4:: with SMTP id e4mr6887997oig.127.1579699766079; Wed, 22 Jan 2020 05:29:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699766; cv=none; d=google.com; s=arc-20160816; b=uvdJXVkHmcNGJkSBI6doQ7N9KZnFm/6Ip1LpA33fZ9yHTuUNHBRooGwER30eHpXDxM o6xRWlcWTN9kc0eX7xZ0Xt68dpCONS5ly6LdKBl4jFE21aNcA0uDHMx68JZWcX2nYBbs valx9lKPbj+DCi0mUprChTmMEJtV+Cel/dDtZ5PeK2nZqfAgiYc/lLkfCSRzrkyayP5L CguLjLm9URBaBzN26qWI3WZBbT4D68EKpJDGUZujSPmsvXIHao0dtIREmfgWrZD/lMrJ NxcVoWcOOsxdGbWAC7poV0cDPOLRq9Vc1fiRQe6JVmB4vFG1ZA5hc82ooNnEP3L+zBJR LULw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=54FNUn5NkrTpGz4kSuHfL/1/epzfmjbq/R/mAa33QsQ=; b=ONfSN8xSliiYpK9k7aSWnB55X8llMB1iaZLqdrdk/DTk7Z3VDmc8Kf8tPpQ8RDZOri /6mxI/MFYvygkatcH1Dxj6b5a8ZL6CblTs7beV+p/udkETZI5r7gqK24Ndq8eqRMCsbK P7kj4VI5Nj2VISlIiv4an4Rf/3WCrl0O1iRNZ3FH5hlT7omn6A7PKqh1jB/Uozw50vMm 3CTrY90xcgl7BXZNlZcFHcKJW33BkfH9Het5QNBWd6xiyUxvyMdbOVBEH+plO2SOeMMq HE9FD5WIOzUashS6nSUFjADwxl37511xtJJ2HgaMU+WvaroWu9vT1IaN+jZtTgB6BWuT TAdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="wF+/ZCs5"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m17si23873636otr.17.2020.01.22.05.29.14; Wed, 22 Jan 2020 05:29:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="wF+/ZCs5"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731058AbgAVN2X (ORCPT + 99 others); Wed, 22 Jan 2020 08:28:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:50514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729475AbgAVN2V (ORCPT ); Wed, 22 Jan 2020 08:28:21 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CD745205F4; Wed, 22 Jan 2020 13:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699700; bh=B0o91/X1hA5pHnJBim6slfSMQUUad8ZS+O7ujX7kfsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wF+/ZCs5qV69Ha5k4OmTzv5Vu0ONF7eUS5mtJluHSUU7iJAGkX0UPZ2UAx1F/GSHT dv2bFctAWHYDY0M61wbYkeg1pfTpFasKwLkqw4XI71nj/HRMuDgCjcjWLFVWZrXaGn PVLq/Xm2QeD4cwtGqtwemUlTreIOiwVm9DuCnRzQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eddie James , Guenter Roeck Subject: [PATCH 5.4 222/222] hwmon: (pmbus/ibm-cffps) Fix LED blink behavior Date: Wed, 22 Jan 2020 10:30:08 +0100 Message-Id: <20200122092849.577706593@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eddie James commit 92b39ad440968bab38eb6577d63c12994601ed94 upstream. 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 Link: https://lore.kernel.org/r/20191106200106.29519-3-eajames@linux.ibm.com Fixes: ef9e1cdf419a3 ("hwmon: (pmbus/cffps) Add led class device for power supply fault led") Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/pmbus/ibm-cffps.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) --- a/drivers/hwmon/pmbus/ibm-cffps.c +++ b/drivers/hwmon/pmbus/ibm-cffps.c @@ -39,9 +39,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 { @@ -296,23 +300,31 @@ static int ibm_cffps_led_brightness_set( 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; @@ -325,10 +337,7 @@ static int ibm_cffps_led_blink_set(struc 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); @@ -337,6 +346,8 @@ static int ibm_cffps_led_blink_set(struc 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;