diff options
author | Stephen Warren <swarren@nvidia.com> | 2011-12-15 18:57:17 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-01-03 03:10:07 -0500 |
commit | 43699dea1ea21a0d5786317a794cb2ba27a6f4fe (patch) | |
tree | 6a1f26cce9cfe04ac93cd62005c14759722ffb74 | |
parent | 63fd5984a9b2214cba7dd7dd7b5a75cf40dde39f (diff) |
pinctrl: pass name instead of device to pin_config_*
Obtaining a "struct pinctrl_dev *" is difficult for code not directly
related to the pinctrl subsystem. However, the device name of the pinctrl
device is fairly well known. So, modify pin_config_*() to take the device
name instead of the "struct pinctrl_dev *".
Signed-off-by: Stephen Warren <swarren@nvidia.com>
[rebased on top of refactoring code]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | Documentation/pinctrl.txt | 2 | ||||
-rw-r--r-- | drivers/pinctrl/pinconf.c | 41 | ||||
-rw-r--r-- | include/linux/pinctrl/pinconf.h | 16 |
3 files changed, 41 insertions, 18 deletions
diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt index f08064368291..44321d3227e8 100644 --- a/Documentation/pinctrl.txt +++ b/Documentation/pinctrl.txt | |||
@@ -208,7 +208,7 @@ unconnected. | |||
208 | 208 | ||
209 | For example, a platform may do this: | 209 | For example, a platform may do this: |
210 | 210 | ||
211 | ret = pin_config_set(dev, "FOO_GPIO_PIN", PLATFORM_X_PULL_UP); | 211 | ret = pin_config_set("foo-dev", "FOO_GPIO_PIN", PLATFORM_X_PULL_UP); |
212 | 212 | ||
213 | To pull up a pin to VDD. The pin configuration driver implements callbacks for | 213 | To pull up a pin to VDD. The pin configuration driver implements callbacks for |
214 | changing pin configuration in the pin controller ops like this: | 214 | changing pin configuration in the pin controller ops like this: |
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c index 124762b57024..57dbb4b478db 100644 --- a/drivers/pinctrl/pinconf.c +++ b/drivers/pinctrl/pinconf.c | |||
@@ -39,17 +39,22 @@ int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin, | |||
39 | 39 | ||
40 | /** | 40 | /** |
41 | * pin_config_get() - get the configuration of a single pin parameter | 41 | * pin_config_get() - get the configuration of a single pin parameter |
42 | * @pctldev: pin controller device for this pin | 42 | * @dev_name: name of the pin controller device for this pin |
43 | * @name: name of the pin to get the config for | 43 | * @name: name of the pin to get the config for |
44 | * @config: the config pointed to by this argument will be filled in with the | 44 | * @config: the config pointed to by this argument will be filled in with the |
45 | * current pin state, it can be used directly by drivers as a numeral, or | 45 | * current pin state, it can be used directly by drivers as a numeral, or |
46 | * it can be dereferenced to any struct. | 46 | * it can be dereferenced to any struct. |
47 | */ | 47 | */ |
48 | int pin_config_get(struct pinctrl_dev *pctldev, const char *name, | 48 | int pin_config_get(const char *dev_name, const char *name, |
49 | unsigned long *config) | 49 | unsigned long *config) |
50 | { | 50 | { |
51 | struct pinctrl_dev *pctldev; | ||
51 | int pin; | 52 | int pin; |
52 | 53 | ||
54 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | ||
55 | if (!pctldev) | ||
56 | return -EINVAL; | ||
57 | |||
53 | pin = pin_get_from_name(pctldev, name); | 58 | pin = pin_get_from_name(pctldev, name); |
54 | if (pin < 0) | 59 | if (pin < 0) |
55 | return pin; | 60 | return pin; |
@@ -82,17 +87,22 @@ int pin_config_set_for_pin(struct pinctrl_dev *pctldev, unsigned pin, | |||
82 | 87 | ||
83 | /** | 88 | /** |
84 | * pin_config_set() - set the configuration of a single pin parameter | 89 | * pin_config_set() - set the configuration of a single pin parameter |
85 | * @pctldev: pin controller device for this pin | 90 | * @dev_name: name of pin controller device for this pin |
86 | * @name: name of the pin to set the config for | 91 | * @name: name of the pin to set the config for |
87 | * @config: the config in this argument will contain the desired pin state, it | 92 | * @config: the config in this argument will contain the desired pin state, it |
88 | * can be used directly by drivers as a numeral, or it can be dereferenced | 93 | * can be used directly by drivers as a numeral, or it can be dereferenced |
89 | * to any struct. | 94 | * to any struct. |
90 | */ | 95 | */ |
91 | int pin_config_set(struct pinctrl_dev *pctldev, const char *name, | 96 | int pin_config_set(const char *dev_name, const char *name, |
92 | unsigned long config) | 97 | unsigned long config) |
93 | { | 98 | { |
99 | struct pinctrl_dev *pctldev; | ||
94 | int pin; | 100 | int pin; |
95 | 101 | ||
102 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | ||
103 | if (!pctldev) | ||
104 | return -EINVAL; | ||
105 | |||
96 | pin = pin_get_from_name(pctldev, name); | 106 | pin = pin_get_from_name(pctldev, name); |
97 | if (pin < 0) | 107 | if (pin < 0) |
98 | return pin; | 108 | return pin; |
@@ -101,12 +111,18 @@ int pin_config_set(struct pinctrl_dev *pctldev, const char *name, | |||
101 | } | 111 | } |
102 | EXPORT_SYMBOL(pin_config_set); | 112 | EXPORT_SYMBOL(pin_config_set); |
103 | 113 | ||
104 | int pin_config_group_get(struct pinctrl_dev *pctldev, const char *pin_group, | 114 | int pin_config_group_get(const char *dev_name, const char *pin_group, |
105 | unsigned long *config) | 115 | unsigned long *config) |
106 | { | 116 | { |
107 | const struct pinconf_ops *ops = pctldev->desc->confops; | 117 | struct pinctrl_dev *pctldev; |
118 | const struct pinconf_ops *ops; | ||
108 | int selector; | 119 | int selector; |
109 | 120 | ||
121 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | ||
122 | if (!pctldev) | ||
123 | return -EINVAL; | ||
124 | ops = pctldev->desc->confops; | ||
125 | |||
110 | if (!ops || !ops->pin_config_group_get) { | 126 | if (!ops || !ops->pin_config_group_get) { |
111 | dev_err(pctldev->dev, "cannot get configuration for pin " | 127 | dev_err(pctldev->dev, "cannot get configuration for pin " |
112 | "group, missing group config get function in " | 128 | "group, missing group config get function in " |
@@ -123,17 +139,24 @@ int pin_config_group_get(struct pinctrl_dev *pctldev, const char *pin_group, | |||
123 | EXPORT_SYMBOL(pin_config_group_get); | 139 | EXPORT_SYMBOL(pin_config_group_get); |
124 | 140 | ||
125 | 141 | ||
126 | int pin_config_group_set(struct pinctrl_dev *pctldev, const char *pin_group, | 142 | int pin_config_group_set(const char *dev_name, const char *pin_group, |
127 | unsigned long config) | 143 | unsigned long config) |
128 | { | 144 | { |
129 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; | 145 | struct pinctrl_dev *pctldev; |
130 | const struct pinconf_ops *ops = pctldev->desc->confops; | 146 | const struct pinconf_ops *ops; |
147 | const struct pinctrl_ops *pctlops; | ||
131 | int selector; | 148 | int selector; |
132 | const unsigned *pins; | 149 | const unsigned *pins; |
133 | unsigned num_pins; | 150 | unsigned num_pins; |
134 | int ret; | 151 | int ret; |
135 | int i; | 152 | int i; |
136 | 153 | ||
154 | pctldev = get_pinctrl_dev_from_dev(NULL, dev_name); | ||
155 | if (!pctldev) | ||
156 | return -EINVAL; | ||
157 | ops = pctldev->desc->confops; | ||
158 | pctlops = pctldev->desc->pctlops; | ||
159 | |||
137 | if (!ops || (!ops->pin_config_group_set && !ops->pin_config_set)) { | 160 | if (!ops || (!ops->pin_config_group_set && !ops->pin_config_set)) { |
138 | dev_err(pctldev->dev, "cannot configure pin group, missing " | 161 | dev_err(pctldev->dev, "cannot configure pin group, missing " |
139 | "config function in driver\n"); | 162 | "config function in driver\n"); |
diff --git a/include/linux/pinctrl/pinconf.h b/include/linux/pinctrl/pinconf.h index 8c2c88ed46b1..477922cf043a 100644 --- a/include/linux/pinctrl/pinconf.h +++ b/include/linux/pinctrl/pinconf.h | |||
@@ -53,39 +53,39 @@ struct pinconf_ops { | |||
53 | unsigned selector); | 53 | unsigned selector); |
54 | }; | 54 | }; |
55 | 55 | ||
56 | extern int pin_config_get(struct pinctrl_dev *pctldev, const char *name, | 56 | extern int pin_config_get(const char *dev_name, const char *name, |
57 | unsigned long *config); | 57 | unsigned long *config); |
58 | extern int pin_config_set(struct pinctrl_dev *pctldev, const char *name, | 58 | extern int pin_config_set(const char *dev_name, const char *name, |
59 | unsigned long config); | 59 | unsigned long config); |
60 | extern int pin_config_group_get(struct pinctrl_dev *pctldev, | 60 | extern int pin_config_group_get(const char *dev_name, |
61 | const char *pin_group, | 61 | const char *pin_group, |
62 | unsigned long *config); | 62 | unsigned long *config); |
63 | extern int pin_config_group_set(struct pinctrl_dev *pctldev, | 63 | extern int pin_config_group_set(const char *dev_name, |
64 | const char *pin_group, | 64 | const char *pin_group, |
65 | unsigned long config); | 65 | unsigned long config); |
66 | 66 | ||
67 | #else | 67 | #else |
68 | 68 | ||
69 | static inline int pin_config_get(struct pinctrl_dev *pctldev, const char *name, | 69 | static inline int pin_config_get(const char *dev_name, const char *name, |
70 | unsigned long *config) | 70 | unsigned long *config) |
71 | { | 71 | { |
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
74 | 74 | ||
75 | static inline int pin_config_set(struct pinctrl_dev *pctldev, const char *name, | 75 | static inline int pin_config_set(const char *dev_name, const char *name, |
76 | unsigned long config) | 76 | unsigned long config) |
77 | { | 77 | { |
78 | return 0; | 78 | return 0; |
79 | } | 79 | } |
80 | 80 | ||
81 | static inline int pin_config_group_get(struct pinctrl_dev *pctldev, | 81 | static inline int pin_config_group_get(const char *dev_name, |
82 | const char *pin_group, | 82 | const char *pin_group, |
83 | unsigned long *config) | 83 | unsigned long *config) |
84 | { | 84 | { |
85 | return 0; | 85 | return 0; |
86 | } | 86 | } |
87 | 87 | ||
88 | static inline int pin_config_group_set(struct pinctrl_dev *pctldev, | 88 | static inline int pin_config_group_set(const char *dev_name, |
89 | const char *pin_group, | 89 | const char *pin_group, |
90 | unsigned long config) | 90 | unsigned long config) |
91 | { | 91 | { |