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

Merge tag 'gpio-updates-for-v5.10-part1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into devel

gpio updates for v5.10 - part 1

- automatically drive GPHY leds in gpio-stp-xway
- refactor ->{get, set}_multiple() in gpio-aggregator
- add support for a new model in rcar-gpio DT bindings
- simplify several GPIO drivers with dev_err_probe()
- disable Direct KBD interrupts in gpio-tc35894
- use DEFINE_SEQ_ATTRIBUTE() in GPIO chardev to shrink code
- switch to using a simpler IDA API in gpiolib
- make devprop_gpiochip_set_names() more generic by using device properties
instead of using fwnode helpers

+201 -164
+1
Documentation/devicetree/bindings/gpio/renesas,rcar-gpio.yaml
··· 37 37 - renesas,gpio-r8a774a1 # RZ/G2M 38 38 - renesas,gpio-r8a774b1 # RZ/G2N 39 39 - renesas,gpio-r8a774c0 # RZ/G2E 40 + - renesas,gpio-r8a774e1 # RZ/G2H 40 41 - renesas,gpio-r8a7795 # R-Car H3 41 42 - renesas,gpio-r8a7796 # R-Car M3-W 42 43 - renesas,gpio-r8a77961 # R-Car M3-W+
-1
drivers/gpio/Makefile
··· 6 6 obj-$(CONFIG_GPIOLIB) += gpiolib.o 7 7 obj-$(CONFIG_GPIOLIB) += gpiolib-devres.o 8 8 obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o 9 - obj-$(CONFIG_GPIOLIB) += gpiolib-devprop.o 10 9 obj-$(CONFIG_GPIOLIB) += gpiolib-cdev.o 11 10 obj-$(CONFIG_OF_GPIO) += gpiolib-of.o 12 11 obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o
+43 -27
drivers/gpio/gpio-aggregator.c
··· 333 333 return gpiod_get_value(fwd->descs[offset]); 334 334 } 335 335 336 - static int gpio_fwd_get_multiple(struct gpio_chip *chip, unsigned long *mask, 336 + static int gpio_fwd_get_multiple(struct gpiochip_fwd *fwd, unsigned long *mask, 337 337 unsigned long *bits) 338 338 { 339 - struct gpiochip_fwd *fwd = gpiochip_get_data(chip); 340 - unsigned long *values, flags = 0; 341 339 struct gpio_desc **descs; 340 + unsigned long *values; 342 341 unsigned int i, j = 0; 343 342 int error; 344 - 345 - if (chip->can_sleep) 346 - mutex_lock(&fwd->mlock); 347 - else 348 - spin_lock_irqsave(&fwd->slock, flags); 349 343 350 344 /* Both values bitmap and desc pointers are stored in tmp[] */ 351 345 values = &fwd->tmp[0]; ··· 350 356 descs[j++] = fwd->descs[i]; 351 357 352 358 error = gpiod_get_array_value(j, descs, NULL, values); 353 - if (!error) { 354 - j = 0; 355 - for_each_set_bit(i, mask, fwd->chip.ngpio) 356 - __assign_bit(i, bits, test_bit(j++, values)); 357 - } 359 + if (error) 360 + return error; 358 361 359 - if (chip->can_sleep) 362 + j = 0; 363 + for_each_set_bit(i, mask, fwd->chip.ngpio) 364 + __assign_bit(i, bits, test_bit(j++, values)); 365 + 366 + return 0; 367 + } 368 + 369 + static int gpio_fwd_get_multiple_locked(struct gpio_chip *chip, 370 + unsigned long *mask, unsigned long *bits) 371 + { 372 + struct gpiochip_fwd *fwd = gpiochip_get_data(chip); 373 + unsigned long flags; 374 + int error; 375 + 376 + if (chip->can_sleep) { 377 + mutex_lock(&fwd->mlock); 378 + error = gpio_fwd_get_multiple(fwd, mask, bits); 360 379 mutex_unlock(&fwd->mlock); 361 - else 380 + } else { 381 + spin_lock_irqsave(&fwd->slock, flags); 382 + error = gpio_fwd_get_multiple(fwd, mask, bits); 362 383 spin_unlock_irqrestore(&fwd->slock, flags); 384 + } 363 385 364 386 return error; 365 387 } ··· 387 377 gpiod_set_value(fwd->descs[offset], value); 388 378 } 389 379 390 - static void gpio_fwd_set_multiple(struct gpio_chip *chip, unsigned long *mask, 380 + static void gpio_fwd_set_multiple(struct gpiochip_fwd *fwd, unsigned long *mask, 391 381 unsigned long *bits) 392 382 { 393 - struct gpiochip_fwd *fwd = gpiochip_get_data(chip); 394 - unsigned long *values, flags = 0; 395 383 struct gpio_desc **descs; 384 + unsigned long *values; 396 385 unsigned int i, j = 0; 397 - 398 - if (chip->can_sleep) 399 - mutex_lock(&fwd->mlock); 400 - else 401 - spin_lock_irqsave(&fwd->slock, flags); 402 386 403 387 /* Both values bitmap and desc pointers are stored in tmp[] */ 404 388 values = &fwd->tmp[0]; ··· 404 400 } 405 401 406 402 gpiod_set_array_value(j, descs, NULL, values); 403 + } 407 404 408 - if (chip->can_sleep) 405 + static void gpio_fwd_set_multiple_locked(struct gpio_chip *chip, 406 + unsigned long *mask, unsigned long *bits) 407 + { 408 + struct gpiochip_fwd *fwd = gpiochip_get_data(chip); 409 + unsigned long flags; 410 + 411 + if (chip->can_sleep) { 412 + mutex_lock(&fwd->mlock); 413 + gpio_fwd_set_multiple(fwd, mask, bits); 409 414 mutex_unlock(&fwd->mlock); 410 - else 415 + } else { 416 + spin_lock_irqsave(&fwd->slock, flags); 417 + gpio_fwd_set_multiple(fwd, mask, bits); 411 418 spin_unlock_irqrestore(&fwd->slock, flags); 419 + } 412 420 } 413 421 414 422 static int gpio_fwd_set_config(struct gpio_chip *chip, unsigned int offset, ··· 486 470 chip->direction_input = gpio_fwd_direction_input; 487 471 chip->direction_output = gpio_fwd_direction_output; 488 472 chip->get = gpio_fwd_get; 489 - chip->get_multiple = gpio_fwd_get_multiple; 473 + chip->get_multiple = gpio_fwd_get_multiple_locked; 490 474 chip->set = gpio_fwd_set; 491 - chip->set_multiple = gpio_fwd_set_multiple; 475 + chip->set_multiple = gpio_fwd_set_multiple_locked; 492 476 chip->base = -1; 493 477 chip->ngpio = ngpios; 494 478 fwd->descs = descs;
+1 -4
drivers/gpio/gpio-bcm-kona.c
··· 590 590 dev_err(dev, "Couldn't determine # GPIO banks\n"); 591 591 return -ENOENT; 592 592 } else if (ret < 0) { 593 - if (ret != -EPROBE_DEFER) 594 - dev_err(dev, "Couldn't determine GPIO banks: (%pe)\n", 595 - ERR_PTR(ret)); 596 - return ret; 593 + return dev_err_probe(dev, ret, "Couldn't determine GPIO banks\n"); 597 594 } 598 595 kona_gpio->num_bank = ret; 599 596
+2 -6
drivers/gpio/gpio-davinci.c
··· 237 237 238 238 for (i = 0; i < nirq; i++) { 239 239 chips->irqs[i] = platform_get_irq(pdev, i); 240 - if (chips->irqs[i] < 0) { 241 - if (chips->irqs[i] != -EPROBE_DEFER) 242 - dev_info(dev, "IRQ not populated, err = %d\n", 243 - chips->irqs[i]); 244 - return chips->irqs[i]; 245 - } 240 + if (chips->irqs[i] < 0) 241 + return dev_err_probe(dev, chips->irqs[i], "IRQ not populated\n"); 246 242 } 247 243 248 244 chips->chip.label = dev_name(dev);
+1 -4
drivers/gpio/gpio-omap.c
··· 1394 1394 if (bank->irq <= 0) { 1395 1395 if (!bank->irq) 1396 1396 bank->irq = -ENXIO; 1397 - if (bank->irq != -EPROBE_DEFER) 1398 - dev_err(dev, 1399 - "can't get irq resource ret=%d\n", bank->irq); 1400 - return bank->irq; 1397 + return dev_err_probe(dev, bank->irq, "can't get irq resource\n"); 1401 1398 } 1402 1399 1403 1400 bank->chip.parent = dev;
+3 -6
drivers/gpio/gpio-pca953x.c
··· 1000 1000 chip->client = client; 1001 1001 1002 1002 reg = devm_regulator_get(&client->dev, "vcc"); 1003 - if (IS_ERR(reg)) { 1004 - ret = PTR_ERR(reg); 1005 - if (ret != -EPROBE_DEFER) 1006 - dev_err(&client->dev, "reg get err: %d\n", ret); 1007 - return ret; 1008 - } 1003 + if (IS_ERR(reg)) 1004 + return dev_err_probe(&client->dev, PTR_ERR(reg), "reg get err\n"); 1005 + 1009 1006 ret = regulator_enable(reg); 1010 1007 if (ret) { 1011 1008 dev_err(&client->dev, "reg en err: %d\n", ret);
+3 -6
drivers/gpio/gpio-pisosr.c
··· 148 148 return -ENOMEM; 149 149 150 150 gpio->load_gpio = devm_gpiod_get_optional(dev, "load", GPIOD_OUT_LOW); 151 - if (IS_ERR(gpio->load_gpio)) { 152 - ret = PTR_ERR(gpio->load_gpio); 153 - if (ret != -EPROBE_DEFER) 154 - dev_err(dev, "Unable to allocate load GPIO\n"); 155 - return ret; 156 - } 151 + if (IS_ERR(gpio->load_gpio)) 152 + return dev_err_probe(dev, PTR_ERR(gpio->load_gpio), 153 + "Unable to allocate load GPIO\n"); 157 154 158 155 mutex_init(&gpio->lock); 159 156
+48 -6
drivers/gpio/gpio-stp-xway.c
··· 41 41 #define XWAY_STP_4HZ BIT(23) 42 42 #define XWAY_STP_8HZ BIT(24) 43 43 #define XWAY_STP_10HZ (BIT(24) | BIT(23)) 44 - #define XWAY_STP_SPEED_MASK (0xf << 23) 44 + #define XWAY_STP_SPEED_MASK (BIT(23) | BIT(24) | BIT(25) | BIT(26) | BIT(27)) 45 + 46 + #define XWAY_STP_FPIS_VALUE BIT(21) 47 + #define XWAY_STP_FPIS_MASK (BIT(20) | BIT(21)) 45 48 46 49 /* clock source for automatic update */ 47 50 #define XWAY_STP_UPD_FPI BIT(31) ··· 57 54 /* 2 groups of 3 bits can be driven by the phys */ 58 55 #define XWAY_STP_PHY_MASK 0x7 59 56 #define XWAY_STP_PHY1_SHIFT 27 60 - #define XWAY_STP_PHY2_SHIFT 15 57 + #define XWAY_STP_PHY2_SHIFT 3 58 + #define XWAY_STP_PHY3_SHIFT 6 59 + #define XWAY_STP_PHY4_SHIFT 15 61 60 62 61 /* STP has 3 groups of 8 bits */ 63 62 #define XWAY_STP_GROUP0 BIT(0) ··· 85 80 u8 dsl; /* the 2 LSBs can be driven by the dsl core */ 86 81 u8 phy1; /* 3 bits can be driven by phy1 */ 87 82 u8 phy2; /* 3 bits can be driven by phy2 */ 83 + u8 phy3; /* 3 bits can be driven by phy3 */ 84 + u8 phy4; /* 3 bits can be driven by phy4 */ 88 85 u8 reserved; /* mask out the hw driven bits in gpio_request */ 89 86 }; 90 87 ··· 121 114 else 122 115 chip->shadow &= ~BIT(gpio); 123 116 xway_stp_w32(chip->virt, chip->shadow, XWAY_STP_CPU0); 124 - xway_stp_w32_mask(chip->virt, 0, XWAY_STP_CON_SWU, XWAY_STP_CON0); 117 + if (!chip->reserved) 118 + xway_stp_w32_mask(chip->virt, 0, XWAY_STP_CON_SWU, XWAY_STP_CON0); 125 119 } 126 120 127 121 /** ··· 196 188 chip->phy2 << XWAY_STP_PHY2_SHIFT, 197 189 XWAY_STP_CON1); 198 190 191 + if (of_machine_is_compatible("lantiq,grx390") 192 + || of_machine_is_compatible("lantiq,ar10")) { 193 + xway_stp_w32_mask(chip->virt, 194 + XWAY_STP_PHY_MASK << XWAY_STP_PHY3_SHIFT, 195 + chip->phy3 << XWAY_STP_PHY3_SHIFT, 196 + XWAY_STP_CON1); 197 + } 198 + 199 + if (of_machine_is_compatible("lantiq,grx390")) { 200 + xway_stp_w32_mask(chip->virt, 201 + XWAY_STP_PHY_MASK << XWAY_STP_PHY4_SHIFT, 202 + chip->phy4 << XWAY_STP_PHY4_SHIFT, 203 + XWAY_STP_CON1); 204 + } 205 + 199 206 /* mask out the hw driven bits in gpio_request */ 200 - chip->reserved = (chip->phy2 << 5) | (chip->phy1 << 2) | chip->dsl; 207 + chip->reserved = (chip->phy4 << 11) | (chip->phy3 << 8) | (chip->phy2 << 5) 208 + | (chip->phy1 << 2) | chip->dsl; 201 209 202 210 /* 203 211 * if we have pins that are driven by hw, we need to tell the stp what 204 212 * clock to use as a timer. 205 213 */ 206 - if (chip->reserved) 214 + if (chip->reserved) { 207 215 xway_stp_w32_mask(chip->virt, XWAY_STP_UPD_MASK, 208 216 XWAY_STP_UPD_FPI, XWAY_STP_CON1); 217 + xway_stp_w32_mask(chip->virt, XWAY_STP_SPEED_MASK, 218 + XWAY_STP_10HZ, XWAY_STP_CON1); 219 + xway_stp_w32_mask(chip->virt, XWAY_STP_FPIS_MASK, 220 + XWAY_STP_FPIS_VALUE, XWAY_STP_CON1); 221 + } 209 222 } 210 223 211 224 static int xway_stp_probe(struct platform_device *pdev) ··· 271 242 /* find out which gpios are controlled by the phys */ 272 243 if (of_machine_is_compatible("lantiq,ar9") || 273 244 of_machine_is_compatible("lantiq,gr9") || 274 - of_machine_is_compatible("lantiq,vr9")) { 245 + of_machine_is_compatible("lantiq,vr9") || 246 + of_machine_is_compatible("lantiq,ar10") || 247 + of_machine_is_compatible("lantiq,grx390")) { 275 248 if (!of_property_read_u32(pdev->dev.of_node, "lantiq,phy1", &phy)) 276 249 chip->phy1 = phy & XWAY_STP_PHY_MASK; 277 250 if (!of_property_read_u32(pdev->dev.of_node, "lantiq,phy2", &phy)) 278 251 chip->phy2 = phy & XWAY_STP_PHY_MASK; 252 + } 253 + 254 + if (of_machine_is_compatible("lantiq,ar10") || 255 + of_machine_is_compatible("lantiq,grx390")) { 256 + if (!of_property_read_u32(pdev->dev.of_node, "lantiq,phy3", &phy)) 257 + chip->phy3 = phy & XWAY_STP_PHY_MASK; 258 + } 259 + 260 + if (of_machine_is_compatible("lantiq,grx390")) { 261 + if (!of_property_read_u32(pdev->dev.of_node, "lantiq,phy4", &phy)) 262 + chip->phy4 = phy & XWAY_STP_PHY_MASK; 279 263 } 280 264 281 265 /* check which edge trigger we should use, default to a falling edge */
+16 -2
drivers/gpio/gpio-tc3589x.c
··· 19 19 * These registers are modified under the irq bus lock and cached to avoid 20 20 * unnecessary writes in bus_sync_unlock. 21 21 */ 22 - enum { REG_IBE, REG_IEV, REG_IS, REG_IE }; 22 + enum { REG_IBE, REG_IEV, REG_IS, REG_IE, REG_DIRECT }; 23 23 24 - #define CACHE_NR_REGS 4 24 + #define CACHE_NR_REGS 5 25 25 #define CACHE_NR_BANKS 3 26 26 27 27 struct tc3589x_gpio { ··· 200 200 [REG_IEV] = TC3589x_GPIOIEV0, 201 201 [REG_IS] = TC3589x_GPIOIS0, 202 202 [REG_IE] = TC3589x_GPIOIE0, 203 + [REG_DIRECT] = TC3589x_DIRECT0, 203 204 }; 204 205 int i, j; 205 206 ··· 229 228 int mask = BIT(offset % 8); 230 229 231 230 tc3589x_gpio->regs[REG_IE][regoffset] &= ~mask; 231 + tc3589x_gpio->regs[REG_DIRECT][regoffset] |= mask; 232 232 } 233 233 234 234 static void tc3589x_gpio_irq_unmask(struct irq_data *d) ··· 241 239 int mask = BIT(offset % 8); 242 240 243 241 tc3589x_gpio->regs[REG_IE][regoffset] |= mask; 242 + tc3589x_gpio->regs[REG_DIRECT][regoffset] &= ~mask; 244 243 } 245 244 246 245 static struct irq_chip tc3589x_gpio_irq_chip = { ··· 334 331 /* Bring the GPIO module out of reset */ 335 332 ret = tc3589x_set_bits(tc3589x, TC3589x_RSTCTRL, 336 333 TC3589x_RSTCTRL_GPIRST, 0); 334 + if (ret < 0) 335 + return ret; 336 + 337 + /* For tc35894, have to disable Direct KBD interrupts, 338 + * else IRQST will always be 0x20, IRQN low level, can't 339 + * clear the irq status. 340 + * TODO: need more test on other tc3589x chip. 341 + * 342 + */ 343 + ret = tc3589x_reg_write(tc3589x, TC3589x_DKBDMSK, 344 + TC3589x_DKBDMSK_ELINT | TC3589x_DKBDMSK_EINT); 337 345 if (ret < 0) 338 346 return ret; 339 347
+3 -5
drivers/gpio/gpio-zynq.c
··· 929 929 930 930 /* Retrieve GPIO clock */ 931 931 gpio->clk = devm_clk_get(&pdev->dev, NULL); 932 - if (IS_ERR(gpio->clk)) { 933 - if (PTR_ERR(gpio->clk) != -EPROBE_DEFER) 934 - dev_err(&pdev->dev, "input clock not found.\n"); 935 - return PTR_ERR(gpio->clk); 936 - } 932 + if (IS_ERR(gpio->clk)) 933 + return dev_err_probe(&pdev->dev, PTR_ERR(gpio->clk), "input clock not found.\n"); 934 + 937 935 ret = clk_prepare_enable(gpio->clk); 938 936 if (ret) { 939 937 dev_err(&pdev->dev, "Unable to enable clock.\n");
-3
drivers/gpio/gpiolib-acpi.c
··· 1221 1221 return; 1222 1222 } 1223 1223 1224 - if (!chip->names) 1225 - devprop_gpiochip_set_names(chip, dev_fwnode(chip->parent)); 1226 - 1227 1224 acpi_gpiochip_request_regions(acpi_gpio); 1228 1225 acpi_gpiochip_scan_gpios(acpi_gpio); 1229 1226 acpi_walk_dep_device_list(handle);
-63
drivers/gpio/gpiolib-devprop.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * Device property helpers for GPIO chips. 4 - * 5 - * Copyright (C) 2016, Intel Corporation 6 - * Author: Mika Westerberg <mika.westerberg@linux.intel.com> 7 - */ 8 - 9 - #include <linux/property.h> 10 - #include <linux/slab.h> 11 - #include <linux/gpio/consumer.h> 12 - #include <linux/gpio/driver.h> 13 - #include <linux/export.h> 14 - 15 - #include "gpiolib.h" 16 - 17 - /** 18 - * devprop_gpiochip_set_names - Set GPIO line names using device properties 19 - * @chip: GPIO chip whose lines should be named, if possible 20 - * @fwnode: Property Node containing the gpio-line-names property 21 - * 22 - * Looks for device property "gpio-line-names" and if it exists assigns 23 - * GPIO line names for the chip. The memory allocated for the assigned 24 - * names belong to the underlying firmware node and should not be released 25 - * by the caller. 26 - */ 27 - void devprop_gpiochip_set_names(struct gpio_chip *chip, 28 - const struct fwnode_handle *fwnode) 29 - { 30 - struct gpio_device *gdev = chip->gpiodev; 31 - const char **names; 32 - int ret, i; 33 - int count; 34 - 35 - count = fwnode_property_read_string_array(fwnode, "gpio-line-names", 36 - NULL, 0); 37 - if (count < 0) 38 - return; 39 - 40 - if (count > gdev->ngpio) { 41 - dev_warn(&gdev->dev, "gpio-line-names is length %d but should be at most length %d", 42 - count, gdev->ngpio); 43 - count = gdev->ngpio; 44 - } 45 - 46 - names = kcalloc(count, sizeof(*names), GFP_KERNEL); 47 - if (!names) 48 - return; 49 - 50 - ret = fwnode_property_read_string_array(fwnode, "gpio-line-names", 51 - names, count); 52 - if (ret < 0) { 53 - dev_warn(&gdev->dev, "failed to read GPIO line names\n"); 54 - kfree(names); 55 - return; 56 - } 57 - 58 - for (i = 0; i < count; i++) 59 - gdev->descs[i].name = names[i]; 60 - 61 - kfree(names); 62 - } 63 - EXPORT_SYMBOL_GPL(devprop_gpiochip_set_names);
-5
drivers/gpio/gpiolib-of.c
··· 1026 1026 if (ret) 1027 1027 return ret; 1028 1028 1029 - /* If the chip defines names itself, these take precedence */ 1030 - if (!chip->names) 1031 - devprop_gpiochip_set_names(chip, 1032 - of_fwnode_handle(chip->of_node)); 1033 - 1034 1029 of_node_get(chip->of_node); 1035 1030 1036 1031 ret = of_gpiochip_scan_gpios(chip);
+61 -23
drivers/gpio/gpiolib.c
··· 340 340 struct gpio_device *gdev = gc->gpiodev; 341 341 int i; 342 342 343 - if (!gc->names) 344 - return 0; 345 - 346 343 /* First check all names if they are unique */ 347 344 for (i = 0; i != gc->ngpio; ++i) { 348 345 struct gpio_desc *gpio; ··· 354 357 /* Then add all names to the GPIO descriptors */ 355 358 for (i = 0; i != gc->ngpio; ++i) 356 359 gdev->descs[i].name = gc->names[i]; 360 + 361 + return 0; 362 + } 363 + 364 + /* 365 + * devprop_gpiochip_set_names - Set GPIO line names using device properties 366 + * @chip: GPIO chip whose lines should be named, if possible 367 + * 368 + * Looks for device property "gpio-line-names" and if it exists assigns 369 + * GPIO line names for the chip. The memory allocated for the assigned 370 + * names belong to the underlying software node and should not be released 371 + * by the caller. 372 + */ 373 + static int devprop_gpiochip_set_names(struct gpio_chip *chip) 374 + { 375 + struct gpio_device *gdev = chip->gpiodev; 376 + struct device *dev = chip->parent; 377 + const char **names; 378 + int ret, i; 379 + int count; 380 + 381 + /* GPIO chip may not have a parent device whose properties we inspect. */ 382 + if (!dev) 383 + return 0; 384 + 385 + count = device_property_string_array_count(dev, "gpio-line-names"); 386 + if (count < 0) 387 + return 0; 388 + 389 + if (count > gdev->ngpio) { 390 + dev_warn(&gdev->dev, "gpio-line-names is length %d but should be at most length %d", 391 + count, gdev->ngpio); 392 + count = gdev->ngpio; 393 + } 394 + 395 + names = kcalloc(count, sizeof(*names), GFP_KERNEL); 396 + if (!names) 397 + return -ENOMEM; 398 + 399 + ret = device_property_read_string_array(dev, "gpio-line-names", 400 + names, count); 401 + if (ret < 0) { 402 + dev_warn(&gdev->dev, "failed to read GPIO line names\n"); 403 + kfree(names); 404 + return ret; 405 + } 406 + 407 + for (i = 0; i < count; i++) 408 + gdev->descs[i].name = names[i]; 409 + 410 + kfree(names); 357 411 358 412 return 0; 359 413 } ··· 474 426 struct gpio_device *gdev = dev_get_drvdata(dev); 475 427 476 428 list_del(&gdev->list); 477 - ida_simple_remove(&gpio_ida, gdev->id); 429 + ida_free(&gpio_ida, gdev->id); 478 430 kfree_const(gdev->label); 479 431 kfree(gdev->descs); 480 432 kfree(gdev); ··· 585 537 gc->of_node = gdev->dev.of_node; 586 538 #endif 587 539 588 - gdev->id = ida_simple_get(&gpio_ida, 0, 0, GFP_KERNEL); 540 + gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL); 589 541 if (gdev->id < 0) { 590 542 ret = gdev->id; 591 543 goto err_free_gdev; ··· 669 621 INIT_LIST_HEAD(&gdev->pin_ranges); 670 622 #endif 671 623 672 - ret = gpiochip_set_desc_names(gc); 624 + if (gc->names) 625 + ret = gpiochip_set_desc_names(gc); 626 + else 627 + ret = devprop_gpiochip_set_names(gc); 673 628 if (ret) 674 629 goto err_remove_from_list; 675 630 ··· 756 705 err_free_descs: 757 706 kfree(gdev->descs); 758 707 err_free_ida: 759 - ida_simple_remove(&gpio_ida, gdev->id); 708 + ida_free(&gpio_ida, gdev->id); 760 709 err_free_gdev: 761 710 /* failures here can mean systems won't boot... */ 762 711 pr_err("%s: GPIOs %d..%d (%s) failed to register, %d\n", __func__, ··· 4453 4402 return 0; 4454 4403 } 4455 4404 4456 - static const struct seq_operations gpiolib_seq_ops = { 4405 + static const struct seq_operations gpiolib_sops = { 4457 4406 .start = gpiolib_seq_start, 4458 4407 .next = gpiolib_seq_next, 4459 4408 .stop = gpiolib_seq_stop, 4460 4409 .show = gpiolib_seq_show, 4461 4410 }; 4462 - 4463 - static int gpiolib_open(struct inode *inode, struct file *file) 4464 - { 4465 - return seq_open(file, &gpiolib_seq_ops); 4466 - } 4467 - 4468 - static const struct file_operations gpiolib_operations = { 4469 - .owner = THIS_MODULE, 4470 - .open = gpiolib_open, 4471 - .read = seq_read, 4472 - .llseek = seq_lseek, 4473 - .release = seq_release, 4474 - }; 4411 + DEFINE_SEQ_ATTRIBUTE(gpiolib); 4475 4412 4476 4413 static int __init gpiolib_debugfs_init(void) 4477 4414 { 4478 4415 /* /sys/kernel/debug/gpio */ 4479 - debugfs_create_file("gpio", S_IFREG | S_IRUGO, NULL, NULL, 4480 - &gpiolib_operations); 4416 + debugfs_create_file("gpio", 0444, NULL, NULL, &gpiolib_fops); 4481 4417 return 0; 4482 4418 } 4483 4419 subsys_initcall(gpiolib_debugfs_init);
-3
include/linux/gpio/driver.h
··· 756 756 enum gpiod_flags dflags); 757 757 void gpiochip_free_own_desc(struct gpio_desc *desc); 758 758 759 - void devprop_gpiochip_set_names(struct gpio_chip *gc, 760 - const struct fwnode_handle *fwnode); 761 - 762 759 #ifdef CONFIG_GPIOLIB 763 760 764 761 /* lock/unlock as IRQ */
+6
include/linux/mfd/tc3589x.h
··· 19 19 #define TC3589x_RSTCTRL_KBDRST (1 << 1) 20 20 #define TC3589x_RSTCTRL_GPIRST (1 << 0) 21 21 22 + #define TC3589x_DKBDMSK_ELINT (1 << 1) 23 + #define TC3589x_DKBDMSK_EINT (1 << 0) 24 + 22 25 /* Keyboard Configuration Registers */ 23 26 #define TC3589x_KBDSETTLE_REG 0x01 24 27 #define TC3589x_KBDBOUNCE 0x02 ··· 103 100 #define TC3589x_GPIOODE1 0xE3 104 101 #define TC3589x_GPIOODM2 0xE4 105 102 #define TC3589x_GPIOODE2 0xE5 103 + 104 + #define TC3589x_DIRECT0 0xEC 105 + #define TC3589x_DKBDMSK 0xF3 106 106 107 107 #define TC3589x_INT_GPIIRQ 0 108 108 #define TC3589x_INT_TI0IRQ 1
+13
include/linux/property.h
··· 170 170 return device_property_read_u64_array(dev, propname, NULL, 0); 171 171 } 172 172 173 + static inline int device_property_string_array_count(struct device *dev, 174 + const char *propname) 175 + { 176 + return device_property_read_string_array(dev, propname, NULL, 0); 177 + } 178 + 173 179 static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode, 174 180 const char *propname) 175 181 { ··· 228 222 const char *propname) 229 223 { 230 224 return fwnode_property_read_u64_array(fwnode, propname, NULL, 0); 225 + } 226 + 227 + static inline int 228 + fwnode_property_string_array_count(const struct fwnode_handle *fwnode, 229 + const char *propname) 230 + { 231 + return fwnode_property_read_string_array(fwnode, propname, NULL, 0); 231 232 } 232 233 233 234 struct software_node;