On Thu, Feb 12, 2015 at 1:28 AM, Rojhalat Ibrahim <imr@xxxxxxxxxxx> wrote: > Use the new gpiod_get_array and gpiod_put_array functions for obtaining and > disposing of GPIO descriptors. > > Cc: David Miller <davem@xxxxxxxxxxxxx> > Signed-off-by: Rojhalat Ibrahim <imr@xxxxxxxxxxx> > --- > Change log: > v5: no change > v4: use shorter names for members of struct gpio_descs > v3: no change > v2: use the new interface > > drivers/net/phy/mdio-mux-gpio.c | 60 ++++++++++++----------------------------- > 1 file changed, 17 insertions(+), 43 deletions(-) > > diff --git a/drivers/net/phy/mdio-mux-gpio.c b/drivers/net/phy/mdio-mux-gpio.c > index 320eb15..c49ad09 100644 > --- a/drivers/net/phy/mdio-mux-gpio.c > +++ b/drivers/net/phy/mdio-mux-gpio.c > @@ -12,33 +12,30 @@ > #include <linux/module.h> > #include <linux/phy.h> > #include <linux/mdio-mux.h> > -#include <linux/of_gpio.h> > +#include <linux/gpio/consumer.h> > > #define DRV_VERSION "1.1" > #define DRV_DESCRIPTION "GPIO controlled MDIO bus multiplexer driver" > > -#define MDIO_MUX_GPIO_MAX_BITS 8 > - > struct mdio_mux_gpio_state { > - struct gpio_desc *gpio[MDIO_MUX_GPIO_MAX_BITS]; > - unsigned int num_gpios; > + struct gpio_descs *gpios; > void *mux_handle; > }; > > static int mdio_mux_gpio_switch_fn(int current_child, int desired_child, > void *data) > { > - int values[MDIO_MUX_GPIO_MAX_BITS]; > - unsigned int n; > struct mdio_mux_gpio_state *s = data; > + int values[s->gpios->ndescs]; > + unsigned int n; > > if (current_child == desired_child) > return 0; > > - for (n = 0; n < s->num_gpios; n++) { > + for (n = 0; n < s->gpios->ndescs; n++) > values[n] = (desired_child >> n) & 1; > - } > - gpiod_set_array_cansleep(s->num_gpios, s->gpio, values); > + > + gpiod_set_array_cansleep(s->gpios->ndescs, s->gpios->desc, values); One suggestion for a possible further improvement: it would be great if the gpiod_set/get_array() functions would work on a struct gpio_descs so users don't have to pass both the number of GPIOs and the array. I don't know whether it would be desirable to keep alternative functions that preserve the current form, for users who want to set multiple GPIOs but cannot use gpiod_get_array(). struct gpiod_descs is easy to build, so maybe we don't need them? -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html