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
696696 const char *con_id,
697697 unsigned int idx,
698698 enum gpiod_flags *dflags,
699− enum gpio_lookup_flags *lookupflags)
699+ unsigned long *lookupflags)
700700 {
701701 struct acpi_device *adev = ACPI_COMPANION(dev);
702702 struct acpi_gpio_info info;
@@ -995,9 +995,12 @@ static void acpi_gpiochip_free_regions(struct acpi_gpio_chip *achip) · 292 unmodified lines
995995 }
996996 }
997997
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)
10011004 {
10021005 struct gpio_chip *chip = achip->chip;
10031006 struct gpio_desc *desc;
@@ -1040,7 +1043,8 @@ static void acpi_gpiochip_scan_gpios(struct acpi_gpio_chip *achip) · 36 unmodified lines
10401043 struct fwnode_handle *fwnode;
10411044
10421045 device_for_each_child_node(chip->parent, fwnode) {
1043− unsigned int lflags, dflags;
1046+ unsigned long lflags;
1047+ unsigned int dflags;
10441048 struct gpio_desc *desc;
10451049 const char *name;
10461050 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
287287 }
288288
289289 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)
292291 {
293292 char prop_name[32]; /* 32 is max size of property name */
294293 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
361360 * @chip: GPIO chip whose hog is parsed
362361 * @idx: Index of the GPIO to parse
363362 * @name: GPIO line name
364− * @lflags: gpio_lookup_flags - returned from of_find_gpio() or
365− * of_parse_own_gpio()
363+ * @lflags: bitmask of gpio_lookup_flags GPIO_* values - returned from
364+ * of_find_gpio() or of_parse_own_gpio()
366365 * @dflags: gpiod_flags - optional GPIO initialization flags
367366 *
368367 * 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
371370 static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
372371 struct gpio_chip *chip,
373372 unsigned int idx, const char **name,
374− enum gpio_lookup_flags *lflags,
373+ unsigned long *lflags,
375374 enum gpiod_flags *dflags)
376375 {
377376 struct device_node *chip_np;
@@ -444,7 +443,7 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip) · 66 unmodified lines
444443 struct gpio_desc *desc = NULL;
445444 struct device_node *np;
446445 const char *name;
447− enum gpio_lookup_flags lflags;
446+ unsigned long lflags;
448447 enum gpiod_flags dflags;
449448 unsigned int i;
450449 int ret;
drivers/gpio/gpiolib.c+6−7
@@ -3923,8 +3923,7 @@ found: · 3922 unmodified lines
39233923 }
39243924
39253925 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)
39283927 {
39293928 struct gpio_desc *desc = ERR_PTR(-ENOENT);
39303929 struct gpiod_lookup_table *table;
@@ -4080,8 +4079,8 @@ EXPORT_SYMBOL_GPL(gpiod_get_optional); · 149 unmodified lines
40804079 * gpiod_configure_flags - helper function to configure a given GPIO
40814080 * @desc: gpio whose value will be assigned
40824081 * @con_id: function within the GPIO consumer
4083− * @lflags: gpio_lookup_flags - returned from of_find_gpio() or
4084− * of_get_gpio_hog()
4082+ * @lflags: bitmask of gpio_lookup_flags GPIO_* values - returned from
4083+ * of_find_gpio() or of_get_gpio_hog()
40854084 * @dflags: gpiod_flags - optional GPIO initialization flags
40864085 *
40874086 * 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
41634162 unsigned int idx,
41644163 enum gpiod_flags flags)
41654164 {
4165+ unsigned long lookupflags = 0;
41664166 struct gpio_desc *desc = NULL;
41674167 int status;
4168− enum gpio_lookup_flags lookupflags = 0;
41694168 /* Maybe we have a device name, maybe not */
41704169 const char *devname = dev ? dev_name(dev) : "?";
41714170
@@ -4403,8 +4402,8 @@ EXPORT_SYMBOL_GPL(gpiod_get_index_optional); · 231 unmodified lines
44034402 * gpiod_hog - Hog the specified GPIO desc given the provided flags
44044403 * @desc: gpio whose value will be assigned
44054404 * @name: gpio line name
4406− * @lflags: gpio_lookup_flags - returned from of_find_gpio() or
4407− * of_get_gpio_hog()
4405+ * @lflags: bitmask of gpio_lookup_flags GPIO_* values - returned from
4406+ * of_find_gpio() or of_get_gpio_hog()
44084407 * @dflags: gpiod_flags - optional GPIO initialization flags
44094408 */
44104409 int gpiod_hog(struct gpio_desc *desc, const char *name,
drivers/gpio/gpiolib.h+4−5
@@ -17,7 +17,6 @@ · 16 unmodified lines
1717 #include <linux/cdev.h>
1818
1919 enum of_gpio_flags;
20−enum gpio_lookup_flags;
2120 struct acpi_device;
2221
2322 /**
@@ -95,7 +94,7 @@ static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" }; · 71 unmodified lines
9594 struct gpio_desc *of_find_gpio(struct device *dev,
9695 const char *con_id,
9796 unsigned int idx,
98− enum gpio_lookup_flags *flags);
97+ unsigned long *lookupflags);
9998 struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np,
10099 const char *list_name, int index, enum of_gpio_flags *flags);
101100 int of_gpiochip_add(struct gpio_chip *gc);
@@ -104,7 +103,7 @@ void of_gpiochip_remove(struct gpio_chip *gc); · 2 unmodified lines
104103 static inline struct gpio_desc *of_find_gpio(struct device *dev,
105104 const char *con_id,
106105 unsigned int idx,
107− enum gpio_lookup_flags *flags)
106+ unsigned long *lookupflags)
108107 {
109108 return ERR_PTR(-ENOENT);
110109 }
@@ -131,7 +130,7 @@ struct gpio_desc *acpi_find_gpio(struct device *dev, · 20 unmodified lines
131130 const char *con_id,
132131 unsigned int idx,
133132 enum gpiod_flags *dflags,
134− enum gpio_lookup_flags *lookupflags);
133+ unsigned long *lookupflags);
135134 struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
136135 const char *propname, int index,
137136 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
158157 static inline struct gpio_desc *
159158 acpi_find_gpio(struct device *dev, const char *con_id,
160159 unsigned int idx, enum gpiod_flags *dflags,
161− enum gpio_lookup_flags *lookupflags)
160+ unsigned long *lookupflags)
162161 {
163162 return ERR_PTR(-ENOENT);
164163 }
include/linux/gpio/machine.h+4−4
@@ -22,7 +22,7 @@ enum gpio_lookup_flags { · 21 unmodified lines
2222 * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
2323 * @con_id: name of the GPIO from the device's point of view
2424 * @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
2626 *
2727 * gpiod_lookup is a lookup table for associating GPIOs to specific devices and
2828 * functions using platform data.
@@ -32,7 +32,7 @@ struct gpiod_lookup { · 3 unmodified lines
3232 u16 chip_hwnum;
3333 const char *con_id;
3434 unsigned int idx;
35− enum gpio_lookup_flags flags;
35+ unsigned long flags;
3636 };
3737
3838 struct gpiod_lookup_table {
@@ -46,7 +46,7 @@ struct gpiod_lookup_table { · 7 unmodified lines
4646 * @chip_label: name of the chip the GPIO belongs to
4747 * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
4848 * @line_name: consumer name for the hogged line
49− * @lflags: mask of GPIO lookup flags
49+ * @lflags: bitmask of gpio_lookup_flags GPIO_* values
5050 * @dflags: GPIO flags used to specify the direction and value
5151 */
5252 struct gpiod_hog {
@@ -54,7 +54,7 @@ struct gpiod_hog { · 1 unmodified line
5454 const char *chip_label;
5555 u16 chip_hwnum;
5656 const char *line_name;
57− enum gpio_lookup_flags lflags;
57+ unsigned long lflags;
5858 int dflags;
5959 };
6060

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