Commit 3b422e9c authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-torvalds-20120418' of...

Merge tag 'for-torvalds-20120418' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl

Pull pinctrl fixes from Linus Walleij:
 - Fixed compilation errors and warnings
 - Stricter checks on the ops vtable

* tag 'for-torvalds-20120418' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
  pinctrl: implement pinctrl_check_ops
  pinctrl: include <linux/bug.h> to prevent compile errors
  pinctrl: fix compile error if not select PINMUX support
parents 3a537430 f84cc342
...@@ -908,10 +908,6 @@ static int pinctrl_groups_show(struct seq_file *s, void *what) ...@@ -908,10 +908,6 @@ static int pinctrl_groups_show(struct seq_file *s, void *what)
const struct pinctrl_ops *ops = pctldev->desc->pctlops; const struct pinctrl_ops *ops = pctldev->desc->pctlops;
unsigned selector = 0; unsigned selector = 0;
/* No grouping */
if (!ops)
return 0;
mutex_lock(&pinctrl_mutex); mutex_lock(&pinctrl_mutex);
seq_puts(s, "registered pin groups:\n"); seq_puts(s, "registered pin groups:\n");
...@@ -1225,6 +1221,19 @@ static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev) ...@@ -1225,6 +1221,19 @@ static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
#endif #endif
static int pinctrl_check_ops(struct pinctrl_dev *pctldev)
{
const struct pinctrl_ops *ops = pctldev->desc->pctlops;
if (!ops ||
!ops->list_groups ||
!ops->get_group_name ||
!ops->get_group_pins)
return -EINVAL;
return 0;
}
/** /**
* pinctrl_register() - register a pin controller device * pinctrl_register() - register a pin controller device
* @pctldesc: descriptor for this pin controller * @pctldesc: descriptor for this pin controller
...@@ -1256,6 +1265,14 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, ...@@ -1256,6 +1265,14 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
INIT_LIST_HEAD(&pctldev->gpio_ranges); INIT_LIST_HEAD(&pctldev->gpio_ranges);
pctldev->dev = dev; pctldev->dev = dev;
/* check core ops for sanity */
ret = pinctrl_check_ops(pctldev);
if (ret) {
pr_err("%s pinctrl ops lacks necessary functions\n",
pctldesc->name);
goto out_err;
}
/* If we're implementing pinmuxing, check the ops for sanity */ /* If we're implementing pinmuxing, check the ops for sanity */
if (pctldesc->pmxops) { if (pctldesc->pmxops) {
ret = pinmux_check_ops(pctldev); ret = pinmux_check_ops(pctldev);
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#ifndef __LINUX_PINCTRL_MACHINE_H #ifndef __LINUX_PINCTRL_MACHINE_H
#define __LINUX_PINCTRL_MACHINE_H #define __LINUX_PINCTRL_MACHINE_H
#include <linux/bug.h>
#include "pinctrl-state.h" #include "pinctrl-state.h"
enum pinctrl_map_type { enum pinctrl_map_type {
...@@ -148,7 +150,7 @@ struct pinctrl_map { ...@@ -148,7 +150,7 @@ struct pinctrl_map {
#define PIN_MAP_CONFIGS_GROUP_HOG_DEFAULT(dev, grp, cfgs) \ #define PIN_MAP_CONFIGS_GROUP_HOG_DEFAULT(dev, grp, cfgs) \
PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, cfgs) PIN_MAP_CONFIGS_GROUP(dev, PINCTRL_STATE_DEFAULT, dev, grp, cfgs)
#ifdef CONFIG_PINMUX #ifdef CONFIG_PINCTRL
extern int pinctrl_register_mappings(struct pinctrl_map const *map, extern int pinctrl_register_mappings(struct pinctrl_map const *map,
unsigned num_maps); unsigned num_maps);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment