linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amerigo Wang <amwang@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, Greg Kroah-Hartman <gregkh@suse.de>,
	Paul Clements <Paul.Clements@steeleye.com>,
	WANG Cong <amwang@redhat.com>, Jiri Kosina <trivial@kernel.org>
Subject: [PATCH] nbd: some trivial improvements
Date: Mon,  8 Aug 2011 17:00:04 +0800	[thread overview]
Message-ID: <1312794004-22047-1-git-send-email-amwang@redhat.com> (raw)

This patch 1) uses task_pid_nr(current) to get the pid of current process,
 2) replaces sysfs_create_file() with device_create_file(), 3) lower
the loglevel of an error message.

Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Paul Clements <Paul.Clements@steeleye.com>
Signed-off-by: WANG Cong <amwang@redhat.com>

---
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index f533f33..07cad4b 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -405,10 +405,10 @@ static int nbd_do_it(struct nbd_device *lo)
 
 	BUG_ON(lo->magic != LO_MAGIC);
 
-	lo->pid = current->pid;
-	ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
+	lo->pid = task_pid_nr(current);
+	ret = device_create_file(disk_to_dev(lo->disk), &pid_attr);
 	if (ret) {
-		printk(KERN_ERR "nbd: sysfs_create_file failed!");
+		printk(KERN_ERR "nbd: device_create_file failed!");
 		lo->pid = 0;
 		return ret;
 	}
@@ -416,7 +416,7 @@ static int nbd_do_it(struct nbd_device *lo)
 	while ((req = nbd_read_stat(lo)) != NULL)
 		nbd_end_request(req);
 
-	sysfs_remove_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
+	device_remove_file(disk_to_dev(lo->disk), &pid_attr);
 	lo->pid = 0;
 	return 0;
 }
@@ -745,7 +745,7 @@ static int __init nbd_init(void)
 	BUILD_BUG_ON(sizeof(struct nbd_request) != 28);
 
 	if (max_part < 0) {
-		printk(KERN_CRIT "nbd: max_part must be >= 0\n");
+		printk(KERN_ERR "nbd: max_part must be >= 0\n");
 		return -EINVAL;
 	}
 

             reply	other threads:[~2011-08-08  9:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-08  9:00 Amerigo Wang [this message]
2011-08-08 16:37 ` [PATCH] nbd: some trivial improvements Joe Perches
2011-08-09  7:13   ` Cong Wang
2011-08-08 17:20 ` Greg KH
2011-08-09  7:16   ` Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1312794004-22047-1-git-send-email-amwang@redhat.com \
    --to=amwang@redhat.com \
    --cc=Paul.Clements@steeleye.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trivial@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).