From: Chandra Seetharaman <sekharan@us.ibm.com>
To: Hannes Reinecke <hare@suse.de>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>,
dm-devel <dm-devel@redhat.com>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/7] scsi_dh: Implement generic device table handling
Date: Wed, 14 May 2008 19:45:51 -0700 [thread overview]
Message-ID: <1210819551.21974.252.camel@chandra-ubuntu> (raw)
In-Reply-To: <20080514144310.1EDBC10B5DF@craiglockhart-ipmi.suse.de>
On Wed, 2008-05-14 at 16:43 +0200, Hannes Reinecke wrote:
<snip>
> +
> +struct scsi_dh_devinfo_list {
> + struct list_head node;
> + char vendor[9];
> + char model[17];
> + struct scsi_device_handler *handler;
> +};
I do not see why we should be duplicating the information that is already present in scsi_dh and is available here thru scsi_dh_list. Instead of walking thru the scsi_dh_dev_list we could walk thru scsi_dh_list and get the same result.
On the other hand, if we could create a cache of the list of devices (vendor-product-scsi_dh triplet) that has been attached, and walk thru that list first before others during attach, it would help (as we would guess there to be multiple of the same device).
> +
> +int scsi_dh_handler_attach(struct scsi_device *sdev,
> + struct scsi_device_handler *scsi_dh);
> +int scsi_dh_handler_detach(struct scsi_device *sdev);
Why is the prototype needed ?
Can this be static ?
>
> static struct scsi_device_handler *get_device_handler(const char *name)
> {
> @@ -33,7 +45,7 @@ static struct scsi_device_handler *get_device_handler(const char *name)
>
<snip>
> +/*
> + * scsi_dh_handler_attach - Attach a device handler to a device
> + * @sdev - SCSI device the device handler should attach to
> + * @scsi_dh - The device handler to attach
> + */
> +int scsi_dh_handler_attach(struct scsi_device *sdev,
> + struct scsi_device_handler *scsi_dh)
> +{
> + int err = -EBUSY;
> +
> + if (sdev->scsi_dh_data)
> + return err;
One of the later patch check for scsi_dh to be same as sdev->scsi_dh_data->scsi_dh. We can check for that here.
One more thing: there are multiple places (in this file and in the hardware handlers) the same check appear. Can we just do it only here and remove all the others ?
> +
> + err = scsi_dh->attach(sdev);
This assumes attach is available, but there is no assertion in
scsi_register_device_handler(). Same is the case with detach(). Either
assert or check for the function availability here.
> +
> + return err;
> +}
> +
> +/*
> + * scsi_dh_handler_detach - Detach a device handler to a device
> + * @sdev - SCSI device the device handler should be detached from
> + */
> +int scsi_dh_handler_detach(struct scsi_device *sdev)
> +{
> + struct scsi_device_handler *scsi_dh;
can avoid the variable and call detach directly ?
> +
> + if (!sdev->scsi_dh_data)
> + return -ENODEV;
Can't we just return 0 ?
> +
> + scsi_dh = sdev->scsi_dh_data->scsi_dh;
> +
> + scsi_dh->detach(sdev);
> +
> + return 0;
> +}
<snip>
> list_add(&scsi_dh->list, &scsi_dh_list);
> spin_unlock(&list_lock);
> + bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh, scsi_dh_notifier_add);
> + printk(KERN_INFO "%s: registered\n", scsi_dh->name);
We can be more descriptive. Like "Hardware handler %s registered" or some such.
> + ret = SCSI_DH_OK;
>
> done:
> return ret;
<snip>
> + }
> list_del(&scsi_dh->list);
> spin_unlock(&list_lock);
> + printk(KERN_INFO "%s: unregistered\n", scsi_dh->name);
Same here.
> + ret = SCSI_DH_OK;
>
> done:
> return ret;
<snip>
next prev parent reply other threads:[~2008-05-15 2:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-14 14:43 [PATCH 1/7] scsi_dh: Implement generic device table handling Hannes Reinecke
2008-05-15 2:45 ` Chandra Seetharaman [this message]
2008-05-15 7:16 ` Hannes Reinecke
2008-05-16 18:32 ` Chandra Seetharaman
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=1210819551.21974.252.camel@chandra-ubuntu \
--to=sekharan@us.ibm.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=dm-devel@redhat.com \
--cc=hare@suse.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