Commit 56edb58b authored by Mike Rapoport's avatar Mike Rapoport Committed by Samuel Ortiz

mfd: add platform_data to mfd_cell

Adding platform_data to mfd_cell allows passing of platform data directly
to the platform_device created for each cell and thus reuse of existing
drivers.
On the other side it can be used as a hook to mfd_cell itself
removing the need in mfd_get_cell method.
Signed-off-by: default avatarMike Rapoport <mike@compulab.co.il>
Acked-by: default avatarDmitry Baryshkov <dbaryshkov@gmail.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@openedhand.com>
parent 7f71ac93
...@@ -32,7 +32,7 @@ static int mfd_add_device(struct platform_device *parent, ...@@ -32,7 +32,7 @@ static int mfd_add_device(struct platform_device *parent,
pdev->dev.parent = &parent->dev; pdev->dev.parent = &parent->dev;
ret = platform_device_add_data(pdev, ret = platform_device_add_data(pdev,
cell, sizeof(struct mfd_cell)); cell->platform_data, cell->data_size);
if (ret) if (ret)
goto fail_device; goto fail_device;
......
...@@ -466,6 +466,10 @@ static int __devinit tc6393xb_probe(struct platform_device *dev) ...@@ -466,6 +466,10 @@ static int __devinit tc6393xb_probe(struct platform_device *dev)
tc6393xb_attach_irq(dev); tc6393xb_attach_irq(dev);
tc6393xb_cells[TC6393XB_CELL_NAND].driver_data = tcpd->nand_data; tc6393xb_cells[TC6393XB_CELL_NAND].driver_data = tcpd->nand_data;
tc6393xb_cells[TC6393XB_CELL_NAND].platform_data =
&tc6393xb_cells[TC6393XB_CELL_NAND];
tc6393xb_cells[TC6393XB_CELL_NAND].data_size =
sizeof(tc6393xb_cells[TC6393XB_CELL_NAND]);
retval = mfd_add_devices(dev, retval = mfd_add_devices(dev,
tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells), tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells),
......
...@@ -29,7 +29,13 @@ struct mfd_cell { ...@@ -29,7 +29,13 @@ struct mfd_cell {
int (*suspend)(struct platform_device *dev); int (*suspend)(struct platform_device *dev);
int (*resume)(struct platform_device *dev); int (*resume)(struct platform_device *dev);
void *driver_data; /* driver-specific data */ /* driver-specific data for MFD-aware "cell" drivers */
void *driver_data;
/* platform_data can be used to either pass data to "generic"
driver or as a hook to mfd_cell for the "cell" drivers */
void *platform_data;
size_t data_size;
/* /*
* This resources can be specified relatievly to the parent device. * This resources can be specified relatievly to the parent device.
...@@ -39,11 +45,6 @@ struct mfd_cell { ...@@ -39,11 +45,6 @@ struct mfd_cell {
const struct resource *resources; const struct resource *resources;
}; };
static inline struct mfd_cell *mfd_get_cell(struct platform_device *pdev)
{
return (struct mfd_cell *)pdev->dev.platform_data;
}
extern int mfd_add_devices(struct platform_device *parent, extern int mfd_add_devices(struct platform_device *parent,
const struct mfd_cell *cells, int n_devs, const struct mfd_cell *cells, int n_devs,
struct resource *mem_base, struct resource *mem_base,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment