diff options
author | NeilBrown <neilb@suse.de> | 2012-02-15 12:21:42 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-02-15 20:17:50 -0500 |
commit | 9f3519d2ed26d2ede5b6432fb64af0e7e8ed13e3 (patch) | |
tree | 21c794c3dcc559208a1d161382e39b5b07e41564 /drivers/w1 | |
parent | bc5bca53cca350eb90fc9f84c2e37ba6383807c3 (diff) |
w1: Fix w1_bq27000
w1_bq27000 adds a bq27000-battery platform device but does not provide
platform data for it. This causes the bq27x00 driver to dereference a NULL
pointer.
So provide the appropriate platform data. This requires modifying
w1_bq27000_read so that it find the w1 device as the parent of the bq device.
Also there is no point exporting w1_bq27000_read as nothing else uses it
or could use it. So make it static.
Finally, as there is no way to track how many batteries have been found, and
we will probably only find one, use an id number of '-1' to assert that this
is a unique instance.
Signed-off-by: NeilBrown <neilb@suse.de>
Tested-by: Thomas Weber <weber@corscience.de>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/w1')
-rw-r--r-- | drivers/w1/slaves/w1_bq27000.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/w1/slaves/w1_bq27000.c b/drivers/w1/slaves/w1_bq27000.c index 8f4c91f6c680..8f10fd2630a0 100644 --- a/drivers/w1/slaves/w1_bq27000.c +++ b/drivers/w1/slaves/w1_bq27000.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/mutex.h> | 17 | #include <linux/mutex.h> |
18 | #include <linux/power/bq27x00_battery.h> | ||
18 | 19 | ||
19 | #include "../w1.h" | 20 | #include "../w1.h" |
20 | #include "../w1_int.h" | 21 | #include "../w1_int.h" |
@@ -39,10 +40,10 @@ void w1_bq27000_write(struct device *dev, u8 buf, u8 reg) | |||
39 | } | 40 | } |
40 | EXPORT_SYMBOL(w1_bq27000_write); | 41 | EXPORT_SYMBOL(w1_bq27000_write); |
41 | 42 | ||
42 | int w1_bq27000_read(struct device *dev, u8 reg) | 43 | static int w1_bq27000_read(struct device *dev, unsigned int reg) |
43 | { | 44 | { |
44 | u8 val; | 45 | u8 val; |
45 | struct w1_slave *sl = container_of(dev, struct w1_slave, dev); | 46 | struct w1_slave *sl = container_of(dev->parent, struct w1_slave, dev); |
46 | 47 | ||
47 | if (!dev) | 48 | if (!dev) |
48 | return 0; | 49 | return 0; |
@@ -52,19 +53,25 @@ int w1_bq27000_read(struct device *dev, u8 reg) | |||
52 | 53 | ||
53 | return val; | 54 | return val; |
54 | } | 55 | } |
55 | EXPORT_SYMBOL(w1_bq27000_read); | 56 | |
57 | static struct bq27000_platform_data bq27000_battery_info = { | ||
58 | .read = w1_bq27000_read, | ||
59 | .name = "bq27000-battery", | ||
60 | }; | ||
56 | 61 | ||
57 | static int w1_bq27000_add_slave(struct w1_slave *sl) | 62 | static int w1_bq27000_add_slave(struct w1_slave *sl) |
58 | { | 63 | { |
59 | int ret; | 64 | int ret; |
60 | int id = 1; | ||
61 | struct platform_device *pdev; | 65 | struct platform_device *pdev; |
62 | 66 | ||
63 | pdev = platform_device_alloc("bq27000-battery", id); | 67 | pdev = platform_device_alloc("bq27000-battery", -1); |
64 | if (!pdev) { | 68 | if (!pdev) { |
65 | ret = -ENOMEM; | 69 | ret = -ENOMEM; |
66 | return ret; | 70 | return ret; |
67 | } | 71 | } |
72 | ret = platform_device_add_data(pdev, | ||
73 | &bq27000_battery_info, | ||
74 | sizeof(bq27000_battery_info)); | ||
68 | pdev->dev.parent = &sl->dev; | 75 | pdev->dev.parent = &sl->dev; |
69 | 76 | ||
70 | ret = platform_device_add(pdev); | 77 | ret = platform_device_add(pdev); |