Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Andy Shevchenko and committed by
Linus Walleij
fed7026a 4050586b

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