diff options
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/core.c | 29 | ||||
-rw-r--r-- | drivers/pinctrl/pinconf.c | 10 | ||||
-rw-r--r-- | drivers/pinctrl/pinmux.c | 37 |
3 files changed, 49 insertions, 27 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 913c83e2bf1c..138e72f74377 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c | |||
@@ -1391,37 +1391,29 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, | |||
1391 | /* check core ops for sanity */ | 1391 | /* check core ops for sanity */ |
1392 | ret = pinctrl_check_ops(pctldev); | 1392 | ret = pinctrl_check_ops(pctldev); |
1393 | if (ret) { | 1393 | if (ret) { |
1394 | pr_err("%s pinctrl ops lacks necessary functions\n", | 1394 | dev_err(dev, "pinctrl ops lacks necessary functions\n"); |
1395 | pctldesc->name); | ||
1396 | goto out_err; | 1395 | goto out_err; |
1397 | } | 1396 | } |
1398 | 1397 | ||
1399 | /* If we're implementing pinmuxing, check the ops for sanity */ | 1398 | /* If we're implementing pinmuxing, check the ops for sanity */ |
1400 | if (pctldesc->pmxops) { | 1399 | if (pctldesc->pmxops) { |
1401 | ret = pinmux_check_ops(pctldev); | 1400 | ret = pinmux_check_ops(pctldev); |
1402 | if (ret) { | 1401 | if (ret) |
1403 | pr_err("%s pinmux ops lacks necessary functions\n", | ||
1404 | pctldesc->name); | ||
1405 | goto out_err; | 1402 | goto out_err; |
1406 | } | ||
1407 | } | 1403 | } |
1408 | 1404 | ||
1409 | /* If we're implementing pinconfig, check the ops for sanity */ | 1405 | /* If we're implementing pinconfig, check the ops for sanity */ |
1410 | if (pctldesc->confops) { | 1406 | if (pctldesc->confops) { |
1411 | ret = pinconf_check_ops(pctldev); | 1407 | ret = pinconf_check_ops(pctldev); |
1412 | if (ret) { | 1408 | if (ret) |
1413 | pr_err("%s pin config ops lacks necessary functions\n", | ||
1414 | pctldesc->name); | ||
1415 | goto out_err; | 1409 | goto out_err; |
1416 | } | ||
1417 | } | 1410 | } |
1418 | 1411 | ||
1419 | /* Register all the pins */ | 1412 | /* Register all the pins */ |
1420 | pr_debug("try to register %d pins on %s...\n", | 1413 | dev_dbg(dev, "try to register %d pins ...\n", pctldesc->npins); |
1421 | pctldesc->npins, pctldesc->name); | ||
1422 | ret = pinctrl_register_pins(pctldev, pctldesc->pins, pctldesc->npins); | 1414 | ret = pinctrl_register_pins(pctldev, pctldesc->pins, pctldesc->npins); |
1423 | if (ret) { | 1415 | if (ret) { |
1424 | pr_err("error during pin registration\n"); | 1416 | dev_err(dev, "error during pin registration\n"); |
1425 | pinctrl_free_pindescs(pctldev, pctldesc->pins, | 1417 | pinctrl_free_pindescs(pctldev, pctldesc->pins, |
1426 | pctldesc->npins); | 1418 | pctldesc->npins); |
1427 | goto out_err; | 1419 | goto out_err; |
@@ -1436,8 +1428,15 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, | |||
1436 | struct pinctrl_state *s = | 1428 | struct pinctrl_state *s = |
1437 | pinctrl_lookup_state_locked(pctldev->p, | 1429 | pinctrl_lookup_state_locked(pctldev->p, |
1438 | PINCTRL_STATE_DEFAULT); | 1430 | PINCTRL_STATE_DEFAULT); |
1439 | if (!IS_ERR(s)) | 1431 | if (IS_ERR(s)) { |
1440 | pinctrl_select_state_locked(pctldev->p, s); | 1432 | dev_dbg(dev, "failed to lookup the default state\n"); |
1433 | } else { | ||
1434 | ret = pinctrl_select_state_locked(pctldev->p, s); | ||
1435 | if (ret) { | ||
1436 | dev_err(dev, | ||
1437 | "failed to select default state\n"); | ||
1438 | } | ||
1439 | } | ||
1441 | } | 1440 | } |
1442 | 1441 | ||
1443 | mutex_unlock(&pinctrl_mutex); | 1442 | mutex_unlock(&pinctrl_mutex); |
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c index 14f48c96b20d..7ce139ef7e64 100644 --- a/drivers/pinctrl/pinconf.c +++ b/drivers/pinctrl/pinconf.c | |||
@@ -28,11 +28,17 @@ int pinconf_check_ops(struct pinctrl_dev *pctldev) | |||
28 | const struct pinconf_ops *ops = pctldev->desc->confops; | 28 | const struct pinconf_ops *ops = pctldev->desc->confops; |
29 | 29 | ||
30 | /* We must be able to read out pin status */ | 30 | /* We must be able to read out pin status */ |
31 | if (!ops->pin_config_get && !ops->pin_config_group_get) | 31 | if (!ops->pin_config_get && !ops->pin_config_group_get) { |
32 | dev_err(pctldev->dev, | ||
33 | "pinconf must be able to read out pin status\n"); | ||
32 | return -EINVAL; | 34 | return -EINVAL; |
35 | } | ||
33 | /* We have to be able to config the pins in SOME way */ | 36 | /* We have to be able to config the pins in SOME way */ |
34 | if (!ops->pin_config_set && !ops->pin_config_group_set) | 37 | if (!ops->pin_config_set && !ops->pin_config_group_set) { |
38 | dev_err(pctldev->dev, | ||
39 | "pinconf has to be able to set a pins config\n"); | ||
35 | return -EINVAL; | 40 | return -EINVAL; |
41 | } | ||
36 | return 0; | 42 | return 0; |
37 | } | 43 | } |
38 | 44 | ||
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 */ |