mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH 3/3] scsi: sd: add support for expect_media_change_suspend flag
Date: Mon, 11 Jan 2021 16:31:10 +0100	[thread overview]
Message-ID: <b6bdd914-7c6d-032f-6412-9bd097f7c059@puri.sm> (raw)
In-Reply-To: <20210111152029.28426-4-martin.kepplinger@puri.sm>

On 11.01.21 16:20, Martin Kepplinger wrote:
> 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).
> 

oops, I'm very sorry, but the following is missing in order for this to 
build:

--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -114,6 +114,7 @@ static void sd_shutdown(struct device *);
  static int sd_suspend_system(struct device *);
  static int sd_suspend_runtime(struct device *);
  static int sd_resume(struct device *);
+static int sd_resume_runtime(struct device *);
  static void sd_rescan(struct device *);
  static blk_status_t sd_init_command(struct scsi_cmnd *SCpnt);
  static void sd_uninit_command(struct scsi_cmnd *SCpnt);

  reply	other threads:[~2021-01-11 15:32 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 ` [PATCH 3/3] scsi: sd: add support for expect_media_change_suspend flag Martin Kepplinger
2021-01-11 15:31   ` Martin Kepplinger [this message]
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=b6bdd914-7c6d-032f-6412-9bd097f7c059@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

all inboxes | Powered by JetHome®