Skip to contentSkip to conversation

UCB1400: Pass ucb1400-gpio data through ac97 bus

PATCH In review Marek Vasut 2 participants 6 messages Aug 9, 2010 – Aug 27, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 UCB1400: Pass ucb1400-gpio data through ac97 bus

---
 drivers/gpio/ucb1400_gpio.c |   19 ++++++-------------
 drivers/mfd/ucb1400_core.c  |    5 +++++
 include/linux/ucb1400.h     |   19 ++++++-------------
 3 files changed, 17 insertions(+), 26 deletions(-)
drivers/gpio/ucb1400_gpio.c +6 -13
index 50e6bd1..fba45a5 100644
@@ -12,8 +12,6 @@
 #include <linux/module.h>
 #include <linux/ucb1400.h>
 
-struct ucb1400_gpio_data *ucbdata;
-
 static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off)
 {
 	struct ucb1400_gpio *gpio;
@@ -50,7 +48,7 @@ static int ucb1400_gpio_probe(struct platform_device *dev)
 	struct ucb1400_gpio *ucb = dev->dev.platform_data;
 	int err = 0;
 
-	if (!(ucbdata && ucbdata->gpio_offset)) {
+	if (!(ucb && ucb->gpio_offset)) {
 		err = -EINVAL;
 		goto err;
 	}
@@ -58,7 +56,7 @@ static int ucb1400_gpio_probe(struct platform_device *dev)
 	platform_set_drvdata(dev, ucb);
 
 	ucb->gc.label = "ucb1400_gpio";
-	ucb->gc.base = ucbdata->gpio_offset;
+	ucb->gc.base = ucb->gpio_offset;
 	ucb->gc.ngpio = 10;
 	ucb->gc.owner = THIS_MODULE;
 
@@ -72,8 +70,8 @@ static int ucb1400_gpio_probe(struct platform_device *dev)
 	if (err)
 		goto err;
 
-	if (ucbdata && ucbdata->gpio_setup)
-		err = ucbdata->gpio_setup(&dev->dev, ucb->gc.ngpio);
+	if (ucb && ucb->gpio_setup)
+		err = ucb->gpio_setup(&dev->dev, ucb->gc.ngpio);
 
 err:
 	return err;
@@ -85,8 +83,8 @@ static int ucb1400_gpio_remove(struct platform_device *dev)
 	int err = 0;
 	struct ucb1400_gpio *ucb = platform_get_drvdata(dev);
 
-	if (ucbdata && ucbdata->gpio_teardown) {
-		err = ucbdata->gpio_teardown(&dev->dev, ucb->gc.ngpio);
+	if (ucb && ucb->gpio_teardown) {
+		err = ucb->gpio_teardown(&dev->dev, ucb->gc.ngpio);
 		if (err)
 			return err;
 	}
@@ -113,11 +111,6 @@ static void __exit ucb1400_gpio_exit(void)
 	platform_driver_unregister(&ucb1400_gpio_driver);
 }
 
-void __init ucb1400_gpio_set_data(struct ucb1400_gpio_data *data)
-{
-	ucbdata = data;
-}
-
 module_init(ucb1400_gpio_init);
 module_exit(ucb1400_gpio_exit);
 
drivers/mfd/ucb1400_core.c +5 -0
index dbe2801..3e24632 100644
@@ -75,6 +75,11 @@ static int ucb1400_core_probe(struct device *dev)
 
 	/* GPIO */
 	ucb_gpio.ac97 = ac97;
+	if (pdata) {
+		ucb_gpio.gpio_setup = pdata->gpio_setup;
+		ucb_gpio.gpio_teardown = pdata->gpio_teardown;
+		ucb_gpio.gpio_offset = pdata->gpio_offset;
+	}
 	ucb->ucb1400_gpio = platform_device_alloc("ucb1400_gpio", -1);
 	if (!ucb->ucb1400_gpio) {
 		err = -ENOMEM;
include/linux/ucb1400.h +6 -13
index 1b47909..1a6bfdd 100644
@@ -83,15 +83,12 @@
 #define UCB_ID			0x7e
 #define UCB_ID_1400             0x4304
 
-struct ucb1400_gpio_data {
-	int gpio_offset;
-	int (*gpio_setup)(struct device *dev, int ngpio);
-	int (*gpio_teardown)(struct device *dev, int ngpio);
-};
-
 struct ucb1400_gpio {
 	struct gpio_chip	gc;
 	struct snd_ac97		*ac97;
+	int			gpio_offset;
+	int (*gpio_setup)(struct device *dev, int ngpio);
+	int (*gpio_teardown)(struct device *dev, int ngpio);
 };
 
 struct ucb1400_ts {
@@ -112,6 +109,9 @@ struct ucb1400 {
 
 struct ucb1400_pdata {
 	int	irq;
+	int	gpio_offset;
+	int (*gpio_setup)(struct device *dev, int ngpio);
+	int (*gpio_teardown)(struct device *dev, int ngpio);
 };
 
 static inline u16 ucb1400_reg_read(struct snd_ac97 *ac97, u16 reg)
@@ -163,11 +163,4 @@ static inline void ucb1400_adc_disable(struct snd_ac97 *ac97)
 
 unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel,
 			      int adcsync);
-
-#ifdef CONFIG_GPIO_UCB1400
-void __init ucb1400_gpio_set_data(struct ucb1400_gpio_data *data);
-#else
-static inline void ucb1400_gpio_set_data(struct ucb1400_gpio_data *data) {}
-#endif
-
 #endif
Signature · 1 line
1.7.1
#1 lore raw

Dne Po 9. srpna 2010 06:16:34 Marek Vasut napsal(a):

Quoted 6 lines
---
 drivers/gpio/ucb1400_gpio.c |   19 ++++++-------------
 drivers/mfd/ucb1400_core.c  |    5 +++++
 include/linux/ucb1400.h     |   19 ++++++-------------
 3 files changed, 17 insertions(+), 26 deletions(-)

Ah right, guys, if possible, let this go through Eric Miao's tree (as I have changes that depend on this). Thanks!

Cheers

Quoted 128 lines
drivers/gpio/ucb1400_gpio.c +6 -13
index 50e6bd1..fba45a5 100644
@@ -12,8 +12,6 @@
 #include <linux/module.h>
 #include <linux/ucb1400.h>
 
-struct ucb1400_gpio_data *ucbdata;
-
 static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off)
 {
 	struct ucb1400_gpio *gpio;
@@ -50,7 +48,7 @@ static int ucb1400_gpio_probe(struct platform_device
 *dev) struct ucb1400_gpio *ucb = dev->dev.platform_data;
 	int err = 0;
 
-	if (!(ucbdata && ucbdata->gpio_offset)) {
+	if (!(ucb && ucb->gpio_offset)) {
 		err = -EINVAL;
 		goto err;
 	}
@@ -58,7 +56,7 @@ static int ucb1400_gpio_probe(struct platform_device
 *dev) platform_set_drvdata(dev, ucb);
 
 	ucb->gc.label = "ucb1400_gpio";
-	ucb->gc.base = ucbdata->gpio_offset;
+	ucb->gc.base = ucb->gpio_offset;
 	ucb->gc.ngpio = 10;
 	ucb->gc.owner = THIS_MODULE;
 
@@ -72,8 +70,8 @@ static int ucb1400_gpio_probe(struct platform_device
 *dev) if (err)
 		goto err;
 
-	if (ucbdata && ucbdata->gpio_setup)
-		err = ucbdata->gpio_setup(&dev->dev, ucb->gc.ngpio);
+	if (ucb && ucb->gpio_setup)
+		err = ucb->gpio_setup(&dev->dev, ucb->gc.ngpio);
 
 err:
 	return err;
@@ -85,8 +83,8 @@ static int ucb1400_gpio_remove(struct platform_device
 *dev) int err = 0;
 	struct ucb1400_gpio *ucb = platform_get_drvdata(dev);
 
-	if (ucbdata && ucbdata->gpio_teardown) {
-		err = ucbdata->gpio_teardown(&dev->dev, ucb->gc.ngpio);
+	if (ucb && ucb->gpio_teardown) {
+		err = ucb->gpio_teardown(&dev->dev, ucb->gc.ngpio);
 		if (err)
 			return err;
 	}
@@ -113,11 +111,6 @@ static void __exit ucb1400_gpio_exit(void)
 	platform_driver_unregister(&ucb1400_gpio_driver);
 }
 
-void __init ucb1400_gpio_set_data(struct ucb1400_gpio_data *data)
-{
-	ucbdata = data;
-}
-
 module_init(ucb1400_gpio_init);
 module_exit(ucb1400_gpio_exit);
 
drivers/mfd/ucb1400_core.c +5 -0
index dbe2801..3e24632 100644
@@ -75,6 +75,11 @@ static int ucb1400_core_probe(struct device *dev)
 
 	/* GPIO */
 	ucb_gpio.ac97 = ac97;
+	if (pdata) {
+		ucb_gpio.gpio_setup = pdata->gpio_setup;
+		ucb_gpio.gpio_teardown = pdata->gpio_teardown;
+		ucb_gpio.gpio_offset = pdata->gpio_offset;
+	}
 	ucb->ucb1400_gpio = platform_device_alloc("ucb1400_gpio", -1);
 	if (!ucb->ucb1400_gpio) {
 		err = -ENOMEM;
include/linux/ucb1400.h +6 -11
index 1b47909..1a6bfdd 100644
@@ -83,15 +83,12 @@
 #define UCB_ID			0x7e
 #define UCB_ID_1400             0x4304
 
-struct ucb1400_gpio_data {
-	int gpio_offset;
-	int (*gpio_setup)(struct device *dev, int ngpio);
-	int (*gpio_teardown)(struct device *dev, int ngpio);
-};
-
 struct ucb1400_gpio {
 	struct gpio_chip	gc;
 	struct snd_ac97		*ac97;
+	int			gpio_offset;
+	int (*gpio_setup)(struct device *dev, int ngpio);
+	int (*gpio_teardown)(struct device *dev, int ngpio);
 };
 
 struct ucb1400_ts {
@@ -112,6 +109,9 @@ struct ucb1400 {
 
 struct ucb1400_pdata {
 	int	irq;
+	int	gpio_offset;
+	int (*gpio_setup)(struct device *dev, int ngpio);
+	int (*gpio_teardown)(struct device *dev, int ngpio);
 };
 
 static inline u16 ucb1400_reg_read(struct snd_ac97 *ac97, u16 reg)
@@ -163,11 +163,4 @@ static inline void ucb1400_adc_disable(struct snd_ac97
 *ac97)
 
 unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel,
 			      int adcsync);
-
-#ifdef CONFIG_GPIO_UCB1400
-void __init ucb1400_gpio_set_data(struct ucb1400_gpio_data *data);
-#else
-static inline void ucb1400_gpio_set_data(struct ucb1400_gpio_data *data)

{} -#endif
-
#endif

#2 lore raw
Quoted 2 lines · On Mon, 9 Aug 2010 06:43:14 +0200 Marek Vasut <[email protected]> wrote:

Dne Po 9. srpna 2010 06:16:34 Marek Vasut napsal(a):

Quoted 1 line

Please don't send unchangelogged patches.

The title tells us what the patch does but provides no hint as to why it does it.

Quoted 8 lines
Quoted 5 lines
---
 drivers/gpio/ucb1400_gpio.c |   19 ++++++-------------
 drivers/mfd/ucb1400_core.c  |    5 +++++
 include/linux/ucb1400.h     |   19 ++++++-------------
 3 files changed, 17 insertions(+), 26 deletions(-)

Ah right, guys, if possible, let this go through Eric Miao's tree (as I have changes that depend on this). Thanks!

He's probably unaware of the patch. Let's cc him.

#3 lore raw

Dne Pá 27. srpna 2010 01:07:36 Andrew Morton napsal(a):

Quoted 7 lines

On Mon, 9 Aug 2010 06:43:14 +0200

Quoted 2 lines · Marek Vasut

Dne Po 9. srpna 2010 06:16:34 Marek Vasut napsal(a):

Quoted 1 line

Please don't send unchangelogged patches.

Unchangelogged? What do you mean ?

Quoted 11 lines

The title tells us what the patch does but provides no hint as to why it does it.

Quoted 7 lines
Quoted 6 lines

---

 drivers/gpio/ucb1400_gpio.c |   19 ++++++-------------
 drivers/mfd/ucb1400_core.c  |    5 +++++
 include/linux/ucb1400.h     |   19 ++++++-------------
 3 files changed, 17 insertions(+), 26 deletions(-)
Quoted 4 lines
Quoted 2 lines

Ah right, guys, if possible, let this go through Eric Miao's tree (as I have changes that depend on this). Thanks!

He's probably unaware of the patch. Let's cc him.

I have this one in my tree and I sent it to Eric as a part of larger patchset. I just wanted to add your Ack eventually.

Cheers

#4 lore raw
Quoted 10 lines · On Fri, 27 Aug 2010 07:50:37 +0200 Marek Vasut <[email protected]> wrote:

Dne P__ 27. srpna 2010 01:07:36 Andrew Morton napsal(a):

Quoted 7 lines

On Mon, 9 Aug 2010 06:43:14 +0200

Quoted 2 lines · Marek Vasut

Dne Po 9. srpna 2010 06:16:34 Marek Vasut napsal(a):

Quoted 1 line

Please don't send unchangelogged patches.

Unchangelogged? What do you mean ?

Patches which don't have any changelog. This patch was sent with no covering explanation.

Quoted 3 lines
Quoted 3 lines

The title tells us what the patch does but provides no hint as to why it does it.

As I indicated. The title tells us what the patch does but didn't tell us *why* it does it. Apparently it is preparatory work for some other patch?

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

---

 drivers/gpio/ucb1400_gpio.c |   19 ++++++-------------
 drivers/mfd/ucb1400_core.c  |    5 +++++
 include/linux/ucb1400.h     |   19 ++++++-------------
 3 files changed, 17 insertions(+), 26 deletions(-)
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Ah right, guys, if possible, let this go through Eric Miao's tree (as I have changes that depend on this). Thanks!

He's probably unaware of the patch. Let's cc him.

I have this one in my tree and I sent it to Eric as a part of larger patchset.

Recently, I assume - it wasn't in this morning's linux-next.

#5 lore raw

Dne Pá 27. srpna 2010 08:14:19 Andrew Morton napsal(a):

Quoted 15 lines · On Fri, 27 Aug 2010 07:50:37 +0200 Marek Vasut <[email protected]> wrote:
Quoted 10 lines

Dne P__ 27. srpna 2010 01:07:36 Andrew Morton napsal(a):

Quoted 7 lines

On Mon, 9 Aug 2010 06:43:14 +0200

Quoted 2 lines · Marek Vasut

Dne Po 9. srpna 2010 06:16:34 Marek Vasut napsal(a):

Quoted 1 line

Please don't send unchangelogged patches.

Unchangelogged? What do you mean ?

Patches which don't have any changelog. This patch was sent with no covering explanation.

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

The title tells us what the patch does but provides no hint as to why it does it.

As I indicated. The title tells us what the patch does but didn't tell us *why* it does it. Apparently it is preparatory work for some other patch?

Ah, stupid me, I see, just checked the patch.

The point is, some time ago (about one year ago ... but certainly after the ucb1400 was split into multiple chunks and ucb1400-gpio was added), there was no way to pass platform data to devices attached to ac97 bus. That's why there was that function "ucb1400_gpio_set_data()".

That's not true anymore, we can just pass the pdata through the ac97 bus to the mfd part of ucb1400 driver (ucb1400-core), which then registers the gpio part of ucb1400. This patch actually makes it possible to pass the pdata through the ac97 bus instead.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines

---

 drivers/gpio/ucb1400_gpio.c |   19 ++++++-------------
 drivers/mfd/ucb1400_core.c  |    5 +++++
 include/linux/ucb1400.h     |   19 ++++++-------------
 3 files changed, 17 insertions(+), 26 deletions(-)

Ah right, guys, if possible, let this go through Eric Miao's tree (as I have changes that depend on this). Thanks!

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

He's probably unaware of the patch. Let's cc him.

I have this one in my tree and I sent it to Eric as a part of larger patchset.

Recently, I assume - it wasn't in this morning's linux-next.

It was sent to linux-arm-kernel as most of the patches were for linux-arm . I sent this one especially on it's own to reduce useless traffic. I'll remember this next time.

Cheers