* [PATCH] nbd: some trivial improvements
@ 2011-08-08 9:00 Amerigo Wang
2011-08-08 16:37 ` Joe Perches
2011-08-08 17:20 ` Greg KH
0 siblings, 2 replies; 5+ messages in thread
From: Amerigo Wang @ 2011-08-08 9:00 UTC (permalink / raw)
To: linux-kernel
Cc: akpm, Greg Kroah-Hartman, Paul Clements, WANG Cong, Jiri Kosina
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;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nbd: some trivial improvements
2011-08-08 9:00 [PATCH] nbd: some trivial improvements Amerigo Wang
@ 2011-08-08 16:37 ` Joe Perches
2011-08-09 7:13 ` Cong Wang
2011-08-08 17:20 ` Greg KH
1 sibling, 1 reply; 5+ messages in thread
From: Joe Perches @ 2011-08-08 16:37 UTC (permalink / raw)
To: Amerigo Wang
Cc: linux-kernel, akpm, Greg Kroah-Hartman, Paul Clements, Jiri Kosina
On Mon, 2011-08-08 at 17:00 +0800, Amerigo Wang wrote:
> 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.
Just trivia:
> diff --git 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!");
Missing "\n".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nbd: some trivial improvements
2011-08-08 9:00 [PATCH] nbd: some trivial improvements Amerigo Wang
2011-08-08 16:37 ` Joe Perches
@ 2011-08-08 17:20 ` Greg KH
2011-08-09 7:16 ` Cong Wang
1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2011-08-08 17:20 UTC (permalink / raw)
To: Amerigo Wang; +Cc: linux-kernel, akpm, Paul Clements, Jiri Kosina
On Mon, Aug 08, 2011 at 05:00:04PM +0800, Amerigo Wang wrote:
> 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.
As you are doing 3 different things, please make this 3 different
patches (remember, one patch per logical thing being done.)
>
> 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!");
Use dev_err() instead please.
> 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");
Again, dev_err() please. That properly identifies exactly which device
had problems.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nbd: some trivial improvements
2011-08-08 16:37 ` Joe Perches
@ 2011-08-09 7:13 ` Cong Wang
0 siblings, 0 replies; 5+ messages in thread
From: Cong Wang @ 2011-08-09 7:13 UTC (permalink / raw)
To: Joe Perches
Cc: linux-kernel, akpm, Greg Kroah-Hartman, Paul Clements, Jiri Kosina
于 2011年08月09日 00:37, Joe Perches 写道:
> On Mon, 2011-08-08 at 17:00 +0800, Amerigo Wang wrote:
>> 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.
>
> Just trivia:
>
>> diff --git 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!");
>
> Missing "\n".
>
Ok, I didn't notice this, will fix it.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nbd: some trivial improvements
2011-08-08 17:20 ` Greg KH
@ 2011-08-09 7:16 ` Cong Wang
0 siblings, 0 replies; 5+ messages in thread
From: Cong Wang @ 2011-08-09 7:16 UTC (permalink / raw)
To: Greg KH; +Cc: linux-kernel, akpm, Paul Clements, Jiri Kosina
于 2011年08月09日 01:20, Greg KH 写道:
> On Mon, Aug 08, 2011 at 05:00:04PM +0800, Amerigo Wang wrote:
>> 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.
>
> As you are doing 3 different things, please make this 3 different
> patches (remember, one patch per logical thing being done.)
Since you insist, will do.
>
>>
>> if (max_part< 0) {
>> - printk(KERN_CRIT "nbd: max_part must be>= 0\n");
>> + printk(KERN_ERR "nbd: max_part must be>= 0\n");
>
> Again, dev_err() please. That properly identifies exactly which device
> had problems.
>
Ok, thanks for pointing this out!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-08-09 7:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-08 9:00 [PATCH] nbd: some trivial improvements Amerigo Wang
2011-08-08 16:37 ` Joe Perches
2011-08-09 7:13 ` Cong Wang
2011-08-08 17:20 ` Greg KH
2011-08-09 7:16 ` Cong Wang
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).