Re: [RFC PATCH 4/6] gpio: add device config helpers

Tomasz Bursztyka

Hi Vlad,

+struct gpio_pin_config {
+ /* In the future, devices will be selected by their handle, not
+ * name.
+ */
+ /* struct device *gpio_controller; */
+ char *gpio_controller;
+ uint32_t gpio_pin;
I see a problem with that: it will fit only device that need to
configure 1 pin.
On cc2520 it requires many ones, and many complex devices will need
more than 1.
This structure does declare only one pin. But you can call the _IDX
macros multiple times:

struct mydev_config {
/* ... */

/* And when declaring the device: */
struct mydev_config mydev_0_config = {
GPIO_PIN_IDX(0, "GPIO_0", 12);
GPIO_PIN_IDX(1, "GPIO_0", 14);
/* ... */
This will bloat things up by repeating controller's name pointer
(which is most likely be the same).
Maybe a variable array of pins would be better then.

I don't have an obvious solution for that.
I'll take a stab at that in the next version, assuming we're comfortable
with the assumption that a device will never have GPIO pins tied to
different controllers.
It might and it's not going to be a rare case.
Again, about cc2520 it uses 2 GPIO controller on quark_se_devboard (it's
board specific obviously)
Actually, take a look at how we addressed this issue in
It's far from being perfect and it's not generic, but it may help.


Join to automatically receive all group messages.