linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: scsi_sysfs.c: Hide wwid sdev attr if VPD is not supported
@ 2019-06-12  2:08 Marcos Paulo de Souza
  2019-06-18 22:47 ` Marcos Paulo de Souza
  2019-06-19  3:35 ` Martin K. Petersen
  0 siblings, 2 replies; 6+ messages in thread
From: Marcos Paulo de Souza @ 2019-06-12  2:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marcos Paulo de Souza, James E.J. Bottomley, Martin K. Petersen,
	open list:SCSI SUBSYSTEM

WWID composed from VPD data from device, specifically page 0x83. So,
when a device does not have VPD support, for example USB storage devices
where VPD is specifically disabled, a read into <blk device>/device/wwid
file will always return ENXIO. To avoid this, change the
scsi_sdev_attr_is_visible function to hide wwid sysfs file when the
devices does not support VPD.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
---
 drivers/scsi/scsi_sysfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index dbb206c90ecf..bfd890fa0c69 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1159,6 +1159,9 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj,
 	struct device *dev = container_of(kobj, struct device, kobj);
 	struct scsi_device *sdev = to_scsi_device(dev);
 
+	/* do not present wwid if the device does not support VPD */
+	if (attr == &dev_attr_wwid.attr && sdev->skip_vpd_pages)
+		return 0;
 
 	if (attr == &dev_attr_queue_depth.attr &&
 	    !sdev->host->hostt->change_queue_depth)
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-06-19  9:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-12  2:08 [PATCH] scsi: scsi_sysfs.c: Hide wwid sdev attr if VPD is not supported Marcos Paulo de Souza
2019-06-18 22:47 ` Marcos Paulo de Souza
2019-06-19  3:35 ` Martin K. Petersen
2019-06-19  6:34   ` Hannes Reinecke
2019-06-19  9:52     ` Marcos Paulo de Souza
2019-06-19  9:57       ` Hannes Reinecke

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).