diff mbox series

[v5,1/6] gpiolib: Introduce a helper to get first GPIO controller node

Message ID 20220414190242.22178-2-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series gpiolib: more helpers and fwnode conversion | expand

Commit Message

Andy Shevchenko April 14, 2022, 7:02 p.m. UTC
Introduce a helper to get first GPIO controller node which drivers
may want to use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/gpio/driver.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Bartosz Golaszewski April 25, 2022, 6:52 p.m. UTC | #1
On Thu, Apr 14, 2022 at 9:02 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Introduce a helper to get first GPIO controller node which drivers
> may want to use.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/gpio/driver.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
> index 12de0b22b4ef..83e2d72e51bb 100644
> --- a/include/linux/gpio/driver.h
> +++ b/include/linux/gpio/driver.h
> @@ -766,4 +766,14 @@ static inline unsigned int gpiochip_node_count(struct device *dev)
>         return count;
>  }
>
> +static inline struct fwnode_handle *gpiochip_node_get_first(struct device *dev)
> +{
> +       struct fwnode_handle *fwnode;
> +
> +       for_each_gpiochip_node(dev, fwnode)
> +               return fwnode;
> +
> +       return NULL;
> +}
> +
>  #endif /* __LINUX_GPIO_DRIVER_H */
> --
> 2.35.1
>

Any chance you could name it get_first_gpiochip_node()? It's static so
we don't have to worry about the prefix and it would make the purpose
more clear.

Bart
Andy Shevchenko April 26, 2022, 10:29 a.m. UTC | #2
On Tue, Apr 26, 2022 at 12:27 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> On Thu, Apr 14, 2022 at 9:02 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > Introduce a helper to get first GPIO controller node which drivers
> > may want to use.

> > +static inline struct fwnode_handle *gpiochip_node_get_first(struct device *dev)
> > +{
> > +       struct fwnode_handle *fwnode;
> > +
> > +       for_each_gpiochip_node(dev, fwnode)
> > +               return fwnode;
> > +
> > +       return NULL;
> > +}
> > +
> >  #endif /* __LINUX_GPIO_DRIVER_H */
> > --
> > 2.35.1
> >
>
> Any chance you could name it get_first_gpiochip_node()? It's static so
> we don't have to worry about the prefix and it would make the purpose
> more clear.

There are two things why I prefer it as is:
1) it's static inline, so it's part of (internal) but still exported API;
2) it's already in my for-next branch which I would like not to
rebase, until it's a really serious issue.

That said, if you still insist I can rename it.
Bartosz Golaszewski May 5, 2022, 1:05 p.m. UTC | #3
On Tue, Apr 26, 2022 at 12:29 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Tue, Apr 26, 2022 at 12:27 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > On Thu, Apr 14, 2022 at 9:02 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > >
> > > Introduce a helper to get first GPIO controller node which drivers
> > > may want to use.
>
> > > +static inline struct fwnode_handle *gpiochip_node_get_first(struct device *dev)
> > > +{
> > > +       struct fwnode_handle *fwnode;
> > > +
> > > +       for_each_gpiochip_node(dev, fwnode)
> > > +               return fwnode;
> > > +
> > > +       return NULL;
> > > +}
> > > +
> > >  #endif /* __LINUX_GPIO_DRIVER_H */
> > > --
> > > 2.35.1
> > >
> >
> > Any chance you could name it get_first_gpiochip_node()? It's static so
> > we don't have to worry about the prefix and it would make the purpose
> > more clear.
>
> There are two things why I prefer it as is:
> 1) it's static inline, so it's part of (internal) but still exported API;
> 2) it's already in my for-next branch which I would like not to
> rebase, until it's a really serious issue.
>
> That said, if you still insist I can rename it.

No that's fine and I also pulled that into my tree.

Bart
Andy Shevchenko May 5, 2022, 1:17 p.m. UTC | #4
On Thu, May 05, 2022 at 03:05:52PM +0200, Bartosz Golaszewski wrote:
> On Tue, Apr 26, 2022 at 12:29 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Tue, Apr 26, 2022 at 12:27 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > > On Thu, Apr 14, 2022 at 9:02 PM Andy Shevchenko
> > > <andriy.shevchenko@linux.intel.com> wrote:

...

> > > Any chance you could name it get_first_gpiochip_node()? It's static so
> > > we don't have to worry about the prefix and it would make the purpose
> > > more clear.
> >
> > There are two things why I prefer it as is:
> > 1) it's static inline, so it's part of (internal) but still exported API;
> > 2) it's already in my for-next branch which I would like not to
> > rebase, until it's a really serious issue.
> >
> > That said, if you still insist I can rename it.
> 
> No that's fine and I also pulled that into my tree.

Thank you!
diff mbox series

Patch

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 12de0b22b4ef..83e2d72e51bb 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -766,4 +766,14 @@  static inline unsigned int gpiochip_node_count(struct device *dev)
 	return count;
 }
 
+static inline struct fwnode_handle *gpiochip_node_get_first(struct device *dev)
+{
+	struct fwnode_handle *fwnode;
+
+	for_each_gpiochip_node(dev, fwnode)
+		return fwnode;
+
+	return NULL;
+}
+
 #endif /* __LINUX_GPIO_DRIVER_H */