Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Mike Anderson <andmike@us.ibm.com>
To: Christoph Hellwig <hch@lst.de>
Cc: James.Bottomley@steeleye.com, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] LDM-based scsi host lookup
Date: Wed, 28 May 2003 00:44:09 -0700	[thread overview]
Message-ID: <20030528074409.GB2028@beaverton.ibm.com> (raw)
In-Reply-To: <20030527112550.GB13798@lst.de>

Looks good. One code comment below.

I have a core class for each child interator patch. Do you think we
should use that instead. It would protect the SCSI code in case the core
changed on how class children are protected. It does have a little more
overhead then your loop though.

Christoph Hellwig [hch@lst.de] wrote:
> @@ -522,16 +522,33 @@
>  }
>  
>  /**
> - * scsi_host_hn_get - get a Scsi_Host by host no and inc ref count
> - * @host_no:	host number to locate
> - *
> - * Return value:
> - * 	A pointer to located Scsi_Host or NULL.
> - **/
> -struct Scsi_Host *scsi_host_hn_get(unsigned short host_no)
> + * scsi_host_lookup - get a reference to a Scsi_Host by host no
> + *
> + * @hostnum:	host number to locate
> + *
> + * Return value:
> + *	A pointer to located Scsi_Host or NULL.
> + **/
> +struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
>  {
> -	/* XXX Inc ref count */
> -	return scsi_find_host_by_num(host_no);
> +	struct class *class = class_get(&shost_class);
> +	struct class_device *cdev;
> +	struct Scsi_Host *shost = NULL, *p;
> +
> +	if (class) {
> +		down_read(&class->subsys.rwsem);
> +		list_for_each_entry(cdev, &class->children, node) {
> +			p = class_to_shost(cdev);
> +			if (p->host_no == hostnum) {
> +				scsi_host_get(p);
> +				shost = p;
> +				break;
> +			}
> +		}
> +		up_read(&class->subsys.rwsem);
> +	}
> +
Need class_put(&shost_class); here ?

> +	return shost;
>  }
-andmike
--
Michael Anderson
andmike@us.ibm.com


  reply	other threads:[~2003-05-28  7:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-27 11:25 [PATCH] LDM-based scsi host lookup Christoph Hellwig
2003-05-28  7:44 ` Mike Anderson [this message]
2003-05-28  9:06   ` 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=20030528074409.GB2028@beaverton.ibm.com \
    --to=andmike@us.ibm.com \
    --cc=James.Bottomley@steeleye.com \
    --cc=hch@lst.de \
    --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