From: Bjorn Andersson Date: Mon, 31 Mar 2014 21:49:55 +0000 (-0700) Subject: pinctrl: msm: Make number of functions variable X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3c25381f9b3375c326f5ead194cb91b5ac181f08;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git pinctrl: msm: Make number of functions variable The various pins may have different number of functions defined, so make this number definable per pin instead of just increasing it to the largest one for all of the platforms. Signed-off-by: Bjorn Andersson Signed-off-by: Linus Walleij --- diff --git a/drivers/pinctrl/pinctrl-msm.c b/drivers/pinctrl/pinctrl-msm.c index e43fbce56598..5fa9341cc589 100644 --- a/drivers/pinctrl/pinctrl-msm.c +++ b/drivers/pinctrl/pinctrl-msm.c @@ -145,12 +145,12 @@ static int msm_pinmux_enable(struct pinctrl_dev *pctldev, if (WARN_ON(g->mux_bit < 0)) return -EINVAL; - for (i = 0; i < ARRAY_SIZE(g->funcs); i++) { + for (i = 0; i < g->nfuncs; i++) { if (g->funcs[i] == function) break; } - if (WARN_ON(i == ARRAY_SIZE(g->funcs))) + if (WARN_ON(i == g->nfuncs)) return -EINVAL; spin_lock_irqsave(&pctrl->lock, flags); diff --git a/drivers/pinctrl/pinctrl-msm.h b/drivers/pinctrl/pinctrl-msm.h index 6e26f1b676d7..7b2a227a590a 100644 --- a/drivers/pinctrl/pinctrl-msm.h +++ b/drivers/pinctrl/pinctrl-msm.h @@ -65,7 +65,8 @@ struct msm_pingroup { const unsigned *pins; unsigned npins; - unsigned funcs[8]; + unsigned *funcs; + unsigned nfuncs; s16 ctl_reg; s16 io_reg; diff --git a/drivers/pinctrl/pinctrl-msm8x74.c b/drivers/pinctrl/pinctrl-msm8x74.c index dde5529807aa..57766d56e257 100644 --- a/drivers/pinctrl/pinctrl-msm8x74.c +++ b/drivers/pinctrl/pinctrl-msm8x74.c @@ -341,7 +341,7 @@ static const unsigned int sdc2_data_pins[] = { 151 }; .name = "gpio" #id, \ .pins = gpio##id##_pins, \ .npins = ARRAY_SIZE(gpio##id##_pins), \ - .funcs = { \ + .funcs = (int[]){ \ MSM_MUX_NA, /* gpio mode */ \ MSM_MUX_##f1, \ MSM_MUX_##f2, \ @@ -351,6 +351,7 @@ static const unsigned int sdc2_data_pins[] = { 151 }; MSM_MUX_##f6, \ MSM_MUX_##f7 \ }, \ + .nfuncs = 8, \ .ctl_reg = 0x1000 + 0x10 * id, \ .io_reg = 0x1004 + 0x10 * id, \ .intr_cfg_reg = 0x1008 + 0x10 * id, \