[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [ANNOUNCE] Yaboot 1.3.11 released



On Fri, Nov 21, 2003 at 12:03:01AM -0900, Ethan Benson wrote:
> > You don't look at the bogus /proc/scsi stuff for that, do you?
> 
> in current ofpath yes, changing this requires significant rework which
> is not going to happen in the 1.x version of yaboot/ofpath.

Well, it apears you aren't actually using the devpath: field in
that's exported in the k2 sata driver.  Ben, what is actually using that
field?  I'll happily adopt all software using it to use the sysfs field
added in my patch below (vs 2.6 mainline):


--- 1.2/drivers/scsi/sata_svw.c	Wed Oct 22 05:13:54 2003
+++ edited/drivers/scsi/sata_svw.c	Thu Nov 20 19:24:41 2003
@@ -38,11 +38,6 @@
 #include "hosts.h"
 #include <linux/libata.h>
 
-#ifdef CONFIG_ALL_PPC
-#include <asm/prom.h>
-#include <asm/pci-bridge.h>
-#endif /* CONFIG_ALL_PPC */
-
 #define DRV_NAME	"ata_k2"
 #define DRV_VERSION	"1.02"
 
@@ -135,68 +130,45 @@
 	 */
 }
 
-
 #ifdef CONFIG_ALL_PPC
+
+#include <asm/prom.h>
+
 /*
- * k2_sata_proc_info
- * inout : decides on the direction of the dataflow and the meaning of the
- *	   variables
- * buffer: If inout==FALSE data is being written to it else read from it
- * *start: If inout==FALSE start of the valid data in the buffer
- * offset: If inout==FALSE offset from the beginning of the imaginary file
- *	   from which we start writing into the buffer
- * length: If inout==FALSE max number of bytes to be written into the buffer
- *	   else number of bytes in the buffer
+ * XXX(hch): cache full_name in the ata_port's private_data?
  */
-static int k2_sata_proc_info(char *page, char **start, off_t offset, int count,
-		   int hostno, int inout)
+static ssize_t k2_sata_show_devspec(struct class_device *class_dev, char *buf)
 {
-	struct Scsi_Host *hpnt;
-	struct ata_port *ap;
-	struct device_node *np;
-	int len, index;
-
-	/* Find ourself. That's locking-broken, shitty etc... but thanks to
-	 * /proc/scsi interface and lack of state kept around in this driver,
-	 * its best I want to do for now...
-	 */
-	hpnt = scsi_hostlist;
-	while (hpnt) {
-		if (hostno == hpnt->host_no)
-			break;
-		hpnt = hpnt->next;
-	}
-	if (!hpnt)
-		return 0;
-
-	/* Find  the ata_port */
-	ap = (struct ata_port *) &hpnt->hostdata[0];
-	if (ap == NULL)
-		return 0;
-
-	/* Find the OF node for the PCI device proper */
-	np = pci_device_to_OF_node(ap->host_set->pdev);
-	if (np == NULL)
+	struct Scsi_Host *shost = class_to_shost(class_dev);
+	struct ata_port *ap = (struct ata_port *)hpnt->hostdata;
+	struct device_node *pci_node, *child_node = NULL;
+	ssize_t rval;
+	int index;
+	
+	pci_node = pci_device_to_OF_node(ap->host_set->pdev);
+	if (!pci_node)
 		return 0;
 
 	/* Match it to a port node */
 	index = (ap == ap->host_set->ports[0]) ? 0 : 1;
-	for (np = np->child; np != NULL; np = np->sibling) {
-		u32 *reg = (u32 *)get_property(np, "reg", NULL);
-		if (!reg)
-			continue;
-		if (index == *reg)
-			break;
+	while ((child_node = of_get_next_child(pci_node, child_node))) {
+		u32 *reg = (u32 *)get_property(child_node, "reg", NULL);
+		if (reg && index == *reg)
+			goto found;
 	}
-	if (np == NULL)
-		return 0;
-
-	len = sprintf(page, "devspec: %s\n", np->full_name);
 
-	return len;
+	return 0;
+ found:
+	rval = snprintf(buf, 20, "%s\n", child_node->full_name);
+	of_node_put(child_node);
+	return rval;
 }
-#endif /* CONFIG_ALL_PPC */
 
+static struct class_device_attribute *k2_sata_host_attrs[] = {
+	k2_ata_show_devspec,
+	NULL,
+};
+#endif /* CONFIG_ALL_PPC */
 
 static Scsi_Host_Template k2_sata_sht = {
 	.module			= THIS_MODULE,
@@ -214,7 +186,7 @@
 	.dma_boundary		= ATA_DMA_BOUNDARY,
 	.slave_configure	= ata_scsi_slave_config,
 #ifdef CONFIG_ALL_PPC
-	.proc_info		= k2_sata_proc_info
+	.shost_attrs		= k2_sata_shost_attrs,
 #endif
 };
 



Reply to: