diff options
-rw-r--r-- | Documentation/driver-api/gpio/consumer.rst | 22 | ||||
-rw-r--r-- | drivers/auxdisplay/hd44780.c | 59 | ||||
-rw-r--r-- | drivers/bus/ts-nbus.c | 15 | ||||
-rw-r--r-- | drivers/gpio/gpio-max3191x.c | 10 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.c | 82 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.h | 4 | ||||
-rw-r--r-- | drivers/i2c/muxes/i2c-mux-gpio.c | 13 | ||||
-rw-r--r-- | drivers/mmc/core/pwrseq_simple.c | 13 | ||||
-rw-r--r-- | drivers/mux/gpio.c | 13 | ||||
-rw-r--r-- | drivers/net/phy/mdio-mux-gpio.c | 11 | ||||
-rw-r--r-- | drivers/pcmcia/soc_common.c | 7 | ||||
-rw-r--r-- | drivers/phy/motorola/phy-mapphone-mdm6600.c | 15 | ||||
-rw-r--r-- | drivers/staging/iio/adc/ad7606.c | 9 | ||||
-rw-r--r-- | drivers/tty/serial/serial_mctrl_gpio.c | 7 | ||||
-rw-r--r-- | include/linux/gpio/consumer.h | 34 |
15 files changed, 137 insertions, 177 deletions
diff --git a/Documentation/driver-api/gpio/consumer.rst b/Documentation/driver-api/gpio/consumer.rst index aa03f389d41d..ed68042ddccf 100644 --- a/Documentation/driver-api/gpio/consumer.rst +++ b/Documentation/driver-api/gpio/consumer.rst | |||
@@ -323,29 +323,29 @@ The following functions get or set the values of an array of GPIOs:: | |||
323 | 323 | ||
324 | int gpiod_get_array_value(unsigned int array_size, | 324 | int gpiod_get_array_value(unsigned int array_size, |
325 | struct gpio_desc **desc_array, | 325 | struct gpio_desc **desc_array, |
326 | int *value_array); | 326 | unsigned long *value_bitmap); |
327 | int gpiod_get_raw_array_value(unsigned int array_size, | 327 | int gpiod_get_raw_array_value(unsigned int array_size, |
328 | struct gpio_desc **desc_array, | 328 | struct gpio_desc **desc_array, |
329 | int *value_array); | 329 | unsigned long *value_bitmap); |
330 | int gpiod_get_array_value_cansleep(unsigned int array_size, | 330 | int gpiod_get_array_value_cansleep(unsigned int array_size, |
331 | struct gpio_desc **desc_array, | 331 | struct gpio_desc **desc_array, |
332 | int *value_array); | 332 | unsigned long *value_bitmap); |
333 | int gpiod_get_raw_array_value_cansleep(unsigned int array_size, | 333 | int gpiod_get_raw_array_value_cansleep(unsigned int array_size, |
334 | struct gpio_desc **desc_array, | 334 | struct gpio_desc **desc_array, |
335 | int *value_array); | 335 | unsigned long *value_bitmap); |
336 | 336 | ||
337 | void gpiod_set_array_value(unsigned int array_size, | 337 | void gpiod_set_array_value(unsigned int array_size, |
338 | struct gpio_desc **desc_array, | 338 | struct gpio_desc **desc_array, |
339 | int *value_array) | 339 | unsigned long *value_bitmap) |
340 | void gpiod_set_raw_array_value(unsigned int array_size, | 340 | void gpiod_set_raw_array_value(unsigned int array_size, |
341 | struct gpio_desc **desc_array, | 341 | struct gpio_desc **desc_array, |
342 | int *value_array) | 342 | unsigned long *value_bitmap) |
343 | void gpiod_set_array_value_cansleep(unsigned int array_size, | 343 | void gpiod_set_array_value_cansleep(unsigned int array_size, |
344 | struct gpio_desc **desc_array, | 344 | struct gpio_desc **desc_array, |
345 | int *value_array) | 345 | unsigned long *value_bitmap) |
346 | void gpiod_set_raw_array_value_cansleep(unsigned int array_size, | 346 | void gpiod_set_raw_array_value_cansleep(unsigned int array_size, |
347 | struct gpio_desc **desc_array, | 347 | struct gpio_desc **desc_array, |
348 | int *value_array) | 348 | unsigned long *value_bitmap) |
349 | 349 | ||
350 | The array can be an arbitrary set of GPIOs. The functions will try to access | 350 | The array can be an arbitrary set of GPIOs. The functions will try to access |
351 | GPIOs belonging to the same bank or chip simultaneously if supported by the | 351 | GPIOs belonging to the same bank or chip simultaneously if supported by the |
@@ -356,8 +356,8 @@ accessed sequentially. | |||
356 | The functions take three arguments: | 356 | The functions take three arguments: |
357 | * array_size - the number of array elements | 357 | * array_size - the number of array elements |
358 | * desc_array - an array of GPIO descriptors | 358 | * desc_array - an array of GPIO descriptors |
359 | * value_array - an array to store the GPIOs' values (get) or | 359 | * value_bitmap - a bitmap to store the GPIOs' values (get) or |
360 | an array of values to assign to the GPIOs (set) | 360 | a bitmap of values to assign to the GPIOs (set) |
361 | 361 | ||
362 | The descriptor array can be obtained using the gpiod_get_array() function | 362 | The descriptor array can be obtained using the gpiod_get_array() function |
363 | or one of its variants. If the group of descriptors returned by that function | 363 | or one of its variants. If the group of descriptors returned by that function |
@@ -366,7 +366,7 @@ the struct gpio_descs returned by gpiod_get_array():: | |||
366 | 366 | ||
367 | struct gpio_descs *my_gpio_descs = gpiod_get_array(...); | 367 | struct gpio_descs *my_gpio_descs = gpiod_get_array(...); |
368 | gpiod_set_array_value(my_gpio_descs->ndescs, my_gpio_descs->desc, | 368 | gpiod_set_array_value(my_gpio_descs->ndescs, my_gpio_descs->desc, |
369 | my_gpio_values); | 369 | my_gpio_value_bitmap); |
370 | 370 | ||
371 | It is also possible to access a completely arbitrary array of descriptors. The | 371 | It is also possible to access a completely arbitrary array of descriptors. The |
372 | descriptors may be obtained using any combination of gpiod_get() and | 372 | descriptors may be obtained using any combination of gpiod_get() and |
diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c index f1a42f0f1ded..e9a893384362 100644 --- a/drivers/auxdisplay/hd44780.c +++ b/drivers/auxdisplay/hd44780.c | |||
@@ -62,17 +62,12 @@ static void hd44780_strobe_gpio(struct hd44780 *hd) | |||
62 | /* write to an LCD panel register in 8 bit GPIO mode */ | 62 | /* write to an LCD panel register in 8 bit GPIO mode */ |
63 | static void hd44780_write_gpio8(struct hd44780 *hd, u8 val, unsigned int rs) | 63 | static void hd44780_write_gpio8(struct hd44780 *hd, u8 val, unsigned int rs) |
64 | { | 64 | { |
65 | int values[10]; /* for DATA[0-7], RS, RW */ | 65 | DECLARE_BITMAP(values, 10); /* for DATA[0-7], RS, RW */ |
66 | unsigned int i, n; | 66 | unsigned int n; |
67 | 67 | ||
68 | for (i = 0; i < 8; i++) | 68 | values[0] = val; |
69 | values[PIN_DATA0 + i] = !!(val & BIT(i)); | 69 | __assign_bit(8, values, rs); |
70 | values[PIN_CTRL_RS] = rs; | 70 | n = hd->pins[PIN_CTRL_RW] ? 10 : 9; |
71 | n = 9; | ||
72 | if (hd->pins[PIN_CTRL_RW]) { | ||
73 | values[PIN_CTRL_RW] = 0; | ||
74 | n++; | ||
75 | } | ||
76 | 71 | ||
77 | /* Present the data to the port */ | 72 | /* Present the data to the port */ |
78 | gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA0], values); | 73 | gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA0], values); |
@@ -83,32 +78,25 @@ static void hd44780_write_gpio8(struct hd44780 *hd, u8 val, unsigned int rs) | |||
83 | /* write to an LCD panel register in 4 bit GPIO mode */ | 78 | /* write to an LCD panel register in 4 bit GPIO mode */ |
84 | static void hd44780_write_gpio4(struct hd44780 *hd, u8 val, unsigned int rs) | 79 | static void hd44780_write_gpio4(struct hd44780 *hd, u8 val, unsigned int rs) |
85 | { | 80 | { |
86 | int values[10]; /* for DATA[0-7], RS, RW, but DATA[0-3] is unused */ | 81 | DECLARE_BITMAP(values, 6); /* for DATA[4-7], RS, RW */ |
87 | unsigned int i, n; | 82 | unsigned int n; |
88 | 83 | ||
89 | /* High nibble + RS, RW */ | 84 | /* High nibble + RS, RW */ |
90 | for (i = 4; i < 8; i++) | 85 | values[0] = val >> 4; |
91 | values[PIN_DATA0 + i] = !!(val & BIT(i)); | 86 | __assign_bit(4, values, rs); |
92 | values[PIN_CTRL_RS] = rs; | 87 | n = hd->pins[PIN_CTRL_RW] ? 6 : 5; |
93 | n = 5; | ||
94 | if (hd->pins[PIN_CTRL_RW]) { | ||
95 | values[PIN_CTRL_RW] = 0; | ||
96 | n++; | ||
97 | } | ||
98 | 88 | ||
99 | /* Present the data to the port */ | 89 | /* Present the data to the port */ |
100 | gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], | 90 | gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], values); |
101 | &values[PIN_DATA4]); | ||
102 | 91 | ||
103 | hd44780_strobe_gpio(hd); | 92 | hd44780_strobe_gpio(hd); |
104 | 93 | ||
105 | /* Low nibble */ | 94 | /* Low nibble */ |
106 | for (i = 0; i < 4; i++) | 95 | values[0] &= ~0x0fUL; |
107 | values[PIN_DATA4 + i] = !!(val & BIT(i)); | 96 | values[0] |= val & 0x0f; |
108 | 97 | ||
109 | /* Present the data to the port */ | 98 | /* Present the data to the port */ |
110 | gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], | 99 | gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], values); |
111 | &values[PIN_DATA4]); | ||
112 | 100 | ||
113 | hd44780_strobe_gpio(hd); | 101 | hd44780_strobe_gpio(hd); |
114 | } | 102 | } |
@@ -155,23 +143,16 @@ static void hd44780_write_cmd_gpio4(struct charlcd *lcd, int cmd) | |||
155 | /* Send 4-bits of a command to the LCD panel in raw 4 bit GPIO mode */ | 143 | /* Send 4-bits of a command to the LCD panel in raw 4 bit GPIO mode */ |
156 | static void hd44780_write_cmd_raw_gpio4(struct charlcd *lcd, int cmd) | 144 | static void hd44780_write_cmd_raw_gpio4(struct charlcd *lcd, int cmd) |
157 | { | 145 | { |
158 | int values[10]; /* for DATA[0-7], RS, RW, but DATA[0-3] is unused */ | 146 | DECLARE_BITMAP(values, 6); /* for DATA[4-7], RS, RW */ |
159 | struct hd44780 *hd = lcd->drvdata; | 147 | struct hd44780 *hd = lcd->drvdata; |
160 | unsigned int i, n; | 148 | unsigned int n; |
161 | 149 | ||
162 | /* Command nibble + RS, RW */ | 150 | /* Command nibble + RS, RW */ |
163 | for (i = 0; i < 4; i++) | 151 | values[0] = cmd & 0x0f; |
164 | values[PIN_DATA4 + i] = !!(cmd & BIT(i)); | 152 | n = hd->pins[PIN_CTRL_RW] ? 6 : 5; |
165 | values[PIN_CTRL_RS] = 0; | ||
166 | n = 5; | ||
167 | if (hd->pins[PIN_CTRL_RW]) { | ||
168 | values[PIN_CTRL_RW] = 0; | ||
169 | n++; | ||
170 | } | ||
171 | 153 | ||
172 | /* Present the data to the port */ | 154 | /* Present the data to the port */ |
173 | gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], | 155 | gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], values); |
174 | &values[PIN_DATA4]); | ||
175 | 156 | ||
176 | hd44780_strobe_gpio(hd); | 157 | hd44780_strobe_gpio(hd); |
177 | } | 158 | } |
diff --git a/drivers/bus/ts-nbus.c b/drivers/bus/ts-nbus.c index 073fd9011154..8dde7c77f62c 100644 --- a/drivers/bus/ts-nbus.c +++ b/drivers/bus/ts-nbus.c | |||
@@ -110,11 +110,9 @@ static void ts_nbus_set_direction(struct ts_nbus *ts_nbus, int direction) | |||
110 | */ | 110 | */ |
111 | static void ts_nbus_reset_bus(struct ts_nbus *ts_nbus) | 111 | static void ts_nbus_reset_bus(struct ts_nbus *ts_nbus) |
112 | { | 112 | { |
113 | int i; | 113 | DECLARE_BITMAP(values, 8); |
114 | int values[8]; | ||
115 | 114 | ||
116 | for (i = 0; i < 8; i++) | 115 | values[0] = 0; |
117 | values[i] = 0; | ||
118 | 116 | ||
119 | gpiod_set_array_value_cansleep(8, ts_nbus->data->desc, values); | 117 | gpiod_set_array_value_cansleep(8, ts_nbus->data->desc, values); |
120 | gpiod_set_value_cansleep(ts_nbus->csn, 0); | 118 | gpiod_set_value_cansleep(ts_nbus->csn, 0); |
@@ -157,14 +155,9 @@ static int ts_nbus_read_byte(struct ts_nbus *ts_nbus, u8 *val) | |||
157 | static void ts_nbus_write_byte(struct ts_nbus *ts_nbus, u8 byte) | 155 | static void ts_nbus_write_byte(struct ts_nbus *ts_nbus, u8 byte) |
158 | { | 156 | { |
159 | struct gpio_descs *gpios = ts_nbus->data; | 157 | struct gpio_descs *gpios = ts_nbus->data; |
160 | int i; | 158 | DECLARE_BITMAP(values, 8); |
161 | int values[8]; | ||
162 | 159 | ||
163 | for (i = 0; i < 8; i++) | 160 | values[0] = byte; |
164 | if (byte & BIT(i)) | ||
165 | values[i] = 1; | ||
166 | else | ||
167 | values[i] = 0; | ||
168 | 161 | ||
169 | gpiod_set_array_value_cansleep(8, gpios->desc, values); | 162 | gpiod_set_array_value_cansleep(8, gpios->desc, values); |
170 | } | 163 | } |
diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c index b5b9cb1fda50..bd4a245fc5a0 100644 --- a/drivers/gpio/gpio-max3191x.c +++ b/drivers/gpio/gpio-max3191x.c | |||
@@ -315,14 +315,16 @@ static void gpiod_set_array_single_value_cansleep(unsigned int ndescs, | |||
315 | struct gpio_desc **desc, | 315 | struct gpio_desc **desc, |
316 | int value) | 316 | int value) |
317 | { | 317 | { |
318 | int i, *values; | 318 | unsigned long *values; |
319 | 319 | ||
320 | values = kmalloc_array(ndescs, sizeof(*values), GFP_KERNEL); | 320 | values = bitmap_alloc(ndescs, GFP_KERNEL); |
321 | if (!values) | 321 | if (!values) |
322 | return; | 322 | return; |
323 | 323 | ||
324 | for (i = 0; i < ndescs; i++) | 324 | if (value) |
325 | values[i] = value; | 325 | bitmap_fill(values, ndescs); |
326 | else | ||
327 | bitmap_zero(values, ndescs); | ||
326 | 328 | ||
327 | gpiod_set_array_value_cansleep(ndescs, desc, values); | 329 | gpiod_set_array_value_cansleep(ndescs, desc, values); |
328 | kfree(values); | 330 | kfree(values); |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e8f8a1999393..b66b2191c5c5 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -427,7 +427,7 @@ static long linehandle_ioctl(struct file *filep, unsigned int cmd, | |||
427 | struct linehandle_state *lh = filep->private_data; | 427 | struct linehandle_state *lh = filep->private_data; |
428 | void __user *ip = (void __user *)arg; | 428 | void __user *ip = (void __user *)arg; |
429 | struct gpiohandle_data ghd; | 429 | struct gpiohandle_data ghd; |
430 | int vals[GPIOHANDLES_MAX]; | 430 | DECLARE_BITMAP(vals, GPIOHANDLES_MAX); |
431 | int i; | 431 | int i; |
432 | 432 | ||
433 | if (cmd == GPIOHANDLE_GET_LINE_VALUES_IOCTL) { | 433 | if (cmd == GPIOHANDLE_GET_LINE_VALUES_IOCTL) { |
@@ -442,7 +442,7 @@ static long linehandle_ioctl(struct file *filep, unsigned int cmd, | |||
442 | 442 | ||
443 | memset(&ghd, 0, sizeof(ghd)); | 443 | memset(&ghd, 0, sizeof(ghd)); |
444 | for (i = 0; i < lh->numdescs; i++) | 444 | for (i = 0; i < lh->numdescs; i++) |
445 | ghd.values[i] = vals[i]; | 445 | ghd.values[i] = test_bit(i, vals); |
446 | 446 | ||
447 | if (copy_to_user(ip, &ghd, sizeof(ghd))) | 447 | if (copy_to_user(ip, &ghd, sizeof(ghd))) |
448 | return -EFAULT; | 448 | return -EFAULT; |
@@ -461,7 +461,7 @@ static long linehandle_ioctl(struct file *filep, unsigned int cmd, | |||
461 | 461 | ||
462 | /* Clamp all values to [0,1] */ | 462 | /* Clamp all values to [0,1] */ |
463 | for (i = 0; i < lh->numdescs; i++) | 463 | for (i = 0; i < lh->numdescs; i++) |
464 | vals[i] = !!ghd.values[i]; | 464 | __assign_bit(i, vals, ghd.values[i]); |
465 | 465 | ||
466 | /* Reuse the array setting function */ | 466 | /* Reuse the array setting function */ |
467 | return gpiod_set_array_value_complex(false, | 467 | return gpiod_set_array_value_complex(false, |
@@ -2784,7 +2784,7 @@ static int gpio_chip_get_multiple(struct gpio_chip *chip, | |||
2784 | int gpiod_get_array_value_complex(bool raw, bool can_sleep, | 2784 | int gpiod_get_array_value_complex(bool raw, bool can_sleep, |
2785 | unsigned int array_size, | 2785 | unsigned int array_size, |
2786 | struct gpio_desc **desc_array, | 2786 | struct gpio_desc **desc_array, |
2787 | int *value_array) | 2787 | unsigned long *value_bitmap) |
2788 | { | 2788 | { |
2789 | int i = 0; | 2789 | int i = 0; |
2790 | 2790 | ||
@@ -2835,7 +2835,7 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep, | |||
2835 | 2835 | ||
2836 | if (!raw && test_bit(FLAG_ACTIVE_LOW, &desc->flags)) | 2836 | if (!raw && test_bit(FLAG_ACTIVE_LOW, &desc->flags)) |
2837 | value = !value; | 2837 | value = !value; |
2838 | value_array[j] = value; | 2838 | __assign_bit(j, value_bitmap, value); |
2839 | trace_gpio_value(desc_to_gpio(desc), 1, value); | 2839 | trace_gpio_value(desc_to_gpio(desc), 1, value); |
2840 | } | 2840 | } |
2841 | 2841 | ||
@@ -2895,9 +2895,9 @@ EXPORT_SYMBOL_GPL(gpiod_get_value); | |||
2895 | 2895 | ||
2896 | /** | 2896 | /** |
2897 | * gpiod_get_raw_array_value() - read raw values from an array of GPIOs | 2897 | * gpiod_get_raw_array_value() - read raw values from an array of GPIOs |
2898 | * @array_size: number of elements in the descriptor / value arrays | 2898 | * @array_size: number of elements in the descriptor array / value bitmap |
2899 | * @desc_array: array of GPIO descriptors whose values will be read | 2899 | * @desc_array: array of GPIO descriptors whose values will be read |
2900 | * @value_array: array to store the read values | 2900 | * @value_bitmap: bitmap to store the read values |
2901 | * | 2901 | * |
2902 | * Read the raw values of the GPIOs, i.e. the values of the physical lines | 2902 | * Read the raw values of the GPIOs, i.e. the values of the physical lines |
2903 | * without regard for their ACTIVE_LOW status. Return 0 in case of success, | 2903 | * without regard for their ACTIVE_LOW status. Return 0 in case of success, |
@@ -2907,20 +2907,21 @@ EXPORT_SYMBOL_GPL(gpiod_get_value); | |||
2907 | * and it will complain if the GPIO chip functions potentially sleep. | 2907 | * and it will complain if the GPIO chip functions potentially sleep. |
2908 | */ | 2908 | */ |
2909 | int gpiod_get_raw_array_value(unsigned int array_size, | 2909 | int gpiod_get_raw_array_value(unsigned int array_size, |
2910 | struct gpio_desc **desc_array, int *value_array) | 2910 | struct gpio_desc **desc_array, |
2911 | unsigned long *value_bitmap) | ||
2911 | { | 2912 | { |
2912 | if (!desc_array) | 2913 | if (!desc_array) |
2913 | return -EINVAL; | 2914 | return -EINVAL; |
2914 | return gpiod_get_array_value_complex(true, false, array_size, | 2915 | return gpiod_get_array_value_complex(true, false, array_size, |
2915 | desc_array, value_array); | 2916 | desc_array, value_bitmap); |
2916 | } | 2917 | } |
2917 | EXPORT_SYMBOL_GPL(gpiod_get_raw_array_value); | 2918 | EXPORT_SYMBOL_GPL(gpiod_get_raw_array_value); |
2918 | 2919 | ||
2919 | /** | 2920 | /** |
2920 | * gpiod_get_array_value() - read values from an array of GPIOs | 2921 | * gpiod_get_array_value() - read values from an array of GPIOs |
2921 | * @array_size: number of elements in the descriptor / value arrays | 2922 | * @array_size: number of elements in the descriptor array / value bitmap |
2922 | * @desc_array: array of GPIO descriptors whose values will be read | 2923 | * @desc_array: array of GPIO descriptors whose values will be read |
2923 | * @value_array: array to store the read values | 2924 | * @value_bitmap: bitmap to store the read values |
2924 | * | 2925 | * |
2925 | * Read the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status | 2926 | * Read the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status |
2926 | * into account. Return 0 in case of success, else an error code. | 2927 | * into account. Return 0 in case of success, else an error code. |
@@ -2929,12 +2930,13 @@ EXPORT_SYMBOL_GPL(gpiod_get_raw_array_value); | |||
2929 | * and it will complain if the GPIO chip functions potentially sleep. | 2930 | * and it will complain if the GPIO chip functions potentially sleep. |
2930 | */ | 2931 | */ |
2931 | int gpiod_get_array_value(unsigned int array_size, | 2932 | int gpiod_get_array_value(unsigned int array_size, |
2932 | struct gpio_desc **desc_array, int *value_array) | 2933 | struct gpio_desc **desc_array, |
2934 | unsigned long *value_bitmap) | ||
2933 | { | 2935 | { |
2934 | if (!desc_array) | 2936 | if (!desc_array) |
2935 | return -EINVAL; | 2937 | return -EINVAL; |
2936 | return gpiod_get_array_value_complex(false, false, array_size, | 2938 | return gpiod_get_array_value_complex(false, false, array_size, |
2937 | desc_array, value_array); | 2939 | desc_array, value_bitmap); |
2938 | } | 2940 | } |
2939 | EXPORT_SYMBOL_GPL(gpiod_get_array_value); | 2941 | EXPORT_SYMBOL_GPL(gpiod_get_array_value); |
2940 | 2942 | ||
@@ -3027,7 +3029,7 @@ static void gpio_chip_set_multiple(struct gpio_chip *chip, | |||
3027 | int gpiod_set_array_value_complex(bool raw, bool can_sleep, | 3029 | int gpiod_set_array_value_complex(bool raw, bool can_sleep, |
3028 | unsigned int array_size, | 3030 | unsigned int array_size, |
3029 | struct gpio_desc **desc_array, | 3031 | struct gpio_desc **desc_array, |
3030 | int *value_array) | 3032 | unsigned long *value_bitmap) |
3031 | { | 3033 | { |
3032 | int i = 0; | 3034 | int i = 0; |
3033 | 3035 | ||
@@ -3056,7 +3058,7 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep, | |||
3056 | do { | 3058 | do { |
3057 | struct gpio_desc *desc = desc_array[i]; | 3059 | struct gpio_desc *desc = desc_array[i]; |
3058 | int hwgpio = gpio_chip_hwgpio(desc); | 3060 | int hwgpio = gpio_chip_hwgpio(desc); |
3059 | int value = value_array[i]; | 3061 | int value = test_bit(i, value_bitmap); |
3060 | 3062 | ||
3061 | if (!raw && test_bit(FLAG_ACTIVE_LOW, &desc->flags)) | 3063 | if (!raw && test_bit(FLAG_ACTIVE_LOW, &desc->flags)) |
3062 | value = !value; | 3064 | value = !value; |
@@ -3152,9 +3154,9 @@ EXPORT_SYMBOL_GPL(gpiod_set_value); | |||
3152 | 3154 | ||
3153 | /** | 3155 | /** |
3154 | * gpiod_set_raw_array_value() - assign values to an array of GPIOs | 3156 | * gpiod_set_raw_array_value() - assign values to an array of GPIOs |
3155 | * @array_size: number of elements in the descriptor / value arrays | 3157 | * @array_size: number of elements in the descriptor array / value bitmap |
3156 | * @desc_array: array of GPIO descriptors whose values will be assigned | 3158 | * @desc_array: array of GPIO descriptors whose values will be assigned |
3157 | * @value_array: array of values to assign | 3159 | * @value_bitmap: bitmap of values to assign |
3158 | * | 3160 | * |
3159 | * Set the raw values of the GPIOs, i.e. the values of the physical lines | 3161 | * Set the raw values of the GPIOs, i.e. the values of the physical lines |
3160 | * without regard for their ACTIVE_LOW status. | 3162 | * without regard for their ACTIVE_LOW status. |
@@ -3163,20 +3165,21 @@ EXPORT_SYMBOL_GPL(gpiod_set_value); | |||
3163 | * complain if the GPIO chip functions potentially sleep. | 3165 | * complain if the GPIO chip functions potentially sleep. |
3164 | */ | 3166 | */ |
3165 | int gpiod_set_raw_array_value(unsigned int array_size, | 3167 | int gpiod_set_raw_array_value(unsigned int array_size, |
3166 | struct gpio_desc **desc_array, int *value_array) | 3168 | struct gpio_desc **desc_array, |
3169 | unsigned long *value_bitmap) | ||
3167 | { | 3170 | { |
3168 | if (!desc_array) | 3171 | if (!desc_array) |
3169 | return -EINVAL; | 3172 | return -EINVAL; |
3170 | return gpiod_set_array_value_complex(true, false, array_size, | 3173 | return gpiod_set_array_value_complex(true, false, array_size, |
3171 | desc_array, value_array); | 3174 | desc_array, value_bitmap); |
3172 | } | 3175 | } |
3173 | EXPORT_SYMBOL_GPL(gpiod_set_raw_array_value); | 3176 | EXPORT_SYMBOL_GPL(gpiod_set_raw_array_value); |
3174 | 3177 | ||
3175 | /** | 3178 | /** |
3176 | * gpiod_set_array_value() - assign values to an array of GPIOs | 3179 | * gpiod_set_array_value() - assign values to an array of GPIOs |
3177 | * @array_size: number of elements in the descriptor / value arrays | 3180 | * @array_size: number of elements in the descriptor array / value bitmap |
3178 | * @desc_array: array of GPIO descriptors whose values will be assigned | 3181 | * @desc_array: array of GPIO descriptors whose values will be assigned |
3179 | * @value_array: array of values to assign | 3182 | * @value_bitmap: bitmap of values to assign |
3180 | * | 3183 | * |
3181 | * Set the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status | 3184 | * Set the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status |
3182 | * into account. | 3185 | * into account. |
@@ -3185,12 +3188,13 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_array_value); | |||
3185 | * complain if the GPIO chip functions potentially sleep. | 3188 | * complain if the GPIO chip functions potentially sleep. |
3186 | */ | 3189 | */ |
3187 | void gpiod_set_array_value(unsigned int array_size, | 3190 | void gpiod_set_array_value(unsigned int array_size, |
3188 | struct gpio_desc **desc_array, int *value_array) | 3191 | struct gpio_desc **desc_array, |
3192 | unsigned long *value_bitmap) | ||
3189 | { | 3193 | { |
3190 | if (!desc_array) | 3194 | if (!desc_array) |
3191 | return; | 3195 | return; |
3192 | gpiod_set_array_value_complex(false, false, array_size, desc_array, | 3196 | gpiod_set_array_value_complex(false, false, array_size, desc_array, |
3193 | value_array); | 3197 | value_bitmap); |
3194 | } | 3198 | } |
3195 | EXPORT_SYMBOL_GPL(gpiod_set_array_value); | 3199 | EXPORT_SYMBOL_GPL(gpiod_set_array_value); |
3196 | 3200 | ||
@@ -3410,9 +3414,9 @@ EXPORT_SYMBOL_GPL(gpiod_get_value_cansleep); | |||
3410 | 3414 | ||
3411 | /** | 3415 | /** |
3412 | * gpiod_get_raw_array_value_cansleep() - read raw values from an array of GPIOs | 3416 | * gpiod_get_raw_array_value_cansleep() - read raw values from an array of GPIOs |
3413 | * @array_size: number of elements in the descriptor / value arrays | 3417 | * @array_size: number of elements in the descriptor array / value bitmap |
3414 | * @desc_array: array of GPIO descriptors whose values will be read | 3418 | * @desc_array: array of GPIO descriptors whose values will be read |
3415 | * @value_array: array to store the read values | 3419 | * @value_bitmap: bitmap to store the read values |
3416 | * | 3420 | * |
3417 | * Read the raw values of the GPIOs, i.e. the values of the physical lines | 3421 | * Read the raw values of the GPIOs, i.e. the values of the physical lines |
3418 | * without regard for their ACTIVE_LOW status. Return 0 in case of success, | 3422 | * without regard for their ACTIVE_LOW status. Return 0 in case of success, |
@@ -3422,21 +3426,21 @@ EXPORT_SYMBOL_GPL(gpiod_get_value_cansleep); | |||
3422 | */ | 3426 | */ |
3423 | int gpiod_get_raw_array_value_cansleep(unsigned int array_size, | 3427 | int gpiod_get_raw_array_value_cansleep(unsigned int array_size, |
3424 | struct gpio_desc **desc_array, | 3428 | struct gpio_desc **desc_array, |
3425 | int *value_array) | 3429 | unsigned long *value_bitmap) |
3426 | { | 3430 | { |
3427 | might_sleep_if(extra_checks); | 3431 | might_sleep_if(extra_checks); |
3428 | if (!desc_array) | 3432 | if (!desc_array) |
3429 | return -EINVAL; | 3433 | return -EINVAL; |
3430 | return gpiod_get_array_value_complex(true, true, array_size, | 3434 | return gpiod_get_array_value_complex(true, true, array_size, |
3431 | desc_array, value_array); | 3435 | desc_array, value_bitmap); |
3432 | } | 3436 | } |
3433 | EXPORT_SYMBOL_GPL(gpiod_get_raw_array_value_cansleep); | 3437 | EXPORT_SYMBOL_GPL(gpiod_get_raw_array_value_cansleep); |
3434 | 3438 | ||
3435 | /** | 3439 | /** |
3436 | * gpiod_get_array_value_cansleep() - read values from an array of GPIOs | 3440 | * gpiod_get_array_value_cansleep() - read values from an array of GPIOs |
3437 | * @array_size: number of elements in the descriptor / value arrays | 3441 | * @array_size: number of elements in the descriptor array / value bitmap |
3438 | * @desc_array: array of GPIO descriptors whose values will be read | 3442 | * @desc_array: array of GPIO descriptors whose values will be read |
3439 | * @value_array: array to store the read values | 3443 | * @value_bitmap: bitmap to store the read values |
3440 | * | 3444 | * |
3441 | * Read the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status | 3445 | * Read the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status |
3442 | * into account. Return 0 in case of success, else an error code. | 3446 | * into account. Return 0 in case of success, else an error code. |
@@ -3445,13 +3449,13 @@ EXPORT_SYMBOL_GPL(gpiod_get_raw_array_value_cansleep); | |||
3445 | */ | 3449 | */ |
3446 | int gpiod_get_array_value_cansleep(unsigned int array_size, | 3450 | int gpiod_get_array_value_cansleep(unsigned int array_size, |
3447 | struct gpio_desc **desc_array, | 3451 | struct gpio_desc **desc_array, |
3448 | int *value_array) | 3452 | unsigned long *value_bitmap) |
3449 | { | 3453 | { |
3450 | might_sleep_if(extra_checks); | 3454 | might_sleep_if(extra_checks); |
3451 | if (!desc_array) | 3455 | if (!desc_array) |
3452 | return -EINVAL; | 3456 | return -EINVAL; |
3453 | return gpiod_get_array_value_complex(false, true, array_size, | 3457 | return gpiod_get_array_value_complex(false, true, array_size, |
3454 | desc_array, value_array); | 3458 | desc_array, value_bitmap); |
3455 | } | 3459 | } |
3456 | EXPORT_SYMBOL_GPL(gpiod_get_array_value_cansleep); | 3460 | EXPORT_SYMBOL_GPL(gpiod_get_array_value_cansleep); |
3457 | 3461 | ||
@@ -3493,9 +3497,9 @@ EXPORT_SYMBOL_GPL(gpiod_set_value_cansleep); | |||
3493 | 3497 | ||
3494 | /** | 3498 | /** |
3495 | * gpiod_set_raw_array_value_cansleep() - assign values to an array of GPIOs | 3499 | * gpiod_set_raw_array_value_cansleep() - assign values to an array of GPIOs |
3496 | * @array_size: number of elements in the descriptor / value arrays | 3500 | * @array_size: number of elements in the descriptor array / value bitmap |
3497 | * @desc_array: array of GPIO descriptors whose values will be assigned | 3501 | * @desc_array: array of GPIO descriptors whose values will be assigned |
3498 | * @value_array: array of values to assign | 3502 | * @value_bitmap: bitmap of values to assign |
3499 | * | 3503 | * |
3500 | * Set the raw values of the GPIOs, i.e. the values of the physical lines | 3504 | * Set the raw values of the GPIOs, i.e. the values of the physical lines |
3501 | * without regard for their ACTIVE_LOW status. | 3505 | * without regard for their ACTIVE_LOW status. |
@@ -3504,13 +3508,13 @@ EXPORT_SYMBOL_GPL(gpiod_set_value_cansleep); | |||
3504 | */ | 3508 | */ |
3505 | int gpiod_set_raw_array_value_cansleep(unsigned int array_size, | 3509 | int gpiod_set_raw_array_value_cansleep(unsigned int array_size, |
3506 | struct gpio_desc **desc_array, | 3510 | struct gpio_desc **desc_array, |
3507 | int *value_array) | 3511 | unsigned long *value_bitmap) |
3508 | { | 3512 | { |
3509 | might_sleep_if(extra_checks); | 3513 | might_sleep_if(extra_checks); |
3510 | if (!desc_array) | 3514 | if (!desc_array) |
3511 | return -EINVAL; | 3515 | return -EINVAL; |
3512 | return gpiod_set_array_value_complex(true, true, array_size, desc_array, | 3516 | return gpiod_set_array_value_complex(true, true, array_size, desc_array, |
3513 | value_array); | 3517 | value_bitmap); |
3514 | } | 3518 | } |
3515 | EXPORT_SYMBOL_GPL(gpiod_set_raw_array_value_cansleep); | 3519 | EXPORT_SYMBOL_GPL(gpiod_set_raw_array_value_cansleep); |
3516 | 3520 | ||
@@ -3533,9 +3537,9 @@ void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) | |||
3533 | 3537 | ||
3534 | /** | 3538 | /** |
3535 | * gpiod_set_array_value_cansleep() - assign values to an array of GPIOs | 3539 | * gpiod_set_array_value_cansleep() - assign values to an array of GPIOs |
3536 | * @array_size: number of elements in the descriptor / value arrays | 3540 | * @array_size: number of elements in the descriptor array / value bitmap |
3537 | * @desc_array: array of GPIO descriptors whose values will be assigned | 3541 | * @desc_array: array of GPIO descriptors whose values will be assigned |
3538 | * @value_array: array of values to assign | 3542 | * @value_bitmap: bitmap of values to assign |
3539 | * | 3543 | * |
3540 | * Set the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status | 3544 | * Set the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status |
3541 | * into account. | 3545 | * into account. |
@@ -3544,13 +3548,13 @@ void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) | |||
3544 | */ | 3548 | */ |
3545 | void gpiod_set_array_value_cansleep(unsigned int array_size, | 3549 | void gpiod_set_array_value_cansleep(unsigned int array_size, |
3546 | struct gpio_desc **desc_array, | 3550 | struct gpio_desc **desc_array, |
3547 | int *value_array) | 3551 | unsigned long *value_bitmap) |
3548 | { | 3552 | { |
3549 | might_sleep_if(extra_checks); | 3553 | might_sleep_if(extra_checks); |
3550 | if (!desc_array) | 3554 | if (!desc_array) |
3551 | return; | 3555 | return; |
3552 | gpiod_set_array_value_complex(false, true, array_size, desc_array, | 3556 | gpiod_set_array_value_complex(false, true, array_size, desc_array, |
3553 | value_array); | 3557 | value_bitmap); |
3554 | } | 3558 | } |
3555 | EXPORT_SYMBOL_GPL(gpiod_set_array_value_cansleep); | 3559 | EXPORT_SYMBOL_GPL(gpiod_set_array_value_cansleep); |
3556 | 3560 | ||
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index a7e49fef73d4..11e83d2eef89 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h | |||
@@ -187,11 +187,11 @@ struct gpio_desc *gpiochip_get_desc(struct gpio_chip *chip, u16 hwnum); | |||
187 | int gpiod_get_array_value_complex(bool raw, bool can_sleep, | 187 | int gpiod_get_array_value_complex(bool raw, bool can_sleep, |
188 | unsigned int array_size, | 188 | unsigned int array_size, |
189 | struct gpio_desc **desc_array, | 189 | struct gpio_desc **desc_array, |
190 | int *value_array); | 190 | unsigned long *value_bitmap); |
191 | int gpiod_set_array_value_complex(bool raw, bool can_sleep, | 191 | int gpiod_set_array_value_complex(bool raw, bool can_sleep, |
192 | unsigned int array_size, | 192 | unsigned int array_size, |
193 | struct gpio_desc **desc_array, | 193 | struct gpio_desc **desc_array, |
194 | int *value_array); | 194 | unsigned long *value_bitmap); |
195 | 195 | ||
196 | /* This is just passed between gpiolib and devres */ | 196 | /* This is just passed between gpiolib and devres */ |
197 | struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, | 197 | struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, |
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index 401308e3d036..d835857bb094 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c | |||
@@ -22,18 +22,15 @@ struct gpiomux { | |||
22 | struct i2c_mux_gpio_platform_data data; | 22 | struct i2c_mux_gpio_platform_data data; |
23 | unsigned gpio_base; | 23 | unsigned gpio_base; |
24 | struct gpio_desc **gpios; | 24 | struct gpio_desc **gpios; |
25 | int *values; | ||
26 | }; | 25 | }; |
27 | 26 | ||
28 | static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val) | 27 | static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val) |
29 | { | 28 | { |
30 | int i; | 29 | DECLARE_BITMAP(values, BITS_PER_TYPE(val)); |
31 | 30 | ||
32 | for (i = 0; i < mux->data.n_gpios; i++) | 31 | values[0] = val; |
33 | mux->values[i] = (val >> i) & 1; | ||
34 | 32 | ||
35 | gpiod_set_array_value_cansleep(mux->data.n_gpios, | 33 | gpiod_set_array_value_cansleep(mux->data.n_gpios, mux->gpios, values); |
36 | mux->gpios, mux->values); | ||
37 | } | 34 | } |
38 | 35 | ||
39 | static int i2c_mux_gpio_select(struct i2c_mux_core *muxc, u32 chan) | 36 | static int i2c_mux_gpio_select(struct i2c_mux_core *muxc, u32 chan) |
@@ -182,15 +179,13 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev) | |||
182 | return -EPROBE_DEFER; | 179 | return -EPROBE_DEFER; |
183 | 180 | ||
184 | muxc = i2c_mux_alloc(parent, &pdev->dev, mux->data.n_values, | 181 | muxc = i2c_mux_alloc(parent, &pdev->dev, mux->data.n_values, |
185 | mux->data.n_gpios * sizeof(*mux->gpios) + | 182 | mux->data.n_gpios * sizeof(*mux->gpios), 0, |
186 | mux->data.n_gpios * sizeof(*mux->values), 0, | ||
187 | i2c_mux_gpio_select, NULL); | 183 | i2c_mux_gpio_select, NULL); |
188 | if (!muxc) { | 184 | if (!muxc) { |
189 | ret = -ENOMEM; | 185 | ret = -ENOMEM; |
190 | goto alloc_failed; | 186 | goto alloc_failed; |
191 | } | 187 | } |
192 | mux->gpios = muxc->priv; | 188 | mux->gpios = muxc->priv; |
193 | mux->values = (int *)(mux->gpios + mux->data.n_gpios); | ||
194 | muxc->priv = mux; | 189 | muxc->priv = mux; |
195 | 190 | ||
196 | platform_set_drvdata(pdev, muxc); | 191 | platform_set_drvdata(pdev, muxc); |
diff --git a/drivers/mmc/core/pwrseq_simple.c b/drivers/mmc/core/pwrseq_simple.c index a8b9fee4d62a..902476ef9a0e 100644 --- a/drivers/mmc/core/pwrseq_simple.c +++ b/drivers/mmc/core/pwrseq_simple.c | |||
@@ -40,18 +40,13 @@ static void mmc_pwrseq_simple_set_gpios_value(struct mmc_pwrseq_simple *pwrseq, | |||
40 | struct gpio_descs *reset_gpios = pwrseq->reset_gpios; | 40 | struct gpio_descs *reset_gpios = pwrseq->reset_gpios; |
41 | 41 | ||
42 | if (!IS_ERR(reset_gpios)) { | 42 | if (!IS_ERR(reset_gpios)) { |
43 | int i, *values; | 43 | DECLARE_BITMAP(values, BITS_PER_TYPE(value)); |
44 | int nvalues = reset_gpios->ndescs; | 44 | int nvalues = reset_gpios->ndescs; |
45 | 45 | ||
46 | values = kmalloc_array(nvalues, sizeof(int), GFP_KERNEL); | 46 | values[0] = value; |
47 | if (!values) | ||
48 | return; | ||
49 | 47 | ||
50 | for (i = 0; i < nvalues; i++) | 48 | gpiod_set_array_value_cansleep(nvalues, reset_gpios->desc, |
51 | values[i] = value; | 49 | values); |
52 | |||
53 | gpiod_set_array_value_cansleep(nvalues, reset_gpios->desc, values); | ||
54 | kfree(values); | ||
55 | } | 50 | } |
56 | } | 51 | } |
57 | 52 | ||
diff --git a/drivers/mux/gpio.c b/drivers/mux/gpio.c index 6fdd9316db8b..46c44532fbd5 100644 --- a/drivers/mux/gpio.c +++ b/drivers/mux/gpio.c | |||
@@ -17,20 +17,17 @@ | |||
17 | 17 | ||
18 | struct mux_gpio { | 18 | struct mux_gpio { |
19 | struct gpio_descs *gpios; | 19 | struct gpio_descs *gpios; |
20 | int *val; | ||
21 | }; | 20 | }; |
22 | 21 | ||
23 | static int mux_gpio_set(struct mux_control *mux, int state) | 22 | static int mux_gpio_set(struct mux_control *mux, int state) |
24 | { | 23 | { |
25 | struct mux_gpio *mux_gpio = mux_chip_priv(mux->chip); | 24 | struct mux_gpio *mux_gpio = mux_chip_priv(mux->chip); |
26 | int i; | 25 | DECLARE_BITMAP(values, BITS_PER_TYPE(state)); |
27 | 26 | ||
28 | for (i = 0; i < mux_gpio->gpios->ndescs; i++) | 27 | values[0] = state; |
29 | mux_gpio->val[i] = (state >> i) & 1; | ||
30 | 28 | ||
31 | gpiod_set_array_value_cansleep(mux_gpio->gpios->ndescs, | 29 | gpiod_set_array_value_cansleep(mux_gpio->gpios->ndescs, |
32 | mux_gpio->gpios->desc, | 30 | mux_gpio->gpios->desc, values); |
33 | mux_gpio->val); | ||
34 | 31 | ||
35 | return 0; | 32 | return 0; |
36 | } | 33 | } |
@@ -58,13 +55,11 @@ static int mux_gpio_probe(struct platform_device *pdev) | |||
58 | if (pins < 0) | 55 | if (pins < 0) |
59 | return pins; | 56 | return pins; |
60 | 57 | ||
61 | mux_chip = devm_mux_chip_alloc(dev, 1, sizeof(*mux_gpio) + | 58 | mux_chip = devm_mux_chip_alloc(dev, 1, sizeof(*mux_gpio)); |
62 | pins * sizeof(*mux_gpio->val)); | ||
63 | if (IS_ERR(mux_chip)) | 59 | if (IS_ERR(mux_chip)) |
64 | return PTR_ERR(mux_chip); | 60 | return PTR_ERR(mux_chip); |
65 | 61 | ||
66 | mux_gpio = mux_chip_priv(mux_chip); | 62 | mux_gpio = mux_chip_priv(mux_chip); |
67 | mux_gpio->val = (int *)(mux_gpio + 1); | ||
68 | mux_chip->ops = &mux_gpio_ops; | 63 | mux_chip->ops = &mux_gpio_ops; |
69 | 64 | ||
70 | mux_gpio->gpios = devm_gpiod_get_array(dev, "mux", GPIOD_OUT_LOW); | 65 | mux_gpio->gpios = devm_gpiod_get_array(dev, "mux", GPIOD_OUT_LOW); |
diff --git a/drivers/net/phy/mdio-mux-gpio.c b/drivers/net/phy/mdio-mux-gpio.c index bc90764a8b8d..e25ccfc8c070 100644 --- a/drivers/net/phy/mdio-mux-gpio.c +++ b/drivers/net/phy/mdio-mux-gpio.c | |||
@@ -20,23 +20,21 @@ | |||
20 | struct mdio_mux_gpio_state { | 20 | struct mdio_mux_gpio_state { |
21 | struct gpio_descs *gpios; | 21 | struct gpio_descs *gpios; |
22 | void *mux_handle; | 22 | void *mux_handle; |
23 | int values[]; | ||
24 | }; | 23 | }; |
25 | 24 | ||
26 | static int mdio_mux_gpio_switch_fn(int current_child, int desired_child, | 25 | static int mdio_mux_gpio_switch_fn(int current_child, int desired_child, |
27 | void *data) | 26 | void *data) |
28 | { | 27 | { |
29 | struct mdio_mux_gpio_state *s = data; | 28 | struct mdio_mux_gpio_state *s = data; |
30 | unsigned int n; | 29 | DECLARE_BITMAP(values, BITS_PER_TYPE(desired_child)); |
31 | 30 | ||
32 | if (current_child == desired_child) | 31 | if (current_child == desired_child) |
33 | return 0; | 32 | return 0; |
34 | 33 | ||
35 | for (n = 0; n < s->gpios->ndescs; n++) | 34 | values[0] = desired_child; |
36 | s->values[n] = (desired_child >> n) & 1; | ||
37 | 35 | ||
38 | gpiod_set_array_value_cansleep(s->gpios->ndescs, s->gpios->desc, | 36 | gpiod_set_array_value_cansleep(s->gpios->ndescs, s->gpios->desc, |
39 | s->values); | 37 | values); |
40 | 38 | ||
41 | return 0; | 39 | return 0; |
42 | } | 40 | } |
@@ -51,8 +49,7 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev) | |||
51 | if (IS_ERR(gpios)) | 49 | if (IS_ERR(gpios)) |
52 | return PTR_ERR(gpios); | 50 | return PTR_ERR(gpios); |
53 | 51 | ||
54 | s = devm_kzalloc(&pdev->dev, struct_size(s, values, gpios->ndescs), | 52 | s = devm_kzalloc(&pdev->dev, sizeof(*s), GFP_KERNEL); |
55 | GFP_KERNEL); | ||
56 | if (!s) { | 53 | if (!s) { |
57 | gpiod_put_array(gpios); | 54 | gpiod_put_array(gpios); |
58 | return -ENOMEM; | 55 | return -ENOMEM; |
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c index c5f2344c189b..ac033d555700 100644 --- a/drivers/pcmcia/soc_common.c +++ b/drivers/pcmcia/soc_common.c | |||
@@ -351,15 +351,16 @@ static int soc_common_pcmcia_config_skt( | |||
351 | 351 | ||
352 | if (ret == 0) { | 352 | if (ret == 0) { |
353 | struct gpio_desc *descs[2]; | 353 | struct gpio_desc *descs[2]; |
354 | int values[2], n = 0; | 354 | DECLARE_BITMAP(values, 2); |
355 | int n = 0; | ||
355 | 356 | ||
356 | if (skt->gpio_reset) { | 357 | if (skt->gpio_reset) { |
357 | descs[n] = skt->gpio_reset; | 358 | descs[n] = skt->gpio_reset; |
358 | values[n++] = !!(state->flags & SS_RESET); | 359 | __assign_bit(n++, values, state->flags & SS_RESET); |
359 | } | 360 | } |
360 | if (skt->gpio_bus_enable) { | 361 | if (skt->gpio_bus_enable) { |
361 | descs[n] = skt->gpio_bus_enable; | 362 | descs[n] = skt->gpio_bus_enable; |
362 | values[n++] = !!(state->flags & SS_OUTPUT_ENA); | 363 | __assign_bit(n++, values, state->flags & SS_OUTPUT_ENA); |
363 | } | 364 | } |
364 | 365 | ||
365 | if (n) | 366 | if (n) |
diff --git a/drivers/phy/motorola/phy-mapphone-mdm6600.c b/drivers/phy/motorola/phy-mapphone-mdm6600.c index 0075fb0bef8c..9162b61ddb95 100644 --- a/drivers/phy/motorola/phy-mapphone-mdm6600.c +++ b/drivers/phy/motorola/phy-mapphone-mdm6600.c | |||
@@ -157,12 +157,9 @@ static const struct phy_ops gpio_usb_ops = { | |||
157 | */ | 157 | */ |
158 | static void phy_mdm6600_cmd(struct phy_mdm6600 *ddata, int val) | 158 | static void phy_mdm6600_cmd(struct phy_mdm6600 *ddata, int val) |
159 | { | 159 | { |
160 | int values[PHY_MDM6600_NR_CMD_LINES]; | 160 | DECLARE_BITMAP(values, PHY_MDM6600_NR_CMD_LINES); |
161 | int i; | ||
162 | 161 | ||
163 | val &= (1 << PHY_MDM6600_NR_CMD_LINES) - 1; | 162 | values[0] = val; |
164 | for (i = 0; i < PHY_MDM6600_NR_CMD_LINES; i++) | ||
165 | values[i] = (val & BIT(i)) >> i; | ||
166 | 163 | ||
167 | gpiod_set_array_value_cansleep(PHY_MDM6600_NR_CMD_LINES, | 164 | gpiod_set_array_value_cansleep(PHY_MDM6600_NR_CMD_LINES, |
168 | ddata->cmd_gpios->desc, values); | 165 | ddata->cmd_gpios->desc, values); |
@@ -176,7 +173,7 @@ static void phy_mdm6600_status(struct work_struct *work) | |||
176 | { | 173 | { |
177 | struct phy_mdm6600 *ddata; | 174 | struct phy_mdm6600 *ddata; |
178 | struct device *dev; | 175 | struct device *dev; |
179 | int values[PHY_MDM6600_NR_STATUS_LINES]; | 176 | DECLARE_BITMAP(values, PHY_MDM6600_NR_STATUS_LINES); |
180 | int error, i, val = 0; | 177 | int error, i, val = 0; |
181 | 178 | ||
182 | ddata = container_of(work, struct phy_mdm6600, status_work.work); | 179 | ddata = container_of(work, struct phy_mdm6600, status_work.work); |
@@ -189,11 +186,11 @@ static void phy_mdm6600_status(struct work_struct *work) | |||
189 | return; | 186 | return; |
190 | 187 | ||
191 | for (i = 0; i < PHY_MDM6600_NR_STATUS_LINES; i++) { | 188 | for (i = 0; i < PHY_MDM6600_NR_STATUS_LINES; i++) { |
192 | val |= values[i] << i; | 189 | val |= test_bit(i, values) << i; |
193 | dev_dbg(ddata->dev, "XXX %s: i: %i values[i]: %i val: %i\n", | 190 | dev_dbg(ddata->dev, "XXX %s: i: %i values[i]: %i val: %i\n", |
194 | __func__, i, values[i], val); | 191 | __func__, i, test_bit(i, values), val); |
195 | } | 192 | } |
196 | ddata->status = val; | 193 | ddata->status = values[0]; |
197 | 194 | ||
198 | dev_info(dev, "modem status: %i %s\n", | 195 | dev_info(dev, "modem status: %i %s\n", |
199 | ddata->status, | 196 | ddata->status, |
diff --git a/drivers/staging/iio/adc/ad7606.c b/drivers/staging/iio/adc/ad7606.c index 25b9fcd5e3a4..9c1d77d48700 100644 --- a/drivers/staging/iio/adc/ad7606.c +++ b/drivers/staging/iio/adc/ad7606.c | |||
@@ -202,7 +202,7 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, | |||
202 | long mask) | 202 | long mask) |
203 | { | 203 | { |
204 | struct ad7606_state *st = iio_priv(indio_dev); | 204 | struct ad7606_state *st = iio_priv(indio_dev); |
205 | int values[3]; | 205 | DECLARE_BITMAP(values, 3); |
206 | int ret, i; | 206 | int ret, i; |
207 | 207 | ||
208 | switch (mask) { | 208 | switch (mask) { |
@@ -227,13 +227,10 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, | |||
227 | if (ret < 0) | 227 | if (ret < 0) |
228 | return ret; | 228 | return ret; |
229 | 229 | ||
230 | values[0] = (ret >> 0) & 1; | 230 | values[0] = ret; |
231 | values[1] = (ret >> 1) & 1; | ||
232 | values[2] = (ret >> 2) & 1; | ||
233 | 231 | ||
234 | mutex_lock(&st->lock); | 232 | mutex_lock(&st->lock); |
235 | gpiod_set_array_value(ARRAY_SIZE(values), st->gpio_os->desc, | 233 | gpiod_set_array_value(3, st->gpio_os->desc, values); |
236 | values); | ||
237 | st->oversampling = val; | 234 | st->oversampling = val; |
238 | mutex_unlock(&st->lock); | 235 | mutex_unlock(&st->lock); |
239 | 236 | ||
diff --git a/drivers/tty/serial/serial_mctrl_gpio.c b/drivers/tty/serial/serial_mctrl_gpio.c index 1c06325beaca..7d9d2c7b6c39 100644 --- a/drivers/tty/serial/serial_mctrl_gpio.c +++ b/drivers/tty/serial/serial_mctrl_gpio.c | |||
@@ -40,7 +40,7 @@ void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl) | |||
40 | { | 40 | { |
41 | enum mctrl_gpio_idx i; | 41 | enum mctrl_gpio_idx i; |
42 | struct gpio_desc *desc_array[UART_GPIO_MAX]; | 42 | struct gpio_desc *desc_array[UART_GPIO_MAX]; |
43 | int value_array[UART_GPIO_MAX]; | 43 | DECLARE_BITMAP(values, UART_GPIO_MAX); |
44 | unsigned int count = 0; | 44 | unsigned int count = 0; |
45 | 45 | ||
46 | if (gpios == NULL) | 46 | if (gpios == NULL) |
@@ -49,10 +49,11 @@ void mctrl_gpio_set(struct mctrl_gpios *gpios, unsigned int mctrl) | |||
49 | for (i = 0; i < UART_GPIO_MAX; i++) | 49 | for (i = 0; i < UART_GPIO_MAX; i++) |
50 | if (gpios->gpio[i] && mctrl_gpios_desc[i].dir_out) { | 50 | if (gpios->gpio[i] && mctrl_gpios_desc[i].dir_out) { |
51 | desc_array[count] = gpios->gpio[i]; | 51 | desc_array[count] = gpios->gpio[i]; |
52 | value_array[count] = !!(mctrl & mctrl_gpios_desc[i].mctrl); | 52 | __assign_bit(count, values, |
53 | mctrl & mctrl_gpios_desc[i].mctrl); | ||
53 | count++; | 54 | count++; |
54 | } | 55 | } |
55 | gpiod_set_array_value(count, desc_array, value_array); | 56 | gpiod_set_array_value(count, desc_array, values); |
56 | } | 57 | } |
57 | EXPORT_SYMBOL_GPL(mctrl_gpio_set); | 58 | EXPORT_SYMBOL_GPL(mctrl_gpio_set); |
58 | 59 | ||
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 21ddbe440030..2b0389f0bec4 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h | |||
@@ -104,36 +104,38 @@ int gpiod_direction_output_raw(struct gpio_desc *desc, int value); | |||
104 | /* Value get/set from non-sleeping context */ | 104 | /* Value get/set from non-sleeping context */ |
105 | int gpiod_get_value(const struct gpio_desc *desc); | 105 | int gpiod_get_value(const struct gpio_desc *desc); |
106 | int gpiod_get_array_value(unsigned int array_size, | 106 | int gpiod_get_array_value(unsigned int array_size, |
107 | struct gpio_desc **desc_array, int *value_array); | 107 | struct gpio_desc **desc_array, |
108 | unsigned long *value_bitmap); | ||
108 | void gpiod_set_value(struct gpio_desc *desc, int value); | 109 | void gpiod_set_value(struct gpio_desc *desc, int value); |
109 | void gpiod_set_array_value(unsigned int array_size, | 110 | void gpiod_set_array_value(unsigned int array_size, |
110 | struct gpio_desc **desc_array, int *value_array); | 111 | struct gpio_desc **desc_array, |
112 | unsigned long *value_bitmap); | ||
111 | int gpiod_get_raw_value(const struct gpio_desc *desc); | 113 | int gpiod_get_raw_value(const struct gpio_desc *desc); |
112 | int gpiod_get_raw_array_value(unsigned int array_size, | 114 | int gpiod_get_raw_array_value(unsigned int array_size, |
113 | struct gpio_desc **desc_array, | 115 | struct gpio_desc **desc_array, |
114 | int *value_array); | 116 | unsigned long *value_bitmap); |
115 | void gpiod_set_raw_value(struct gpio_desc *desc, int value); | 117 | void gpiod_set_raw_value(struct gpio_desc *desc, int value); |
116 | int gpiod_set_raw_array_value(unsigned int array_size, | 118 | int gpiod_set_raw_array_value(unsigned int array_size, |
117 | struct gpio_desc **desc_array, | 119 | struct gpio_desc **desc_array, |
118 | int *value_array); | 120 | unsigned long *value_bitmap); |
119 | 121 | ||
120 | /* Value get/set from sleeping context */ | 122 | /* Value get/set from sleeping context */ |
121 | int gpiod_get_value_cansleep(const struct gpio_desc *desc); | 123 | int gpiod_get_value_cansleep(const struct gpio_desc *desc); |
122 | int gpiod_get_array_value_cansleep(unsigned int array_size, | 124 | int gpiod_get_array_value_cansleep(unsigned int array_size, |
123 | struct gpio_desc **desc_array, | 125 | struct gpio_desc **desc_array, |
124 | int *value_array); | 126 | unsigned long *value_bitmap); |
125 | void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); | 127 | void gpiod_set_value_cansleep(struct gpio_desc *desc, int value); |
126 | void gpiod_set_array_value_cansleep(unsigned int array_size, | 128 | void gpiod_set_array_value_cansleep(unsigned int array_size, |
127 | struct gpio_desc **desc_array, | 129 | struct gpio_desc **desc_array, |
128 | int *value_array); | 130 | unsigned long *value_bitmap); |
129 | int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc); | 131 | int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc); |
130 | int gpiod_get_raw_array_value_cansleep(unsigned int array_size, | 132 | int gpiod_get_raw_array_value_cansleep(unsigned int array_size, |
131 | struct gpio_desc **desc_array, | 133 | struct gpio_desc **desc_array, |
132 | int *value_array); | 134 | unsigned long *value_bitmap); |
133 | void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value); | 135 | void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, int value); |
134 | int gpiod_set_raw_array_value_cansleep(unsigned int array_size, | 136 | int gpiod_set_raw_array_value_cansleep(unsigned int array_size, |
135 | struct gpio_desc **desc_array, | 137 | struct gpio_desc **desc_array, |
136 | int *value_array); | 138 | unsigned long *value_bitmap); |
137 | 139 | ||
138 | int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); | 140 | int gpiod_set_debounce(struct gpio_desc *desc, unsigned debounce); |
139 | int gpiod_set_transitory(struct gpio_desc *desc, bool transitory); | 141 | int gpiod_set_transitory(struct gpio_desc *desc, bool transitory); |
@@ -330,7 +332,7 @@ static inline int gpiod_get_value(const struct gpio_desc *desc) | |||
330 | } | 332 | } |
331 | static inline int gpiod_get_array_value(unsigned int array_size, | 333 | static inline int gpiod_get_array_value(unsigned int array_size, |
332 | struct gpio_desc **desc_array, | 334 | struct gpio_desc **desc_array, |
333 | int *value_array) | 335 | unsigned long *value_bitmap) |
334 | { | 336 | { |
335 | /* GPIO can never have been requested */ | 337 | /* GPIO can never have been requested */ |
336 | WARN_ON(1); | 338 | WARN_ON(1); |
@@ -343,7 +345,7 @@ static inline void gpiod_set_value(struct gpio_desc *desc, int value) | |||
343 | } | 345 | } |
344 | static inline void gpiod_set_array_value(unsigned int array_size, | 346 | static inline void gpiod_set_array_value(unsigned int array_size, |
345 | struct gpio_desc **desc_array, | 347 | struct gpio_desc **desc_array, |
346 | int *value_array) | 348 | unsigned long *value_bitmap) |
347 | { | 349 | { |
348 | /* GPIO can never have been requested */ | 350 | /* GPIO can never have been requested */ |
349 | WARN_ON(1); | 351 | WARN_ON(1); |
@@ -356,7 +358,7 @@ static inline int gpiod_get_raw_value(const struct gpio_desc *desc) | |||
356 | } | 358 | } |
357 | static inline int gpiod_get_raw_array_value(unsigned int array_size, | 359 | static inline int gpiod_get_raw_array_value(unsigned int array_size, |
358 | struct gpio_desc **desc_array, | 360 | struct gpio_desc **desc_array, |
359 | int *value_array) | 361 | unsigned long *value_bitmap) |
360 | { | 362 | { |
361 | /* GPIO can never have been requested */ | 363 | /* GPIO can never have been requested */ |
362 | WARN_ON(1); | 364 | WARN_ON(1); |
@@ -369,7 +371,7 @@ static inline void gpiod_set_raw_value(struct gpio_desc *desc, int value) | |||
369 | } | 371 | } |
370 | static inline int gpiod_set_raw_array_value(unsigned int array_size, | 372 | static inline int gpiod_set_raw_array_value(unsigned int array_size, |
371 | struct gpio_desc **desc_array, | 373 | struct gpio_desc **desc_array, |
372 | int *value_array) | 374 | unsigned long *value_bitmap) |
373 | { | 375 | { |
374 | /* GPIO can never have been requested */ | 376 | /* GPIO can never have been requested */ |
375 | WARN_ON(1); | 377 | WARN_ON(1); |
@@ -384,7 +386,7 @@ static inline int gpiod_get_value_cansleep(const struct gpio_desc *desc) | |||
384 | } | 386 | } |
385 | static inline int gpiod_get_array_value_cansleep(unsigned int array_size, | 387 | static inline int gpiod_get_array_value_cansleep(unsigned int array_size, |
386 | struct gpio_desc **desc_array, | 388 | struct gpio_desc **desc_array, |
387 | int *value_array) | 389 | unsigned long *value_bitmap) |
388 | { | 390 | { |
389 | /* GPIO can never have been requested */ | 391 | /* GPIO can never have been requested */ |
390 | WARN_ON(1); | 392 | WARN_ON(1); |
@@ -397,7 +399,7 @@ static inline void gpiod_set_value_cansleep(struct gpio_desc *desc, int value) | |||
397 | } | 399 | } |
398 | static inline void gpiod_set_array_value_cansleep(unsigned int array_size, | 400 | static inline void gpiod_set_array_value_cansleep(unsigned int array_size, |
399 | struct gpio_desc **desc_array, | 401 | struct gpio_desc **desc_array, |
400 | int *value_array) | 402 | unsigned long *value_bitmap) |
401 | { | 403 | { |
402 | /* GPIO can never have been requested */ | 404 | /* GPIO can never have been requested */ |
403 | WARN_ON(1); | 405 | WARN_ON(1); |
@@ -410,7 +412,7 @@ static inline int gpiod_get_raw_value_cansleep(const struct gpio_desc *desc) | |||
410 | } | 412 | } |
411 | static inline int gpiod_get_raw_array_value_cansleep(unsigned int array_size, | 413 | static inline int gpiod_get_raw_array_value_cansleep(unsigned int array_size, |
412 | struct gpio_desc **desc_array, | 414 | struct gpio_desc **desc_array, |
413 | int *value_array) | 415 | unsigned long *value_bitmap) |
414 | { | 416 | { |
415 | /* GPIO can never have been requested */ | 417 | /* GPIO can never have been requested */ |
416 | WARN_ON(1); | 418 | WARN_ON(1); |
@@ -424,7 +426,7 @@ static inline void gpiod_set_raw_value_cansleep(struct gpio_desc *desc, | |||
424 | } | 426 | } |
425 | static inline int gpiod_set_raw_array_value_cansleep(unsigned int array_size, | 427 | static inline int gpiod_set_raw_array_value_cansleep(unsigned int array_size, |
426 | struct gpio_desc **desc_array, | 428 | struct gpio_desc **desc_array, |
427 | int *value_array) | 429 | unsigned long *value_bitmap) |
428 | { | 430 | { |
429 | /* GPIO can never have been requested */ | 431 | /* GPIO can never have been requested */ |
430 | WARN_ON(1); | 432 | WARN_ON(1); |