Skip to content

Commit 7e47976

Browse files
hreineckemartinkpetersen
authored andcommitted
scsi_sysfs: add 'is_bin_visible' callback
Add 'is_bin_visible' callback to blank out unsupported vpd pages. Reviewed-by: Shane Seymour <shane.seymour@hpe.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent fddbeb8 commit 7e47976

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/scsi/scsi_sysfs.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,22 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj,
10231023
return attr->mode;
10241024
}
10251025

1026+
static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj,
1027+
struct bin_attribute *attr, int i)
1028+
{
1029+
struct device *dev = container_of(kobj, struct device, kobj);
1030+
struct scsi_device *sdev = to_scsi_device(dev);
1031+
1032+
1033+
if (attr == &dev_attr_vpd_pg80 && !sdev->vpd_pg80)
1034+
return 0;
1035+
1036+
if (attr == &dev_attr_vpd_pg83 && sdev->vpd_pg83)
1037+
return 0;
1038+
1039+
return S_IRUGO;
1040+
}
1041+
10261042
/* Default template for device attributes. May NOT be modified */
10271043
static struct attribute *scsi_sdev_attrs[] = {
10281044
&dev_attr_device_blocked.attr,
@@ -1068,6 +1084,7 @@ static struct attribute_group scsi_sdev_attr_group = {
10681084
.attrs = scsi_sdev_attrs,
10691085
.bin_attrs = scsi_sdev_bin_attrs,
10701086
.is_visible = scsi_sdev_attr_is_visible,
1087+
.is_bin_visible = scsi_sdev_bin_attr_is_visible,
10711088
};
10721089

10731090
static const struct attribute_group *scsi_sdev_attr_groups[] = {

0 commit comments

Comments
 (0)