summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorEmil Renner Berthing <emil.renner.berthing@canonical.com>2024-10-11 16:48:25 +0200
committerLinus Walleij <linus.walleij@linaro.org>2024-10-11 21:27:41 +0200
commit1fc30cd9277063bb797eeafe73a1f3faa6177492 (patch)
tree8a3281cec09d6ffae7981acd28e7f17c5aa5c679 /drivers
parentd1e16e219901965e6c0715adb92750ed865fda43 (diff)
pinctrl: th1520: Factor out casts
Limit the casts to get the mux data and flags from the driver data pointer with each pin to two inline functions as requested by Andy during review. Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com> Reviewed-by: Drew Fustini <dfustini@tenstorrent.com> Tested-by: Drew Fustini <dfustini@tenstorrent.com> Link: https://lore.kernel.org/20241011144826.381104-4-emil.renner.berthing@canonical.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pinctrl/pinctrl-th1520.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/pinctrl/pinctrl-th1520.c b/drivers/pinctrl/pinctrl-th1520.c
index 8bd40cb2f013..7474d8da32f9 100644
--- a/drivers/pinctrl/pinctrl-th1520.c
+++ b/drivers/pinctrl/pinctrl-th1520.c
@@ -152,6 +152,16 @@ static enum th1520_muxtype th1520_muxtype_get(const char *str)
(TH1520_MUX_##m0 << 0) | (TH1520_MUX_##m1 << 5) | (TH1520_MUX_##m2 << 10) | \
(TH1520_MUX_##m3 << 15) | (TH1520_MUX_##m4 << 20) | (TH1520_MUX_##m5 << 25)) }
+static unsigned long th1520_pad_muxdata(void *drv_data)
+{
+ return (uintptr_t)drv_data & TH1520_PAD_MUXDATA;
+}
+
+static bool th1520_pad_no_padcfg(void *drv_data)
+{
+ return (uintptr_t)drv_data & TH1520_PAD_NO_PADCFG;
+}
+
static const struct pinctrl_pin_desc th1520_group1_pins[] = {
TH1520_PAD(0, OSC_CLK_IN, ____, ____, ____, ____, ____, ____, TH1520_PAD_NO_PADCFG),
TH1520_PAD(1, OSC_CLK_OUT, ____, ____, ____, ____, ____, ____, TH1520_PAD_NO_PADCFG),
@@ -590,7 +600,7 @@ static int th1520_pinconf_get(struct pinctrl_dev *pctldev,
u32 value;
u32 arg;
- if ((uintptr_t)desc->drv_data & TH1520_PAD_NO_PADCFG)
+ if (th1520_pad_no_padcfg(desc->drv_data))
return -ENOTSUPP;
value = readl_relaxed(th1520_padcfg(thp, pin));
@@ -660,7 +670,7 @@ static int th1520_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
unsigned int i;
u16 mask, value;
- if ((uintptr_t)desc->drv_data & TH1520_PAD_NO_PADCFG)
+ if (th1520_pad_no_padcfg(desc->drv_data))
return -ENOTSUPP;
mask = 0;
@@ -793,12 +803,14 @@ static int th1520_pinmux_set_mux(struct pinctrl_dev *pctldev,
{
struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev);
const struct function_desc *func = pinmux_generic_get_function(pctldev, fsel);
+ enum th1520_muxtype muxtype = (uintptr_t)func->data;
if (!func)
return -EINVAL;
+
return th1520_pinmux_set(thp, thp->desc.pins[gsel].number,
- (uintptr_t)thp->desc.pins[gsel].drv_data & TH1520_PAD_MUXDATA,
- (uintptr_t)func->data);
+ th1520_pad_muxdata(thp->desc.pins[gsel].drv_data),
+ muxtype);
}
static int th1520_gpio_request_enable(struct pinctrl_dev *pctldev,
@@ -809,7 +821,7 @@ static int th1520_gpio_request_enable(struct pinctrl_dev *pctldev,
const struct pin_desc *desc = pin_desc_get(pctldev, offset);
return th1520_pinmux_set(thp, offset,
- (uintptr_t)desc->drv_data & TH1520_PAD_MUXDATA,
+ th1520_pad_muxdata(desc->drv_data),
TH1520_MUX_GPIO);
}