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-v5.3-6' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio

Pull GPIO fixes from Linus Walleij:
"I don't really like to send so many fixes at the very last minute, but
the bug-sport activity is unpredictable.

Four fixes, three are -stable material that will go everywhere, one is
for the current cycle:

- An ACPI DSDT error fixup of the type we always see and Hans
invariably gets to fix.

- A OF quirk fix for the current release (v5.3)

- Some consistency checks on the userspace ABI.

- A memory leak"

* tag 'gpio-v5.3-6' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
gpiolib: acpi: Add gpiolib_acpi_run_edge_events_on_boot option and blacklist
gpiolib: of: fix fallback quirks handling
gpio: fix line flag validation in lineevent_create
gpio: fix line flag validation in linehandle_create
gpio: mockup: add missing single_release()

+59 -27
+1
drivers/gpio/gpio-mockup.c
··· 309 309 .read = gpio_mockup_debugfs_read, 310 310 .write = gpio_mockup_debugfs_write, 311 311 .llseek = no_llseek, 312 + .release = single_release, 312 313 }; 313 314 314 315 static void gpio_mockup_debugfs_setup(struct device *dev,
+38 -4
drivers/gpio/gpiolib-acpi.c
··· 7 7 * Mika Westerberg <mika.westerberg@linux.intel.com> 8 8 */ 9 9 10 + #include <linux/dmi.h> 10 11 #include <linux/errno.h> 11 12 #include <linux/gpio/consumer.h> 12 13 #include <linux/gpio/driver.h> ··· 19 18 #include <linux/pinctrl/pinctrl.h> 20 19 21 20 #include "gpiolib.h" 21 + 22 + static int run_edge_events_on_boot = -1; 23 + module_param(run_edge_events_on_boot, int, 0444); 24 + MODULE_PARM_DESC(run_edge_events_on_boot, 25 + "Run edge _AEI event-handlers at boot: 0=no, 1=yes, -1=auto"); 22 26 23 27 /** 24 28 * struct acpi_gpio_event - ACPI GPIO event handler data ··· 176 170 event->irq_requested = true; 177 171 178 172 /* Make sure we trigger the initial state of edge-triggered IRQs */ 179 - value = gpiod_get_raw_value_cansleep(event->desc); 180 - if (((event->irqflags & IRQF_TRIGGER_RISING) && value == 1) || 181 - ((event->irqflags & IRQF_TRIGGER_FALLING) && value == 0)) 182 - event->handler(event->irq, event); 173 + if (run_edge_events_on_boot && 174 + (event->irqflags & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING))) { 175 + value = gpiod_get_raw_value_cansleep(event->desc); 176 + if (((event->irqflags & IRQF_TRIGGER_RISING) && value == 1) || 177 + ((event->irqflags & IRQF_TRIGGER_FALLING) && value == 0)) 178 + event->handler(event->irq, event); 179 + } 183 180 } 184 181 185 182 static void acpi_gpiochip_request_irqs(struct acpi_gpio_chip *acpi_gpio) ··· 1292 1283 } 1293 1284 /* We must use _sync so that this runs after the first deferred_probe run */ 1294 1285 late_initcall_sync(acpi_gpio_handle_deferred_request_irqs); 1286 + 1287 + static const struct dmi_system_id run_edge_events_on_boot_blacklist[] = { 1288 + { 1289 + .matches = { 1290 + DMI_MATCH(DMI_SYS_VENDOR, "MINIX"), 1291 + DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"), 1292 + } 1293 + }, 1294 + {} /* Terminating entry */ 1295 + }; 1296 + 1297 + static int acpi_gpio_setup_params(void) 1298 + { 1299 + if (run_edge_events_on_boot < 0) { 1300 + if (dmi_check_system(run_edge_events_on_boot_blacklist)) 1301 + run_edge_events_on_boot = 0; 1302 + else 1303 + run_edge_events_on_boot = 1; 1304 + } 1305 + 1306 + return 0; 1307 + } 1308 + 1309 + /* Directly after dmi_setup() which runs as core_initcall() */ 1310 + postcore_initcall(acpi_gpio_setup_params);
+9 -18
drivers/gpio/gpiolib-of.c
··· 343 343 344 344 desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx, 345 345 &of_flags); 346 - /* 347 - * -EPROBE_DEFER in our case means that we found a 348 - * valid GPIO property, but no controller has been 349 - * registered so far. 350 - * 351 - * This means we don't need to look any further for 352 - * alternate name conventions, and we should really 353 - * preserve the return code for our user to be able to 354 - * retry probing later. 355 - */ 356 - if (IS_ERR(desc) && PTR_ERR(desc) == -EPROBE_DEFER) 357 - return desc; 358 346 359 - if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) 347 + if (!IS_ERR(desc) || PTR_ERR(desc) != -ENOENT) 360 348 break; 361 349 } 362 350 363 - /* Special handling for SPI GPIOs if used */ 364 - if (IS_ERR(desc)) 351 + if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) { 352 + /* Special handling for SPI GPIOs if used */ 365 353 desc = of_find_spi_gpio(dev, con_id, &of_flags); 366 - if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) { 354 + } 355 + 356 + if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) { 367 357 /* This quirk looks up flags and all */ 368 358 desc = of_find_spi_cs_gpio(dev, con_id, idx, flags); 369 359 if (!IS_ERR(desc)) 370 360 return desc; 371 361 } 372 362 373 - /* Special handling for regulator GPIOs if used */ 374 - if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) 363 + if (IS_ERR(desc) && PTR_ERR(desc) == -ENOENT) { 364 + /* Special handling for regulator GPIOs if used */ 375 365 desc = of_find_regulator_gpio(dev, con_id, &of_flags); 366 + } 376 367 377 368 if (IS_ERR(desc)) 378 369 return desc;
+11 -5
drivers/gpio/gpiolib.c
··· 536 536 return -EINVAL; 537 537 538 538 /* 539 + * Do not allow both INPUT & OUTPUT flags to be set as they are 540 + * contradictory. 541 + */ 542 + if ((lflags & GPIOHANDLE_REQUEST_INPUT) && 543 + (lflags & GPIOHANDLE_REQUEST_OUTPUT)) 544 + return -EINVAL; 545 + 546 + /* 539 547 * Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If 540 548 * the hardware actually supports enabling both at the same time the 541 549 * electrical result would be disastrous. ··· 934 926 } 935 927 936 928 /* This is just wrong: we don't look for events on output lines */ 937 - if (lflags & GPIOHANDLE_REQUEST_OUTPUT) { 929 + if ((lflags & GPIOHANDLE_REQUEST_OUTPUT) || 930 + (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) || 931 + (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)) { 938 932 ret = -EINVAL; 939 933 goto out_free_label; 940 934 } ··· 950 940 951 941 if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW) 952 942 set_bit(FLAG_ACTIVE_LOW, &desc->flags); 953 - if (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) 954 - set_bit(FLAG_OPEN_DRAIN, &desc->flags); 955 - if (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE) 956 - set_bit(FLAG_OPEN_SOURCE, &desc->flags); 957 943 958 944 ret = gpiod_direction_input(desc); 959 945 if (ret)