aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-28 21:15:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-28 21:15:41 -0400
commit5dfb66ba8c4a96eb732942c9f78629e4db1a51d4 (patch)
treed443adb4d02ac2599baf402698a589a9b814e478 /drivers
parent1d9b9f6a53d77ed801ba875f937d6dabbfc381ce (diff)
parent424f525a1241351da947fb48a938128ddd774511 (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
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/mfd-core.c32
-rw-r--r--drivers/mfd/tc6393xb.c8
2 files changed, 21 insertions, 19 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
18static int mfd_add_device(struct platform_device *parent, 18static 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
78int mfd_add_devices( 78int 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
100static int mfd_remove_devices_fn(struct device *dev, void *unused) 99static 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
107void mfd_remove_devices(struct platform_device *parent) 105void 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}
111EXPORT_SYMBOL(mfd_remove_devices); 109EXPORT_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);