sh-pfc: Simplify the sh_pfc_gpio_is_pin() logic
The function is guaranteed to be called with a gpio number smaller than
nr_pins. The condition can the be simplified, and the function inlined.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c
index 3ad938f..db9af4e 100644
--- a/drivers/pinctrl/sh-pfc/gpio.c
+++ b/drivers/pinctrl/sh-pfc/gpio.c
@@ -42,6 +42,11 @@
static int gpio_pin_request(struct gpio_chip *gc, unsigned offset)
{
+ struct sh_pfc *pfc = gpio_to_pfc(gc);
+
+ if (pfc->info->pins[offset].enum_id == 0)
+ return -EINVAL;
+
return pinctrl_request_gpio(offset);
}
@@ -52,12 +57,10 @@
static void gpio_pin_set_value(struct sh_pfc *pfc, unsigned offset, int value)
{
- struct pinmux_data_reg *dr = NULL;
- int bit = 0;
+ struct pinmux_data_reg *dr;
+ int bit;
- if (sh_pfc_get_data_reg(pfc, offset, &dr, &bit) != 0)
- BUG();
-
+ sh_pfc_get_data_reg(pfc, offset, &dr, &bit);
sh_pfc_write_bit(dr, bit, value);
}
@@ -77,12 +80,10 @@
static int gpio_pin_get(struct gpio_chip *gc, unsigned offset)
{
struct sh_pfc *pfc = gpio_to_pfc(gc);
- struct pinmux_data_reg *dr = NULL;
- int bit = 0;
+ struct pinmux_data_reg *dr;
+ int bit;
- if (sh_pfc_get_data_reg(pfc, offset, &dr, &bit) != 0)
- return -EINVAL;
-
+ sh_pfc_get_data_reg(pfc, offset, &dr, &bit);
return sh_pfc_read_bit(dr, bit);
}