Skip to content

Commit 27a33f9

Browse files
Uwe Kleine-Königgregkh
authored andcommitted
driver core/platform_device_add_data: set platform_data to NULL if !data
This makes the data = NULL case more consistent to the data != NULL case. The functional change is that now platform_device_add_data(somepdev, NULL, somesize) sets pdev->dev.platform_data to NULL instead of not touching it. Reviewed-by: Viresh Kumar <viresh.kumar@st.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 7f100d1 commit 27a33f9

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

‎drivers/base/platform.c‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,16 @@ EXPORT_SYMBOL_GPL(platform_device_add_resources);
220220
int platform_device_add_data(struct platform_device *pdev, const void *data,
221221
size_t size)
222222
{
223-
void *d;
223+
void *d = NULL;
224224

225-
if (!data)
226-
return 0;
227-
228-
d = kmemdup(data, size, GFP_KERNEL);
229-
if (d) {
230-
pdev->dev.platform_data = d;
231-
return 0;
225+
if (data) {
226+
d = kmemdup(data, size, GFP_KERNEL);
227+
if (!d)
228+
return -ENOMEM;
232229
}
233-
return -ENOMEM;
230+
231+
pdev->dev.platform_data = d;
232+
return 0;
234233
}
235234
EXPORT_SYMBOL_GPL(platform_device_add_data);
236235

0 commit comments

Comments
 (0)