aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/core.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@wwwdotorg.org>2012-03-16 16:54:25 -0400
committerLinus Walleij <linus.walleij@linaro.org>2012-04-18 07:53:10 -0400
commitd26bc49fa401be2b71838b6a4b387196cd12a534 (patch)
tree463315affe87f7fefa96086f589b3b8681320ccd /drivers/pinctrl/core.c
parent22f099d0fcb33073a1f1f10402a16b28602e20f2 (diff)
pinctrl: implement pinctrl_check_ops
Most code assumes that the pinctrl ops are present. Validate this when registering a pinctrl driver. Remove the one place in the code that was checking whether one of these non-optional ops was present. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/core.c')
-rw-r--r--drivers/pinctrl/core.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index ec3b8cc188af..df6296c5f47b 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -908,10 +908,6 @@ static int pinctrl_groups_show(struct seq_file *s, void *what)
908 const struct pinctrl_ops *ops = pctldev->desc->pctlops; 908 const struct pinctrl_ops *ops = pctldev->desc->pctlops;
909 unsigned selector = 0; 909 unsigned selector = 0;
910 910
911 /* No grouping */
912 if (!ops)
913 return 0;
914
915 mutex_lock(&pinctrl_mutex); 911 mutex_lock(&pinctrl_mutex);
916 912
917 seq_puts(s, "registered pin groups:\n"); 913 seq_puts(s, "registered pin groups:\n");
@@ -1225,6 +1221,19 @@ static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
1225 1221
1226#endif 1222#endif
1227 1223
1224static int pinctrl_check_ops(struct pinctrl_dev *pctldev)
1225{
1226 const struct pinctrl_ops *ops = pctldev->desc->pctlops;
1227
1228 if (!ops ||
1229 !ops->list_groups ||
1230 !ops->get_group_name ||
1231 !ops->get_group_pins)
1232 return -EINVAL;
1233
1234 return 0;
1235}
1236
1228/** 1237/**
1229 * pinctrl_register() - register a pin controller device 1238 * pinctrl_register() - register a pin controller device
1230 * @pctldesc: descriptor for this pin controller 1239 * @pctldesc: descriptor for this pin controller
@@ -1256,6 +1265,14 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
1256 INIT_LIST_HEAD(&pctldev->gpio_ranges); 1265 INIT_LIST_HEAD(&pctldev->gpio_ranges);
1257 pctldev->dev = dev; 1266 pctldev->dev = dev;
1258 1267
1268 /* check core ops for sanity */
1269 ret = pinctrl_check_ops(pctldev);
1270 if (ret) {
1271 pr_err("%s pinctrl ops lacks necessary functions\n",
1272 pctldesc->name);
1273 goto out_err;
1274 }
1275
1259 /* If we're implementing pinmuxing, check the ops for sanity */ 1276 /* If we're implementing pinmuxing, check the ops for sanity */
1260 if (pctldesc->pmxops) { 1277 if (pctldesc->pmxops) {
1261 ret = pinmux_check_ops(pctldev); 1278 ret = pinmux_check_ops(pctldev);