linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] pinctrl: Add "struct seq_file;" to pinconf.h
@ 2011-12-15 23:57 Stephen Warren
  2011-12-15 23:57 ` [PATCH 2/2] pinctrl: Pass name instead of device to pin_config_* Stephen Warren
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2011-12-15 23:57 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel, Stephen Warren

This allows one to include pinconf.h without having to include other
headers first.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 include/linux/pinctrl/pinconf.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/pinctrl/pinconf.h b/include/linux/pinctrl/pinconf.h
index d5b72e6..8c2c88e 100644
--- a/include/linux/pinctrl/pinconf.h
+++ b/include/linux/pinctrl/pinconf.h
@@ -15,6 +15,7 @@
 #ifdef CONFIG_PINCONF
 
 struct pinctrl_dev;
+struct seq_file;
 
 /**
  * struct pinconf_ops - pin config operations, to be implemented by
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] pinctrl: Pass name instead of device to pin_config_*
  2011-12-15 23:57 [PATCH 1/2] pinctrl: Add "struct seq_file;" to pinconf.h Stephen Warren
@ 2011-12-15 23:57 ` Stephen Warren
  2011-12-18 22:27   ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2011-12-15 23:57 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel, Stephen Warren

Obtaining a "struct pinctrl_dev *" is difficult for code not directly
related to the pinctrl subsystem. However, the device name of the pinctrl
device is fairly well known. So, modify pin_config_*() to take the device
name instead of the "struct pinctrl_dev *".

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 drivers/pinctrl/pinconf.c       |   43 ++++++++++++++++++++++++++++++--------
 include/linux/pinctrl/pinconf.h |   16 +++++++-------
 2 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
index 3ddd4e9..38c5b41 100644
--- a/drivers/pinctrl/pinconf.c
+++ b/drivers/pinctrl/pinconf.c
@@ -31,12 +31,18 @@
  *	current pin state, it can be used directly by drivers as a numeral, or
  *	it can be dereferenced to any struct.
  */
-int pin_config_get(struct pinctrl_dev *pctldev, const char *name,
+int pin_config_get(const char *dev_name, const char *name,
 			  unsigned long *config)
 {
-	const struct pinconf_ops *ops = pctldev->desc->confops;
+	struct pinctrl_dev *pctldev;
+	const struct pinconf_ops *ops;
 	int pin;
 
+	pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
+	if (!pctldev)
+		return -EINVAL;
+	ops = pctldev->desc->confops;
+
 	pin = pin_get_from_name(pctldev, name);
 	if (pin < 0)
 		return pin;
@@ -59,13 +65,19 @@ EXPORT_SYMBOL(pin_config_get);
  *	can be used directly by drivers as a numeral, or it can be dereferenced
  *	to any struct.
  */
-int pin_config_set(struct pinctrl_dev *pctldev, const char *name,
+int pin_config_set(const char *dev_name, const char *name,
 		   unsigned long config)
 {
-	const struct pinconf_ops *ops = pctldev->desc->confops;
+	struct pinctrl_dev *pctldev;
+	const struct pinconf_ops *ops;
 	int pin;
 	int ret;
 
+	pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
+	if (!pctldev)
+		return -EINVAL;
+	ops = pctldev->desc->confops;
+
 	pin = pin_get_from_name(pctldev, name);
 	if (pin < 0)
 		return pin;
@@ -87,12 +99,18 @@ int pin_config_set(struct pinctrl_dev *pctldev, const char *name,
 }
 EXPORT_SYMBOL(pin_config_set);
 
-int pin_config_group_get(struct pinctrl_dev *pctldev, const char *pin_group,
+int pin_config_group_get(const char *dev_name, const char *pin_group,
 			 unsigned long *config)
 {
-	const struct pinconf_ops *ops = pctldev->desc->confops;
+	struct pinctrl_dev *pctldev;
+	const struct pinconf_ops *ops;
 	int selector;
 
+	pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
+	if (!pctldev)
+		return -EINVAL;
+	ops = pctldev->desc->confops;
+
 	if (!ops || !ops->pin_config_group_get) {
 		dev_err(pctldev->dev, "cannot get configuration for pin "
 			"group, missing group config get function in "
@@ -109,17 +127,24 @@ int pin_config_group_get(struct pinctrl_dev *pctldev, const char *pin_group,
 EXPORT_SYMBOL(pin_config_group_get);
 
 
-int pin_config_group_set(struct pinctrl_dev *pctldev, const char *pin_group,
+int pin_config_group_set(const char *dev_name, const char *pin_group,
 			 unsigned long config)
 {
-	const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
-	const struct pinconf_ops *ops = pctldev->desc->confops;
+	struct pinctrl_dev *pctldev;
+	const struct pinconf_ops *ops;
+	const struct pinctrl_ops *pctlops;
 	int selector;
 	const unsigned *pins;
 	unsigned num_pins;
 	int ret;
 	int i;
 
+	pctldev = get_pinctrl_dev_from_dev(NULL, dev_name);
+	if (!pctldev)
+		return -EINVAL;
+	ops = pctldev->desc->confops;
+	pctlops = pctldev->desc->pctlops;
+
 	if (!ops || (!ops->pin_config_group_set && !ops->pin_config_set)) {
 		dev_err(pctldev->dev, "cannot configure pin group, missing "
 			"config function in driver\n");
diff --git a/include/linux/pinctrl/pinconf.h b/include/linux/pinctrl/pinconf.h
index 8c2c88e..477922c 100644
--- a/include/linux/pinctrl/pinconf.h
+++ b/include/linux/pinctrl/pinconf.h
@@ -53,39 +53,39 @@ struct pinconf_ops {
 					   unsigned selector);
 };
 
-extern int pin_config_get(struct pinctrl_dev *pctldev, const char *name,
+extern int pin_config_get(const char *dev_name, const char *name,
 			  unsigned long *config);
-extern int pin_config_set(struct pinctrl_dev *pctldev, const char *name,
+extern int pin_config_set(const char *dev_name, const char *name,
 			  unsigned long config);
-extern int pin_config_group_get(struct pinctrl_dev *pctldev,
+extern int pin_config_group_get(const char *dev_name,
 				const char *pin_group,
 				unsigned long *config);
-extern int pin_config_group_set(struct pinctrl_dev *pctldev,
+extern int pin_config_group_set(const char *dev_name,
 				const char *pin_group,
 				unsigned long config);
 
 #else
 
-static inline int pin_config_get(struct pinctrl_dev *pctldev, const char *name,
+static inline int pin_config_get(const char *dev_name, const char *name,
 				 unsigned long *config)
 {
 	return 0;
 }
 
-static inline int pin_config_set(struct pinctrl_dev *pctldev, const char *name,
+static inline int pin_config_set(const char *dev_name, const char *name,
 				 unsigned long config)
 {
 	return 0;
 }
 
-static inline int pin_config_group_get(struct pinctrl_dev *pctldev,
+static inline int pin_config_group_get(const char *dev_name,
 				       const char *pin_group,
 				       unsigned long *config)
 {
 	return 0;
 }
 
-static inline int pin_config_group_set(struct pinctrl_dev *pctldev,
+static inline int pin_config_group_set(const char *dev_name,
 				       const char *pin_group,
 				       unsigned long config)
 {
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] pinctrl: Pass name instead of device to pin_config_*
  2011-12-15 23:57 ` [PATCH 2/2] pinctrl: Pass name instead of device to pin_config_* Stephen Warren
@ 2011-12-18 22:27   ` Linus Walleij
  2011-12-19 18:20     ` Stephen Warren
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2011-12-18 22:27 UTC (permalink / raw)
  To: Stephen Warren; +Cc: linux-kernel

On Fri, Dec 16, 2011 at 12:57 AM, Stephen Warren <swarren@nvidia.com> wrote:

> Obtaining a "struct pinctrl_dev *" is difficult for code not directly
> related to the pinctrl subsystem. However, the device name of the pinctrl
> device is fairly well known. So, modify pin_config_*() to take the device
> name instead of the "struct pinctrl_dev *".
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>

Thanks Stephen, excellent, both applied.

I had to fix it up a bit to match the other
refactoring patch I made so check the result in my tree or -next.

Linus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 2/2] pinctrl: Pass name instead of device to pin_config_*
  2011-12-18 22:27   ` Linus Walleij
@ 2011-12-19 18:20     ` Stephen Warren
  2012-01-01 13:32       ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2011-12-19 18:20 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel

Linus Walleij wrote at Sunday, December 18, 2011 3:27 PM:
> On Fri, Dec 16, 2011 at 12:57 AM, Stephen Warren <swarren@nvidia.com> wrote:
> 
> > Obtaining a "struct pinctrl_dev *" is difficult for code not directly
> > related to the pinctrl subsystem. However, the device name of the pinctrl
> > device is fairly well known. So, modify pin_config_*() to take the device
> > name instead of the "struct pinctrl_dev *".
> >
> > Signed-off-by: Stephen Warren <swarren@nvidia.com>
> 
> Thanks Stephen, excellent, both applied.
> 
> I had to fix it up a bit to match the other
> refactoring patch I made so check the result in my tree or -next.

Yes, I think that looks fine, thanks.

Thanks for fixing up the documentation for me too.

BTW, do you know which commits you're planning on you're planning on
sending to mainline during the next merge window? If it includes these
two patches, I may be able to convert Tegra over to using the new pinctrl
driver in 3.3. And is your for-next branch stable (i.e. never rebased)
so that the arm-soc tree can use it as a dependency for my patches?

-- 
nvpublic


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] pinctrl: Pass name instead of device to pin_config_*
  2011-12-19 18:20     ` Stephen Warren
@ 2012-01-01 13:32       ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2012-01-01 13:32 UTC (permalink / raw)
  To: Stephen Warren; +Cc: linux-kernel

On Mon, Dec 19, 2011 at 7:20 PM, Stephen Warren <swarren@nvidia.com> wrote:
> Linus Walleij wrote at Sunday, December 18, 2011 3:27 PM:
>>
>> I had to fix it up a bit to match the other
>> refactoring patch I made so check the result in my tree or -next.
>
> Yes, I think that looks fine, thanks.
>
> Thanks for fixing up the documentation for me too.
>
> BTW, do you know which commits you're planning on you're planning on
> sending to mainline during the next merge window? If it includes these
> two patches,

Yes, everything that has landed in -next will be sent upstream,
including this.

> I may be able to convert Tegra over to using the new pinctrl
> driver in 3.3. And is your for-next branch stable (i.e. never rebased)
> so that the arm-soc tree can use it as a dependency for my patches?

It is rebased infrequently, and never this late in the -rc series.
I may add fixes on top though.

The for-next branch is basically a subset of devel excluding
any controversial stuff, so up to a certain point, then I keep
the under discussion stuff on top of for-next.

Thanks,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-01-01 13:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-15 23:57 [PATCH 1/2] pinctrl: Add "struct seq_file;" to pinconf.h Stephen Warren
2011-12-15 23:57 ` [PATCH 2/2] pinctrl: Pass name instead of device to pin_config_* Stephen Warren
2011-12-18 22:27   ` Linus Walleij
2011-12-19 18:20     ` Stephen Warren
2012-01-01 13:32       ` Linus Walleij

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).