Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/sameo/mfd-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6:
  mfd: Fetch cell pointer from platform_device->mfd_cell
  • Loading branch information
Linus Torvalds committed Apr 12, 2011
2 parents 0d88f6e + e710d7d commit e328f05
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions drivers/base/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ static void platform_device_release(struct device *dev)

of_device_node_put(&pa->pdev.dev);
kfree(pa->pdev.dev.platform_data);
kfree(pa->pdev.mfd_cell);
kfree(pa->pdev.resource);
kfree(pa);
}
Expand Down
16 changes: 14 additions & 2 deletions drivers/mfd/mfd-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ int mfd_cell_disable(struct platform_device *pdev)
}
EXPORT_SYMBOL(mfd_cell_disable);

static int mfd_platform_add_cell(struct platform_device *pdev,
const struct mfd_cell *cell)
{
if (!cell)
return 0;

pdev->mfd_cell = kmemdup(cell, sizeof(*cell), GFP_KERNEL);
if (!pdev->mfd_cell)
return -ENOMEM;

return 0;
}

static int mfd_add_device(struct device *parent, int id,
const struct mfd_cell *cell,
struct resource *mem_base,
Expand All @@ -75,7 +88,7 @@ static int mfd_add_device(struct device *parent, int id,

pdev->dev.parent = parent;

ret = platform_device_add_data(pdev, cell, sizeof(*cell));
ret = mfd_platform_add_cell(pdev, cell);
if (ret)
goto fail_res;

Expand Down Expand Up @@ -123,7 +136,6 @@ static int mfd_add_device(struct device *parent, int id,

return 0;

/* platform_device_del(pdev); */
fail_res:
kfree(res);
fail_device:
Expand Down
13 changes: 11 additions & 2 deletions include/linux/mfd/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,25 @@ extern int mfd_clone_cell(const char *cell, const char **clones,
*/
static inline const struct mfd_cell *mfd_get_cell(struct platform_device *pdev)
{
return pdev->dev.platform_data;
return pdev->mfd_cell;
}

/*
* Given a platform device that's been created by mfd_add_devices(), fetch
* the .mfd_data entry from the mfd_cell that created it.
* Otherwise just return the platform_data pointer.
* This maintains compatibility with platform drivers whose devices aren't
* created by the mfd layer, and expect platform_data to contain what would've
* otherwise been in mfd_data.
*/
static inline void *mfd_get_data(struct platform_device *pdev)
{
return mfd_get_cell(pdev)->mfd_data;
const struct mfd_cell *cell = mfd_get_cell(pdev);

if (cell)
return cell->mfd_data;
else
return pdev->dev.platform_data;
}

extern int mfd_add_devices(struct device *parent, int id,
Expand Down
5 changes: 5 additions & 0 deletions include/linux/platform_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <linux/device.h>
#include <linux/mod_devicetable.h>

struct mfd_cell;

struct platform_device {
const char * name;
int id;
Expand All @@ -23,6 +25,9 @@ struct platform_device {

const struct platform_device_id *id_entry;

/* MFD cell pointer */
struct mfd_cell *mfd_cell;

/* arch specific additions */
struct pdev_archdata archdata;
};
Expand Down

0 comments on commit e328f05

Please sign in to comment.