gpiolib sysfs access when CONFIG_GPIO_CDEV is not set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Following an update to the 5.10-rc1 kernel, I found out that trying to
export a GPIO using /sys/class/gpio/export fails with the kernel
reporting a message in the kernel logs:

# echo 41 >/sys/class/gpio/export
[   46.761394] kobject_add_internal failed for gpio (error: -2 parent:
gpiochip2)
sh: write error: No such file or directory
#

I have tracked it to the fact that I have CONFIG_GPIO_CDEV is disabled in
my kernel config: Enabling CONFIG_GPIO_CDEV made export work again.

Enabling CONFIG_GPIO_CDEV and commenting all the code in
gpiolib_cdev_register() except the final "return 0;" made the issue
appear again, leading me to think that the issue is related to
something that is done cdev_device_add() must be done to fix the
issue.

Looking at the code of cdev_device_add() I was able to determine that
the device_add() call made there is required to get the gpiolib sysfs
export to work again.

In the end I have done this (which I won't even pretend is the proper
way to fix this), and sysfs attributes are finally working without
CONFIG_GPIO_CDEV:

diff --git a/drivers/gpio/gpiolib-cdev.h b/drivers/gpio/gpiolib-cdev.h
index cb41dd757338..dd72bd0e4af4 100644
--- a/drivers/gpio/gpiolib-cdev.h
+++ b/drivers/gpio/gpiolib-cdev.h
@@ -16,7 +16,7 @@ void gpiolib_cdev_unregister(struct gpio_device *gdev);

 static inline int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt)
 {
-    return 0;
+    return device_add(&gdev->dev);
 }

 static inline void gpiolib_cdev_unregister(struct gpio_device *gdev)

If this is the preferred solution I can send a proper patch.

Best Regards,

-- 
Nicolas Schichan



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux