Message ID | 20220920011747.824280-1-jay.xu@rock-chips.com |
---|---|
State | New |
Headers | show |
Series | [RESEND] gpiolib: make gpiochip_find_by_name to be common function | expand |
On Tue, Sep 20, 2022 at 3:17 AM Jianqun Xu <jay.xu@rock-chips.com> wrote: > > Move find_chip_by_name from gpiolib to the gpio/driver.h, also rename to > gpiochip_find_by_name, make it to be a common function. > Why did you resend it immediately? And what is the reason for this change? Bart > Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com> > --- > drivers/gpio/gpiolib.c | 16 ++-------------- > include/linux/gpio/driver.h | 12 ++++++++++++ > 2 files changed, 14 insertions(+), 14 deletions(-) > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index cc9c0a12259e..c06334772c47 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -935,18 +935,6 @@ struct gpio_chip *gpiochip_find(void *data, > } > EXPORT_SYMBOL_GPL(gpiochip_find); > > -static int gpiochip_match_name(struct gpio_chip *gc, void *data) > -{ > - const char *name = data; > - > - return !strcmp(gc->label, name); > -} > - > -static struct gpio_chip *find_chip_by_name(const char *name) > -{ > - return gpiochip_find((void *)name, gpiochip_match_name); > -} > - > #ifdef CONFIG_GPIOLIB_IRQCHIP > > /* > @@ -3660,7 +3648,7 @@ void gpiod_add_hogs(struct gpiod_hog *hogs) > * The chip may have been registered earlier, so check if it > * exists and, if so, try to hog the line now. > */ > - gc = find_chip_by_name(hog->chip_label); > + gc = gpiochip_find_by_name(hog->chip_label); > if (gc) > gpiochip_machine_hog(gc, hog); > } > @@ -3745,7 +3733,7 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, > return ERR_PTR(-EPROBE_DEFER); > } > > - gc = find_chip_by_name(p->key); > + gc = gpiochip_find_by_name(p->key); > > if (!gc) { > /* > diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h > index 6aeea1071b1b..4ed26a7d98ff 100644 > --- a/include/linux/gpio/driver.h > +++ b/include/linux/gpio/driver.h > @@ -618,6 +618,18 @@ extern int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip > extern struct gpio_chip *gpiochip_find(void *data, > int (*match)(struct gpio_chip *gc, void *data)); > > +static int gpiochip_match_name(struct gpio_chip *gc, void *data) > +{ > + const char *name = data; > + > + return !strcmp(gc->label, name); > +} > + > +static inline struct gpio_chip *gpiochip_find_by_name(const char *name) > +{ > + return gpiochip_find((void *)name, gpiochip_match_name); > +} > + > bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset); > int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset); > void gpiochip_relres_irq(struct gpio_chip *gc, unsigned int offset); > -- > 2.25.1 >
On Tue, Sep 20, 2022 at 08:39:59AM +0200, Bartosz Golaszewski wrote: > On Tue, Sep 20, 2022 at 3:17 AM Jianqun Xu <jay.xu@rock-chips.com> wrote: > > > > Move find_chip_by_name from gpiolib to the gpio/driver.h, also rename to > > gpiochip_find_by_name, make it to be a common function. > > Why did you resend it immediately? I'm also puzzled with this. It's not the first time you resend the lot for the unknown reasons. > And what is the reason for this change? First of all, it's Suggested-by: me (missed tag), second, it should be a part of the patch set to answer your question.
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index cc9c0a12259e..c06334772c47 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -935,18 +935,6 @@ struct gpio_chip *gpiochip_find(void *data, } EXPORT_SYMBOL_GPL(gpiochip_find); -static int gpiochip_match_name(struct gpio_chip *gc, void *data) -{ - const char *name = data; - - return !strcmp(gc->label, name); -} - -static struct gpio_chip *find_chip_by_name(const char *name) -{ - return gpiochip_find((void *)name, gpiochip_match_name); -} - #ifdef CONFIG_GPIOLIB_IRQCHIP /* @@ -3660,7 +3648,7 @@ void gpiod_add_hogs(struct gpiod_hog *hogs) * The chip may have been registered earlier, so check if it * exists and, if so, try to hog the line now. */ - gc = find_chip_by_name(hog->chip_label); + gc = gpiochip_find_by_name(hog->chip_label); if (gc) gpiochip_machine_hog(gc, hog); } @@ -3745,7 +3733,7 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, return ERR_PTR(-EPROBE_DEFER); } - gc = find_chip_by_name(p->key); + gc = gpiochip_find_by_name(p->key); if (!gc) { /* diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 6aeea1071b1b..4ed26a7d98ff 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -618,6 +618,18 @@ extern int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip extern struct gpio_chip *gpiochip_find(void *data, int (*match)(struct gpio_chip *gc, void *data)); +static int gpiochip_match_name(struct gpio_chip *gc, void *data) +{ + const char *name = data; + + return !strcmp(gc->label, name); +} + +static inline struct gpio_chip *gpiochip_find_by_name(const char *name) +{ + return gpiochip_find((void *)name, gpiochip_match_name); +} + bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset); int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset); void gpiochip_relres_irq(struct gpio_chip *gc, unsigned int offset);
Move find_chip_by_name from gpiolib to the gpio/driver.h, also rename to gpiochip_find_by_name, make it to be a common function. Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com> --- drivers/gpio/gpiolib.c | 16 ++-------------- include/linux/gpio/driver.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-)