diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-09-24 00:25:02 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-09-24 00:25:02 -0400 |
commit | c1d9728ecc5b560465df3c0c0d3b3825c2710b40 (patch) | |
tree | d0abb5c923a7a3eca2d4b2c3e1964bf484870909 /drivers/base | |
parent | 165415f700b0c77fa1f8db6198f48582639adf78 (diff) | |
parent | 87e807b6c461bbd449496a4c3ab78ab164a4ba97 (diff) |
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/attribute_container.c | 5 | ||||
-rw-r--r-- | drivers/base/class.c | 23 | ||||
-rw-r--r-- | drivers/base/dd.c | 3 | ||||
-rw-r--r-- | drivers/base/firmware_class.c | 9 | ||||
-rw-r--r-- | drivers/base/map.c | 3 | ||||
-rw-r--r-- | drivers/base/platform.c | 3 |
6 files changed, 28 insertions, 18 deletions
diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c index 373e7b728fa7..6b2eb6f39b4d 100644 --- a/drivers/base/attribute_container.c +++ b/drivers/base/attribute_container.c | |||
@@ -152,12 +152,13 @@ attribute_container_add_device(struct device *dev, | |||
152 | 152 | ||
153 | if (!cont->match(cont, dev)) | 153 | if (!cont->match(cont, dev)) |
154 | continue; | 154 | continue; |
155 | ic = kmalloc(sizeof(struct internal_container), GFP_KERNEL); | 155 | |
156 | ic = kzalloc(sizeof(*ic), GFP_KERNEL); | ||
156 | if (!ic) { | 157 | if (!ic) { |
157 | dev_printk(KERN_ERR, dev, "failed to allocate class container\n"); | 158 | dev_printk(KERN_ERR, dev, "failed to allocate class container\n"); |
158 | continue; | 159 | continue; |
159 | } | 160 | } |
160 | memset(ic, 0, sizeof(struct internal_container)); | 161 | |
161 | ic->cont = cont; | 162 | ic->cont = cont; |
162 | class_device_initialize(&ic->classdev); | 163 | class_device_initialize(&ic->classdev); |
163 | ic->classdev.dev = get_device(dev); | 164 | ic->classdev.dev = get_device(dev); |
diff --git a/drivers/base/class.c b/drivers/base/class.c index d164c32a97ad..ce23dc8c18c5 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -189,12 +189,11 @@ struct class *class_create(struct module *owner, char *name) | |||
189 | struct class *cls; | 189 | struct class *cls; |
190 | int retval; | 190 | int retval; |
191 | 191 | ||
192 | cls = kmalloc(sizeof(struct class), GFP_KERNEL); | 192 | cls = kzalloc(sizeof(*cls), GFP_KERNEL); |
193 | if (!cls) { | 193 | if (!cls) { |
194 | retval = -ENOMEM; | 194 | retval = -ENOMEM; |
195 | goto error; | 195 | goto error; |
196 | } | 196 | } |
197 | memset(cls, 0x00, sizeof(struct class)); | ||
198 | 197 | ||
199 | cls->name = name; | 198 | cls->name = name; |
200 | cls->owner = owner; | 199 | cls->owner = owner; |
@@ -500,13 +499,13 @@ int class_device_add(struct class_device *class_dev) | |||
500 | /* add the needed attributes to this device */ | 499 | /* add the needed attributes to this device */ |
501 | if (MAJOR(class_dev->devt)) { | 500 | if (MAJOR(class_dev->devt)) { |
502 | struct class_device_attribute *attr; | 501 | struct class_device_attribute *attr; |
503 | attr = kmalloc(sizeof(*attr), GFP_KERNEL); | 502 | attr = kzalloc(sizeof(*attr), GFP_KERNEL); |
504 | if (!attr) { | 503 | if (!attr) { |
505 | error = -ENOMEM; | 504 | error = -ENOMEM; |
506 | kobject_del(&class_dev->kobj); | 505 | kobject_del(&class_dev->kobj); |
507 | goto register_done; | 506 | goto register_done; |
508 | } | 507 | } |
509 | memset(attr, sizeof(*attr), 0x00); | 508 | |
510 | attr->attr.name = "dev"; | 509 | attr->attr.name = "dev"; |
511 | attr->attr.mode = S_IRUGO; | 510 | attr->attr.mode = S_IRUGO; |
512 | attr->attr.owner = parent->owner; | 511 | attr->attr.owner = parent->owner; |
@@ -577,12 +576,11 @@ struct class_device *class_device_create(struct class *cls, dev_t devt, | |||
577 | if (cls == NULL || IS_ERR(cls)) | 576 | if (cls == NULL || IS_ERR(cls)) |
578 | goto error; | 577 | goto error; |
579 | 578 | ||
580 | class_dev = kmalloc(sizeof(struct class_device), GFP_KERNEL); | 579 | class_dev = kzalloc(sizeof(*class_dev), GFP_KERNEL); |
581 | if (!class_dev) { | 580 | if (!class_dev) { |
582 | retval = -ENOMEM; | 581 | retval = -ENOMEM; |
583 | goto error; | 582 | goto error; |
584 | } | 583 | } |
585 | memset(class_dev, 0x00, sizeof(struct class_device)); | ||
586 | 584 | ||
587 | class_dev->devt = devt; | 585 | class_dev->devt = devt; |
588 | class_dev->dev = device; | 586 | class_dev->dev = device; |
@@ -671,6 +669,7 @@ void class_device_destroy(struct class *cls, dev_t devt) | |||
671 | int class_device_rename(struct class_device *class_dev, char *new_name) | 669 | int class_device_rename(struct class_device *class_dev, char *new_name) |
672 | { | 670 | { |
673 | int error = 0; | 671 | int error = 0; |
672 | char *old_class_name = NULL, *new_class_name = NULL; | ||
674 | 673 | ||
675 | class_dev = class_device_get(class_dev); | 674 | class_dev = class_device_get(class_dev); |
676 | if (!class_dev) | 675 | if (!class_dev) |
@@ -679,12 +678,24 @@ int class_device_rename(struct class_device *class_dev, char *new_name) | |||
679 | pr_debug("CLASS: renaming '%s' to '%s'\n", class_dev->class_id, | 678 | pr_debug("CLASS: renaming '%s' to '%s'\n", class_dev->class_id, |
680 | new_name); | 679 | new_name); |
681 | 680 | ||
681 | if (class_dev->dev) | ||
682 | old_class_name = make_class_name(class_dev); | ||
683 | |||
682 | strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN); | 684 | strlcpy(class_dev->class_id, new_name, KOBJ_NAME_LEN); |
683 | 685 | ||
684 | error = kobject_rename(&class_dev->kobj, new_name); | 686 | error = kobject_rename(&class_dev->kobj, new_name); |
685 | 687 | ||
688 | if (class_dev->dev) { | ||
689 | new_class_name = make_class_name(class_dev); | ||
690 | sysfs_create_link(&class_dev->dev->kobj, &class_dev->kobj, | ||
691 | new_class_name); | ||
692 | sysfs_remove_link(&class_dev->dev->kobj, old_class_name); | ||
693 | } | ||
686 | class_device_put(class_dev); | 694 | class_device_put(class_dev); |
687 | 695 | ||
696 | kfree(old_class_name); | ||
697 | kfree(new_class_name); | ||
698 | |||
688 | return error; | 699 | return error; |
689 | } | 700 | } |
690 | 701 | ||
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index d5bbce38282f..3565e9795301 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -40,6 +40,9 @@ | |||
40 | */ | 40 | */ |
41 | void device_bind_driver(struct device * dev) | 41 | void device_bind_driver(struct device * dev) |
42 | { | 42 | { |
43 | if (klist_node_attached(&dev->knode_driver)) | ||
44 | return; | ||
45 | |||
43 | pr_debug("bound device '%s' to driver '%s'\n", | 46 | pr_debug("bound device '%s' to driver '%s'\n", |
44 | dev->bus_id, dev->driver->name); | 47 | dev->bus_id, dev->driver->name); |
45 | klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices); | 48 | klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices); |
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 5bfa2e9a7c26..4acb2c5733c3 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c | |||
@@ -301,9 +301,9 @@ fw_register_class_device(struct class_device **class_dev_p, | |||
301 | const char *fw_name, struct device *device) | 301 | const char *fw_name, struct device *device) |
302 | { | 302 | { |
303 | int retval; | 303 | int retval; |
304 | struct firmware_priv *fw_priv = kmalloc(sizeof (struct firmware_priv), | 304 | struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv), |
305 | GFP_KERNEL); | 305 | GFP_KERNEL); |
306 | struct class_device *class_dev = kmalloc(sizeof (struct class_device), | 306 | struct class_device *class_dev = kzalloc(sizeof(*class_dev), |
307 | GFP_KERNEL); | 307 | GFP_KERNEL); |
308 | 308 | ||
309 | *class_dev_p = NULL; | 309 | *class_dev_p = NULL; |
@@ -313,8 +313,6 @@ fw_register_class_device(struct class_device **class_dev_p, | |||
313 | retval = -ENOMEM; | 313 | retval = -ENOMEM; |
314 | goto error_kfree; | 314 | goto error_kfree; |
315 | } | 315 | } |
316 | memset(fw_priv, 0, sizeof (*fw_priv)); | ||
317 | memset(class_dev, 0, sizeof (*class_dev)); | ||
318 | 316 | ||
319 | init_completion(&fw_priv->completion); | 317 | init_completion(&fw_priv->completion); |
320 | fw_priv->attr_data = firmware_attr_data_tmpl; | 318 | fw_priv->attr_data = firmware_attr_data_tmpl; |
@@ -402,14 +400,13 @@ _request_firmware(const struct firmware **firmware_p, const char *name, | |||
402 | if (!firmware_p) | 400 | if (!firmware_p) |
403 | return -EINVAL; | 401 | return -EINVAL; |
404 | 402 | ||
405 | *firmware_p = firmware = kmalloc(sizeof (struct firmware), GFP_KERNEL); | 403 | *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); |
406 | if (!firmware) { | 404 | if (!firmware) { |
407 | printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n", | 405 | printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n", |
408 | __FUNCTION__); | 406 | __FUNCTION__); |
409 | retval = -ENOMEM; | 407 | retval = -ENOMEM; |
410 | goto out; | 408 | goto out; |
411 | } | 409 | } |
412 | memset(firmware, 0, sizeof (*firmware)); | ||
413 | 410 | ||
414 | retval = fw_setup_class_device(firmware, &class_dev, name, device, | 411 | retval = fw_setup_class_device(firmware, &class_dev, name, device, |
415 | hotplug); | 412 | hotplug); |
diff --git a/drivers/base/map.c b/drivers/base/map.c index 2f455d86793c..b449dae6f0d3 100644 --- a/drivers/base/map.c +++ b/drivers/base/map.c | |||
@@ -135,7 +135,7 @@ retry: | |||
135 | struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem) | 135 | struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem) |
136 | { | 136 | { |
137 | struct kobj_map *p = kmalloc(sizeof(struct kobj_map), GFP_KERNEL); | 137 | struct kobj_map *p = kmalloc(sizeof(struct kobj_map), GFP_KERNEL); |
138 | struct probe *base = kmalloc(sizeof(struct probe), GFP_KERNEL); | 138 | struct probe *base = kzalloc(sizeof(*base), GFP_KERNEL); |
139 | int i; | 139 | int i; |
140 | 140 | ||
141 | if ((p == NULL) || (base == NULL)) { | 141 | if ((p == NULL) || (base == NULL)) { |
@@ -144,7 +144,6 @@ struct kobj_map *kobj_map_init(kobj_probe_t *base_probe, struct semaphore *sem) | |||
144 | return NULL; | 144 | return NULL; |
145 | } | 145 | } |
146 | 146 | ||
147 | memset(base, 0, sizeof(struct probe)); | ||
148 | base->dev = 1; | 147 | base->dev = 1; |
149 | base->range = ~0; | 148 | base->range = ~0; |
150 | base->get = base_probe; | 149 | base->get = base_probe; |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 3a5f4c991797..361e204209eb 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -225,13 +225,12 @@ struct platform_device *platform_device_register_simple(char *name, unsigned int | |||
225 | struct platform_object *pobj; | 225 | struct platform_object *pobj; |
226 | int retval; | 226 | int retval; |
227 | 227 | ||
228 | pobj = kmalloc(sizeof(struct platform_object) + sizeof(struct resource) * num, GFP_KERNEL); | 228 | pobj = kzalloc(sizeof(*pobj) + sizeof(struct resource) * num, GFP_KERNEL); |
229 | if (!pobj) { | 229 | if (!pobj) { |
230 | retval = -ENOMEM; | 230 | retval = -ENOMEM; |
231 | goto error; | 231 | goto error; |
232 | } | 232 | } |
233 | 233 | ||
234 | memset(pobj, 0, sizeof(*pobj)); | ||
235 | pobj->pdev.name = name; | 234 | pobj->pdev.name = name; |
236 | pobj->pdev.id = id; | 235 | pobj->pdev.id = id; |
237 | pobj->pdev.dev.release = platform_device_release_simple; | 236 | pobj->pdev.dev.release = platform_device_release_simple; |