aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/nbd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r--drivers/block/nbd.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index b4c0888aedc..ba9b17e507e 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -375,14 +375,17 @@ harderror:
375 return NULL; 375 return NULL;
376} 376}
377 377
378static ssize_t pid_show(struct gendisk *disk, char *page) 378static ssize_t pid_show(struct device *dev,
379 struct device_attribute *attr, char *buf)
379{ 380{
380 return sprintf(page, "%ld\n", 381 struct gendisk *disk = dev_to_disk(dev);
382
383 return sprintf(buf, "%ld\n",
381 (long) ((struct nbd_device *)disk->private_data)->pid); 384 (long) ((struct nbd_device *)disk->private_data)->pid);
382} 385}
383 386
384static struct disk_attribute pid_attr = { 387static struct device_attribute pid_attr = {
385 .attr = { .name = "pid", .mode = S_IRUGO }, 388 .attr = { .name = "pid", .mode = S_IRUGO, .owner = THIS_MODULE },
386 .show = pid_show, 389 .show = pid_show,
387}; 390};
388 391
@@ -394,7 +397,7 @@ static int nbd_do_it(struct nbd_device *lo)
394 BUG_ON(lo->magic != LO_MAGIC); 397 BUG_ON(lo->magic != LO_MAGIC);
395 398
396 lo->pid = current->pid; 399 lo->pid = current->pid;
397 ret = sysfs_create_file(&lo->disk->kobj, &pid_attr.attr); 400 ret = sysfs_create_file(&lo->disk->dev.kobj, &pid_attr.attr);
398 if (ret) { 401 if (ret) {
399 printk(KERN_ERR "nbd: sysfs_create_file failed!"); 402 printk(KERN_ERR "nbd: sysfs_create_file failed!");
400 return ret; 403 return ret;
@@ -403,7 +406,7 @@ static int nbd_do_it(struct nbd_device *lo)
403 while ((req = nbd_read_stat(lo)) != NULL) 406 while ((req = nbd_read_stat(lo)) != NULL)
404 nbd_end_request(req); 407 nbd_end_request(req);
405 408
406 sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr); 409 sysfs_remove_file(&lo->disk->dev.kobj, &pid_attr.attr);
407 return 0; 410 return 0;
408} 411}
409 412