aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-05-19 21:24:11 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-19 21:24:11 -0400
commit39ab05c8e0b519ff0a04a869f065746e6e8c3d95 (patch)
treee73f0ba74c4ea7a80dff9b2dd9445a3a74190e28 /drivers/base
parent1477fcc290b3d5c2614bde98bf3b1154c538860d (diff)
parentc42d2237143fcf35cff642cefe2bcf7786aae312 (diff)
Merge branch 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6
* 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (44 commits) debugfs: Silence DEBUG_STRICT_USER_COPY_CHECKS=y warning sysfs: remove "last sysfs file:" line from the oops messages drivers/base/memory.c: fix warning due to "memory hotplug: Speed up add/remove when blocks are larger than PAGES_PER_SECTION" memory hotplug: Speed up add/remove when blocks are larger than PAGES_PER_SECTION SYSFS: Fix erroneous comments for sysfs_update_group(). driver core: remove the driver-model structures from the documentation driver core: Add the device driver-model structures to kerneldoc Translated Documentation/email-clients.txt RAW driver: Remove call to kobject_put(). reboot: disable usermodehelper to prevent fs access efivars: prevent oops on unload when efi is not enabled Allow setting of number of raw devices as a module parameter Introduce CONFIG_GOOGLE_FIRMWARE driver: Google Memory Console driver: Google EFI SMI x86: Better comments for get_bios_ebda() x86: get_bios_ebda_length() misc: fix ti-st build issues params.c: Use new strtobool function to process boolean inputs debugfs: move to new strtobool ... Fix up trivial conflicts in fs/debugfs/file.c due to the same patch being applied twice, and an unrelated cleanup nearby.
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/core.c7
-rw-r--r--drivers/base/dd.c12
-rw-r--r--drivers/base/memory.c29
-rw-r--r--drivers/base/platform.c38
4 files changed, 41 insertions, 45 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 81b78ede37c..bc8729d603a 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -400,7 +400,7 @@ static void device_remove_groups(struct device *dev,
400static int device_add_attrs(struct device *dev) 400static int device_add_attrs(struct device *dev)
401{ 401{
402 struct class *class = dev->class; 402 struct class *class = dev->class;
403 struct device_type *type = dev->type; 403 const struct device_type *type = dev->type;
404 int error; 404 int error;
405 405
406 if (class) { 406 if (class) {
@@ -440,7 +440,7 @@ static int device_add_attrs(struct device *dev)
440static void device_remove_attrs(struct device *dev) 440static void device_remove_attrs(struct device *dev)
441{ 441{
442 struct class *class = dev->class; 442 struct class *class = dev->class;
443 struct device_type *type = dev->type; 443 const struct device_type *type = dev->type;
444 444
445 device_remove_groups(dev, dev->groups); 445 device_remove_groups(dev, dev->groups);
446 446
@@ -1314,8 +1314,7 @@ EXPORT_SYMBOL_GPL(put_device);
1314EXPORT_SYMBOL_GPL(device_create_file); 1314EXPORT_SYMBOL_GPL(device_create_file);
1315EXPORT_SYMBOL_GPL(device_remove_file); 1315EXPORT_SYMBOL_GPL(device_remove_file);
1316 1316
1317struct root_device 1317struct root_device {
1318{
1319 struct device dev; 1318 struct device dev;
1320 struct module *owner; 1319 struct module *owner;
1321}; 1320};
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 29917c7506c..6658da743c3 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -245,6 +245,10 @@ int device_attach(struct device *dev)
245 245
246 device_lock(dev); 246 device_lock(dev);
247 if (dev->driver) { 247 if (dev->driver) {
248 if (klist_node_attached(&dev->p->knode_driver)) {
249 ret = 1;
250 goto out_unlock;
251 }
248 ret = device_bind_driver(dev); 252 ret = device_bind_driver(dev);
249 if (ret == 0) 253 if (ret == 0)
250 ret = 1; 254 ret = 1;
@@ -257,6 +261,7 @@ int device_attach(struct device *dev)
257 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); 261 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
258 pm_runtime_put_sync(dev); 262 pm_runtime_put_sync(dev);
259 } 263 }
264out_unlock:
260 device_unlock(dev); 265 device_unlock(dev);
261 return ret; 266 return ret;
262} 267}
@@ -408,17 +413,16 @@ void *dev_get_drvdata(const struct device *dev)
408} 413}
409EXPORT_SYMBOL(dev_get_drvdata); 414EXPORT_SYMBOL(dev_get_drvdata);
410 415
411void dev_set_drvdata(struct device *dev, void *data) 416int dev_set_drvdata(struct device *dev, void *data)
412{ 417{
413 int error; 418 int error;
414 419
415 if (!dev)
416 return;
417 if (!dev->p) { 420 if (!dev->p) {
418 error = device_private_init(dev); 421 error = device_private_init(dev);
419 if (error) 422 if (error)
420 return; 423 return error;
421 } 424 }
422 dev->p->driver_data = data; 425 dev->p->driver_data = data;
426 return 0;
423} 427}
424EXPORT_SYMBOL(dev_set_drvdata); 428EXPORT_SYMBOL(dev_set_drvdata);
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 3da6a43b775..0a134a424a3 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -48,7 +48,8 @@ static const char *memory_uevent_name(struct kset *kset, struct kobject *kobj)
48 return MEMORY_CLASS_NAME; 48 return MEMORY_CLASS_NAME;
49} 49}
50 50
51static int memory_uevent(struct kset *kset, struct kobject *obj, struct kobj_uevent_env *env) 51static int memory_uevent(struct kset *kset, struct kobject *obj,
52 struct kobj_uevent_env *env)
52{ 53{
53 int retval = 0; 54 int retval = 0;
54 55
@@ -228,10 +229,11 @@ int memory_isolate_notify(unsigned long val, void *v)
228 * OK to have direct references to sparsemem variables in here. 229 * OK to have direct references to sparsemem variables in here.
229 */ 230 */
230static int 231static int
231memory_section_action(unsigned long phys_index, unsigned long action) 232memory_block_action(unsigned long phys_index, unsigned long action)
232{ 233{
233 int i; 234 int i;
234 unsigned long start_pfn, start_paddr; 235 unsigned long start_pfn, start_paddr;
236 unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block;
235 struct page *first_page; 237 struct page *first_page;
236 int ret; 238 int ret;
237 239
@@ -243,7 +245,7 @@ memory_section_action(unsigned long phys_index, unsigned long action)
243 * that way. 245 * that way.
244 */ 246 */
245 if (action == MEM_ONLINE) { 247 if (action == MEM_ONLINE) {
246 for (i = 0; i < PAGES_PER_SECTION; i++) { 248 for (i = 0; i < nr_pages; i++) {
247 if (PageReserved(first_page+i)) 249 if (PageReserved(first_page+i))
248 continue; 250 continue;
249 251
@@ -257,12 +259,12 @@ memory_section_action(unsigned long phys_index, unsigned long action)
257 switch (action) { 259 switch (action) {
258 case MEM_ONLINE: 260 case MEM_ONLINE:
259 start_pfn = page_to_pfn(first_page); 261 start_pfn = page_to_pfn(first_page);
260 ret = online_pages(start_pfn, PAGES_PER_SECTION); 262 ret = online_pages(start_pfn, nr_pages);
261 break; 263 break;
262 case MEM_OFFLINE: 264 case MEM_OFFLINE:
263 start_paddr = page_to_pfn(first_page) << PAGE_SHIFT; 265 start_paddr = page_to_pfn(first_page) << PAGE_SHIFT;
264 ret = remove_memory(start_paddr, 266 ret = remove_memory(start_paddr,
265 PAGES_PER_SECTION << PAGE_SHIFT); 267 nr_pages << PAGE_SHIFT);
266 break; 268 break;
267 default: 269 default:
268 WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: " 270 WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: "
@@ -276,7 +278,7 @@ memory_section_action(unsigned long phys_index, unsigned long action)
276static int memory_block_change_state(struct memory_block *mem, 278static int memory_block_change_state(struct memory_block *mem,
277 unsigned long to_state, unsigned long from_state_req) 279 unsigned long to_state, unsigned long from_state_req)
278{ 280{
279 int i, ret = 0; 281 int ret = 0;
280 282
281 mutex_lock(&mem->state_mutex); 283 mutex_lock(&mem->state_mutex);
282 284
@@ -288,20 +290,11 @@ static int memory_block_change_state(struct memory_block *mem,
288 if (to_state == MEM_OFFLINE) 290 if (to_state == MEM_OFFLINE)
289 mem->state = MEM_GOING_OFFLINE; 291 mem->state = MEM_GOING_OFFLINE;
290 292
291 for (i = 0; i < sections_per_block; i++) { 293 ret = memory_block_action(mem->start_section_nr, to_state);
292 ret = memory_section_action(mem->start_section_nr + i,
293 to_state);
294 if (ret)
295 break;
296 }
297
298 if (ret) {
299 for (i = 0; i < sections_per_block; i++)
300 memory_section_action(mem->start_section_nr + i,
301 from_state_req);
302 294
295 if (ret)
303 mem->state = from_state_req; 296 mem->state = from_state_req;
304 } else 297 else
305 mem->state = to_state; 298 mem->state = to_state;
306 299
307out: 300out:
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 48425f18302..1c291af637b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -192,18 +192,18 @@ 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 kfree(pdev->resource);
204 pdev->resource = r;
205 pdev->num_resources = num;
206 return 0;
207} 207}
208EXPORT_SYMBOL_GPL(platform_device_add_resources); 208EXPORT_SYMBOL_GPL(platform_device_add_resources);
209 209
@@ -220,17 +220,17 @@ EXPORT_SYMBOL_GPL(platform_device_add_resources);
220int platform_device_add_data(struct platform_device *pdev, const void *data, 220int platform_device_add_data(struct platform_device *pdev, const void *data,
221 size_t size) 221 size_t size)
222{ 222{
223 void *d; 223 void *d = NULL;
224 224
225 if (!data) 225 if (data) {
226 return 0; 226 d = kmemdup(data, size, GFP_KERNEL);
227 227 if (!d)
228 d = kmemdup(data, size, GFP_KERNEL); 228 return -ENOMEM;
229 if (d) {
230 pdev->dev.platform_data = d;
231 return 0;
232 } 229 }
233 return -ENOMEM; 230
231 kfree(pdev->dev.platform_data);
232 pdev->dev.platform_data = d;
233 return 0;
234} 234}
235EXPORT_SYMBOL_GPL(platform_device_add_data); 235EXPORT_SYMBOL_GPL(platform_device_add_data);
236 236