From: "=?UTF-8?Q?Kristian_H=C3=B8gsberg?=" Subject: Re: [PATCH] firewire: fw-sbp2: implement sysfs ieee1394_id Date: Wed, 30 May 2007 21:11:56 -0400 Message-ID: <59ad55d30705301811g8512232y1ab328d140f69f49@mail.gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from nz-out-0506.google.com ([64.233.162.230]:59776 "EHLO nz-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756045AbXEaBL5 (ORCPT ); Wed, 30 May 2007 21:11:57 -0400 Received: by nz-out-0506.google.com with SMTP id n1so3896nzf for ; Wed, 30 May 2007 18:11:56 -0700 (PDT) In-Reply-To: Content-Disposition: inline Sender: linux-scsi-owner@vger.kernel.org List-Id: linux-scsi@vger.kernel.org To: Stefan Richter Cc: linux1394-devel@lists.sourceforge.net, linux-scsi@vger.kernel.org On 5/27/07, Stefan Richter wrote: > The attribute /sys/bus/scsi/devices/*:*:*:*/ieee1394_id, as generated by > the old sbp2 driver, is typically used to create persistently named > links in /dev/disk/by-id. > > Signed-off-by: Stefan Richter Looks good to me. Signed-off-by: Kristian Hoegsberg > --- > drivers/firewire/fw-device.h | 1 > drivers/firewire/fw-sbp2.c | 53 +++++++++++++++++++++++++++++++++++ > 2 files changed, 54 insertions(+) > > Index: linux/drivers/firewire/fw-sbp2.c > =================================================================== > --- linux.orig/drivers/firewire/fw-sbp2.c > +++ linux/drivers/firewire/fw-sbp2.c > @@ -1102,6 +1102,58 @@ static int sbp2_scsi_abort(struct scsi_c > return SUCCESS; > } > > +/* > + * Format of /sys/bus/scsi/devices/.../ieee1394_id: > + * u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal) > + * > + * This is the concatenation of target port identifier and logical unit > + * identifier as per SAM-2...SAM-4 annex A. > + */ > +static ssize_t > +sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr, > + char *buf) > +{ > + struct scsi_device *sdev = to_scsi_device(dev); > + struct sbp2_device *sd; > + struct fw_unit *unit; > + struct fw_device *device; > + u32 directory_id; > + struct fw_csr_iterator ci; > + int key, value, lun; > + > + if (!sdev) > + return 0; > + sd = (struct sbp2_device *)sdev->host->hostdata; > + unit = sd->unit; > + device = fw_device(unit->device.parent); > + > + /* implicit directory ID */ > + directory_id = ((unit->directory - device->config_rom) * 4 > + + CSR_CONFIG_ROM) & 0xffffff; > + > + /* explicit directory ID, overrides implicit ID if present */ > + fw_csr_iterator_init(&ci, unit->directory); > + while (fw_csr_iterator_next(&ci, &key, &value)) > + if (key == CSR_DIRECTORY_ID) { > + directory_id = value; > + break; > + } > + > + /* FIXME: Make this work for multi-lun devices. */ > + lun = 0; > + > + return sprintf(buf, "%08x%08x:%06x:%04x\n", > + device->config_rom[3], device->config_rom[4], > + directory_id, lun); > +} > + > +static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL); > + > +static struct device_attribute *sbp2_scsi_sysfs_attrs[] = { > + &dev_attr_ieee1394_id, > + NULL > +}; > + > static struct scsi_host_template scsi_driver_template = { > .module = THIS_MODULE, > .name = "SBP-2 IEEE-1394", > @@ -1115,6 +1167,7 @@ static struct scsi_host_template scsi_dr > .use_clustering = ENABLE_CLUSTERING, > .cmd_per_lun = 1, > .can_queue = 1, > + .sdev_attrs = sbp2_scsi_sysfs_attrs, > }; > > MODULE_AUTHOR("Kristian Hoegsberg "); > Index: linux/drivers/firewire/fw-device.h > =================================================================== > --- linux.orig/drivers/firewire/fw-device.h > +++ linux/drivers/firewire/fw-device.h > @@ -99,6 +99,7 @@ fw_unit(struct device *dev) > #define CSR_DEPENDENT_INFO 0x14 > #define CSR_MODEL 0x17 > #define CSR_INSTANCE 0x18 > +#define CSR_DIRECTORY_ID 0x20 > > #define SBP2_COMMAND_SET_SPECIFIER 0x38 > #define SBP2_COMMAND_SET 0x39 > > -- > Stefan Richter > -=====-=-=== -=-= ==-== > http://arcgraph.de/sr/ > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > mailing list linux1394-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux1394-devel >