On Wed, Sep 23, 2020 at 04:18:39PM +0200, Marek Behún wrote: > Convert from OF api to fwnode API, so that it is possible to bind this > driver without device-tree. > > The fwnode API does not expose a function to read a specific element of > an array. We therefore change the types of the ns2_led_modval structure > so that we can read the whole modval array with one fwnode call. > > Signed-off-by: Marek Behún <kabel@xxxxxxxxxx> > Cc: Simon Guinot <simon.guinot@xxxxxxxxxxxx> > --- > drivers/leds/leds-ns2.c | 60 ++++++++++++++++++++--------------------- > 1 file changed, 29 insertions(+), 31 deletions(-) ... > -static int ns2_led_register(struct device *dev, struct device_node *np, > +static int ns2_led_register(struct device *dev, struct fwnode_handle *node, > struct ns2_led *led) > { > struct led_init_data init_data = {}; > struct ns2_led_modval *modval; > enum ns2_led_modes mode; > - int nmodes, ret, i; > + int nmodes, ret; > > - led->cmd = devm_gpiod_get_from_of_node(dev, np, "cmd-gpio", 0, > - GPIOD_ASIS, np->name); > + led->cmd = devm_fwnode_gpiod_get_index(dev, node, "cmd-gpio", 0, > + GPIOD_ASIS, > + fwnode_get_name(node)); > if (IS_ERR(led->cmd)) > return PTR_ERR(led->cmd); > > - led->slow = devm_gpiod_get_from_of_node(dev, np, "slow-gpio", 0, > - GPIOD_ASIS, np->name); > + led->slow = devm_fwnode_gpiod_get_index(dev, node, "slow-gpio", 0, > + GPIOD_ASIS, > + fwnode_get_name(node)); Hi Marek, You need to remove the "-gpio" suffix for the con_id parameter. It is automatically and systematically appended in the fwnode_gpiod_get_index function... With this change, I can confirm that the led-ns2 driver is still working using the DT path after applying the two fwnode patches (merged on the top of the "linux,default-trigger" series). I tested it on a d2 Network board. I need a little bit more time to test the fwnode support on my x86 boards (with board setup files). Simon
Attachment:
signature.asc
Description: PGP signature