diff options
author | John Crispin <blogic@openwrt.org> | 2012-04-26 10:47:11 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-04-26 17:11:04 -0400 |
commit | ad6e1107baa2e7fda55c2020c25127eab9c0122b (patch) | |
tree | fab32aafbdc9f2fd53d69afcaaf0b8997beea2af /drivers/pinctrl/pinmux.c | |
parent | 02ae6da28fb7aa31d8bf1972c99e83c58b684198 (diff) |
pinctrl: enhance reporting of errors when loading from DT
There are a few places in the api where the code simply returns -EINVAL when
it finds an error. An example is pinmux_map_to_setting() which now reports an
error if we try to match a group with a function that it does not support.
The reporting of errors in pinconf_check_ops and pinmux_check_ops now has the
same style and is located inside the according functions and not the calling
code.
When the map is found in the DT but the default state can not be selected we
get an error to know that the code at least tried.
The patch also removes a stray word from one comment and a "->" from another
for the sake of consistency.
Finally we replace a few pr_err/debug() calls with dev_err/dbg().
Thanks go to Stephen Warren for reviewing the patch and enhancing the reporting
inside pinmux_map_to_setting().
Signed-off-by: John Crispin <blogic@openwrt.org>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinmux.c')
-rw-r--r-- | drivers/pinctrl/pinmux.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 7cd0c7d0f2cf..2df753508eca 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c | |||
@@ -42,9 +42,10 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev) | |||
42 | !ops->get_function_name || | 42 | !ops->get_function_name || |
43 | !ops->get_function_groups || | 43 | !ops->get_function_groups || |
44 | !ops->enable || | 44 | !ops->enable || |
45 | !ops->disable) | 45 | !ops->disable) { |
46 | dev_err(pctldev->dev, "pinmux ops lacks necessary functions\n"); | ||
46 | return -EINVAL; | 47 | return -EINVAL; |
47 | 48 | } | |
48 | /* Check that all functions registered have names */ | 49 | /* Check that all functions registered have names */ |
49 | nfuncs = ops->get_functions_count(pctldev); | 50 | nfuncs = ops->get_functions_count(pctldev); |
50 | while (selector < nfuncs) { | 51 | while (selector < nfuncs) { |
@@ -143,7 +144,7 @@ static int pin_request(struct pinctrl_dev *pctldev, | |||
143 | status = 0; | 144 | status = 0; |
144 | 145 | ||
145 | if (status) { | 146 | if (status) { |
146 | dev_err(pctldev->dev, "->request on device %s failed for pin %d\n", | 147 | dev_err(pctldev->dev, "request on device %s failed for pin %d\n", |
147 | pctldev->desc->name, pin); | 148 | pctldev->desc->name, pin); |
148 | module_put(pctldev->owner); | 149 | module_put(pctldev->owner); |
149 | } | 150 | } |
@@ -330,17 +331,26 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, | |||
330 | } | 331 | } |
331 | 332 | ||
332 | ret = pinmux_func_name_to_selector(pctldev, map->data.mux.function); | 333 | ret = pinmux_func_name_to_selector(pctldev, map->data.mux.function); |
333 | if (ret < 0) | 334 | if (ret < 0) { |
335 | dev_err(pctldev->dev, "invalid function %s in map table\n", | ||
336 | map->data.mux.function); | ||
334 | return ret; | 337 | return ret; |
338 | } | ||
335 | setting->data.mux.func = ret; | 339 | setting->data.mux.func = ret; |
336 | 340 | ||
337 | ret = pmxops->get_function_groups(pctldev, setting->data.mux.func, | 341 | ret = pmxops->get_function_groups(pctldev, setting->data.mux.func, |
338 | &groups, &num_groups); | 342 | &groups, &num_groups); |
339 | if (ret < 0) | 343 | if (ret < 0) { |
344 | dev_err(pctldev->dev, "can't query groups for function %s\n", | ||
345 | map->data.mux.function); | ||
340 | return ret; | 346 | return ret; |
341 | if (!num_groups) | 347 | } |
348 | if (!num_groups) { | ||
349 | dev_err(pctldev->dev, | ||
350 | "function %s can't be selected on any group\n", | ||
351 | map->data.mux.function); | ||
342 | return -EINVAL; | 352 | return -EINVAL; |
343 | 353 | } | |
344 | if (map->data.mux.group) { | 354 | if (map->data.mux.group) { |
345 | bool found = false; | 355 | bool found = false; |
346 | group = map->data.mux.group; | 356 | group = map->data.mux.group; |
@@ -350,15 +360,22 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, | |||
350 | break; | 360 | break; |
351 | } | 361 | } |
352 | } | 362 | } |
353 | if (!found) | 363 | if (!found) { |
364 | dev_err(pctldev->dev, | ||
365 | "invalid group \"%s\" for function \"%s\"\n", | ||
366 | group, map->data.mux.function); | ||
354 | return -EINVAL; | 367 | return -EINVAL; |
368 | } | ||
355 | } else { | 369 | } else { |
356 | group = groups[0]; | 370 | group = groups[0]; |
357 | } | 371 | } |
358 | 372 | ||
359 | ret = pinctrl_get_group_selector(pctldev, group); | 373 | ret = pinctrl_get_group_selector(pctldev, group); |
360 | if (ret < 0) | 374 | if (ret < 0) { |
375 | dev_err(pctldev->dev, "invalid group %s in map table\n", | ||
376 | map->data.mux.group); | ||
361 | return ret; | 377 | return ret; |
378 | } | ||
362 | setting->data.mux.group = ret; | 379 | setting->data.mux.group = ret; |
363 | 380 | ||
364 | ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins, | 381 | ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins, |
@@ -375,7 +392,7 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, | |||
375 | ret = pin_request(pctldev, pins[i], map->dev_name, NULL); | 392 | ret = pin_request(pctldev, pins[i], map->dev_name, NULL); |
376 | if (ret) { | 393 | if (ret) { |
377 | dev_err(pctldev->dev, | 394 | dev_err(pctldev->dev, |
378 | "could not get request pin %d on device %s\n", | 395 | "could not request pin %d on device %s\n", |
379 | pins[i], pinctrl_dev_get_name(pctldev)); | 396 | pins[i], pinctrl_dev_get_name(pctldev)); |
380 | /* On error release all taken pins */ | 397 | /* On error release all taken pins */ |
381 | i--; /* this pin just failed */ | 398 | i--; /* this pin just failed */ |