From: Hannes Reinecke <hare@suse.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>, Ewan Milne <emilne@redhat.com>,
Bart van Assche <bart.vanassche@sandisk.com>,
James Bottomley <james.bottomley@hansenpartnership.com>,
linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
Hannes Reinecke <hare@suse.com>
Subject: [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback
Date: Tue, 1 Mar 2016 05:52:25 +0100 [thread overview]
Message-ID: <1456807945-88857-1-git-send-email-hare@suse.de> (raw)
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
next reply other threads:[~2016-03-01 4:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 4:52 Hannes Reinecke [this message]
2016-03-01 6:45 ` [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback Seymour, Shane M
2016-03-01 9:08 ` Johannes Thumshirn
2016-03-01 13:04 ` Christoph Hellwig
2016-03-02 7:33 ` Hannes Reinecke
2016-03-02 9:19 ` Christoph Hellwig
2016-03-02 9:34 ` Hannes Reinecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456807945-88857-1-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=bart.vanassche@sandisk.com \
--cc=emilne@redhat.com \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).