lkml.org 
[lkml]   [2005]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] use device_for_each_child() to properly access child devices.
Date
From
[PATCH] use device_for_each_child() to properly access child devices.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
commit 9a881f166f473373589ce6f3fdc47b44a1450e2d
tree 7f845c4f30aec7df6052a4503d3a76bf2a4362c0
parent 20b1e674230b642be662c5975923a0160ab9cbdc
author gregkh@suse.de <gregkh@suse.de> Fri, 25 Mar 2005 15:52:00 -0800
committer Greg Kroah-Hartman <gregkh@suse.de> Mon, 20 Jun 2005 15:15:22 -0700

drivers/scsi/scsi_transport_spi.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -348,17 +348,21 @@ spi_transport_rd_attr(rd_strm, "%d\n");
spi_transport_rd_attr(rti, "%d\n");
spi_transport_rd_attr(pcomp_en, "%d\n");

+/* we only care about the first child device so we return 1 */
+static int child_iter(struct device *dev, void *data)
+{
+ struct scsi_device *sdev = to_scsi_device(dev);
+
+ spi_dv_device(sdev);
+ return 1;
+}
+
static ssize_t
store_spi_revalidate(struct class_device *cdev, const char *buf, size_t count)
{
struct scsi_target *starget = transport_class_to_starget(cdev);

- /* FIXME: we're relying on an awful lot of device internals
- * here. We really need a function to get the first available
- * child */
- struct device *dev = container_of(starget->dev.children.next, struct device, node);
- struct scsi_device *sdev = to_scsi_device(dev);
- spi_dv_device(sdev);
+ device_for_each_child(&starget->dev, NULL, child_iter);
return count;
}
static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-06-21 04:42    [W:0.097 / U:2.320 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site