Skip to content

Commit 1fc30cd

Browse files
esmillinusw
authored andcommitted
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 <[email protected]> Reviewed-by: Drew Fustini <[email protected]> Tested-by: Drew Fustini <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent d1e16e2 commit 1fc30cd

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

drivers/pinctrl/pinctrl-th1520.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ static enum th1520_muxtype th1520_muxtype_get(const char *str)
152152
(TH1520_MUX_##m0 << 0) | (TH1520_MUX_##m1 << 5) | (TH1520_MUX_##m2 << 10) | \
153153
(TH1520_MUX_##m3 << 15) | (TH1520_MUX_##m4 << 20) | (TH1520_MUX_##m5 << 25)) }
154154

155+
static unsigned long th1520_pad_muxdata(void *drv_data)
156+
{
157+
return (uintptr_t)drv_data & TH1520_PAD_MUXDATA;
158+
}
159+
160+
static bool th1520_pad_no_padcfg(void *drv_data)
161+
{
162+
return (uintptr_t)drv_data & TH1520_PAD_NO_PADCFG;
163+
}
164+
155165
static const struct pinctrl_pin_desc th1520_group1_pins[] = {
156166
TH1520_PAD(0, OSC_CLK_IN, ____, ____, ____, ____, ____, ____, TH1520_PAD_NO_PADCFG),
157167
TH1520_PAD(1, OSC_CLK_OUT, ____, ____, ____, ____, ____, ____, TH1520_PAD_NO_PADCFG),
@@ -590,7 +600,7 @@ static int th1520_pinconf_get(struct pinctrl_dev *pctldev,
590600
u32 value;
591601
u32 arg;
592602

593-
if ((uintptr_t)desc->drv_data & TH1520_PAD_NO_PADCFG)
603+
if (th1520_pad_no_padcfg(desc->drv_data))
594604
return -ENOTSUPP;
595605

596606
value = readl_relaxed(th1520_padcfg(thp, pin));
@@ -660,7 +670,7 @@ static int th1520_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
660670
unsigned int i;
661671
u16 mask, value;
662672

663-
if ((uintptr_t)desc->drv_data & TH1520_PAD_NO_PADCFG)
673+
if (th1520_pad_no_padcfg(desc->drv_data))
664674
return -ENOTSUPP;
665675

666676
mask = 0;
@@ -793,12 +803,14 @@ static int th1520_pinmux_set_mux(struct pinctrl_dev *pctldev,
793803
{
794804
struct th1520_pinctrl *thp = pinctrl_dev_get_drvdata(pctldev);
795805
const struct function_desc *func = pinmux_generic_get_function(pctldev, fsel);
806+
enum th1520_muxtype muxtype = (uintptr_t)func->data;
796807

797808
if (!func)
798809
return -EINVAL;
810+
799811
return th1520_pinmux_set(thp, thp->desc.pins[gsel].number,
800-
(uintptr_t)thp->desc.pins[gsel].drv_data & TH1520_PAD_MUXDATA,
801-
(uintptr_t)func->data);
812+
th1520_pad_muxdata(thp->desc.pins[gsel].drv_data),
813+
muxtype);
802814
}
803815

804816
static int th1520_gpio_request_enable(struct pinctrl_dev *pctldev,
@@ -809,7 +821,7 @@ static int th1520_gpio_request_enable(struct pinctrl_dev *pctldev,
809821
const struct pin_desc *desc = pin_desc_get(pctldev, offset);
810822

811823
return th1520_pinmux_set(thp, offset,
812-
(uintptr_t)desc->drv_data & TH1520_PAD_MUXDATA,
824+
th1520_pad_muxdata(desc->drv_data),
813825
TH1520_MUX_GPIO);
814826
}
815827

0 commit comments

Comments
 (0)