From: Martin Kepplinger <martin.kepplinger@puri.sm>
To: jejb@linux.ibm.com, martin.petersen@oracle.com,
stern@rowland.harvard.edu, bvanassche@acm.org
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
Martin Kepplinger <martin.kepplinger@puri.sm>
Subject: [PATCH 3/3] scsi: sd: add support for expect_media_change_suspend flag
Date: Mon, 11 Jan 2021 16:20:29 +0100 [thread overview]
Message-ID: <20210111152029.28426-4-martin.kepplinger@puri.sm> (raw)
In-Reply-To: <20210111152029.28426-1-martin.kepplinger@puri.sm>
Make the sd driver act appropriately when the user has set
expect_media_change_suspend for a device.
Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---
drivers/scsi/sd.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a3d2d4bc4a3d..ad89f8c76a27 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -608,7 +608,7 @@ static const struct dev_pm_ops sd_pm_ops = {
.poweroff = sd_suspend_system,
.restore = sd_resume,
.runtime_suspend = sd_suspend_runtime,
- .runtime_resume = sd_resume,
+ .runtime_resume = sd_resume_runtime,
};
static struct scsi_driver sd_template = {
@@ -3699,6 +3699,25 @@ static int sd_resume(struct device *dev)
return ret;
}
+static int sd_resume_runtime(struct device *dev)
+{
+ struct scsi_disk *sdkp = dev_get_drvdata(dev);
+ int ret;
+
+ if (!sdkp) /* E.g.: runtime resume at the start of sd_probe() */
+ return 0;
+
+ /*
+ * expect_media_change_suspend is the userspace setting and
+ * expecting_media_change is what is checked and cleared in the
+ * error path if we set it here.
+ */
+ if (sdkp->device->expect_media_change_suspend)
+ sdkp->device->expecting_media_change = 1;
+
+ return sd_resume(dev);
+}
+
/**
* init_sd - entry point for this driver (both when built in or when
* a module).
--
2.20.1
next prev parent reply other threads:[~2021-01-11 15:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-11 15:20 [PATCH 0/3] scsi: add runtime PM workaround for SD cardreaders Martin Kepplinger
2021-01-11 15:20 ` [PATCH 1/3] scsi: add expecting_media_change flag to error path Martin Kepplinger
2021-01-11 15:20 ` [PATCH 2/3] scsi: add expect_media_change_suspend sysfs device setting Martin Kepplinger
2021-01-11 15:20 ` Martin Kepplinger [this message]
2021-01-11 15:31 ` [PATCH 3/3] scsi: sd: add support for expect_media_change_suspend flag Martin Kepplinger
2021-01-11 17:37 ` kernel test robot
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=20210111152029.28426-4-martin.kepplinger@puri.sm \
--to=martin.kepplinger@puri.sm \
--cc=bvanassche@acm.org \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stern@rowland.harvard.edu \
/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).