[PATCH 4/5] pinctrl: mediatek: common-v1: Commonize spec_pupd callback
Chen-Yu Tsai
wenst at chromium.org
Mon Feb 21 18:55:16 PST 2022
On Mon, Feb 21, 2022 at 5:59 PM Chen-Yu Tsai <wenst at chromium.org> wrote:
>
> On Thu, Feb 10, 2022 at 10:20 PM AngeloGioacchino Del Regno
> <angelogioacchino.delregno at collabora.com> wrote:
> >
> > Reduce code size and duplication by using a common spec_pupd callback,
> > which is possible to use on all of the pinctrl drivers that are
> > using the v1 pinctrl-mtk-common code, with the exception of mt8135,
> > which has a different handling compared to the others.
> > Since the callback function signature was changed, this had to be
> > propagated to pinctrl-mt8135's spec_pull_set().
> >
> > Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno at collabora.com>
> > ---
>
> [...]
>
> > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> > index 007da39b68c9..5e1d17512a0d 100644
> > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
> > @@ -222,9 +222,8 @@ static int mtk_pconf_set_driving(struct mtk_pinctrl *pctl,
> > }
> >
> > int mtk_pctrl_spec_pull_set_samereg(struct regmap *regmap,
> > - const struct mtk_pin_spec_pupd_set_samereg *pupd_infos,
> > - unsigned int info_num, unsigned int pin,
> > - unsigned char align, bool isup, unsigned int r1r0)
> > + const struct mtk_pinctrl_devdata *devdata,
> > + unsigned int pin, bool isup, unsigned int r1r0)
> > {
> > unsigned int i;
> > unsigned int reg_pupd, reg_set, reg_rst;
> > @@ -232,8 +231,11 @@ int mtk_pctrl_spec_pull_set_samereg(struct regmap *regmap,
> > const struct mtk_pin_spec_pupd_set_samereg *spec_pupd_pin;
> > bool find = false;
> >
> > - for (i = 0; i < info_num; i++) {
> > - if (pin == pupd_infos[i].pin) {
> > + if (!devdata->spec_pupd)
> > + return -EINVAL;
> > +
> > + for (i = 0; i < devdata->n_spec_pupd; i++) {
> > + if (pin == devdata->spec_pupd[i].pin) {
> > find = true;
> > break;
> > }
> > @@ -242,9 +244,9 @@ int mtk_pctrl_spec_pull_set_samereg(struct regmap *regmap,
> > if (!find)
> > return -EINVAL;
> >
> > - spec_pupd_pin = pupd_infos + i;
> > - reg_set = spec_pupd_pin->offset + align;
> > - reg_rst = spec_pupd_pin->offset + (align << 1);
> > + spec_pupd_pin = devdata->spec_pupd + i;
> > + reg_set = spec_pupd_pin->offset + devdata->port_align;
> > + reg_rst = spec_pupd_pin->offset + (devdata->port_align << 1);
> >
> > if (isup)
> > reg_pupd = reg_rst;
> > @@ -293,12 +295,13 @@ static int mtk_pconf_set_pull_select(struct mtk_pinctrl *pctl,
> > * resistor bit, so we need this special handle.
> > */
> > if (pctl->devdata->spec_pull_set) {
> > - /* For special pins, bias-disable is set by R1R0,
> > + /* For special pins, bias-disable is set by R1R0
>
> Nit: This seems unrelated, and doesn't read correctly either way.
Once removed,
Reviewed-by: Chen-Yu Tsai <wenst at chromium.org>
More information about the Linux-mediatek
mailing list