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
This commit is contained in:
Коммит
5dfb66ba8c
|
@ -15,24 +15,24 @@
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/mfd/core.h>
|
#include <linux/mfd/core.h>
|
||||||
|
|
||||||
static int mfd_add_device(struct platform_device *parent,
|
static int mfd_add_device(struct device *parent, int id,
|
||||||
const struct mfd_cell *cell,
|
const struct mfd_cell *cell,
|
||||||
struct resource *mem_base,
|
struct resource *mem_base,
|
||||||
int irq_base)
|
int irq_base)
|
||||||
{
|
{
|
||||||
struct resource res[cell->num_resources];
|
struct resource res[cell->num_resources];
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
int ret = -ENOMEM;
|
int ret = -ENOMEM;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
pdev = platform_device_alloc(cell->name, parent->id);
|
pdev = platform_device_alloc(cell->name, id);
|
||||||
if (!pdev)
|
if (!pdev)
|
||||||
goto fail_alloc;
|
goto fail_alloc;
|
||||||
|
|
||||||
pdev->dev.parent = &parent->dev;
|
pdev->dev.parent = parent;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -75,17 +75,16 @@ fail_alloc:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mfd_add_devices(
|
int mfd_add_devices(struct device *parent, int id,
|
||||||
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,
|
int irq_base)
|
||||||
int irq_base)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
for (i = 0; i < n_devs; i++) {
|
for (i = 0; i < n_devs; i++) {
|
||||||
ret = mfd_add_device(parent, cells + i, mem_base, irq_base);
|
ret = mfd_add_device(parent, id, cells + i, mem_base, irq_base);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -99,14 +98,13 @@ EXPORT_SYMBOL(mfd_add_devices);
|
||||||
|
|
||||||
static int mfd_remove_devices_fn(struct device *dev, void *unused)
|
static int mfd_remove_devices_fn(struct device *dev, void *unused)
|
||||||
{
|
{
|
||||||
platform_device_unregister(
|
platform_device_unregister(to_platform_device(dev));
|
||||||
container_of(dev, struct platform_device, dev));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mfd_remove_devices(struct platform_device *parent)
|
void mfd_remove_devices(struct device *parent)
|
||||||
{
|
{
|
||||||
device_for_each_child(&parent->dev, NULL, mfd_remove_devices_fn);
|
device_for_each_child(parent, NULL, mfd_remove_devices_fn);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(mfd_remove_devices);
|
EXPORT_SYMBOL(mfd_remove_devices);
|
||||||
|
|
||||||
|
|
|
@ -466,8 +466,12 @@ 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->dev, dev->id,
|
||||||
tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells),
|
tc6393xb_cells, ARRAY_SIZE(tc6393xb_cells),
|
||||||
iomem, tcpd->irq_base);
|
iomem, tcpd->irq_base);
|
||||||
|
|
||||||
|
@ -501,7 +505,7 @@ static int __devexit tc6393xb_remove(struct platform_device *dev)
|
||||||
struct tc6393xb *tc6393xb = platform_get_drvdata(dev);
|
struct tc6393xb *tc6393xb = platform_get_drvdata(dev);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mfd_remove_devices(dev);
|
mfd_remove_devices(&dev->dev);
|
||||||
|
|
||||||
if (tc6393xb->irq)
|
if (tc6393xb->irq)
|
||||||
tc6393xb_detach_irq(dev);
|
tc6393xb_detach_irq(dev);
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#ifndef MFD_CORE_H
|
|
||||||
#define MFD_CORE_H
|
|
||||||
/*
|
/*
|
||||||
* drivers/mfd/mfd-core.h
|
* drivers/mfd/mfd-core.h
|
||||||
*
|
*
|
||||||
|
@ -13,6 +11,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef MFD_CORE_H
|
||||||
|
#define MFD_CORE_H
|
||||||
|
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -28,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.
|
||||||
|
@ -38,18 +45,11 @@ struct mfd_cell {
|
||||||
const struct resource *resources;
|
const struct resource *resources;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct mfd_cell *
|
extern int mfd_add_devices(struct device *parent, int id,
|
||||||
mfd_get_cell(struct platform_device *pdev)
|
const struct mfd_cell *cells, int n_devs,
|
||||||
{
|
struct resource *mem_base,
|
||||||
return (struct mfd_cell *)pdev->dev.platform_data;
|
int irq_base);
|
||||||
}
|
|
||||||
|
|
||||||
extern int mfd_add_devices(
|
extern void mfd_remove_devices(struct device *parent);
|
||||||
struct platform_device *parent,
|
|
||||||
const struct mfd_cell *cells, int n_devs,
|
|
||||||
struct resource *mem_base,
|
|
||||||
int irq_base);
|
|
||||||
|
|
||||||
extern void mfd_remove_devices(struct platform_device *parent);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче