Right way to get the gpio values from the device tree in the device driver for BeagleboneBlack

Hello,

This topic is not solely related to beagleboneBlack , still posting on this group .

With reference to the example below what is the correct way to get the gpio values from the device tree :

I modified the existing leds-ns2 device tree as below(slow1 ,cmd1) :

blue-sata {

label = “ns2:blue:sata”;

slow-gpio = <&gpio0 29 0>;

cmd-gpio = <&gpio0 30 0>;

  • slow1-gpio=<&gpio 31 0>;

  • cmd1-gpio=<&gpio 32 0>;

modes-map = <NS_V2_LED_OFF 0 1

NS_V2_LED_ON 1 0

NS_V2_LED_ON 0 0

NS_V2_LED_SATA 1 1>;

};

And modified the driver by adding slow1 and cmd1 in all the structure (just like slow and cmd) in the attached leds-ns2.c driver

But when I am trying to get the gpio number for slow1 and cmd1 I am getting the below error(number gpio #31 and 32 are random numbers of gpio for testing, does it matters?) :

error : leds-ns2:probe of ns2-leds failed with error -2.What does error code -2 represents ?Is this a device tree parsing error?

ret = of_get_named_gpio(child, “slow1-gpio”, 0);

if (ret < 0)

return ret;

same error if I try to get the cmd1-gpio .

Thanks in advance !

Regards,

Rp

leds-ns2.c (9.97 KB)

http://linux.die.net/man/3/strerror

Thanks , I figured it out ! I was not putting the valid gpio in the <&gpio0 0>