From: Christoph Hellwig <hch@lst.de>
To: Chandra Seetharaman <sekharan@us.ibm.com>,
Hannes Reinecke <hare@suse.de>,
Mike Christie <michaelc@cs.wisc.edu>
Cc: Sean Stewart <Sean.Stewart@netapp.com>,
Bart Van Assche <bvanassche@acm.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/6] scsi: device handlers must have attach and detach methods
Date: Sun, 19 Oct 2014 18:00:02 +0200 [thread overview]
Message-ID: <1413734404-1426-5-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1413734404-1426-1-git-send-email-hch@lst.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/scsi/device_handler/scsi_dh.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c
index 1a8dbf3..d8a8aac 100644
--- a/drivers/scsi/device_handler/scsi_dh.c
+++ b/drivers/scsi/device_handler/scsi_dh.c
@@ -108,19 +108,17 @@ static int scsi_dh_handler_attach(struct scsi_device *sdev,
return 0;
}
- if (scsi_dh->attach) {
- if (!try_module_get(scsi_dh->module))
- return -EINVAL;
-
- err = scsi_dh->attach(sdev);
- if (err) {
- module_put(scsi_dh->module);
- return err;
- }
+ if (!try_module_get(scsi_dh->module))
+ return -EINVAL;
- kref_init(&sdev->scsi_dh_data->kref);
- sdev->scsi_dh_data->sdev = sdev;
+ err = scsi_dh->attach(sdev);
+ if (err) {
+ module_put(scsi_dh->module);
+ return err;
}
+
+ kref_init(&sdev->scsi_dh_data->kref);
+ sdev->scsi_dh_data->sdev = sdev;
return err;
}
@@ -154,7 +152,7 @@ static void scsi_dh_handler_detach(struct scsi_device *sdev,
if (!scsi_dh)
scsi_dh = sdev->scsi_dh_data->scsi_dh;
- if (scsi_dh && scsi_dh->detach)
+ if (scsi_dh)
kref_put(&sdev->scsi_dh_data->kref, __detach_handler);
}
@@ -343,6 +341,9 @@ int scsi_register_device_handler(struct scsi_device_handler *scsi_dh)
if (get_device_handler(scsi_dh->name))
return -EBUSY;
+ if (!scsi_dh->attach || !scsi_dh->detach)
+ return -EINVAL;
+
spin_lock(&list_lock);
list_add(&scsi_dh->list, &scsi_dh_list);
spin_unlock(&list_lock);
--
1.9.1
next prev parent reply other threads:[~2014-10-19 15:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-19 15:59 device handler cleanups Christoph Hellwig
2014-10-19 15:59 ` [PATCH 1/6] scsi_dh: get module reference outside of device handler Christoph Hellwig
2014-10-20 6:01 ` Hannes Reinecke
2014-10-20 6:53 ` Christoph Hellwig
2014-10-20 8:06 ` Hannes Reinecke
2014-10-19 16:00 ` [PATCH 2/6] scsi: use container_of to get at device handler private data Christoph Hellwig
2014-10-20 6:02 ` Hannes Reinecke
2014-10-19 16:00 ` [PATCH 3/6] scsi: remove struct scsi_dh_devlist Christoph Hellwig
2014-10-20 6:03 ` Hannes Reinecke
2014-10-19 16:00 ` Christoph Hellwig [this message]
2014-10-20 6:04 ` [PATCH 4/6] scsi: device handlers must have attach and detach methods Hannes Reinecke
2014-10-19 16:00 ` [PATCH 5/6] scsi_dh_hp_sw: fix return value on failed allocation Christoph Hellwig
2014-10-20 6:04 ` Hannes Reinecke
2014-10-19 16:00 ` [PATCH 6/6] scsi: handle more device handler setup/teardown in common code Christoph Hellwig
2014-10-20 6:06 ` Hannes Reinecke
2014-10-28 17:53 ` Mike Christie
2014-10-30 9:00 ` Christoph Hellwig
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=1413734404-1426-5-git-send-email-hch@lst.de \
--to=hch@lst.de \
--cc=Sean.Stewart@netapp.com \
--cc=bvanassche@acm.org \
--cc=hare@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=michaelc@cs.wisc.edu \
--cc=sekharan@us.ibm.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
all inboxes | Powered by JetHome®