Skip to content

Commit 5dfb66b

Browse files
committed
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
2 parents 1d9b9f6 + 424f525 commit 5dfb66b

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

drivers/mfd/mfd-core.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@
1515
#include <linux/platform_device.h>
1616
#include <linux/mfd/core.h>
1717

18-
static int mfd_add_device(struct platform_device *parent,
19-
const struct mfd_cell *cell,
20-
struct resource *mem_base,
21-
int irq_base)
18+
static int mfd_add_device(struct device *parent, int id,
19+
const struct mfd_cell *cell,
20+
struct resource *mem_base,
21+
int irq_base)
2222
{
2323
struct resource res[cell->num_resources];
2424
struct platform_device *pdev;
2525
int ret = -ENOMEM;
2626
int r;
2727

28-
pdev = platform_device_alloc(cell->name, parent->id);
28+
pdev = platform_device_alloc(cell->name, id);
2929
if (!pdev)
3030
goto fail_alloc;
3131

32-
pdev->dev.parent = &parent->dev;
32+
pdev->dev.parent = parent;
3333

3434
ret = platform_device_add_data(pdev,
35-
cell, sizeof(struct mfd_cell));
35+
cell->platform_data, cell->data_size);
3636
if (ret)
3737
goto fail_device;
3838

@@ -75,17 +75,16 @@ static int mfd_add_device(struct platform_device *parent,
7575
return ret;
7676
}
7777

78-
int mfd_add_devices(
79-
struct platform_device *parent,
80-
const struct mfd_cell *cells, int n_devs,
81-
struct resource *mem_base,
82-
int irq_base)
78+
int mfd_add_devices(struct device *parent, int id,
79+
const struct mfd_cell *cells, int n_devs,
80+
struct resource *mem_base,
81+
int irq_base)
8382
{
8483
int i;
8584
int ret = 0;
8685

8786
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);
8988
if (ret)
9089
break;
9190
}
@@ -99,14 +98,13 @@ EXPORT_SYMBOL(mfd_add_devices);
9998

10099
static int mfd_remove_devices_fn(struct device *dev, void *unused)
101100
{
102-
platform_device_unregister(
103-
container_of(dev, struct platform_device, dev));
101+
platform_device_unregister(to_platform_device(dev));
104102
return 0;
105103
}
106104

107-
void mfd_remove_devices(struct platform_device *parent)
105+
void mfd_remove_devices(struct device *parent)
108106
{
109-
device_for_each_child(&parent->dev, NULL, mfd_remove_devices_fn);
107+
device_for_each_child(parent, NULL, mfd_remove_devices_fn);
110108
}
111109
EXPORT_SYMBOL(mfd_remove_devices);
112110

drivers/mfd/tc6393xb.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,12 @@ static int __devinit tc6393xb_probe(struct platform_device *dev)
466466
tc6393xb_attach_irq(dev);
467467

468468
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]);
469473

470-
retval = mfd_add_devices(dev,
474+
retval = mfd_add_devices(&dev->dev, dev->id,
471475
tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells),
472476
iomem, tcpd->irq_base);
473477

@@ -501,7 +505,7 @@ static int __devexit tc6393xb_remove(struct platform_device *dev)
501505
struct tc6393xb *tc6393xb = platform_get_drvdata(dev);
502506
int ret;
503507

504-
mfd_remove_devices(dev);
508+
mfd_remove_devices(&dev->dev);
505509

506510
if (tc6393xb->irq)
507511
tc6393xb_detach_irq(dev);

include/linux/mfd/core.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#ifndef MFD_CORE_H
2-
#define MFD_CORE_H
31
/*
42
* drivers/mfd/mfd-core.h
53
*
@@ -13,6 +11,9 @@
1311
*
1412
*/
1513

14+
#ifndef MFD_CORE_H
15+
#define MFD_CORE_H
16+
1617
#include <linux/platform_device.h>
1718

1819
/*
@@ -28,7 +29,13 @@ struct mfd_cell {
2829
int (*suspend)(struct platform_device *dev);
2930
int (*resume)(struct platform_device *dev);
3031

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;
3239

3340
/*
3441
* This resources can be specified relatievly to the parent device.
@@ -38,18 +45,11 @@ struct mfd_cell {
3845
const struct resource *resources;
3946
};
4047

41-
static inline struct mfd_cell *
42-
mfd_get_cell(struct platform_device *pdev)
43-
{
44-
return (struct mfd_cell *)pdev->dev.platform_data;
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);
48+
extern int mfd_add_devices(struct device *parent, int id,
49+
const struct mfd_cell *cells, int n_devs,
50+
struct resource *mem_base,
51+
int irq_base);
5252

53-
extern void mfd_remove_devices(struct platform_device *parent);
53+
extern void mfd_remove_devices(struct device *parent);
5454

5555
#endif

0 commit comments

Comments
 (0)