Skip to contentSkip to conversation

virtio_blk: Use sysfs_match_string() helper

PATCH In review Andy Shevchenko 3 participants 6 messages Jun 9, 2017 – Jul 18, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio_blk: Use sysfs_match_string() helper

Use sysfs_match_string() helper instead of open coded variant.

Cc "Michael S. Tsirkin" <[email protected]>
Cc Jason Wang <[email protected]>
---
 drivers/block/virtio_blk.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/block/virtio_blk.c +2 -5
index 553cc4c542b4..0e707b8cce9d 100644
@@ -541,12 +541,9 @@ virtblk_cache_type_store(struct device *dev, struct device_attribute *attr,
 	int i;
 
 	BUG_ON(!virtio_has_feature(vblk->vdev, VIRTIO_BLK_F_CONFIG_WCE));
-	for (i = ARRAY_SIZE(virtblk_cache_types); --i >= 0; )
-		if (sysfs_streq(buf, virtblk_cache_types[i]))
-			break;
-
+	i = sysfs_match_string(virtblk_cache_types, buf);
 	if (i < 0)
-		return -EINVAL;
+		return i;
 
 	virtio_cwrite8(vdev, offsetof(struct virtio_blk_config, wce), i);
 	virtblk_update_cache_mode(vdev);
Signature · 1 line
2.11.0
#1 lore raw
Quoted 1 line · Andy Shevchenko

Use sysfs_match_string() helper instead of open coded variant.

Did I miss maintainer?

Quoted 30 lines
Cc "Michael S. Tsirkin" <[email protected]>
Cc Jason Wang <[email protected]>

---
 drivers/block/virtio_blk.c | 7 ++-----

 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/block/virtio_blk.c +0 -0
index 553cc4c542b4..0e707b8cce9d 100644
@@ -541,12 +541,9 @@ virtblk_cache_type_store(struct device *dev,
 struct device_attribute *attr,
  	int i;


  BUG_ON(!virtio_has_feature(vblk->vdev,
VIRTIO_BLK_F_CONFIG_WCE));

drivers/block/virtio_blk.c +1 -4
-	for (i = ARRAY_SIZE(virtblk_cache_types); --i >= 0; )
-		if (sysfs_streq(buf, virtblk_cache_types[i]))
-			break;
-
+	i = sysfs_match_string(virtblk_cache_types, buf);

  if (i < 0)

drivers/block/virtio_blk.c +1 -1
-		return -EINVAL;
+		return i;


  virtio_cwrite8(vdev, offsetof(struct virtio_blk_config, wce), i);
  virtblk_update_cache_mode(vdev);

Signature · 6 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#2 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

Use sysfs_match_string() helper instead of open coded variant.

Did I miss maintainer?

Quoted 4 lines
Cc "Michael S. Tsirkin" <[email protected]>
Cc Jason Wang <[email protected]>

You didn't, I'll merge this in the next PULL.

Thanks!

Quoted 30 lines
Quoted 26 lines

---
 drivers/block/virtio_blk.c | 7 ++-----

 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/block/virtio_blk.c +0 -0
index 553cc4c542b4..0e707b8cce9d 100644
@@ -541,12 +541,9 @@ virtblk_cache_type_store(struct device *dev,
 struct device_attribute *attr,
  	int i;


  BUG_ON(!virtio_has_feature(vblk->vdev,
VIRTIO_BLK_F_CONFIG_WCE));

drivers/block/virtio_blk.c +1 -4
-	for (i = ARRAY_SIZE(virtblk_cache_types); --i >= 0; )
-		if (sysfs_streq(buf, virtblk_cache_types[i]))
-			break;
-
+	i = sysfs_match_string(virtblk_cache_types, buf);

  if (i < 0)

drivers/block/virtio_blk.c +1 -1
-		return -EINVAL;
+		return i;


  virtio_cwrite8(vdev, offsetof(struct virtio_blk_config, wce), i);
  virtblk_update_cache_mode(vdev);

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#3 lore raw
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

Use sysfs_match_string() helper instead of open coded variant.

Did I miss maintainer?

You didn't, I'll merge this in the next PULL.

I didn't see this in v4.13-rc1. Shall I resend?

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#4 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

Use sysfs_match_string() helper instead of open coded variant.

Did I miss maintainer?

You didn't, I'll merge this in the next PULL.

I didn't see this in v4.13-rc1. Shall I resend?

Thanks for the patch and sorry about a delay.

It's because I didn't send a pull - this cycle is so quiet, that is the single patch I have. I was hoping for the balloon free page hint patches to get there but it does not look like that is happening soon. I'll merge it you do not need to resend.

Quoted 3 lines
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
Reviewed-by
#5 lore raw
In reply to Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
Quoted 1 line · Andy Shevchenko

Use sysfs_match_string() helper instead of open coded variant.

Did I miss maintainer?

Nope :)

Quoted 27 lines
Quoted 27 lines
Cc "Michael S. Tsirkin" <[email protected]>
Cc Jason Wang <[email protected]>
---
  drivers/block/virtio_blk.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
drivers/block/virtio_blk.c +2 -5
index 553cc4c542b4..0e707b8cce9d 100644
@@ -541,12 +541,9 @@ virtblk_cache_type_store(struct device *dev,
 struct device_attribute *attr,
  	int i;
 
  	BUG_ON(!virtio_has_feature(vblk->vdev,
 VIRTIO_BLK_F_CONFIG_WCE));
-	for (i = ARRAY_SIZE(virtblk_cache_types); --i >= 0; )
-		if (sysfs_streq(buf, virtblk_cache_types[i]))
-			break;
-
+	i = sysfs_match_string(virtblk_cache_types, buf);
  	if (i < 0)
-		return -EINVAL;
+		return i;
 
Quoted 3 lines
Quoted 3 lines

virtio_cwrite8(vdev, offsetof(struct virtio_blk_config, wce),
i);
virtblk_update_cache_mode(vdev);

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization