From a28dbea0ad3bd8144f3348eb5c20fabc2f12b4b5 Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Tue, 19 Oct 2010 01:21:06 +0200 Subject: mfd: Add devices platform data when the cell data size is not 0 When the cell data_size is 0, the resulting platform_data pointer will be set to ZERO_SIZE_PTR. That could be misleading for device drivers running a NULL check on thei platform_data pointer before dereferencing it. Signed-off-by: Brian Harring Signed-off-by: Samuel Ortiz --- drivers/mfd/mfd-core.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index d1c8605d4ed..ec99f681e77 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -38,10 +38,12 @@ static int mfd_add_device(struct device *parent, int id, pdev->dev.parent = parent; platform_set_drvdata(pdev, cell->driver_data); - ret = platform_device_add_data(pdev, - cell->platform_data, cell->data_size); - if (ret) - goto fail_res; + if (cell->data_size) { + ret = platform_device_add_data(pdev, + cell->platform_data, cell->data_size); + if (ret) + goto fail_res; + } for (r = 0; r < cell->num_resources; r++) { res[r].name = cell->resources[r].name; -- cgit v1.2.3-70-g09d2