core: relax gpiod_chip_open() for symbolic links
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 6 Feb 2020 18:13:58 +0000 (20:13 +0200)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Fri, 7 Feb 2020 12:47:56 +0000 (13:47 +0100)
commitba91f719044f4350595b8b0f19b483da38540e02
treef2b72f0e505d896517db4f05e072ac0e84a1eeb7
parent573f3a91ace8fbff9e1751c63e328319b41a9e27
core: relax gpiod_chip_open() for symbolic links

User may ask device helper tool, for example, udev, to create a specific
symbolic link to a device node. GPIO chip character device node is not
exceptional. However, libgpiod in the commit d9b1c1f14c6b
("core: harden gpiod_chip_open()") went way too far in the hardening device
node check.

Relax that hardening for symbolic link to fix the regression.

Reproducer:

  % gpioinfo /dev/gpiochip5
  gpiochip5 - 16 lines:
      line   0:  "MUX33_DIR" "uart1-rx-oe" output active-high [used]
      ...

  % ln -sf /dev/gpiochip5 /dev/MyGPIO_5

  % gpioinfo /dev/MyGPIO_5
  gpioinfo: looking up chip /dev/MyGPIO_5: Inappropriate ioctl for device

Link: https://stackoverflow.com/questions/60057494/gpio-issue-with-sym-link
Fixes: d9b1c1f14c6b ("core: harden gpiod_chip_open()")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
lib/core.c