Skip to contentSkip to conversation

gpio: generic: add request function pointer

PATCH Superseded Anthony Fee 2 participants 4 messages May 12, 2014 – May 19, 2014 GPIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: generic: add request function pointer

gpiolib will require all gpio drivers to expicitly set the request function pointer in future. To encourage gpio driver developers to adhere to this standard gpio-generic.c now sets this function pointer.

---
 drivers/gpio/gpio-generic.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpio/gpio-generic.c +0 -0
index b5dff9e..fea8c82 100644
@@ -388,6 +388,14 @@ static int bgpio_setup_direction(struct bgpio_chip 

*bgc,

        return 0;

}

+static int bgpio_request(struct gpio_chip *chip, unsigned gpio_pin) +{
+ if (gpio_pin < chip->ngpio)
+ return 0;
+
+ return -EINVAL;
+}
+
int bgpio_remove(struct bgpio_chip *bgc)

 {
        return gpiochip_remove(&bgc->gc);
@@ -413,6 +421,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device 
*dev,
        bgc->gc.label = dev_name(dev);
        bgc->gc.base = -1;
        bgc->gc.ngpio = bgc->bits;

+ bgc->gc.request = bgpio_request;

        ret = bgpio_setup_io(bgc, dat, set, clr);
        if (ret)
Signature · 1 line
1.9.0
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Anthony Fee

gpiolib will require all gpio drivers to expicitly set the request function pointer in future. To encourage gpio driver developers to adhere to this standard gpio-generic.c now sets this function pointer.

for the non-HTML version. :)

On top of being future-proof, having the GPIO range check is also a good thing.

Quoted 42 lines
---
 drivers/gpio/gpio-generic.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpio/gpio-generic.c +8 -0
index b5dff9e..fea8c82 100644
@@ -388,6 +388,14 @@ static int bgpio_setup_direction(struct bgpio_chip
 *bgc,
        return 0;
 }
 
+static int bgpio_request(struct gpio_chip *chip, unsigned gpio_pin)
+{
+       if (gpio_pin < chip->ngpio)
+               return 0;
+
+       return -EINVAL;
+}
+
 int bgpio_remove(struct bgpio_chip *bgc)
 {
        return gpiochip_remove(&bgc->gc);
drivers/gpio/gpio-generic.c +1 -0
@@ -413,6 +421,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device
 *dev,
        bgc->gc.label = dev_name(dev);
        bgc->gc.base = -1;
        bgc->gc.ngpio = bgc->bits;
+       bgc->gc.request = bgpio_request;
 
        ret = bgpio_setup_io(bgc, dat, set, clr);

if (ret)
--
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

Yes sorry about the spam! I only realised after that I had HTML enabled :)

Quoted 55 lines · Alexandre Courbot
Quoted 3 lines · Anthony Fee

gpiolib will require all gpio drivers to expicitly set the request function pointer in future. To encourage gpio driver developers to adhere to this standard gpio-generic.c now sets this function pointer.

for the non-HTML version. :)

On top of being future-proof, having the GPIO range check is also a good thing.

Quoted 44 lines
---
 drivers/gpio/gpio-generic.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpio/gpio-generic.c +0 -0
index b5dff9e..fea8c82 100644
@@ -388,6 +388,14 @@ static int bgpio_setup_direction(struct 

bgpio_chip
*bgc,

        return 0;

}

drivers/gpio/gpio-generic.c +8 -0
+static int bgpio_request(struct gpio_chip *chip, unsigned gpio_pin)
+{
+       if (gpio_pin < chip->ngpio)
+               return 0;
+
+       return -EINVAL;
+}
+
 int bgpio_remove(struct bgpio_chip *bgc)
 {
        return gpiochip_remove(&bgc->gc);
@@ -413,6 +421,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct 

device
*dev,

        bgc->gc.label = dev_name(dev);
        bgc->gc.base = -1;
        bgc->gc.ngpio = bgc->bits;

+ bgc->gc.request = bgpio_request;

        ret = bgpio_setup_io(bgc, dat, set, clr);
        if (ret)

--
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Alexandre Courbot

Hi Guys,

I'm going to resubmit this to the mailing list as a v2 patch due to formatting issues. Sorry for the confusion, I'm sending the patch with git send-email so there shouldn't be any issues.

Thanks,
Anthony

Quoted 55 lines · Alexandre Courbot
Quoted 3 lines · Anthony Fee

gpiolib will require all gpio drivers to expicitly set the request function pointer in future. To encourage gpio driver developers to adhere to this standard gpio-generic.c now sets this function pointer.

for the non-HTML version. :)

On top of being future-proof, having the GPIO range check is also a good thing.

Quoted 44 lines
---
 drivers/gpio/gpio-generic.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpio/gpio-generic.c +0 -0
index b5dff9e..fea8c82 100644
@@ -388,6 +388,14 @@ static int bgpio_setup_direction(struct 

bgpio_chip
*bgc,

        return 0;

}

drivers/gpio/gpio-generic.c +8 -0
+static int bgpio_request(struct gpio_chip *chip, unsigned gpio_pin)
+{
+       if (gpio_pin < chip->ngpio)
+               return 0;
+
+       return -EINVAL;
+}
+
 int bgpio_remove(struct bgpio_chip *bgc)
 {
        return gpiochip_remove(&bgc->gc);
@@ -413,6 +421,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct 

device
*dev,

        bgc->gc.label = dev_name(dev);
        bgc->gc.base = -1;
        bgc->gc.ngpio = bgc->bits;

+ bgc->gc.request = bgpio_request;

        ret = bgpio_setup_io(bgc, dat, set, clr);
        if (ret)

--
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 15 lines
Anthony Fee
Software Engineer
EMUTEX LTD.
Callan Centre, National Technology Park, Limerick, Ireland
Phone: +353 (0)61 514496, Mobile: +353 (0)86 3197614
Web: www.emutex.com, Email: [email protected]

This email may contain information, which is confidential and/or
privileged. The information is intended solely for the use of the
individual or entity named above. If you are not the intended recipient, be
aware that any disclosure, copying, distribution or use of the contents is
prohibited. If you have received this electronic transmission in error,
please notify the sender by telephone or return email and delete the
material from your computer. Emutex Ltd is registered in Ireland, No
256238, at Callan Centre, National Technology Park, Limerick, Ireland.