aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pinctrl/sh-pfc/core.c19
-rw-r--r--drivers/pinctrl/sh-pfc/gpio.c13
-rw-r--r--drivers/pinctrl/sh-pfc/pinctrl.c24
3 files changed, 25 insertions, 31 deletions
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c
index 3a949465e88e..a04c497deccd 100644
--- a/drivers/pinctrl/sh-pfc/core.c
+++ b/drivers/pinctrl/sh-pfc/core.c
@@ -93,7 +93,7 @@ int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin)
93 offset += range->end - range->begin + 1; 93 offset += range->end - range->begin + 1;
94 } 94 }
95 95
96 return -1; 96 return -EINVAL;
97} 97}
98 98
99static int sh_pfc_enum_in_range(pinmux_enum_t enum_id, 99static int sh_pfc_enum_in_range(pinmux_enum_t enum_id,
@@ -233,7 +233,7 @@ static int sh_pfc_get_config_reg(struct sh_pfc *pfc, pinmux_enum_t enum_id,
233 k++; 233 k++;
234 } 234 }
235 235
236 return -1; 236 return -EINVAL;
237} 237}
238 238
239static int sh_pfc_mark_to_enum(struct sh_pfc *pfc, pinmux_enum_t mark, int pos, 239static int sh_pfc_mark_to_enum(struct sh_pfc *pfc, pinmux_enum_t mark, int pos,
@@ -255,7 +255,7 @@ static int sh_pfc_mark_to_enum(struct sh_pfc *pfc, pinmux_enum_t mark, int pos,
255 } 255 }
256 256
257 pr_err("cannot locate data/mark enum_id for mark %d\n", mark); 257 pr_err("cannot locate data/mark enum_id for mark %d\n", mark);
258 return -1; 258 return -EINVAL;
259} 259}
260 260
261int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type) 261int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type)
@@ -264,6 +264,7 @@ int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type)
264 pinmux_enum_t enum_id; 264 pinmux_enum_t enum_id;
265 const struct pinmux_range *range; 265 const struct pinmux_range *range;
266 int in_range, pos, field, value; 266 int in_range, pos, field, value;
267 int ret;
267 268
268 switch (pinmux_type) { 269 switch (pinmux_type) {
269 270
@@ -288,7 +289,7 @@ int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type)
288 break; 289 break;
289 290
290 default: 291 default:
291 return -1; 292 return -EINVAL;
292 } 293 }
293 294
294 pos = 0; 295 pos = 0;
@@ -297,8 +298,8 @@ int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type)
297 value = 0; 298 value = 0;
298 while (1) { 299 while (1) {
299 pos = sh_pfc_mark_to_enum(pfc, mark, pos, &enum_id); 300 pos = sh_pfc_mark_to_enum(pfc, mark, pos, &enum_id);
300 if (pos <= 0) 301 if (pos < 0)
301 return -1; 302 return pos;
302 303
303 if (!enum_id) 304 if (!enum_id)
304 break; 305 break;
@@ -341,9 +342,9 @@ int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type)
341 if (!in_range) 342 if (!in_range)
342 continue; 343 continue;
343 344
344 if (sh_pfc_get_config_reg(pfc, enum_id, &cr, 345 ret = sh_pfc_get_config_reg(pfc, enum_id, &cr, &field, &value);
345 &field, &value) != 0) 346 if (ret < 0)
346 return -1; 347 return ret;
347 348
348 sh_pfc_write_config_reg(pfc, cr, field, value); 349 sh_pfc_write_config_reg(pfc, cr, field, value);
349 } 350 }
diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c
index 480beae2ee67..e299f14bc50a 100644
--- a/drivers/pinctrl/sh-pfc/gpio.c
+++ b/drivers/pinctrl/sh-pfc/gpio.c
@@ -276,22 +276,17 @@ static int gpio_function_request(struct gpio_chip *gc, unsigned offset)
276 struct sh_pfc *pfc = gpio_to_pfc(gc); 276 struct sh_pfc *pfc = gpio_to_pfc(gc);
277 unsigned int mark = pfc->info->func_gpios[offset].enum_id; 277 unsigned int mark = pfc->info->func_gpios[offset].enum_id;
278 unsigned long flags; 278 unsigned long flags;
279 int ret = -EINVAL; 279 int ret;
280 280
281 pr_notice_once("Use of GPIO API for function requests is deprecated, convert to pinctrl\n"); 281 pr_notice_once("Use of GPIO API for function requests is deprecated, convert to pinctrl\n");
282 282
283 if (mark == 0) 283 if (mark == 0)
284 return ret; 284 return -EINVAL;
285 285
286 spin_lock_irqsave(&pfc->lock, flags); 286 spin_lock_irqsave(&pfc->lock, flags);
287 287 ret = sh_pfc_config_mux(pfc, mark, PINMUX_TYPE_FUNCTION);
288 if (sh_pfc_config_mux(pfc, mark, PINMUX_TYPE_FUNCTION))
289 goto done;
290
291 ret = 0;
292
293done:
294 spin_unlock_irqrestore(&pfc->lock, flags); 288 spin_unlock_irqrestore(&pfc->lock, flags);
289
295 return ret; 290 return ret;
296} 291}
297 292
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c
index b4960df6aa2d..c15091096f65 100644
--- a/drivers/pinctrl/sh-pfc/pinctrl.c
+++ b/drivers/pinctrl/sh-pfc/pinctrl.c
@@ -114,18 +114,16 @@ static int sh_pfc_func_enable(struct pinctrl_dev *pctldev, unsigned selector,
114 const struct sh_pfc_pin_group *grp = &pfc->info->groups[group]; 114 const struct sh_pfc_pin_group *grp = &pfc->info->groups[group];
115 unsigned long flags; 115 unsigned long flags;
116 unsigned int i; 116 unsigned int i;
117 int ret = -EINVAL; 117 int ret = 0;
118 118
119 spin_lock_irqsave(&pfc->lock, flags); 119 spin_lock_irqsave(&pfc->lock, flags);
120 120
121 for (i = 0; i < grp->nr_pins; ++i) { 121 for (i = 0; i < grp->nr_pins; ++i) {
122 if (sh_pfc_config_mux(pfc, grp->mux[i], PINMUX_TYPE_FUNCTION)) 122 ret = sh_pfc_config_mux(pfc, grp->mux[i], PINMUX_TYPE_FUNCTION);
123 goto done; 123 if (ret < 0)
124 break;
124 } 125 }
125 126
126 ret = 0;
127
128done:
129 spin_unlock_irqrestore(&pfc->lock, flags); 127 spin_unlock_irqrestore(&pfc->lock, flags);
130 return ret; 128 return ret;
131} 129}
@@ -144,7 +142,7 @@ static int sh_pfc_reconfig_pin(struct sh_pfc_pinctrl *pmx, unsigned offset,
144 const struct sh_pfc_pin *pin = &pfc->info->pins[idx]; 142 const struct sh_pfc_pin *pin = &pfc->info->pins[idx];
145 unsigned int mark = pin->enum_id; 143 unsigned int mark = pin->enum_id;
146 unsigned long flags; 144 unsigned long flags;
147 int ret = -EINVAL; 145 int ret;
148 146
149 spin_lock_irqsave(&pfc->lock, flags); 147 spin_lock_irqsave(&pfc->lock, flags);
150 148
@@ -156,17 +154,17 @@ static int sh_pfc_reconfig_pin(struct sh_pfc_pinctrl *pmx, unsigned offset,
156 case PINMUX_TYPE_INPUT_PULLDOWN: 154 case PINMUX_TYPE_INPUT_PULLDOWN:
157 break; 155 break;
158 default: 156 default:
159 goto err; 157 ret = -EINVAL;
158 goto done;
160 } 159 }
161 160
162 if (sh_pfc_config_mux(pfc, mark, new_type) != 0) 161 ret = sh_pfc_config_mux(pfc, mark, new_type);
163 goto err; 162 if (ret < 0)
163 goto done;
164 164
165 cfg->type = new_type; 165 cfg->type = new_type;
166 166
167 ret = 0; 167done:
168
169err:
170 spin_unlock_irqrestore(&pfc->lock, flags); 168 spin_unlock_irqrestore(&pfc->lock, flags);
171 169
172 return ret; 170 return ret;