diff options
Diffstat (limited to 'drivers/block/pktcdvd.c')
-rw-r--r-- | drivers/block/pktcdvd.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 3535ef896677..e9de1712e5a0 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -110,17 +110,18 @@ static struct pktcdvd_kobj* pkt_kobj_create(struct pktcdvd_device *pd, | |||
110 | struct kobj_type* ktype) | 110 | struct kobj_type* ktype) |
111 | { | 111 | { |
112 | struct pktcdvd_kobj *p; | 112 | struct pktcdvd_kobj *p; |
113 | int error; | ||
114 | |||
113 | p = kzalloc(sizeof(*p), GFP_KERNEL); | 115 | p = kzalloc(sizeof(*p), GFP_KERNEL); |
114 | if (!p) | 116 | if (!p) |
115 | return NULL; | 117 | return NULL; |
116 | kobject_set_name(&p->kobj, "%s", name); | ||
117 | p->kobj.parent = parent; | ||
118 | p->kobj.ktype = ktype; | ||
119 | p->pd = pd; | 118 | p->pd = pd; |
120 | if (kobject_register(&p->kobj) != 0) { | 119 | error = kobject_init_and_add(&p->kobj, ktype, parent, "%s", name); |
120 | if (error) { | ||
121 | kobject_put(&p->kobj); | 121 | kobject_put(&p->kobj); |
122 | return NULL; | 122 | return NULL; |
123 | } | 123 | } |
124 | kobject_uevent(&p->kobj, KOBJ_ADD); | ||
124 | return p; | 125 | return p; |
125 | } | 126 | } |
126 | /* | 127 | /* |
@@ -129,7 +130,7 @@ static struct pktcdvd_kobj* pkt_kobj_create(struct pktcdvd_device *pd, | |||
129 | static void pkt_kobj_remove(struct pktcdvd_kobj *p) | 130 | static void pkt_kobj_remove(struct pktcdvd_kobj *p) |
130 | { | 131 | { |
131 | if (p) | 132 | if (p) |
132 | kobject_unregister(&p->kobj); | 133 | kobject_put(&p->kobj); |
133 | } | 134 | } |
134 | /* | 135 | /* |
135 | * default release function for pktcdvd kernel objects. | 136 | * default release function for pktcdvd kernel objects. |
@@ -301,18 +302,16 @@ static struct kobj_type kobj_pkt_type_wqueue = { | |||
301 | static void pkt_sysfs_dev_new(struct pktcdvd_device *pd) | 302 | static void pkt_sysfs_dev_new(struct pktcdvd_device *pd) |
302 | { | 303 | { |
303 | if (class_pktcdvd) { | 304 | if (class_pktcdvd) { |
304 | pd->clsdev = class_device_create(class_pktcdvd, | 305 | pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, "%s", pd->name); |
305 | NULL, pd->pkt_dev, | 306 | if (IS_ERR(pd->dev)) |
306 | NULL, "%s", pd->name); | 307 | pd->dev = NULL; |
307 | if (IS_ERR(pd->clsdev)) | ||
308 | pd->clsdev = NULL; | ||
309 | } | 308 | } |
310 | if (pd->clsdev) { | 309 | if (pd->dev) { |
311 | pd->kobj_stat = pkt_kobj_create(pd, "stat", | 310 | pd->kobj_stat = pkt_kobj_create(pd, "stat", |
312 | &pd->clsdev->kobj, | 311 | &pd->dev->kobj, |
313 | &kobj_pkt_type_stat); | 312 | &kobj_pkt_type_stat); |
314 | pd->kobj_wqueue = pkt_kobj_create(pd, "write_queue", | 313 | pd->kobj_wqueue = pkt_kobj_create(pd, "write_queue", |
315 | &pd->clsdev->kobj, | 314 | &pd->dev->kobj, |
316 | &kobj_pkt_type_wqueue); | 315 | &kobj_pkt_type_wqueue); |
317 | } | 316 | } |
318 | } | 317 | } |
@@ -322,7 +321,7 @@ static void pkt_sysfs_dev_remove(struct pktcdvd_device *pd) | |||
322 | pkt_kobj_remove(pd->kobj_stat); | 321 | pkt_kobj_remove(pd->kobj_stat); |
323 | pkt_kobj_remove(pd->kobj_wqueue); | 322 | pkt_kobj_remove(pd->kobj_wqueue); |
324 | if (class_pktcdvd) | 323 | if (class_pktcdvd) |
325 | class_device_destroy(class_pktcdvd, pd->pkt_dev); | 324 | device_destroy(class_pktcdvd, pd->pkt_dev); |
326 | } | 325 | } |
327 | 326 | ||
328 | 327 | ||