diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-28 21:15:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-28 21:15:41 -0400 |
commit | 5dfb66ba8c4a96eb732942c9f78629e4db1a51d4 (patch) | |
tree | d443adb4d02ac2599baf402698a589a9b814e478 | |
parent | 1d9b9f6a53d77ed801ba875f937d6dabbfc381ce (diff) | |
parent | 424f525a1241351da947fb48a938128ddd774511 (diff) |
Merge branch 'for-linus' of git://git.o-hand.com/linux-mfd
* 'for-linus' of git://git.o-hand.com/linux-mfd:
mfd: accept pure device as a parent, not only platform_device
mfd: add platform_data to mfd_cell
mfd: Coding style fixes
mfd: Use to_platform_device instead of container_of
-rw-r--r-- | drivers/mfd/mfd-core.c | 32 | ||||
-rw-r--r-- | drivers/mfd/tc6393xb.c | 8 | ||||
-rw-r--r-- | include/linux/mfd/core.h | 30 |
3 files changed, 36 insertions, 34 deletions
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 0454be4266c1..9c9c126ed334 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c | |||
@@ -15,24 +15,24 @@ | |||
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/mfd/core.h> | 16 | #include <linux/mfd/core.h> |
17 | 17 | ||
18 | static int mfd_add_device(struct platform_device *parent, | 18 | static int mfd_add_device(struct device *parent, int id, |
19 | const struct mfd_cell *cell, | 19 | const struct mfd_cell *cell, |
20 | struct resource *mem_base, | 20 | struct resource *mem_base, |
21 | int irq_base) | 21 | int irq_base) |
22 | { | 22 | { |
23 | struct resource res[cell->num_resources]; | 23 | struct resource res[cell->num_resources]; |
24 | struct platform_device *pdev; | 24 | struct platform_device *pdev; |
25 | int ret = -ENOMEM; | 25 | int ret = -ENOMEM; |
26 | int r; | 26 | int r; |
27 | 27 | ||
28 | pdev = platform_device_alloc(cell->name, parent->id); | 28 | pdev = platform_device_alloc(cell->name, id); |
29 | if (!pdev) | 29 | if (!pdev) |
30 | goto fail_alloc; | 30 | goto fail_alloc; |
31 | 31 | ||
32 | pdev->dev.parent = &parent->dev; | 32 | pdev->dev.parent = parent; |
33 | 33 | ||
34 | ret = platform_device_add_data(pdev, | 34 | ret = platform_device_add_data(pdev, |
35 | cell, sizeof(struct mfd_cell)); | 35 | cell->platform_data, cell->data_size); |
36 | if (ret) | 36 | if (ret) |
37 | goto fail_device; | 37 | goto fail_device; |
38 | 38 | ||
@@ -75,17 +75,16 @@ fail_alloc: | |||
75 | return ret; | 75 | return ret; |
76 | } | 76 | } |
77 | 77 | ||
78 | int mfd_add_devices( | 78 | int mfd_add_devices(struct device *parent, int id, |
79 | struct platform_device *parent, | 79 | const struct mfd_cell *cells, int n_devs, |
80 | const struct mfd_cell *cells, int n_devs, | 80 | struct resource *mem_base, |
81 | struct resource *mem_base, | 81 | int irq_base) |
82 | int irq_base) | ||
83 | { | 82 | { |
84 | int i; | 83 | int i; |
85 | int ret = 0; | 84 | int ret = 0; |
86 | 85 | ||
87 | for (i = 0; i < n_devs; i++) { | 86 | for (i = 0; i < n_devs; i++) { |
88 | ret = mfd_add_device(parent, cells + i, mem_base, irq_base); | 87 | ret = mfd_add_device(parent, id, cells + i, mem_base, irq_base); |
89 | if (ret) | 88 | if (ret) |
90 | break; | 89 | break; |
91 | } | 90 | } |
@@ -99,14 +98,13 @@ EXPORT_SYMBOL(mfd_add_devices); | |||
99 | 98 | ||
100 | static int mfd_remove_devices_fn(struct device *dev, void *unused) | 99 | static int mfd_remove_devices_fn(struct device *dev, void *unused) |
101 | { | 100 | { |
102 | platform_device_unregister( | 101 | platform_device_unregister(to_platform_device(dev)); |
103 | container_of(dev, struct platform_device, dev)); | ||
104 | return 0; | 102 | return 0; |
105 | } | 103 | } |
106 | 104 | ||
107 | void mfd_remove_devices(struct platform_device *parent) | 105 | void mfd_remove_devices(struct device *parent) |
108 | { | 106 | { |
109 | device_for_each_child(&parent->dev, NULL, mfd_remove_devices_fn); | 107 | device_for_each_child(parent, NULL, mfd_remove_devices_fn); |
110 | } | 108 | } |
111 | EXPORT_SYMBOL(mfd_remove_devices); | 109 | EXPORT_SYMBOL(mfd_remove_devices); |
112 | 110 | ||
diff --git a/drivers/mfd/tc6393xb.c b/drivers/mfd/tc6393xb.c index 94e55e8e7ce6..f4fd797c1590 100644 --- a/drivers/mfd/tc6393xb.c +++ b/drivers/mfd/tc6393xb.c | |||
@@ -466,8 +466,12 @@ static int __devinit tc6393xb_probe(struct platform_device *dev) | |||
466 | tc6393xb_attach_irq(dev); | 466 | tc6393xb_attach_irq(dev); |
467 | 467 | ||
468 | tc6393xb_cells[TC6393XB_CELL_NAND].driver_data = tcpd->nand_data; | 468 | tc6393xb_cells[TC6393XB_CELL_NAND].driver_data = tcpd->nand_data; |
469 | tc6393xb_cells[TC6393XB_CELL_NAND].platform_data = | ||
470 | &tc6393xb_cells[TC6393XB_CELL_NAND]; | ||
471 | tc6393xb_cells[TC6393XB_CELL_NAND].data_size = | ||
472 | sizeof(tc6393xb_cells[TC6393XB_CELL_NAND]); | ||
469 | 473 | ||
470 | retval = mfd_add_devices(dev, | 474 | retval = mfd_add_devices(&dev->dev, dev->id, |
471 | tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells), | 475 | tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells), |
472 | iomem, tcpd->irq_base); | 476 | iomem, tcpd->irq_base); |
473 | 477 | ||
@@ -501,7 +505,7 @@ static int __devexit tc6393xb_remove(struct platform_device *dev) | |||
501 | struct tc6393xb *tc6393xb = platform_get_drvdata(dev); | 505 | struct tc6393xb *tc6393xb = platform_get_drvdata(dev); |
502 | int ret; | 506 | int ret; |
503 | 507 | ||
504 | mfd_remove_devices(dev); | 508 | mfd_remove_devices(&dev->dev); |
505 | 509 | ||
506 | if (tc6393xb->irq) | 510 | if (tc6393xb->irq) |
507 | tc6393xb_detach_irq(dev); | 511 | tc6393xb_detach_irq(dev); |
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index bb3dd0545928..49ef857cdb2d 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h | |||
@@ -1,5 +1,3 @@ | |||
1 | #ifndef MFD_CORE_H | ||
2 | #define MFD_CORE_H | ||
3 | /* | 1 | /* |
4 | * drivers/mfd/mfd-core.h | 2 | * drivers/mfd/mfd-core.h |
5 | * | 3 | * |
@@ -13,6 +11,9 @@ | |||
13 | * | 11 | * |
14 | */ | 12 | */ |
15 | 13 | ||
14 | #ifndef MFD_CORE_H | ||
15 | #define MFD_CORE_H | ||
16 | |||
16 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
17 | 18 | ||
18 | /* | 19 | /* |
@@ -28,7 +29,13 @@ struct mfd_cell { | |||
28 | int (*suspend)(struct platform_device *dev); | 29 | int (*suspend)(struct platform_device *dev); |
29 | int (*resume)(struct platform_device *dev); | 30 | int (*resume)(struct platform_device *dev); |
30 | 31 | ||
31 | void *driver_data; /* driver-specific data */ | 32 | /* driver-specific data for MFD-aware "cell" drivers */ |
33 | void *driver_data; | ||
34 | |||
35 | /* platform_data can be used to either pass data to "generic" | ||
36 | driver or as a hook to mfd_cell for the "cell" drivers */ | ||
37 | void *platform_data; | ||
38 | size_t data_size; | ||
32 | 39 | ||
33 | /* | 40 | /* |
34 | * This resources can be specified relatievly to the parent device. | 41 | * This resources can be specified relatievly to the parent device. |
@@ -38,18 +45,11 @@ struct mfd_cell { | |||
38 | const struct resource *resources; | 45 | const struct resource *resources; |
39 | }; | 46 | }; |
40 | 47 | ||
41 | static inline struct mfd_cell * | 48 | extern int mfd_add_devices(struct device *parent, int id, |
42 | mfd_get_cell(struct platform_device *pdev) | 49 | const struct mfd_cell *cells, int n_devs, |
43 | { | 50 | struct resource *mem_base, |
44 | return (struct mfd_cell *)pdev->dev.platform_data; | 51 | int irq_base); |
45 | } | ||
46 | |||
47 | extern int mfd_add_devices( | ||
48 | struct platform_device *parent, | ||
49 | const struct mfd_cell *cells, int n_devs, | ||
50 | struct resource *mem_base, | ||
51 | int irq_base); | ||
52 | 52 | ||
53 | extern void mfd_remove_devices(struct platform_device *parent); | 53 | extern void mfd_remove_devices(struct device *parent); |
54 | 54 | ||
55 | #endif | 55 | #endif |