History

gpiolib: Make use of enum gpio_lookup_flags consistent

The library uses enum gpio_lookup_flags to define the possible characteristics of GPIO pin. Since enumerator listed only individual bits the common use of it is in a form of a bitmask of gpio_lookup_flags GPIO_* values. The more correct type for this is unsigned long. Due to above convert all users to use unsigned long instead of enum gpio_lookup_flags except enumerator definition. While here, make field and parameter descriptions consistent as well.

Andy Shevchenko committed 7 years ago

Commit fed70261 parent 40505865 files · +28 −27Browse files

Unified · Split

5 files
  1. drivers/gpio/gpiolib-acpi.c +9 −5
  2. drivers/gpio/gpiolib-of.c +5 −6
  3. drivers/gpio/gpiolib.c +6 −7
  4. drivers/gpio/gpiolib.h +4 −5
  5. include/linux/gpio/machine.h +4 −4
drivers/gpio/gpiolib-acpi.c+9−5
@@ -696,7 +696,7 @@ struct gpio_desc *acpi_find_gpio(struct device *dev, · 695 unmodified lines
696 const char *con_id,696 const char *con_id,
697 unsigned int idx,697 unsigned int idx,
698 enum gpiod_flags *dflags,698 enum gpiod_flags *dflags,
699 enum gpio_lookup_flags *lookupflags)699 unsigned long *lookupflags)
700{700{
701 struct acpi_device *adev = ACPI_COMPANION(dev);701 struct acpi_device *adev = ACPI_COMPANION(dev);
702 struct acpi_gpio_info info;702 struct acpi_gpio_info info;
@@ -995,9 +995,12 @@ static void acpi_gpiochip_free_regions(struct acpi_gpio_chip *achip) · 292 unmodified lines
995 }995 }
996}996}
997 997
998static struct gpio_desc *acpi_gpiochip_parse_own_gpio(998static struct gpio_desc *
999 struct acpi_gpio_chip *achip, struct fwnode_handle *fwnode,999acpi_gpiochip_parse_own_gpio(struct acpi_gpio_chip *achip,
1000 const char **name, unsigned int *lflags, unsigned int *dflags)1000 struct fwnode_handle *fwnode,
1001 const char **name,
1002 unsigned long *lflags,
1003 unsigned int *dflags)
1001{1004{
1002 struct gpio_chip *chip = achip->chip;1005 struct gpio_chip *chip = achip->chip;
1003 struct gpio_desc *desc;1006 struct gpio_desc *desc;
@@ -1040,7 +1043,8 @@ static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip) · 36 unmodified lines
1040 struct fwnode_handle *fwnode;1043 struct fwnode_handle *fwnode;
1041 1044
1042 device_for_each_child_node(chip->parent, fwnode) {1045 device_for_each_child_node(chip->parent, fwnode) {
1043 unsigned int lflags, dflags;1046 unsigned long lflags;
1047 unsigned int dflags;
1044 struct gpio_desc *desc;1048 struct gpio_desc *desc;
1045 const char *name;1049 const char *name;
1046 int ret;1050 int ret;
drivers/gpio/gpiolib-of.c+5−6
@@ -287,8 +287,7 @@ static struct gpio_desc *of_find_regulator_gpio(struct device *dev, const char * · 286 unmodified lines
287}287}
288 288
289struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,289struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
290 unsigned int idx,290 unsigned int idx, unsigned long *flags)
291 enum gpio_lookup_flags *flags)
292{291{
293 char prop_name[32]; /* 32 is max size of property name */292 char prop_name[32]; /* 32 is max size of property name */
294 enum of_gpio_flags of_flags;293 enum of_gpio_flags of_flags;
@@ -361,8 +360,8 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, · 66 unmodified lines
361 * @chip: GPIO chip whose hog is parsed360 * @chip: GPIO chip whose hog is parsed
362 * @idx: Index of the GPIO to parse361 * @idx: Index of the GPIO to parse
363 * @name: GPIO line name362 * @name: GPIO line name
364 * @lflags: gpio_lookup_flags - returned from of_find_gpio() or363 * @lflags: bitmask of gpio_lookup_flags GPIO_* values - returned from
365 * of_parse_own_gpio()364 * of_find_gpio() or of_parse_own_gpio()
366 * @dflags: gpiod_flags - optional GPIO initialization flags365 * @dflags: gpiod_flags - optional GPIO initialization flags
367 *366 *
368 * Returns GPIO descriptor to use with Linux GPIO API, or one of the errno367 * Returns GPIO descriptor to use with Linux GPIO API, or one of the errno
@@ -371,7 +370,7 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, · 2 unmodified lines
371static struct gpio_desc *of_parse_own_gpio(struct device_node *np,370static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
372 struct gpio_chip *chip,371 struct gpio_chip *chip,
373 unsigned int idx, const char **name,372 unsigned int idx, const char **name,
374 enum gpio_lookup_flags *lflags,373 unsigned long *lflags,
375 enum gpiod_flags *dflags)374 enum gpiod_flags *dflags)
376{375{
377 struct device_node *chip_np;376 struct device_node *chip_np;
@@ -444,7 +443,7 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip) · 66 unmodified lines
444 struct gpio_desc *desc = NULL;443 struct gpio_desc *desc = NULL;
445 struct device_node *np;444 struct device_node *np;
446 const char *name;445 const char *name;
447 enum gpio_lookup_flags lflags;446 unsigned long lflags;
448 enum gpiod_flags dflags;447 enum gpiod_flags dflags;
449 unsigned int i;448 unsigned int i;
450 int ret;449 int ret;
drivers/gpio/gpiolib.c+6−7
@@ -3923,8 +3923,7 @@ found: · 3922 unmodified lines
3923}3923}
3924 3924
3925static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,3925static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id,
3926 unsigned int idx,3926 unsigned int idx, unsigned long *flags)
3927 enum gpio_lookup_flags *flags)
3928{3927{
3929 struct gpio_desc *desc = ERR_PTR(-ENOENT);3928 struct gpio_desc *desc = ERR_PTR(-ENOENT);
3930 struct gpiod_lookup_table *table;3929 struct gpiod_lookup_table *table;
@@ -4080,8 +4079,8 @@ EXPORT_SYMBOL_GPL(gpiod_get_optional); · 149 unmodified lines
4080 * gpiod_configure_flags - helper function to configure a given GPIO4079 * gpiod_configure_flags - helper function to configure a given GPIO
4081 * @desc: gpio whose value will be assigned4080 * @desc: gpio whose value will be assigned
4082 * @con_id: function within the GPIO consumer4081 * @con_id: function within the GPIO consumer
4083 * @lflags: gpio_lookup_flags - returned from of_find_gpio() or4082 * @lflags: bitmask of gpio_lookup_flags GPIO_* values - returned from
4084 * of_get_gpio_hog()4083 * of_find_gpio() or of_get_gpio_hog()
4085 * @dflags: gpiod_flags - optional GPIO initialization flags4084 * @dflags: gpiod_flags - optional GPIO initialization flags
4086 *4085 *
4087 * Return 0 on success, -ENOENT if no GPIO has been assigned to the4086 * Return 0 on success, -ENOENT if no GPIO has been assigned to the
@@ -4163,9 +4162,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev, · 75 unmodified lines
4163 unsigned int idx,4162 unsigned int idx,
4164 enum gpiod_flags flags)4163 enum gpiod_flags flags)
4165{4164{
4165 unsigned long lookupflags = 0;
4166 struct gpio_desc *desc = NULL;4166 struct gpio_desc *desc = NULL;
4167 int status;4167 int status;
4168 enum gpio_lookup_flags lookupflags = 0;
4169 /* Maybe we have a device name, maybe not */4168 /* Maybe we have a device name, maybe not */
4170 const char *devname = dev ? dev_name(dev) : "?";4169 const char *devname = dev ? dev_name(dev) : "?";
4171 4170
@@ -4403,8 +4402,8 @@ EXPORT_SYMBOL_GPL(gpiod_get_index_optional); · 231 unmodified lines
4403 * gpiod_hog - Hog the specified GPIO desc given the provided flags4402 * gpiod_hog - Hog the specified GPIO desc given the provided flags
4404 * @desc: gpio whose value will be assigned4403 * @desc: gpio whose value will be assigned
4405 * @name: gpio line name4404 * @name: gpio line name
4406 * @lflags: gpio_lookup_flags - returned from of_find_gpio() or4405 * @lflags: bitmask of gpio_lookup_flags GPIO_* values - returned from
4407 * of_get_gpio_hog()4406 * of_find_gpio() or of_get_gpio_hog()
4408 * @dflags: gpiod_flags - optional GPIO initialization flags4407 * @dflags: gpiod_flags - optional GPIO initialization flags
4409 */4408 */
4410int gpiod_hog(struct gpio_desc *desc, const char *name,4409int gpiod_hog(struct gpio_desc *desc, const char *name,
drivers/gpio/gpiolib.h+4−5
@@ -17,7 +17,6 @@ · 16 unmodified lines
17#include <linux/cdev.h>17#include <linux/cdev.h>
18 18
19enum of_gpio_flags;19enum of_gpio_flags;
20enum gpio_lookup_flags;
21struct acpi_device;20struct acpi_device;
22 21
23/**22/**
@@ -95,7 +94,7 @@ static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" }; · 71 unmodified lines
95struct gpio_desc *of_find_gpio(struct device *dev,94struct gpio_desc *of_find_gpio(struct device *dev,
96 const char *con_id,95 const char *con_id,
97 unsigned int idx,96 unsigned int idx,
98 enum gpio_lookup_flags *flags);97 unsigned long *lookupflags);
99struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np,98struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np,
100 const char *list_name, int index, enum of_gpio_flags *flags);99 const char *list_name, int index, enum of_gpio_flags *flags);
101int of_gpiochip_add(struct gpio_chip *gc);100int of_gpiochip_add(struct gpio_chip *gc);
@@ -104,7 +103,7 @@ void of_gpiochip_remove(struct gpio_chip *gc); · 2 unmodified lines
104static inline struct gpio_desc *of_find_gpio(struct device *dev,103static inline struct gpio_desc *of_find_gpio(struct device *dev,
105 const char *con_id,104 const char *con_id,
106 unsigned int idx,105 unsigned int idx,
107 enum gpio_lookup_flags *flags)106 unsigned long *lookupflags)
108{107{
109 return ERR_PTR(-ENOENT);108 return ERR_PTR(-ENOENT);
110}109}
@@ -131,7 +130,7 @@ struct gpio_desc *acpi_find_gpio(struct device *dev, · 20 unmodified lines
131 const char *con_id,130 const char *con_id,
132 unsigned int idx,131 unsigned int idx,
133 enum gpiod_flags *dflags,132 enum gpiod_flags *dflags,
134 enum gpio_lookup_flags *lookupflags);133 unsigned long *lookupflags);
135struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,134struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
136 const char *propname, int index,135 const char *propname, int index,
137 struct acpi_gpio_info *info);136 struct acpi_gpio_info *info);
@@ -158,7 +157,7 @@ acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags, struct acpi_gpio_info *inf · 20 unmodified lines
158static inline struct gpio_desc *157static inline struct gpio_desc *
159acpi_find_gpio(struct device *dev, const char *con_id,158acpi_find_gpio(struct device *dev, const char *con_id,
160 unsigned int idx, enum gpiod_flags *dflags,159 unsigned int idx, enum gpiod_flags *dflags,
161 enum gpio_lookup_flags *lookupflags)160 unsigned long *lookupflags)
162{161{
163 return ERR_PTR(-ENOENT);162 return ERR_PTR(-ENOENT);
164}163}
include/linux/gpio/machine.h+4−4
@@ -22,7 +22,7 @@ enum gpio_lookup_flags { · 21 unmodified lines
22 * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO22 * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
23 * @con_id: name of the GPIO from the device's point of view23 * @con_id: name of the GPIO from the device's point of view
24 * @idx: index of the GPIO in case several GPIOs share the same name24 * @idx: index of the GPIO in case several GPIOs share the same name
25 * @flags: mask of GPIO_* values25 * @flags: bitmask of gpio_lookup_flags GPIO_* values
26 *26 *
27 * gpiod_lookup is a lookup table for associating GPIOs to specific devices and27 * gpiod_lookup is a lookup table for associating GPIOs to specific devices and
28 * functions using platform data.28 * functions using platform data.
@@ -32,7 +32,7 @@ struct gpiod_lookup { · 3 unmodified lines
32 u16 chip_hwnum;32 u16 chip_hwnum;
33 const char *con_id;33 const char *con_id;
34 unsigned int idx;34 unsigned int idx;
35 enum gpio_lookup_flags flags;35 unsigned long flags;
36};36};
37 37
38struct gpiod_lookup_table {38struct gpiod_lookup_table {
@@ -46,7 +46,7 @@ struct gpiod_lookup_table { · 7 unmodified lines
46 * @chip_label: name of the chip the GPIO belongs to46 * @chip_label: name of the chip the GPIO belongs to
47 * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO47 * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
48 * @line_name: consumer name for the hogged line48 * @line_name: consumer name for the hogged line
49 * @lflags: mask of GPIO lookup flags49 * @lflags: bitmask of gpio_lookup_flags GPIO_* values
50 * @dflags: GPIO flags used to specify the direction and value50 * @dflags: GPIO flags used to specify the direction and value
51 */51 */
52struct gpiod_hog {52struct gpiod_hog {
@@ -54,7 +54,7 @@ struct gpiod_hog { · 1 unmodified line
54 const char *chip_label;54 const char *chip_label;
55 u16 chip_hwnum;55 u16 chip_hwnum;
56 const char *line_name;56 const char *line_name;
57 enum gpio_lookup_flags lflags;57 unsigned long lflags;
58 int dflags;58 int dflags;
59};59};
60 60

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t