* [PATCH 1/8] scsi_sysfs: add 'is_bin_visible' callback
@ 2016-03-01 4:51 Hannes Reinecke
2016-03-01 4:56 ` Hannes Reinecke
0 siblings, 1 reply; 2+ messages in thread
From: Hannes Reinecke @ 2016-03-01 4:51 UTC (permalink / raw)
To: Martin K. Petersen
Cc: Christoph Hellwig, Ewan Milne, Bart van Assche, James Bottomley,
linux-scsi, Hannes Reinecke, Hannes Reinecke
Add 'is_bin_visible' callback to blank out unsupported vpd pages.
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
drivers/scsi/scsi_sysfs.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 00bc721..d8b275b 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -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[] = {
--
2.6.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/8] scsi_sysfs: add 'is_bin_visible' callback
2016-03-01 4:51 [PATCH 1/8] scsi_sysfs: add 'is_bin_visible' callback Hannes Reinecke
@ 2016-03-01 4:56 ` Hannes Reinecke
0 siblings, 0 replies; 2+ messages in thread
From: Hannes Reinecke @ 2016-03-01 4:56 UTC (permalink / raw)
To: Hannes Reinecke, Martin K. Petersen
Cc: Christoph Hellwig, Ewan Milne, Bart van Assche, James Bottomley,
linux-scsi
On 03/01/2016 12:51 PM, Hannes Reinecke wrote:
> Add 'is_bin_visible' callback to blank out unsupported vpd pages.
>
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
> drivers/scsi/scsi_sysfs.c | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
Sorry, this is actually a stand-alone patch.
I'll be resending it with the proper subject.
Cheers,
Hannes
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-01 4:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01 4:51 [PATCH 1/8] scsi_sysfs: add 'is_bin_visible' callback Hannes Reinecke
2016-03-01 4:56 ` 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).