public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: linux-scsi@vger.kernel.org
Cc: James Bottomley <JBottomley@parallels.com>,
	David Dillow <dillowda@ornl.gov>
Subject: [PATCH 16/18] scsi: Add scsi_host_template.slave_delete callback
Date: Sat, 14 Jan 2012 12:55:25 +0000	[thread overview]
Message-ID: <12084055.3HXOlOaeVy@asus> (raw)
In-Reply-To: <3109536.qySrY1Ts3e@asus>

Add a callback function in the SCSI host template that is invoked
just before device removal. This allows drivers that keep a
reference to the device itself to remove that reference.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Cc: James Bottomley <JBottomley@parallels.com>
Cc: David Dillow <dillowda@ornl.gov>
---
 drivers/scsi/scsi_sysfs.c |    7 ++++++-
 include/scsi/scsi_host.h  |    9 +++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 04c2a27..ea5658d 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -572,7 +572,12 @@ static DEVICE_ATTR(rescan, S_IWUSR, NULL, store_rescan_field);
 
 static void sdev_store_delete_callback(struct device *dev)
 {
-	scsi_remove_device(to_scsi_device(dev));
+	struct scsi_device *sdev = to_scsi_device(dev);
+	struct scsi_host_template *sht = sdev->host->hostt;
+
+	if (sht->slave_delete)
+		sht->slave_delete(sdev);
+	scsi_remove_device(sdev);
 }
 
 static ssize_t
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 5f7d5b3..7c92948 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -233,6 +233,15 @@ struct scsi_host_template {
 	 */
 	int (* slave_configure)(struct scsi_device *);
 
+	/**
+	 * Callback invoked just before scsi_remove_device() will be invoked
+	 * e.g. if device removal has been requested via the sdev "delete"
+	 * sysfs attribute.
+	 *
+	 * Status: OPTIONAL
+	 */
+	void (* slave_delete)(struct scsi_device *);
+
 	/*
 	 * Immediately prior to deallocating the device and after all activity
 	 * has ceased the mid layer calls this point so that the low level
-- 
1.7.7



  parent reply	other threads:[~2012-01-14 12:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-14 12:36 [PATCH 00/18, v2] Make ib_srp better suited for H.A. purposes Bart Van Assche
2012-01-14 12:47 ` [PATCH 09/18] srp_transport: Fix atttribute registration Bart Van Assche
2012-01-14 12:48 ` [PATCH 10/18] srp_transport: Simplify attribute initialization code Bart Van Assche
2012-01-14 12:50 ` [PATCH 11/18] srp_transport: Document sysfs attributes Bart Van Assche
2012-01-14 12:52 ` [PATCH 13/18] ib_srp: Allow SRP disconnect through sysfs Bart Van Assche
2012-02-26  6:33   ` David Dillow
2012-01-14 12:55 ` Bart Van Assche [this message]
2012-01-14 12:56 ` [PATCH 17/18] srp_transport: Add transport layer recovery support Bart Van Assche
2012-07-16 22:07   ` Mike Christie
2012-07-16 22:28     ` David Dillow
2012-07-16 22:38       ` Mike Christie
2012-07-16 22:44         ` David Dillow
2012-07-17 12:59       ` bart
2012-08-18 10:50       ` Bart Van Assche
2012-08-19 23:09         ` David Dillow
2012-07-16 22:29     ` Mike Christie
2012-01-14 22:10 ` [PATCH 00/18, v2] Make ib_srp better suited for H.A. purposes David Dillow
     [not found]   ` <1326579013.8227.4.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org>
2012-01-15  9:28     ` Bart Van Assche
     [not found]       ` <CAO+b5-qv0LRFZ3QkyS+bFXF7Sx7WPeqgSX3q5Ph-jCFKNU0uCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-05  6:13         ` David Dillow

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=12084055.3HXOlOaeVy@asus \
    --to=bvanassche@acm.org \
    --cc=JBottomley@parallels.com \
    --cc=dillowda@ornl.gov \
    --cc=linux-scsi@vger.kernel.org \
    /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