Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gpio: amd-fch: ionly return allowed values from amd_fch_gpio_get()

As of 86ef402d805d ("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: 86ef402d805d ("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>

authored by

Dmitry Torokhov and committed by
Bartosz Golaszewski
fbd03587 6766f590

+4 -3
+4 -3
drivers/gpio/gpio-amd-fch.c
··· 8 8 * 9 9 */ 10 10 11 + #include <linux/bitfield.h> 11 12 #include <linux/err.h> 12 13 #include <linux/io.h> 13 14 #include <linux/kernel.h> ··· 121 120 unsigned int offset) 122 121 { 123 122 unsigned long flags; 124 - int ret; 123 + u32 val; 125 124 struct amd_fch_gpio_priv *priv = gpiochip_get_data(gc); 126 125 void __iomem *ptr = amd_fch_gpio_addr(priv, offset); 127 126 128 127 spin_lock_irqsave(&priv->lock, flags); 129 - ret = (readl_relaxed(ptr) & AMD_FCH_GPIO_FLAG_READ); 128 + val = readl_relaxed(ptr); 130 129 spin_unlock_irqrestore(&priv->lock, flags); 131 130 132 - return ret; 131 + return FIELD_GET(AMD_FCH_GPIO_FLAG_READ, val); 133 132 } 134 133 135 134 static int amd_fch_gpio_request(struct gpio_chip *chip,