Re: [PATCH V1 1/2] gpio: make it possible to set active-state on GPIO lines

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

 



On Mon, May 6, 2019 at 9:57 AM Harish Jenny K N
<harish_kandiga@xxxxxxxxxx> wrote:

> Can the userspace consumers define the polarity?

Yes. From userspace after opening the GPIO character
device:

#include <linux/gpio.h>

struct gpiohandle_request req;

req.flags = GPIOHANDLE_REQUEST_ACTIVE_LOW | GPIOHANDLE_REQUEST_OUTPUT;
req.lines = 1;
req.lineoffsets[0] = 0;

ret = ioctl(fd, GPIO_GET_LINEHANDLE_IOCTL, &req);
(...)

For more details on how to use the character device see tools/gpio/*
in the kernel tree.

> Intention was to define polarity for lines which are not having consumers from kernelspace.

OK the above should work fine :)

> > Even when using GPIOs from userspace (which I do not
> > recommend) the character device suppors a polarity flag
> > GPIOLINE_FLAG_ACTIVE_LOW so also userspace
> > consumers define polarity.
>
> yes. aware of the GPIOLINE_FLAG_ACTIVE_LOW flag to get the status.

Sorry, I was being unclear,
GPIOHANDLE_REQUEST_ACTIVE_LOW
is what you want to use.

Yours,
Linus Walleij



[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