0
votes

i am quiet new at writing kernel drivers and there is something bothering me a lot. It would be great if you could kcik me into the right direction.

I am writing a module for a device, that has to be powered via putting a GPIO to HIGH-State.

  1. In Documentation/gpio/* are texts, which say i should use the new descriptor-based interface of the GPIO Framework. But how to use it? When i make an include like #include it compiles and i can run the driver. But using gpiod_get(...) just returns fffffffffffffffe. It makes sense somehow, as the implentation of that function within linux/gpio/consumer.h is

static inline struct gpio_desc *__must_check gpiod_get(struct device *dev, const char *con_id,enum gpiod_flags flags){ return ERR_PTR(-ENOSYS); }

The implementation of the function exists in drivers/gpio/devres.c as well. How can i use that one?

It looks to me as i am not supposed to use that implementation.

I hope you can help me as it is getting really irritating.

1
If you look into linux/gpio/consumer.h, it has two declarations of gpiod_get function: the first one is simple declaration, and the second one is declaration with definition. The first one corresponds to CONFIG_GPIOLIB configuration option enabled, and has usefull implementation in drivers/gpio/devres.c. The second one corresponds to the disabled option, and its implementation means just "not implemented". So you need to have CONFIG_GPIOLIB option enabled for use GPIO. - Tsyvarev
Thanks for your reply. You definitly encourage me to re-think my build-system, as CONFIG_GPIOLIB is set in my kernel defconfig. But probably not in my out-of-tree sources... I'll tell you about the outcome when i got so far - guenni_90

1 Answers

0
votes

As it turned out it was just necessary to include the file gpio/gpiolib as well which delivers additional definitions.