aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2011-04-20 03:44:44 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-04-22 20:09:13 -0400
commitcea896238fbfdbce254f51fc8fd78c59df50081f (patch)
tree4536217e6a2f43432384e526e962d2240b141c23 /drivers/base
parent251e031d132ea3d03e0a32f2240c67f449979c5d (diff)
driver core/platform_device_add_resources: set resource to NULL if !res
This makes the res = NULL case more consistant to the res != NULL case as now both overwrite pdev->resource. 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>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/platform.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 58ad8e8ad7a3..667f282f8b7b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -192,18 +192,17 @@ EXPORT_SYMBOL_GPL(platform_device_alloc);
192int platform_device_add_resources(struct platform_device *pdev, 192int platform_device_add_resources(struct platform_device *pdev,
193 const struct resource *res, unsigned int num) 193 const struct resource *res, unsigned int num)
194{ 194{
195 struct resource *r; 195 struct resource *r = NULL;
196 196
197 if (!res) 197 if (res) {
198 return 0; 198 r = kmemdup(res, sizeof(struct resource) * num, GFP_KERNEL);
199 199 if (!r)
200 r = kmemdup(res, sizeof(struct resource) * num, GFP_KERNEL); 200 return -ENOMEM;
201 if (r) {
202 pdev->resource = r;
203 pdev->num_resources = num;
204 return 0;
205 } 201 }
206 return -ENOMEM; 202
203 pdev->resource = r;
204 pdev->num_resources = num;
205 return 0;
207} 206}
208EXPORT_SYMBOL_GPL(platform_device_add_resources); 207EXPORT_SYMBOL_GPL(platform_device_add_resources);
209 208