2020-06-12 07:16:37

by 王擎

[permalink] [raw]
Subject: [PATCH] drivers\block: Use kobj_to_dev() API

Use kobj_to_dev() API instead of container_of().

Signed-off-by: Wang Qing <[email protected]>
---
drivers/block/virtio_blk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
mode change 100644 => 100755 drivers/block/virtio_blk.c

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 9d21bf0..c808405
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -630,7 +630,7 @@ static struct attribute *virtblk_attrs[] = {
static umode_t virtblk_attrs_are_visible(struct kobject *kobj,
struct attribute *a, int n)
{
- struct device *dev = container_of(kobj, struct device, kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct gendisk *disk = dev_to_disk(dev);
struct virtio_blk *vblk = disk->private_data;
struct virtio_device *vdev = vblk->vdev;
--
2.7.4


2020-06-12 14:30:00

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: [PATCH] drivers\block: Use kobj_to_dev() API

On Fri, Jun 12, 2020 at 03:10:56PM +0800, Wang Qing wrote:
> Use kobj_to_dev() API instead of container_of().
>
> Signed-off-by: Wang Qing <[email protected]>
> ---
> drivers/block/virtio_blk.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> mode change 100644 => 100755 drivers/block/virtio_blk.c


Subject should probably use "/". Besides that - trivial tree?

>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 9d21bf0..c808405
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -630,7 +630,7 @@ static struct attribute *virtblk_attrs[] = {
> static umode_t virtblk_attrs_are_visible(struct kobject *kobj,
> struct attribute *a, int n)
> {
> - struct device *dev = container_of(kobj, struct device, kobj);
> + struct device *dev = kobj_to_dev(kobj);
> struct gendisk *disk = dev_to_disk(dev);
> struct virtio_blk *vblk = disk->private_data;
> struct virtio_device *vdev = vblk->vdev;
> --
> 2.7.4

2020-06-15 07:29:35

by 王擎

[permalink] [raw]
Subject: Re:Re: [PATCH] drivers\block: Use kobj_to_dev() API


Subject: Re: [PATCH] drivers\block: Use kobj_to_dev() API>On Fri, Jun 12, 2020 at 03:10:56PM +0800, Wang Qing wrote:
>> Use kobj_to_dev() API instead of container_of().
>>
>> Signed-off-by: Wang Qing <[email protected]>
>> ---
>> drivers/block/virtio_blk.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> mode change 100644 => 100755 drivers/block/virtio_blk.c
>
>
>Subject should probably use "/". Besides that - trivial tree?
Sorry, I will modify subject using "/". But what do you mean about trivial tree?
>
>>
>> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
>> index 9d21bf0..c808405
>> --- a/drivers/block/virtio_blk.c
>> +++ b/drivers/block/virtio_blk.c
>> @@ -630,7 +630,7 @@ static struct attribute *virtblk_attrs[] = {
>> static umode_t virtblk_attrs_are_visible(struct kobject *kobj,
>> struct attribute *a, int n)
>> {
>> - struct device *dev = container_of(kobj, struct device, kobj);
>> + struct device *dev = kobj_to_dev(kobj);
>> struct gendisk *disk = dev_to_disk(dev);
>> struct virtio_blk *vblk = disk->private_data;
>> struct virtio_device *vdev = vblk->vdev;
>> --
>> 2.7.4
>


2020-06-19 18:37:51

by Stefan Hajnoczi

[permalink] [raw]
Subject: Re: [PATCH] drivers\block: Use kobj_to_dev() API

On Fri, Jun 12, 2020 at 03:10:56PM +0800, Wang Qing wrote:
> Use kobj_to_dev() API instead of container_of().
>
> Signed-off-by: Wang Qing <[email protected]>
> ---
> drivers/block/virtio_blk.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> mode change 100644 => 100755 drivers/block/virtio_blk.c

Please fix the '\' -> '/' in the commit message. Looks good otherwise:

Reviewed-by: Stefan Hajnoczi <[email protected]>


Attachments:
(No filename) (447.00 B)
signature.asc (499.00 B)
Download all attachments

2020-08-04 08:41:54

by Ming Lei

[permalink] [raw]
Subject: Re: [PATCH] drivers\block: Use kobj_to_dev() API

On Fri, Jun 12, 2020 at 03:10:56PM +0800, Wang Qing wrote:
> Use kobj_to_dev() API instead of container_of().
>
> Signed-off-by: Wang Qing <[email protected]>
> ---
> drivers/block/virtio_blk.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> mode change 100644 => 100755 drivers/block/virtio_blk.c
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 9d21bf0..c808405
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -630,7 +630,7 @@ static struct attribute *virtblk_attrs[] = {
> static umode_t virtblk_attrs_are_visible(struct kobject *kobj,
> struct attribute *a, int n)
> {
> - struct device *dev = container_of(kobj, struct device, kobj);
> + struct device *dev = kobj_to_dev(kobj);
> struct gendisk *disk = dev_to_disk(dev);
> struct virtio_blk *vblk = disk->private_data;
> struct virtio_device *vdev = vblk->vdev;
> --
> 2.7.4
>

Reviewed-by: Ming Lei <[email protected]>

--
Ming