提交 051a58b4 编写于 作者: S Stephen Boyd 提交者: Linus Walleij

pinctrl: msm: Simplify msm_config_reg() and callers

We don't need to check for a negative reg here because reg is
always the same and is always non-negative. Also, collapse the
switch statement down for the duplicate cases.
Signed-off-by: NStephen Boyd <sboyd@codeaurora.org>
Acked-by: NBjorn Andersson <bjorn.andersson@sonymobile.com>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 1a0840ae
...@@ -200,28 +200,17 @@ static const struct pinmux_ops msm_pinmux_ops = { ...@@ -200,28 +200,17 @@ static const struct pinmux_ops msm_pinmux_ops = {
static int msm_config_reg(struct msm_pinctrl *pctrl, static int msm_config_reg(struct msm_pinctrl *pctrl,
const struct msm_pingroup *g, const struct msm_pingroup *g,
unsigned param, unsigned param,
s16 *reg,
unsigned *mask, unsigned *mask,
unsigned *bit) unsigned *bit)
{ {
switch (param) { switch (param) {
case PIN_CONFIG_BIAS_DISABLE: case PIN_CONFIG_BIAS_DISABLE:
*reg = g->ctl_reg;
*bit = g->pull_bit;
*mask = 3;
break;
case PIN_CONFIG_BIAS_PULL_DOWN: case PIN_CONFIG_BIAS_PULL_DOWN:
*reg = g->ctl_reg;
*bit = g->pull_bit;
*mask = 3;
break;
case PIN_CONFIG_BIAS_PULL_UP: case PIN_CONFIG_BIAS_PULL_UP:
*reg = g->ctl_reg;
*bit = g->pull_bit; *bit = g->pull_bit;
*mask = 3; *mask = 3;
break; break;
case PIN_CONFIG_DRIVE_STRENGTH: case PIN_CONFIG_DRIVE_STRENGTH:
*reg = g->ctl_reg;
*bit = g->drv_bit; *bit = g->drv_bit;
*mask = 7; *mask = 7;
break; break;
...@@ -235,12 +224,6 @@ static int msm_config_reg(struct msm_pinctrl *pctrl, ...@@ -235,12 +224,6 @@ static int msm_config_reg(struct msm_pinctrl *pctrl,
return -ENOTSUPP; return -ENOTSUPP;
} }
if (*reg < 0) {
dev_err(pctrl->dev, "Config param %04x not supported on group %s\n",
param, g->name);
return -ENOTSUPP;
}
return 0; return 0;
} }
...@@ -278,17 +261,16 @@ static int msm_config_group_get(struct pinctrl_dev *pctldev, ...@@ -278,17 +261,16 @@ static int msm_config_group_get(struct pinctrl_dev *pctldev,
unsigned mask; unsigned mask;
unsigned arg; unsigned arg;
unsigned bit; unsigned bit;
s16 reg;
int ret; int ret;
u32 val; u32 val;
g = &pctrl->soc->groups[group]; g = &pctrl->soc->groups[group];
ret = msm_config_reg(pctrl, g, param, &reg, &mask, &bit); ret = msm_config_reg(pctrl, g, param, &mask, &bit);
if (ret < 0) if (ret < 0)
return ret; return ret;
val = readl(pctrl->regs + reg); val = readl(pctrl->regs + g->ctl_reg);
arg = (val >> bit) & mask; arg = (val >> bit) & mask;
/* Convert register value to pinconf value */ /* Convert register value to pinconf value */
...@@ -336,7 +318,6 @@ static int msm_config_group_set(struct pinctrl_dev *pctldev, ...@@ -336,7 +318,6 @@ static int msm_config_group_set(struct pinctrl_dev *pctldev,
unsigned mask; unsigned mask;
unsigned arg; unsigned arg;
unsigned bit; unsigned bit;
s16 reg;
int ret; int ret;
u32 val; u32 val;
int i; int i;
...@@ -347,7 +328,7 @@ static int msm_config_group_set(struct pinctrl_dev *pctldev, ...@@ -347,7 +328,7 @@ static int msm_config_group_set(struct pinctrl_dev *pctldev,
param = pinconf_to_config_param(configs[i]); param = pinconf_to_config_param(configs[i]);
arg = pinconf_to_config_argument(configs[i]); arg = pinconf_to_config_argument(configs[i]);
ret = msm_config_reg(pctrl, g, param, &reg, &mask, &bit); ret = msm_config_reg(pctrl, g, param, &mask, &bit);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -396,10 +377,10 @@ static int msm_config_group_set(struct pinctrl_dev *pctldev, ...@@ -396,10 +377,10 @@ static int msm_config_group_set(struct pinctrl_dev *pctldev,
} }
spin_lock_irqsave(&pctrl->lock, flags); spin_lock_irqsave(&pctrl->lock, flags);
val = readl(pctrl->regs + reg); val = readl(pctrl->regs + g->ctl_reg);
val &= ~(mask << bit); val &= ~(mask << bit);
val |= arg << bit; val |= arg << bit;
writel(val, pctrl->regs + reg); writel(val, pctrl->regs + g->ctl_reg);
spin_unlock_irqrestore(&pctrl->lock, flags); spin_unlock_irqrestore(&pctrl->lock, flags);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册