[PATCH] tosa_battery: fix FTBFS bug due to driver_data access

Previous thread: [PATCH] UML: UML libc linking error fix by Matthew Ryan Maurer on Tuesday, April 27, 2010 - 5:16 am. (1 message)

Next thread: ehci_hcd causes immediate wakeup from suspend to RAM or disk on Asus P4P800-VM by Ondrej Zary on Tuesday, April 27, 2010 - 6:23 am. (3 messages)
From: Dmitry Eremin-Solenikov
Date: Tuesday, April 27, 2010 - 6:18 am

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/power/tosa_battery.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/tosa_battery.c b/drivers/power/tosa_battery.c
index 2eab35a..ee04936 100644
--- a/drivers/power/tosa_battery.c
+++ b/drivers/power/tosa_battery.c
@@ -61,7 +61,7 @@ static unsigned long tosa_read_bat(struct tosa_bat *bat)
 	mutex_lock(&bat_lock);
 	gpio_set_value(bat->gpio_bat, 1);
 	msleep(5);
-	value = wm97xx_read_aux_adc(bat->psy.dev->parent->driver_data,
+	value = wm97xx_read_aux_adc(dev_get_drvdata(bat->psy.dev->parent),
 			bat->adc_bat);
 	gpio_set_value(bat->gpio_bat, 0);
 	mutex_unlock(&bat_lock);
@@ -81,7 +81,7 @@ static unsigned long tosa_read_temp(struct tosa_bat *bat)
 	mutex_lock(&bat_lock);
 	gpio_set_value(bat->gpio_temp, 1);
 	msleep(5);
-	value = wm97xx_read_aux_adc(bat->psy.dev->parent->driver_data,
+	value = wm97xx_read_aux_adc(dev_get_drvdata(bat->psy.dev->parent),
 			bat->adc_temp);
 	gpio_set_value(bat->gpio_temp, 0);
 	mutex_unlock(&bat_lock);
-- 
1.7.0

--

From: Andrew Morton
Date: Tuesday, April 27, 2010 - 3:48 pm

On Tue, 27 Apr 2010 17:18:22 +0400

Please don't send unchangelogged patches.

Please don't send patches which require recipients to go googling
acronyms to work out wtf you're up to.

<googles the acronym>

Ah, it appears to be a build fix.

Please always quote the compiler errors when fixing a build error.

IOW: bah.

--

From: Anton Vorontsov
Date: Friday, April 30, 2010 - 11:13 am

It seems that the driver isn't buildable since 2.6.32
(i.e. commit b4028437 "Driver core: move dev_get/set_drvdata to
drivers/base/dd.c").

Also, IIRC it was deprecated in favor of wm97xx_battery.c
driver.

So, I'm not picking this patch for 2.6.34, it's not a
new regression, and the driver is probably needs to be
removed.

Any objections on the patch down below?

- - - -
From 464e18bb5c7230daaa741d308f76cf0671be4bf2 Mon Sep 17 00:00:00 2001
From: Anton Vorontsov <cbouatmailru@gmail.com>
Date: Fri, 30 Apr 2010 21:55:58 +0400
Subject: [PATCH] Remove tosa_battery driver

- The driver is broken since commit b4028437 "Driver core: move
  dev_get/set_drvdata to drivers/base/dd.c", i.e. since 2.6.32;

- The driver isn't selected by any ARM defconfig.

- wm97xx_battery is a more generic driver, and should be suitable
  as a replacement;

So, remove the tosa_battery driver.

Signed-off-by: Anton Vorontsov <Anton Vorontsov>
---
 drivers/power/Kconfig        |    7 -
 drivers/power/Makefile       |    1 -
 drivers/power/tosa_battery.c |  486 ------------------------------------------
 3 files changed, 0 insertions(+), 494 deletions(-)
 delete mode 100644 drivers/power/tosa_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index c59bcb7..058347d 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -84,13 +84,6 @@ config BATTERY_OLPC
 	help
 	  Say Y to enable support for the battery on the OLPC laptop.
 
-config BATTERY_TOSA
-	tristate "Sharp SL-6000 (tosa) battery"
-	depends on MACH_TOSA && MFD_TC6393XB && TOUCHSCREEN_WM97XX
-	help
-	  Say Y to enable support for the battery on the Sharp Zaurus
-	  SL-6000 (tosa) models.
-
 config BATTERY_COLLIE
 	tristate "Sharp SL-5500 (collie) battery"
 	depends on SA1100_COLLIE && MCP_UCB1200
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index a82f292..dd4de16 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -25,7 +25,6 @@ obj-$(CONFIG_BATTERY_DS2760)	+= ...
From: Dmitry Eremin-Solenikov
Date: Friday, April 30, 2010 - 1:40 pm

Hello,

On Fri, Apr 30, 2010 at 10:13 PM, Anton Vorontsov

Yes. wm97xx_battery handles only one battery, while tosa uses 3
different batterires.
So, wm97xx_battery needs to be adapted/enhanced.

-- 
With best wishes
Dmitry
--


On Sat, May 01, 2010 at 12:40:54AM +0400, Dmitry Eremin-Solenikov wrote:

Eh. I see, thanks for making this clear. I added some changelog
and applied the following patch to battery-2.6.git:

- - -
From: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Date: Tue, 27 Apr 2010 17:18:22 +0400
Subject: [PATCH] tosa_battery: Fix build error due to direct driver_data usage

The driver isn't buildable since 2.6.32 (i.e. commit b4028437
"Driver core: move dev_get/set_drvdata to drivers/base/dd.c"):

  CC      tosa_battery.o
tosa_battery.c: In function 'tosa_read_bat':
tosa_battery.c:64: error: 'struct device' has no member named 'driver_data'
tosa_battery.c: In function 'tosa_read_temp':
tosa_battery.c:84: error: 'struct device' has no member named 'driver_data'

Nowadays we must not access driver_data directly, use dev_get_drvdata()
instead.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
---
 drivers/power/tosa_battery.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/tosa_battery.c b/drivers/power/tosa_battery.c
index 2eab35a..ee04936 100644
--- a/drivers/power/tosa_battery.c
+++ b/drivers/power/tosa_battery.c
@@ -61,7 +61,7 @@ static unsigned long tosa_read_bat(struct tosa_bat *bat)
 	mutex_lock(&bat_lock);
 	gpio_set_value(bat->gpio_bat, 1);
 	msleep(5);
-	value = wm97xx_read_aux_adc(bat->psy.dev->parent->driver_data,
+	value = wm97xx_read_aux_adc(dev_get_drvdata(bat->psy.dev->parent),
 			bat->adc_bat);
 	gpio_set_value(bat->gpio_bat, 0);
 	mutex_unlock(&bat_lock);
@@ -81,7 +81,7 @@ static unsigned long tosa_read_temp(struct tosa_bat *bat)
 	mutex_lock(&bat_lock);
 	gpio_set_value(bat->gpio_temp, 1);
 	msleep(5);
-	value = wm97xx_read_aux_adc(bat->psy.dev->parent->driver_data,
+	value = wm97xx_read_aux_adc(dev_get_drvdata(bat->psy.dev->parent),
 			bat->adc_temp);
 	gpio_set_value(bat->gpio_temp, ...
From: Dmitry Eremin-Solenikov
Date: Sunday, May 2, 2010 - 1:52 pm

Thank you. Merging these two drivers is on my goal list, but it won't



-- 
With best wishes
Dmitry
--


TBH I'm not entirely sure it's worth it - I'd be somewhat surprised to
see users outside of tosa for the more complex functionality.
--

Previous thread: [PATCH] UML: UML libc linking error fix by Matthew Ryan Maurer on Tuesday, April 27, 2010 - 5:16 am. (1 message)

Next thread: ehci_hcd causes immediate wakeup from suspend to RAM or disk on Asus P4P800-VM by Ondrej Zary on Tuesday, April 27, 2010 - 6:23 am. (3 messages)