diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-03-10 11:55:19 -0400 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-03-15 08:33:54 -0400 |
commit | 0d00f00a1077ae89fb0ecbbba8da4c2c6bc93446 (patch) | |
tree | 59a9f74dce11bf25ae3d7af2897e43ffe7d43359 /drivers/pinctrl/sh-pfc | |
parent | c58d9c1b26e3ab2933abc7d5444e945ddad44809 (diff) |
sh-pfc: Merge sh_pfc_reconfig_pin() into sh_pfc_gpio_set_direction()
The sh_pfc_reconfig_pin() is only called from a single location. Merge
it into its call site to make the code easier to follow.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/sh-pfc')
-rw-r--r-- | drivers/pinctrl/sh-pfc/pinctrl.c | 71 |
1 files changed, 32 insertions, 39 deletions
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c index 79fa170b4872..36f08f826a5e 100644 --- a/drivers/pinctrl/sh-pfc/pinctrl.c +++ b/drivers/pinctrl/sh-pfc/pinctrl.c | |||
@@ -135,43 +135,6 @@ static void sh_pfc_func_disable(struct pinctrl_dev *pctldev, unsigned selector, | |||
135 | { | 135 | { |
136 | } | 136 | } |
137 | 137 | ||
138 | static int sh_pfc_reconfig_pin(struct sh_pfc_pinctrl *pmx, unsigned offset, | ||
139 | int new_type) | ||
140 | { | ||
141 | struct sh_pfc *pfc = pmx->pfc; | ||
142 | int idx = sh_pfc_get_pin_index(pfc, offset); | ||
143 | struct sh_pfc_pin_config *cfg = &pmx->configs[idx]; | ||
144 | const struct sh_pfc_pin *pin = &pfc->info->pins[idx]; | ||
145 | unsigned int mark = pin->enum_id; | ||
146 | unsigned long flags; | ||
147 | int ret; | ||
148 | |||
149 | spin_lock_irqsave(&pfc->lock, flags); | ||
150 | |||
151 | switch (cfg->type) { | ||
152 | case PINMUX_TYPE_GPIO: | ||
153 | case PINMUX_TYPE_OUTPUT: | ||
154 | case PINMUX_TYPE_INPUT: | ||
155 | case PINMUX_TYPE_INPUT_PULLUP: | ||
156 | case PINMUX_TYPE_INPUT_PULLDOWN: | ||
157 | break; | ||
158 | default: | ||
159 | ret = -EINVAL; | ||
160 | goto done; | ||
161 | } | ||
162 | |||
163 | ret = sh_pfc_config_mux(pfc, mark, new_type); | ||
164 | if (ret < 0) | ||
165 | goto done; | ||
166 | |||
167 | cfg->type = new_type; | ||
168 | |||
169 | done: | ||
170 | spin_unlock_irqrestore(&pfc->lock, flags); | ||
171 | |||
172 | return ret; | ||
173 | } | ||
174 | |||
175 | static int sh_pfc_gpio_request_enable(struct pinctrl_dev *pctldev, | 138 | static int sh_pfc_gpio_request_enable(struct pinctrl_dev *pctldev, |
176 | struct pinctrl_gpio_range *range, | 139 | struct pinctrl_gpio_range *range, |
177 | unsigned offset) | 140 | unsigned offset) |
@@ -216,9 +179,39 @@ static int sh_pfc_gpio_set_direction(struct pinctrl_dev *pctldev, | |||
216 | unsigned offset, bool input) | 179 | unsigned offset, bool input) |
217 | { | 180 | { |
218 | struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); | 181 | struct sh_pfc_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev); |
219 | int type = input ? PINMUX_TYPE_INPUT : PINMUX_TYPE_OUTPUT; | 182 | struct sh_pfc *pfc = pmx->pfc; |
183 | int new_type = input ? PINMUX_TYPE_INPUT : PINMUX_TYPE_OUTPUT; | ||
184 | int idx = sh_pfc_get_pin_index(pfc, offset); | ||
185 | struct sh_pfc_pin_config *cfg = &pmx->configs[idx]; | ||
186 | const struct sh_pfc_pin *pin = &pfc->info->pins[idx]; | ||
187 | unsigned int mark = pin->enum_id; | ||
188 | unsigned long flags; | ||
189 | int ret; | ||
220 | 190 | ||
221 | return sh_pfc_reconfig_pin(pmx, offset, type); | 191 | spin_lock_irqsave(&pfc->lock, flags); |
192 | |||
193 | switch (cfg->type) { | ||
194 | case PINMUX_TYPE_GPIO: | ||
195 | case PINMUX_TYPE_OUTPUT: | ||
196 | case PINMUX_TYPE_INPUT: | ||
197 | case PINMUX_TYPE_INPUT_PULLUP: | ||
198 | case PINMUX_TYPE_INPUT_PULLDOWN: | ||
199 | break; | ||
200 | default: | ||
201 | ret = -EINVAL; | ||
202 | goto done; | ||
203 | } | ||
204 | |||
205 | ret = sh_pfc_config_mux(pfc, mark, new_type); | ||
206 | if (ret < 0) | ||
207 | goto done; | ||
208 | |||
209 | cfg->type = new_type; | ||
210 | |||
211 | done: | ||
212 | spin_unlock_irqrestore(&pfc->lock, flags); | ||
213 | |||
214 | return ret; | ||
222 | } | 215 | } |
223 | 216 | ||
224 | static const struct pinmux_ops sh_pfc_pinmux_ops = { | 217 | static const struct pinmux_ops sh_pfc_pinmux_ops = { |