From: Hans de Goede <hdegoede@redhat.com>
To: "Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
"Lee Jones" <lee.jones@linaro.org>,
"Linus Walleij" <linus.walleij@linaro.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
intel-gfx <intel-gfx@lists.freedesktop.org>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org
Subject: [PATCH 1/5] pinctrl: Export pinctrl_unregister_mappings
Date: Sun, 15 Dec 2019 17:38:06 +0100 [thread overview]
Message-ID: <20191215163810.52356-2-hdegoede@redhat.com> (raw)
In-Reply-To: <20191215163810.52356-1-hdegoede@redhat.com>
Rename pinctrl_unregister_map to pinctrl_unregister_mappings so that
its naming matches its pinctrl_register_mappings counter-part and
export it.
The purpose of this patch is to allow non-dt platforms to register
pinctrl mappings from code which is build as a module, which requires
being able to unregister the mapping when the module is unloaded to
avoid dangling pointers; and to avoid registering the mapping multiple
times, when the module gets reloaded later.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/pinctrl/core.c | 11 ++++++++++-
drivers/pinctrl/core.h | 3 ++-
drivers/pinctrl/devicetree.c | 2 +-
include/linux/pinctrl/machine.h | 5 +++++
4 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 2bbd8ee93507..c98f8cc9c7ca 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1431,6 +1431,7 @@ int pinctrl_register_map(const struct pinctrl_map *maps, unsigned num_maps,
return -ENOMEM;
maps_node->num_maps = num_maps;
+ maps_node->dup = dup;
if (dup) {
maps_node->maps = kmemdup(maps, sizeof(*maps) * num_maps,
GFP_KERNEL);
@@ -1463,7 +1464,12 @@ int pinctrl_register_mappings(const struct pinctrl_map *maps,
}
EXPORT_SYMBOL_GPL(pinctrl_register_mappings);
-void pinctrl_unregister_map(const struct pinctrl_map *map)
+/**
+ * pinctrl_unregister_mappings() - unregister a set of pin controller mappings
+ * @maps: the pincontrol mappings table passed to pinctrl_register_mappings()
+ * when registering the mappings.
+ */
+void pinctrl_unregister_mappings(const struct pinctrl_map *map)
{
struct pinctrl_maps *maps_node;
@@ -1471,6 +1477,8 @@ void pinctrl_unregister_map(const struct pinctrl_map *map)
list_for_each_entry(maps_node, &pinctrl_maps, node) {
if (maps_node->maps == map) {
list_del(&maps_node->node);
+ if (maps_node->dup)
+ kfree(maps_node->maps);
kfree(maps_node);
mutex_unlock(&pinctrl_maps_mutex);
return;
@@ -1478,6 +1486,7 @@ void pinctrl_unregister_map(const struct pinctrl_map *map)
}
mutex_unlock(&pinctrl_maps_mutex);
}
+EXPORT_SYMBOL_GPL(pinctrl_unregister_mappings);
/**
* pinctrl_force_sleep() - turn a given controller device into sleep state
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 7f34167a0405..cba38ef13b1d 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -175,11 +175,13 @@ struct pin_desc {
* @node: mapping table list node
* @maps: array of mapping table entries
* @num_maps: the number of entries in @maps
+ * @dup: has the mapping table been memdup-ed by us?
*/
struct pinctrl_maps {
struct list_head node;
const struct pinctrl_map *maps;
unsigned num_maps;
+ bool dup;
};
#ifdef CONFIG_GENERIC_PINCTRL_GROUPS
@@ -238,7 +240,6 @@ pinctrl_find_gpio_range_from_pin_nolock(struct pinctrl_dev *pctldev,
int pinctrl_register_map(const struct pinctrl_map *maps, unsigned num_maps,
bool dup);
-void pinctrl_unregister_map(const struct pinctrl_map *map);
extern int pinctrl_force_sleep(struct pinctrl_dev *pctldev);
extern int pinctrl_force_default(struct pinctrl_dev *pctldev);
diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
index 674920daac26..a1925962a3e2 100644
--- a/drivers/pinctrl/devicetree.c
+++ b/drivers/pinctrl/devicetree.c
@@ -51,7 +51,7 @@ void pinctrl_dt_free_maps(struct pinctrl *p)
struct pinctrl_dt_map *dt_map, *n1;
list_for_each_entry_safe(dt_map, n1, &p->dt_maps, node) {
- pinctrl_unregister_map(dt_map->map);
+ pinctrl_unregister_mappings(dt_map->map);
list_del(&dt_map->node);
dt_free_map(dt_map->pctldev, dt_map->map,
dt_map->num_maps);
diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h
index ddd1b2773431..e987dc9fd2af 100644
--- a/include/linux/pinctrl/machine.h
+++ b/include/linux/pinctrl/machine.h
@@ -153,6 +153,7 @@ struct pinctrl_map {
extern int pinctrl_register_mappings(const struct pinctrl_map *map,
unsigned num_maps);
+extern void pinctrl_unregister_mappings(const struct pinctrl_map *map);
extern void pinctrl_provide_dummies(void);
#else
@@ -162,6 +163,10 @@ static inline int pinctrl_register_mappings(const struct pinctrl_map *map,
return 0;
}
+static inline void pinctrl_unregister_mappings(const struct pinctrl_map *map)
+{
+}
+
static inline void pinctrl_provide_dummies(void)
{
}
--
2.23.0
next prev parent reply other threads:[~2019-12-15 16:38 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-15 16:38 [PATCH 0/5] drm/i915/dsi: Control panel and backlight enable GPIOs from VBT Hans de Goede
2019-12-15 16:38 ` Hans de Goede [this message]
2019-12-15 16:38 ` [PATCH 2/5] drm/i915/dsi: Move poking of panel-enable GPIO to intel_dsi_vbt.c Hans de Goede
2019-12-16 10:27 ` Linus Walleij
2019-12-16 13:51 ` Ville Syrjälä
2019-12-15 16:38 ` [PATCH 3/5] drm/i915/dsi: Init panel-enable GPIO to low when the LCD is initially off Hans de Goede
2019-12-16 10:28 ` Linus Walleij
2019-12-16 13:45 ` Ville Syrjälä
2019-12-16 13:51 ` Hans de Goede
2019-12-16 14:14 ` Ville Syrjälä
2019-12-16 14:59 ` Hans de Goede
2019-12-15 16:38 ` [PATCH 4/5] drm/i915/dsi: Move Crystal Cove PMIC panel GPIO lookup from mfd to the i915 driver Hans de Goede
2019-12-16 10:30 ` Linus Walleij
2019-12-16 12:16 ` Andy Shevchenko
2019-12-16 13:13 ` Hans de Goede
2019-12-16 13:56 ` Ville Syrjälä
2019-12-16 14:16 ` Hans de Goede
2019-12-15 16:38 ` [PATCH 5/5] drm/i915/dsi: Control panel and backlight enable GPIOs on BYT Hans de Goede
2019-12-16 10:29 ` Linus Walleij
2019-12-16 14:04 ` Ville Syrjälä
2019-12-16 14:28 ` Hans de Goede
2019-12-16 10:26 ` [PATCH 0/5] drm/i915/dsi: Control panel and backlight enable GPIOs from VBT Linus Walleij
2019-12-16 10:59 ` Hans de Goede
2019-12-16 11:11 ` Hans de Goede
2019-12-16 12:16 ` Linus Walleij
2019-12-16 13:25 ` Hans de Goede
2019-12-16 12:18 ` Andy Shevchenko
2019-12-16 16:10 ` Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191215163810.52356-2-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=ville.syrjala@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).