The patch titled gpio: updates to sysfs support has been added to the -mm tree. Its filename is gpio-sysfs-interface-updated-update.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: gpio: updates to sysfs support From: David Brownell <david-b@xxxxxxxxxxx> Update and bugfix the patch adding sysfs GPIO support: * Bugfix: the test initializing the IS_OUT flag for output-only GPIOs had the sense inverted. * Update: when gpio_chip.dev is provided, list it in the debugfs dump. Device nodes are unique; the "label" isn't. The bug of course caused output-only GPIOs to misbehave, but it also made just-exported (or generally: only-requested) GPIOs always appear to be outputs in sysfs and debugfs. That's wrong more often than it's right, although it gets corrected when the direction is assigned. Signed-off-by: David Brownell <dbrownell@xxxxxxxxxxxxxxxxxxxxx> Cc: Guennadi Liakhovetski <g.liakhovetski@xxxxxxxxxxxxxx> Cc: Greg KH <greg@xxxxxxxxx> Cc: Kay Sievers <kay.sievers@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/gpio/gpiolib.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff -puN drivers/gpio/gpiolib.c~gpio-sysfs-interface-updated-update drivers/gpio/gpiolib.c --- a/drivers/gpio/gpiolib.c~gpio-sysfs-interface-updated-update +++ a/drivers/gpio/gpiolib.c @@ -685,7 +685,14 @@ int gpiochip_add(struct gpio_chip *chip) if (status == 0) { for (id = base; id < base + chip->ngpio; id++) { gpio_desc[id].chip = chip; - gpio_desc[id].flags = chip->direction_input + + /* REVISIT: most hardware initializes GPIOs as + * inputs (often with pullups enabled) so power + * usage is minimized. Linux code should set the + * gpio direction first thing; but until it does, + * we may expose the wrong direction in sysfs. + */ + gpio_desc[id].flags = !chip->direction_input ? (1 << FLAG_IS_OUT) : 0; } @@ -1108,17 +1115,28 @@ static int gpiolib_show(struct seq_file /* REVISIT this isn't locked against gpio_chip removal ... */ for (gpio = 0; gpio_is_valid(gpio); gpio++) { + struct device *dev; + if (chip == gpio_desc[gpio].chip) continue; chip = gpio_desc[gpio].chip; if (!chip) continue; - seq_printf(s, "%sGPIOs %d-%d, %s%s:\n", + seq_printf(s, "%sGPIOs %d-%d", started ? "\n" : "", - chip->base, chip->base + chip->ngpio - 1, - chip->label ? : "generic", - chip->can_sleep ? ", can sleep" : ""); + chip->base, chip->base + chip->ngpio - 1); + dev = chip->dev; + if (dev) + seq_printf(s, ", %s/%s", + dev->bus ? dev->bus->name : "no-bus", + dev->bus_id); + if (chip->label) + seq_printf(s, ", %s", chip->label); + if (chip->can_sleep) + seq_printf(s, ", can sleep"); + seq_printf(s, ":\n"); + started = 1; if (chip->dbg_show) chip->dbg_show(s, chip); _ Patches currently in -mm which might be from david-b@xxxxxxxxxxx are origin.patch rtc_read_alarm-handles-wraparound.patch gpio-pca953x-i2c-handles-max7310-too.patch ntp-let-update_persistent_clock-sleep.patch jffs2-summary-allocation-dont-use-vmalloc.patch asic3-gpiolib-support.patch asic3-remove-children-platform-data.patch asic3-new-gpio-configuration-code.patch sm501-add-gpiolib-support.patch sm501-gpio-dynamic-registration-for-pci-devices.patch sm501-gpio-i2c-support.patch rtc-rtc-rs5c372-smbus-conversion-support.patch rtc-rtc-rs5c732-add-support-for-ricoh-r2025s-d-rtc.patch rtc-m41t80-sort-header-inclusions-for-readability.patch rtc-m41t80-use-pr_info-as-appropriate.patch rtc-remove-bkl-for-ioctl.patch rtc-add-support-for-st-m41t94-spi-rtc.patch gpio-gpio-driver-for-max7301-spi-gpio-expander.patch gpio-gpio-driver-for-max7301-spi-gpio-expander-checkpatch-fixes.patch gpio-sysfs-interface-updated-update.patch gpio-mcp23s08-handles-multiple-chips-per-chipselect.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html