From: James Bottomley <James.Bottomley@steeleye.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>,
SCSI Mailing List <linux-scsi@vger.kernel.org>
Cc: Patrick Mochel <mochel@osdl.org>, Greg KH <greg@kroah.com>,
Mike Anderson <andmike@us.ibm.com>
Subject: [RFC] support for sysfs string based properties for SCSI (1/3)
Date: 03 May 2003 14:11:36 -0500 [thread overview]
Message-ID: <1051989099.2036.7.camel@mulgrave> (raw)
[-- Attachment #1: Type: text/plain, Size: 816 bytes --]
This first patch is of general interest (the other two are going to the
SCSI list only).
The problem this seeks to solve is that we have a bunch of properties in
SCSI that we'd like to expose through the sysfs interface. The
mid-layer can get their values, but setting them requires co-operation
from the host drivers, thus we'd like to expose a show/store interface
to all the SCSI drivers.
The current one call back per sysfs file is a bit unwieldy for
encapsulating in an interface like this. what this patch does is to
allow a fallback show/store method of the bus type (if the device type
doesn't exist). However, the bus_type show/store passes in the
attribute so a comparison may be done against the name of the attribute.
For details of how all this gets used, see the following SCSI patches.
James
[-- Attachment #2: tmp.diff --]
[-- Type: text/plain, Size: 3127 bytes --]
===== drivers/scsi/NCR_D700.c 1.8 vs edited =====
--- 1.8/drivers/scsi/NCR_D700.c Sun Apr 27 05:31:39 2003
+++ edited/drivers/scsi/NCR_D700.c Thu May 1 11:11:48 2003
@@ -169,16 +169,18 @@
struct Scsi_Host *hosts[2];
};
-static int NCR_D700_probe_one(struct NCR_D700_private *p, int chan,
+static int
+NCR_D700_probe_one(struct NCR_D700_private *p, int siop,
int irq, int slot, u32 region, int differential)
{
struct NCR_700_Host_Parameters *hostdata;
struct Scsi_Host *host;
+ int ret;
hostdata = kmalloc(sizeof(*hostdata), GFP_KERNEL);
if (!hostdata) {
- printk(KERN_ERR "NCR D700: Failed to allocate host data "
- "for channel %d, detatching\n", chan);
+ printk(KERN_ERR "NCR D700: SIOP%d: Failed to allocate host"
+ "data, detatching\n", siop);
return -ENOMEM;
}
memset(hostdata, 0, sizeof(*hostdata));
@@ -186,41 +188,49 @@
if (!request_region(region, 64, "NCR_D700")) {
printk(KERN_ERR "NCR D700: Failed to reserve IO region 0x%x\n",
region);
- kfree(hostdata);
- return -ENODEV;
+ ret = -ENODEV;
+ goto region_failed;
}
/* Fill in the three required pieces of hostdata */
hostdata->base = region;
- hostdata->differential = (((1<<chan) & differential) != 0);
+ hostdata->differential = (((1<<siop) & differential) != 0);
hostdata->clock = NCR_D700_CLOCK_MHZ;
- /* and register the chip */
+ /* and register the siop */
host = NCR_700_detect(&NCR_D700_driver_template, hostdata);
if (!host) {
- kfree(hostdata);
- release_region(host->base, 64);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto detect_failed;
}
host->irq = irq;
/* FIXME: Read this from SUS */
- host->this_id = id_array[slot * 2 + chan];
+ host->this_id = id_array[slot * 2 + siop];
printk(KERN_NOTICE "NCR D700: SIOP%d, SCSI id is %d\n",
- chan, host->this_id);
+ siop, host->this_id);
if (request_irq(irq, NCR_700_intr, SA_SHIRQ, "NCR_D700", host)) {
- printk(KERN_ERR "NCR D700, channel %d: irq problem, "
- "detatching\n", chan);
- scsi_unregister(host);
- NCR_700_release(host);
- return -ENODEV;
+ printk(KERN_ERR "NCR D700: SIOP%d: irq problem, "
+ "detatching\n", siop);
+ ret = -ENODEV;
+ goto irq_failed;
}
- scsi_add_host(host, NULL);
+ scsi_add_host(host, p->dev);
- p->hosts[chan] = host;
+ p->hosts[siop] = host;
hostdata->dev = p->dev;
return 0;
+
+ irq_failed:
+ scsi_unregister(host);
+ NCR_700_release(host);
+ detect_failed:
+ release_region(host->base, 64);
+ region_failed:
+ kfree(hostdata);
+
+ return ret;
}
/* Detect a D700 card. Note, because of the setup --- the chips are
@@ -305,8 +315,15 @@
/* plumb in both 700 chips */
for (i = 0; i < 2; i++) {
- found |= NCR_D700_probe_one(p, i, irq, slot,
- offset_addr | (0x80 * i), differential);
+ int err;
+
+ if ((err = NCR_D700_probe_one(p, i, irq, slot,
+ offset_addr + (0x80 * i),
+ differential)) != 0)
+ printk("D700: SIOP%d: probe failed, error = %d\n",
+ i, err);
+ else
+ found++;
}
if (!found) {
next reply other threads:[~2003-05-03 18:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-03 19:11 James Bottomley [this message]
2003-05-03 19:19 ` [RFC] support for sysfs string based properties for SCSI (1/3) James Bottomley
2003-05-03 19:25 ` [RFC] support for sysfs string based properties for SCSI (2/3) James Bottomley
2003-05-03 19:30 ` [RFC] support for sysfs string based properties for SCSI (3/3) James Bottomley
2003-05-05 17:02 ` [RFC] support for sysfs string based properties for SCSI (1/3) Greg KH
2003-05-05 17:08 ` James Bottomley
2003-05-05 17:17 ` Greg KH
2003-05-05 20:08 ` Mike Anderson
2003-05-06 0:05 ` James Bottomley
2003-05-13 21:02 ` Patrick Mochel
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=1051989099.2036.7.camel@mulgrave \
--to=james.bottomley@steeleye.com \
--cc=andmike@us.ibm.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mochel@osdl.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 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.