scsi_sysfs: add 'is_bin_visible' callback
PATCH RESEND 1/1 scsi_sysfs: add 'is_bin_visible' callback
Add 'is_bin_visible' callback to blank out unsupported vpd pages.
--- drivers/scsi/scsi_sysfs.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/scsi/scsi_sysfs.c +23 -0
@@ -1023,6 +1023,28 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj,return attr->mode; } +static umode_t scsi_sdev_bin_attr_is_visible (struct kobject *kobj, +struct bin_attribute *attr,int i) +{ + struct device *dev = container_of(kobj, struct device, kobj); +struct scsi_device *sdev =to_scsi_device (dev); + + +rcu_read_lock (); +if (attr == &dev_attr_vpd_pg80 && + !rcu_dereference (sdev->vpd_pg80)) { +rcu_read_unlock (); +return 0 ; + } +if (attr == &dev_attr_vpd_pg83 && + !rcu_dereference (sdev->vpd_pg83)) { +rcu_read_unlock (); +return 0 ; + } +rcu_read_unlock (); +return S_IRUGO ; +} +/* Default template for device attributes. May NOT be modified */ static struct attribute *scsi_sdev_attrs[] = { &dev_attr_device_blocked.attr,
@@ -1068,6 +1090,7 @@ static struct attribute_group scsi_sdev_attr_group = { .attrs = scsi_sdev_attrs, .bin_attrs = scsi_sdev_bin_attrs, .is_visible = scsi_sdev_attr_is_visible, + .is_bin_visible = scsi_sdev_bin_attr_is_visible, };static const struct attribute_group *scsi_sdev_attr_groups[] = {
Signature · 1 line
2.6.2
Quoted 3 lines · Hannes Reinecke
Add '
is_bin_visible' callback to blank out unsupported vpd pages.Signed-off-by Hannes Reinecke <[email protected]>
Signature · 10 lines
Johannes Thumshirn Storage [email protected] +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Hannes Reinecke
drivers/scsi/scsi_sysfs.c +6
-0+ struct device *dev = container_of(kobj, struct device, kobj); +struct scsi_device *sdev =to_scsi_device (dev); + + +rcu_read_lock (); + if (attr == &dev_attr_vpd_pg80 &&
drivers/scsi/scsi_sysfs.c static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj, · line 1044
Quoted 10 lines
drivers/scsi/scsi_sysfs.c +10
-0+ !rcu_dereference(sdev->vpd_pg80)) { +rcu_read_unlock (); +return 0 ; + } +if (attr == &dev_attr_vpd_pg83 && + !rcu_dereference (sdev->vpd_pg83)) { +rcu_read_unlock (); +return 0 ; + } +rcu_read_unlock ();
We are only checking the pointers for being non-zero. No need for the rcu_read_lock() or rcu_dereference() here.
Otherwise this looks fine to me.
Hannes Reinecke
Reviewed-by ?Quoted 12 lines · Christoph Hellwig
Quoted 11 lines · Hannes Reinecke
drivers/scsi/scsi_sysfs.c +11
-0+ struct device *dev = container_of(kobj, struct device, kobj); +struct scsi_device *sdev =to_scsi_device (dev); + + +rcu_read_lock (); +if (attr == &dev_attr_vpd_pg80 && + !rcu_dereference (sdev->vpd_pg80)) { +rcu_read_unlock (); +return 0 ; + } + if (attr == &dev_attr_vpd_pg83 &&
Quoted 9 lines
drivers/scsi/scsi_sysfs.c static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj, · line 1044
Quoted 5 lines
drivers/scsi/scsi_sysfs.c +5
-0+ !rcu_dereference(sdev->vpd_pg83)) { +rcu_read_unlock (); +return 0 ; + } +rcu_read_unlock ();We are only checking the pointers for being non-zero. No need for the
rcu_read_lock()orrcu_dereference()here.
Better to be same than sorry; some overly clever code analysis tool might trip over it otherwise.
Quoted 1 line
Otherwise this looks fine to me.
Cheers,
Hannes
Signature · 8 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 16 lines · Hannes Reinecke
Quoted 7 lines
Quoted 7 lines
drivers/scsi/scsi_sysfs.c +7
-0+rcu_read_lock (); +if (attr == &dev_attr_vpd_pg80 && + !rcu_dereference (sdev->vpd_pg80)) { +rcu_read_unlock (); +return 0 ; + } + if (attr == &dev_attr_vpd_pg83 &&Quoted 9 lines
drivers/scsi/scsi_sysfs.c static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj, · line 1044
Quoted 5 lines
drivers/scsi/scsi_sysfs.c +5
-0+ !rcu_dereference(sdev->vpd_pg83)) { +rcu_read_unlock (); +return 0 ; + } +rcu_read_unlock ();We are only checking the pointers for being non-zero. No need for the
rcu_read_lock()orrcu_dereference()here.
Quoted 2 lines
Better to be same than sorry; some overly clever code analysis tool might trip over it otherwise.
It shouldn't. There is no dereference going on here.
Quoted 4 lines
Quoted 2 lines
Otherwise this looks fine to me.
Reviewed-by ?
Only without the cargo culted rcu magic.
Quoted 17 lines · Christoph Hellwig
Quoted 16 lines · Hannes Reinecke
Quoted 16 lines
drivers/scsi/scsi_sysfs.c static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj, · line 1044
Quoted 12 lines
drivers/scsi/scsi_sysfs.c +12
-0+rcu_read_lock (); +if (attr == &dev_attr_vpd_pg80 && + !rcu_dereference (sdev->vpd_pg80)) { +rcu_read_unlock (); +return 0 ; + } +if (attr == &dev_attr_vpd_pg83 && + !rcu_dereference (sdev->vpd_pg83)) { +rcu_read_unlock (); +return 0 ; + } +rcu_read_unlock ();We are only checking the pointers for being non-zero. No need for the
rcu_read_lock()orrcu_dereference()here.
Quoted 5 lines
Quoted 2 lines
Better to be same than sorry; some overly clever code analysis tool might trip over it otherwise.
It shouldn't. There is no dereference going on here.
Ok.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Otherwise this looks fine to me.
Reviewed-by ?Only without the cargo culted rcu magic.
Okay, will be resending it.
Cheers,
Hannes