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>
Subject: [PATCH 6/6] scsi_sysfs: call 'device_add' after attaching device handler
Date: Tue, 1 Mar 2016 05:55:43 +0100 [thread overview]
Message-ID: <1456808143-88932-7-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1456808143-88932-1-git-send-email-hare@suse.de>
'device_add' will be evaluating the 'is_visible' callback
when creating the sysfs attributes. As by this time the
device handler has not been attached the 'access_state'
attribute will never be visible.
This patch moves the code around so that the device handler
is present by the time 'is_visible' is evaluated to
correctly display the 'access_state' attribute.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/scsi/scsi_sysfs.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index b6a1af8..4e7f944 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1226,13 +1226,6 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
scsi_autopm_get_device(sdev);
- error = device_add(&sdev->sdev_gendev);
- if (error) {
- sdev_printk(KERN_INFO, sdev,
- "failed to add device: %d\n", error);
- return error;
- }
-
error = scsi_dh_add_device(sdev);
if (error)
/*
@@ -1241,6 +1234,13 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
sdev_printk(KERN_INFO, sdev,
"failed to add device handler: %d\n", error);
+ error = device_add(&sdev->sdev_gendev);
+ if (error) {
+ sdev_printk(KERN_INFO, sdev,
+ "failed to add device: %d\n", error);
+ return error;
+ }
+
device_enable_async_suspend(&sdev->sdev_dev);
error = device_add(&sdev->sdev_dev);
if (error) {
--
2.6.2
next prev parent reply other threads:[~2016-03-01 4:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 4:55 [PATCH 0/6] SCSI 'access_state' attribute Hannes Reinecke
2016-03-01 4:55 ` [PATCH 1/6] scsi: Add 'access_state' and 'preferred_path' attribute Hannes Reinecke
2016-03-01 7:08 ` Seymour, Shane M
2016-03-01 8:01 ` Hannes Reinecke
2016-03-01 13:06 ` Christoph Hellwig
2016-03-01 20:54 ` Bart Van Assche
2016-03-01 4:55 ` [PATCH 2/6] scsi_dh_alua: use common definitions for ALUA state Hannes Reinecke
2016-03-01 18:47 ` Bart Van Assche
2016-03-01 4:55 ` [PATCH 3/6] scsi_dh_alua: update 'access_state' field Hannes Reinecke
2016-03-01 4:55 ` [PATCH 4/6] scsi_dh_rdac: " Hannes Reinecke
2016-03-01 13:08 ` Christoph Hellwig
2016-03-01 4:55 ` [PATCH 5/6] scsi_dh_emc: " Hannes Reinecke
2016-03-01 13:08 ` Christoph Hellwig
2016-03-01 4:55 ` Hannes Reinecke [this message]
2016-03-01 13:07 ` [PATCH 6/6] scsi_sysfs: call 'device_add' after attaching device handler Christoph Hellwig
2016-03-01 18:51 ` Bart Van Assche
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=1456808143-88932-7-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=bart.vanassche@sandisk.com \
--cc=emilne@redhat.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).