All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>,
	Chandra Seetharaman <sekharan@us.ibm.com>,
	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: Re: [PATCH 4/6] scsi: device handlers must have attach and detach methods
Date: Mon, 20 Oct 2014 08:04:16 +0200	[thread overview]
Message-ID: <5444A5E0.3080006@suse.de> (raw)
In-Reply-To: <1413734404-1426-5-git-send-email-hch@lst.de>

On 10/19/2014 06:00 PM, Christoph Hellwig wrote:
> 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);
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

  reply	other threads:[~2014-10-20  6:04 UTC|newest]

Thread overview: 18+ 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 ` [PATCH 4/6] scsi: device handlers must have attach and detach methods Christoph Hellwig
2014-10-20  6:04   ` Hannes Reinecke [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2014-10-30  9:19 device handler cleanups V2 Christoph Hellwig
2014-10-30  9:19 ` [PATCH 4/6] scsi: device handlers must have attach and detach methods 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=5444A5E0.3080006@suse.de \
    --to=hare@suse.de \
    --cc=Sean.Stewart@netapp.com \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.