lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.1205230020210.11851@axis700.grange>
Date:	Wed, 23 May 2012 00:23:58 +0200 (CEST)
From:	Guennadi Liakhovetski <g.liakhovetski@....de>
To:	Linus Walleij <linus.walleij@...aro.org>
cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] pinctrl: add a pinctrl_mux_group_selected() function

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@....de>
---

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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ