[PATCH] pinctrl: add a pinctrl_mux_group_selected() function

From: Guennadi Liakhovetski
Date: Tue May 22 2012 - 18:24:00 EST


This patch adds a new function to allow clients to verify, whether a
certain group is selected in the currently active setting or not.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@xxxxxx>
---

Maybe there is already a way to do this without adding a new function, I
haven't found one, hence this patch.

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index ec3b8cc18..4e768d4 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -310,6 +310,32 @@ void pinctrl_remove_gpio_range(struct pinctrl_dev *pctldev,
EXPORT_SYMBOL_GPL(pinctrl_remove_gpio_range);

/**
+ * pinctrl_mux_group_selected() - check, whether a group is currently selected
+ */
+bool pinctrl_mux_group_selected(struct pinctrl *p, const char *group)
+{
+ struct pinctrl_setting *setting;
+
+ list_for_each_entry(setting, &p->state->settings, node) {
+ struct pinctrl_dev *pctldev = setting->pctldev;
+ const struct pinctrl_ops *ops = pctldev->desc->pctlops;
+ const char *gname;
+
+ if (setting->type != PIN_MAP_TYPE_MUX_GROUP)
+ continue;
+
+ gname = ops->get_group_name(pctldev, setting->data.mux.group);
+ if (!strcmp(gname, group)) {
+ dev_dbg(setting->pctldev->dev, "%s(): group %s found\n", __func__, group);
+ return true;
+ }
+ }
+ pr_debug("%s(): group %s not found\n", __func__, group);
+ return false;
+}
+EXPORT_SYMBOL_GPL(pinctrl_mux_group_selected);
+
+/**
* pinctrl_get_group_selector() - returns the group selector for a group
* @pctldev: the pin controller handling the group
* @pin_group: the pin group to look up
diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h
index 191e726..31d6c6f 100644
--- a/include/linux/pinctrl/consumer.h
+++ b/include/linux/pinctrl/consumer.h
@@ -35,6 +35,7 @@ extern struct pinctrl_state * __must_check pinctrl_lookup_state(
struct pinctrl *p,
const char *name);
extern int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *s);
+extern bool pinctrl_mux_group_selected(struct pinctrl *p, const char *group);

extern struct pinctrl * __must_check devm_pinctrl_get(struct device *dev);
extern void devm_pinctrl_put(struct pinctrl *p);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/