Skip to content

Commit fbd0358

Browse files
dtorBartosz Golaszewski
authored andcommitted
gpio: amd-fch: ionly return allowed values from amd_fch_gpio_get()
As of 86ef402 ("gpiolib: sanitize the return value of gpio_chip::get()") gpiolib requires drivers implementing GPIOs to only return 0, 1 or negative error for the get() callbacks. Ensure that amd-fch complies with this requirement. Fixes: 86ef402 ("gpiolib: sanitize the return value of gpio_chip::get()") Reported-and-tested-by: Tj <tj.iam.tj@proton.me> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Link: https://patch.msgid.link/aZTlwnvHt2Gho4yN@google.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent 6766f59 commit fbd0358

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/gpio/gpio-amd-fch.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*
99
*/
1010

11+
#include <linux/bitfield.h>
1112
#include <linux/err.h>
1213
#include <linux/io.h>
1314
#include <linux/kernel.h>
@@ -120,15 +121,15 @@ static int amd_fch_gpio_get(struct gpio_chip *gc,
120121
unsigned int offset)
121122
{
122123
unsigned long flags;
123-
int ret;
124+
u32 val;
124125
struct amd_fch_gpio_priv *priv = gpiochip_get_data(gc);
125126
void __iomem *ptr = amd_fch_gpio_addr(priv, offset);
126127

127128
spin_lock_irqsave(&priv->lock, flags);
128-
ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_READ);
129+
val = readl_relaxed(ptr);
129130
spin_unlock_irqrestore(&priv->lock, flags);
130131

131-
return ret;
132+
return FIELD_GET(AMD_FCH_GPIO_FLAG_READ, val);
132133
}
133134

134135
static int amd_fch_gpio_request(struct gpio_chip *chip,

0 commit comments

Comments
 (0)