[1/8] drivers/gpio/gpiolib: Add support for removing registered consumer lookup table
diff mbox

Message ID 1430316005-16480-2-git-send-email-shobhit.kumar@intel.com
State New
Headers show

Commit Message

Shobhit Kumar April 29, 2015, 1:59 p.m. UTC
In case we unload and load a driver module again that is registering a
lookup table, without this it will result in multiple entries. Provide
an option to remove the lookup table on driver unload

v2: Ccing maintainers

Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
---
 drivers/gpio/gpiolib.c       | 13 +++++++++++++
 include/linux/gpio/machine.h |  1 +
 2 files changed, 14 insertions(+)

Comments

Linus Walleij May 6, 2015, 2:49 p.m. UTC | #1
On Wed, Apr 29, 2015 at 3:59 PM, Shobhit Kumar <shobhit.kumar@intel.com> wrote:

> In case we unload and load a driver module again that is registering a
> lookup table, without this it will result in multiple entries. Provide
> an option to remove the lookup table on driver unload
>
> v2: Ccing maintainers
>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Alexandre Courbot <gnurou@gmail.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
> Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Since it is core support I'd prefer to merge this into the GPIO git
tree. Is it OK or do you need to merge it through some other means?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Daniel Vetter May 6, 2015, 3:09 p.m. UTC | #2
On Wed, May 06, 2015 at 04:49:36PM +0200, Linus Walleij wrote:
> On Wed, Apr 29, 2015 at 3:59 PM, Shobhit Kumar <shobhit.kumar@intel.com> wrote:
> 
> > In case we unload and load a driver module again that is registering a
> > lookup table, without this it will result in multiple entries. Provide
> > an option to remove the lookup table on driver unload
> >
> > v2: Ccing maintainers
> >
> > Cc: Samuel Ortiz <sameo@linux.intel.com>
> > Cc: Linus Walleij <linus.walleij@linaro.org>
> > Cc: Alexandre Courbot <gnurou@gmail.com>
> > Cc: Thierry Reding <thierry.reding@gmail.com>
> > Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
> > Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

I think the gpio/pwm and mfd parts would all need to go in through the
same tree. i915 parts are decoupled. I guess I could do a branch with just
those patches, tag it and then send a pull request to all 3 subsystems
once it's reviewed. Would that be ok?
-Daniel
Linus Walleij May 12, 2015, 8:52 a.m. UTC | #3
On Wed, May 6, 2015 at 5:09 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Wed, May 06, 2015 at 04:49:36PM +0200, Linus Walleij wrote:
>> On Wed, Apr 29, 2015 at 3:59 PM, Shobhit Kumar <shobhit.kumar@intel.com> wrote:
>>
>> > In case we unload and load a driver module again that is registering a
>> > lookup table, without this it will result in multiple entries. Provide
>> > an option to remove the lookup table on driver unload
>> >
>> > v2: Ccing maintainers
>> >
>> > Cc: Samuel Ortiz <sameo@linux.intel.com>
>> > Cc: Linus Walleij <linus.walleij@linaro.org>
>> > Cc: Alexandre Courbot <gnurou@gmail.com>
>> > Cc: Thierry Reding <thierry.reding@gmail.com>
>> > Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
>> > Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
>>
>> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
>
> I think the gpio/pwm and mfd parts would all need to go in through the
> same tree. i915 parts are decoupled. I guess I could do a branch with just
> those patches, tag it and then send a pull request to all 3 subsystems
> once it's reviewed. Would that be ok?

That's an immutable branch I guess, and yeah I think it's OK.
I usually only pull these in if/when there are conflicts in -next.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 59eaa23..2420af9 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1658,6 +1658,19 @@  void gpiod_add_lookup_table(struct gpiod_lookup_table *table)
 	mutex_unlock(&gpio_lookup_lock);
 }
 
+/**
+ * gpiod_remove_lookup_table() - unregister GPIO device consumers
+ * @table: table of consumers to unregister
+ */
+void gpiod_remove_lookup_table(struct gpiod_lookup_table *table)
+{
+	mutex_lock(&gpio_lookup_lock);
+
+	list_del(&table->list);
+
+	mutex_unlock(&gpio_lookup_lock);
+}
+
 static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
 				      unsigned int idx,
 				      enum gpio_lookup_flags *flags)
diff --git a/include/linux/gpio/machine.h b/include/linux/gpio/machine.h
index e270614..c0d712d 100644
--- a/include/linux/gpio/machine.h
+++ b/include/linux/gpio/machine.h
@@ -57,5 +57,6 @@  struct gpiod_lookup_table {
 }
 
 void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
+void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
 
 #endif /* __LINUX_GPIO_MACHINE_H */