aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/gpio
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@nvidia.com>2013-12-02 22:20:11 -0500
committerLinus Walleij <linus.walleij@linaro.org>2013-12-09 08:05:51 -0500
commitad824783fb23bbc8295cffb6214b3b82d25f7d4a (patch)
tree745d128c1d04dca7a6c7b10dd737f116f13ddcb1 /include/linux/gpio
parentbdc54ef45d7670aeb52ce73f8b7ad5f3e5563661 (diff)
gpio: better lookup method for platform GPIOs
Change the format of the platform GPIO lookup tables to make them less confusing and improve lookup efficiency. The previous format was a single linked-list that required to compare the device name and function ID of every single GPIO defined for each lookup. Switch that to a list of per-device tables, so that the lookup can be done in two steps, omitting the GPIOs that are not relevant for a particular device. The matching rules are now defined as follows: - The device name must match *exactly*, and can be NULL for GPIOs not assigned to a particular device, - If the function ID in the lookup table is NULL, the con_id argument of gpiod_get() will not be used for lookup. However, if it is defined, it must match exactly. - The index must always match. Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/gpio')
-rw-r--r--include/linux/gpio/driver.h21
1 files changed, 10 insertions, 11 deletions
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index c849676c6787..44c66b29a2d9 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -141,7 +141,6 @@ enum gpio_lookup_flags {
141 * platform data. 141 * platform data.
142 */ 142 */
143struct gpiod_lookup { 143struct gpiod_lookup {
144 struct list_head list;
145 /* 144 /*
146 * name of the chip the GPIO belongs to 145 * name of the chip the GPIO belongs to
147 */ 146 */
@@ -151,10 +150,6 @@ struct gpiod_lookup {
151 */ 150 */
152 u16 chip_hwnum; 151 u16 chip_hwnum;
153 /* 152 /*
154 * name of device that can claim this GPIO
155 */
156 const char *dev_id;
157 /*
158 * name of the GPIO from the device's point of view 153 * name of the GPIO from the device's point of view
159 */ 154 */
160 const char *con_id; 155 const char *con_id;
@@ -168,28 +163,32 @@ struct gpiod_lookup {
168 enum gpio_lookup_flags flags; 163 enum gpio_lookup_flags flags;
169}; 164};
170 165
166struct gpiod_lookup_table {
167 struct list_head list;
168 const char *dev_id;
169 struct gpiod_lookup table[];
170};
171
171/* 172/*
172 * Simple definition of a single GPIO under a con_id 173 * Simple definition of a single GPIO under a con_id
173 */ 174 */
174#define GPIO_LOOKUP(_chip_label, _chip_hwnum, _dev_id, _con_id, _flags) \ 175#define GPIO_LOOKUP(_chip_label, _chip_hwnum, _con_id, _flags) \
175 GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _dev_id, _con_id, 0, _flags) 176 GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, 0, _flags)
176 177
177/* 178/*
178 * Use this macro if you need to have several GPIOs under the same con_id. 179 * Use this macro if you need to have several GPIOs under the same con_id.
179 * Each GPIO needs to use a different index and can be accessed using 180 * Each GPIO needs to use a different index and can be accessed using
180 * gpiod_get_index() 181 * gpiod_get_index()
181 */ 182 */
182#define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _dev_id, _con_id, _idx, \ 183#define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, _idx, _flags) \
183 _flags) \
184{ \ 184{ \
185 .chip_label = _chip_label, \ 185 .chip_label = _chip_label, \
186 .chip_hwnum = _chip_hwnum, \ 186 .chip_hwnum = _chip_hwnum, \
187 .dev_id = _dev_id, \
188 .con_id = _con_id, \ 187 .con_id = _con_id, \
189 .idx = _idx, \ 188 .idx = _idx, \
190 .flags = _flags, \ 189 .flags = _flags, \
191} 190}
192 191
193void gpiod_add_table(struct gpiod_lookup *table, size_t size); 192void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
194 193
195#endif 194#endif