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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'gpio-fixes-for-v6.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio fixes from Bartosz Golaszewski:

- fix regressions in regmap cache initialization in gpio-104-idio-16
and gpio-pci-idio-16

- configure first 16 GPIO lines of the IDIO-16 as fixed outputs

- fix duplicated IRQ mapping that can lead to an RCU stall in gpio-ljca

- fix printf formatters passed to dev_err() and make failure to set
debounce period non fatal

* tag 'gpio-fixes-for-v6.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
gpio: ljca: Fix duplicated IRQ mapping
gpiolib: acpi: Use %pe when passing an error pointer to dev_err()
gpiolib: acpi: Make set debounce errors non fatal
gpio: idio-16: Define fixed direction of the GPIO lines
gpio: regmap: add the .fixed_direction_output configuration parameter
gpio: pci-idio-16: Define maximum valid register address offset
gpio: 104-idio-16: Define maximum valid register address offset

+56 -27
+1
drivers/gpio/gpio-104-idio-16.c
··· 59 59 .reg_stride = 1, 60 60 .val_bits = 8, 61 61 .io_port = true, 62 + .max_register = 0x5, 62 63 .wr_table = &idio_16_wr_table, 63 64 .rd_table = &idio_16_rd_table, 64 65 .volatile_table = &idio_16_rd_table,
+5
drivers/gpio/gpio-idio-16.c
··· 6 6 7 7 #define DEFAULT_SYMBOL_NAMESPACE "GPIO_IDIO_16" 8 8 9 + #include <linux/bitmap.h> 9 10 #include <linux/bits.h> 10 11 #include <linux/device.h> 11 12 #include <linux/err.h> ··· 108 107 struct idio_16_data *data; 109 108 struct regmap_irq_chip *chip; 110 109 struct regmap_irq_chip_data *chip_data; 110 + DECLARE_BITMAP(fixed_direction_output, IDIO_16_NGPIO); 111 111 112 112 if (!config->parent) 113 113 return -EINVAL; ··· 165 163 gpio_config.reg_stride = IDIO_16_REG_STRIDE; 166 164 gpio_config.irq_domain = regmap_irq_get_domain(chip_data); 167 165 gpio_config.reg_mask_xlate = idio_16_reg_mask_xlate; 166 + 167 + bitmap_from_u64(fixed_direction_output, GENMASK_U64(15, 0)); 168 + gpio_config.fixed_direction_output = fixed_direction_output; 168 169 169 170 return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config)); 170 171 }
+3 -11
drivers/gpio/gpio-ljca.c
··· 286 286 { 287 287 const struct ljca_gpio_packet *packet = evt_data; 288 288 struct ljca_gpio_dev *ljca_gpio = context; 289 - int i, irq; 289 + int i; 290 290 291 291 if (cmd != LJCA_GPIO_INT_EVENT) 292 292 return; 293 293 294 294 for (i = 0; i < packet->num; i++) { 295 - irq = irq_find_mapping(ljca_gpio->gc.irq.domain, 296 - packet->item[i].index); 297 - if (!irq) { 298 - dev_err(ljca_gpio->gc.parent, 299 - "gpio_id %u does not mapped to IRQ yet\n", 300 - packet->item[i].index); 301 - return; 302 - } 303 - 304 - generic_handle_domain_irq(ljca_gpio->gc.irq.domain, irq); 295 + generic_handle_domain_irq(ljca_gpio->gc.irq.domain, 296 + packet->item[i].index); 305 297 set_bit(packet->item[i].index, ljca_gpio->reenable_irqs); 306 298 } 307 299
+1
drivers/gpio/gpio-pci-idio-16.c
··· 41 41 .reg_stride = 1, 42 42 .val_bits = 8, 43 43 .io_port = true, 44 + .max_register = 0x7, 44 45 .wr_table = &idio_16_wr_table, 45 46 .rd_table = &idio_16_rd_table, 46 47 .volatile_table = &idio_16_rd_table,
+24 -2
drivers/gpio/gpio-regmap.c
··· 31 31 unsigned int reg_clr_base; 32 32 unsigned int reg_dir_in_base; 33 33 unsigned int reg_dir_out_base; 34 + unsigned long *fixed_direction_output; 34 35 35 36 #ifdef CONFIG_REGMAP_IRQ 36 37 int regmap_irq_line; ··· 134 133 struct gpio_regmap *gpio = gpiochip_get_data(chip); 135 134 unsigned int base, val, reg, mask; 136 135 int invert, ret; 136 + 137 + if (gpio->fixed_direction_output) { 138 + if (test_bit(offset, gpio->fixed_direction_output)) 139 + return GPIO_LINE_DIRECTION_OUT; 140 + else 141 + return GPIO_LINE_DIRECTION_IN; 142 + } 137 143 138 144 if (gpio->reg_dat_base && !gpio->reg_set_base) 139 145 return GPIO_LINE_DIRECTION_IN; ··· 292 284 goto err_free_gpio; 293 285 } 294 286 287 + if (config->fixed_direction_output) { 288 + gpio->fixed_direction_output = bitmap_alloc(chip->ngpio, 289 + GFP_KERNEL); 290 + if (!gpio->fixed_direction_output) { 291 + ret = -ENOMEM; 292 + goto err_free_gpio; 293 + } 294 + bitmap_copy(gpio->fixed_direction_output, 295 + config->fixed_direction_output, chip->ngpio); 296 + } 297 + 295 298 /* if not set, assume there is only one register */ 296 299 gpio->ngpio_per_reg = config->ngpio_per_reg; 297 300 if (!gpio->ngpio_per_reg) ··· 319 300 320 301 ret = gpiochip_add_data(chip, gpio); 321 302 if (ret < 0) 322 - goto err_free_gpio; 303 + goto err_free_bitmap; 323 304 324 305 #ifdef CONFIG_REGMAP_IRQ 325 306 if (config->regmap_irq_chip) { ··· 328 309 config->regmap_irq_line, config->regmap_irq_flags, 329 310 0, config->regmap_irq_chip, &gpio->irq_chip_data); 330 311 if (ret) 331 - goto err_free_gpio; 312 + goto err_free_bitmap; 332 313 333 314 irq_domain = regmap_irq_get_domain(gpio->irq_chip_data); 334 315 } else ··· 345 326 346 327 err_remove_gpiochip: 347 328 gpiochip_remove(chip); 329 + err_free_bitmap: 330 + bitmap_free(gpio->fixed_direction_output); 348 331 err_free_gpio: 349 332 kfree(gpio); 350 333 return ERR_PTR(ret); ··· 365 344 #endif 366 345 367 346 gpiochip_remove(&gpio->gpio_chip); 347 + bitmap_free(gpio->fixed_direction_output); 368 348 kfree(gpio); 369 349 } 370 350 EXPORT_SYMBOL_GPL(gpio_regmap_unregister);
+17 -14
drivers/gpio/gpiolib-acpi-core.c
··· 291 291 return GPIOD_ASIS; 292 292 } 293 293 294 + static void acpi_gpio_set_debounce_timeout(struct gpio_desc *desc, 295 + unsigned int acpi_debounce) 296 + { 297 + int ret; 298 + 299 + /* ACPI uses hundredths of milliseconds units */ 300 + acpi_debounce *= 10; 301 + ret = gpio_set_debounce_timeout(desc, acpi_debounce); 302 + if (ret) 303 + gpiod_warn(desc, "Failed to set debounce-timeout %u: %d\n", 304 + acpi_debounce, ret); 305 + } 306 + 294 307 static struct gpio_desc *acpi_request_own_gpiod(struct gpio_chip *chip, 295 308 struct acpi_resource_gpio *agpio, 296 309 unsigned int index, ··· 313 300 enum gpiod_flags flags = acpi_gpio_to_gpiod_flags(agpio, polarity); 314 301 unsigned int pin = agpio->pin_table[index]; 315 302 struct gpio_desc *desc; 316 - int ret; 317 303 318 304 desc = gpiochip_request_own_desc(chip, pin, label, polarity, flags); 319 305 if (IS_ERR(desc)) 320 306 return desc; 321 307 322 - /* ACPI uses hundredths of milliseconds units */ 323 - ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout * 10); 324 - if (ret) 325 - dev_warn(chip->parent, 326 - "Failed to set debounce-timeout for pin 0x%04X, err %d\n", 327 - pin, ret); 308 + acpi_gpio_set_debounce_timeout(desc, agpio->debounce_timeout); 328 309 329 310 return desc; 330 311 } ··· 382 375 desc = acpi_request_own_gpiod(chip, agpio, 0, "ACPI:Event"); 383 376 if (IS_ERR(desc)) { 384 377 dev_err(chip->parent, 385 - "Failed to request GPIO for pin 0x%04X, err %ld\n", 386 - pin, PTR_ERR(desc)); 378 + "Failed to request GPIO for pin 0x%04X, err %pe\n", 379 + pin, desc); 387 380 return AE_OK; 388 381 } 389 382 ··· 951 944 bool can_fallback = acpi_can_fallback_to_crs(adev, con_id); 952 945 struct acpi_gpio_info info = {}; 953 946 struct gpio_desc *desc; 954 - int ret; 955 947 956 948 desc = __acpi_find_gpio(fwnode, con_id, idx, can_fallback, &info); 957 949 if (IS_ERR(desc)) ··· 965 959 acpi_gpio_update_gpiod_flags(dflags, &info); 966 960 acpi_gpio_update_gpiod_lookup_flags(lookupflags, &info); 967 961 968 - /* ACPI uses hundredths of milliseconds units */ 969 - ret = gpio_set_debounce_timeout(desc, info.debounce * 10); 970 - if (ret) 971 - return ERR_PTR(ret); 962 + acpi_gpio_set_debounce_timeout(desc, info.debounce); 972 963 973 964 return desc; 974 965 }
+5
include/linux/gpio/regmap.h
··· 38 38 * offset to a register/bitmask pair. If not 39 39 * given the default gpio_regmap_simple_xlate() 40 40 * is used. 41 + * @fixed_direction_output: 42 + * (Optional) Bitmap representing the fixed direction of 43 + * the GPIO lines. Useful when there are GPIO lines with a 44 + * fixed direction mixed together in the same register. 41 45 * @drvdata: (Optional) Pointer to driver specific data which is 42 46 * not used by gpio-remap but is provided "as is" to the 43 47 * driver callback(s). ··· 89 85 int reg_stride; 90 86 int ngpio_per_reg; 91 87 struct irq_domain *irq_domain; 88 + unsigned long *fixed_direction_output; 92 89 93 90 #ifdef CONFIG_REGMAP_IRQ 94 91 struct regmap_irq_chip *regmap_irq_chip;