hal: Branch 'master' - 4 commits

David Zeuthen david at kemper.freedesktop.org
Tue Mar 27 16:37:16 PDT 2007


 hald/linux/device.c                      |  322 +++++--------------------------
 hald/linux/probing/probe-ieee1394-unit.c |  107 +++++++---
 2 files changed, 138 insertions(+), 291 deletions(-)

New commits:
diff-tree 88680b55673e5237600d3e4864c8d9a2effafa0f (from 7eec6d10132bb48f890a66816f9fecc703a22ae4)
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Tue Mar 27 13:23:55 2007 -0400

    use sysfs attributes instead of parsing config rom file.
    
    The new firewire stack now exports sysfs attributes corresponding to
    the key contained in the config rom.  With this change, HAL doesn't have
    to parse the config rom but can parse the device properties by reading
    attribute files.
    
    Signed-off-by: Kristian Høgsberg <krh at redhat.com>

diff --git a/hald/linux/device.c b/hald/linux/device.c
index a8af37e..d109e9b 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -2230,182 +2230,69 @@ ieee1394_compute_udi (HalDevice *d)
 
 /*--------------------------------------------------------------------------------------------------------------*/
 
-#define CSR_OFFSET	0x40
-#define CSR_LEAF	0x80
-#define CSR_DIRECTORY	0xc0
-
-#define CSR_DESCRIPTOR		0x01
-#define CSR_VENDOR		0x03
-#define CSR_HARDWARE_VERSION	0x04
-#define CSR_NODE_CAPABILITIES	0x0c
-#define CSR_UNIT		0x11
-#define CSR_SPECIFIER_ID	0x12
-#define CSR_VERSION		0x13
-#define CSR_DEPENDENT_INFO	0x14
-#define CSR_MODEL		0x17
-#define CSR_INSTANCE		0x18
-
-#define SBP2_COMMAND_SET_SPECIFIER	0x38
-#define SBP2_COMMAND_SET		0x39
-#define SBP2_COMMAND_SET_REVISION	0x3b
-#define SBP2_FIRMWARE_REVISION		0x3c
-
-static char *
-decode_textual_descriptor(uint32_t *block, char *buffer, size_t size)
+static HalDevice *
+firewire_add_device (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev)
 {
-	unsigned int length;
-	uint32_t *p, *end;
-	
-	length = block[0] >> 16;
-	if (block[1] != 0 || block[2] != 0) {
-		snprintf(buffer, length, "unknown encoding/language: 0x%08x/0x%08x\n",
-			 buffer[1], buffer[2]);
-		return buffer;
-	}
-	
-	p = &block[3];
-	memset(buffer, 0, size);
-	if (length - 2 > size / 4)
-		end = &block[3 + size / 4];
-	else
-		end = &block[length + 1];
-	
-	while (p < end) {
-		* (uint32_t *) buffer = __cpu_to_be32(*p);
-		buffer += 4;
-		p++;
-	}
-	
-	return buffer;
-}
-
-#define ARRAY_LENGTH(a) (sizeof(a)/sizeof((a)[0]))
-
+	HalDevice *d = NULL;
+	gchar buf[64];
 
-struct csr_iterator {
-	uint32_t *p;
-	uint32_t *end;
-};
+	if (device_file == NULL)
+		goto out;
 
-static void
-csr_iterator_init(struct csr_iterator *ci, uint32_t *p)
-{
-	ci->p = p + 1;
-	ci->end = ci->p + (p[0] >> 16);
-}
+	d = hal_device_new ();
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "info.subsystem", "ieee1394");
+	hal_device_property_set_string (d, "info.bus", "ieee1394");
+	hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
+	hal_device_add_capability (d, "ieee1394");
+	hal_device_property_set_string (d, "ieee1394.device", device_file);
+	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
 
-static int
-csr_iterator_next(struct csr_iterator *ci, int *key, int *value)
-{
-	*key = *ci->p >> 24;
-	*value = *ci->p & 0xffffff;
+	hal_util_set_uint64_from_file (d, "ieee1394.guid", sysfs_path, "guid", 16);	
+	hal_util_set_int_from_file  (d, "ieee1394.vendor_id", sysfs_path, "vendor", 16);
+	hal_util_set_int_from_file  (d, "ieee1394.product_id", sysfs_path, "model", 16);
+	hal_util_set_int_from_file  (d, "ieee1394.harware_version", sysfs_path, "harware_version", 16);
 
-	return ci->p++ < ci->end;
-}
+	if (!hal_util_set_string_from_file (d, "ieee1394.vendor", sysfs_path, "vendor_name")) {
+		/* FIXME: We should do a OUI lookup here, see
+		 * http://standards.ieee.org/regauth/oui/oui.txt */
 
-static void
-firewire_parse_config_rom (HalDevice *d, uint32_t *rom)
-{
-	struct csr_iterator ci;
-	int key, value, last_key = 0, vendor = 0, model = 0;
-	uint64_t guid;
-	char buffer[256];
-	
-	guid = ((__u64)rom[3] << 32) | rom[4];
-	hal_device_property_set_uint64 (d, "ieee1394.guid", guid);
-	
-	csr_iterator_init(&ci, rom + 5);
-	while (csr_iterator_next(&ci, &key, &value)) {
-		switch (key) {
-		case CSR_VENDOR:
-			vendor = value;
-			hal_device_property_set_int (d, "ieee1394.vendor_id", vendor);
-			break;
-		case CSR_MODEL:
-			model = value;
-			hal_device_property_set_int (d, "ieee1394.product_id", vendor);
-			break;
-		case CSR_DESCRIPTOR | CSR_LEAF:
-			if (last_key == CSR_VENDOR) {
-				decode_textual_descriptor(ci.p - 1 + value,
-							  buffer, sizeof buffer);
-				hal_device_property_set_string (d, "ieee1394.vendor", buffer);
-			} else if (last_key == CSR_MODEL) {
-				decode_textual_descriptor(ci.p - 1 + value,
-							  buffer, sizeof buffer);
-				hal_device_property_set_string (d, "ieee1394.product", buffer);
-			}
-			break;
-		case CSR_HARDWARE_VERSION:
-			hal_device_property_set_int (d, "ieee1394.hardware_version", value);
-			break;
-			
-		}
-
-		last_key = key;
+		g_snprintf (buf, sizeof (buf), "Unknown (0x%06x)", 
+			    hal_device_property_get_int (d, "ieee1394.vendor_id"));
+		hal_device_property_set_string (d, "ieee1394.vendor", buf);
 	}
-}
 
+	hal_util_set_string_from_file (d, "ieee1394.product", sysfs_path, "model_name");
 
-static void
-decode_sbp2_entry (HalDevice *d, int key, int value)
-{
-	switch (key) {
-	case SBP2_FIRMWARE_REVISION:
-		hal_device_property_set_int (d, "ieee1394_unit.sbp2.firmware_revision", value);
-		break;
-	}
+ out:
+	return d;
 }
 
-struct specifier {
+static HalDevice *
+firewire_add_unit (const gchar *sysfs_path, int unit_id, HalDevice *parent_dev)
+{
 	int specifier_id;
 	int version;
-	void (*decode_entry) (HalDevice *d, int key, int value);
-} specifiers[] = {
-	{
-		0x00609e,
-		0x010483,
-		decode_sbp2_entry
-	}
-};
+	HalDevice *d;
+
+	d = hal_device_new ();
+	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+	hal_device_property_set_string (d, "info.subsystem", "ieee1394_unit");
+	hal_device_property_set_string (d, "info.bus", "ieee1394_unit");
+	hal_device_property_set_string (d, "info.parent",
+					hal_device_get_udi (parent_dev));
+	hal_device_property_set_string (d, "ieee1394_unit.originating_device", 
+					hal_device_get_udi (parent_dev));
+	hal_device_property_set_int (d, "ieee1394_unit.unit_index", unit_id);
+	hal_device_add_capability (d, "ieee1394_unit");
+	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
+
+	hal_util_set_int_from_file  (d, "ieee1394.vendor_id", sysfs_path, "../vendor_id", 16);
+	hal_util_get_int_from_file  (sysfs_path, "specifier_id", &specifier_id, 16);
+	hal_device_property_set_int (d, "ieee1394_unit.specifier_id", specifier_id);
+	hal_util_get_int_from_file  (sysfs_path, "version", &version, 16);
+	hal_device_property_set_int (d, "ieee1394_unit.version", version);
 
-static void
-firewire_unit_parse_config_rom (HalDevice *d, uint32_t *rom, int index)
-{
-	struct csr_iterator ci;
-	unsigned int i;
-	int key;
-	int value;
-	int specifier_id = 0;
-	int version = 0;
-	
-	csr_iterator_init(&ci, rom + index);
-	while (csr_iterator_next(&ci, &key, &value)) {
-		switch (key) {
-		case CSR_SPECIFIER_ID:
-			specifier_id = value;
-			hal_device_property_set_int (d, "ieee1394_unit.specifier_id", specifier_id);
-			break;
-		case CSR_VERSION:
-			version = value;
-			hal_device_property_set_int (d, "ieee1394_unit.version", version);
-			break;
-			
-		default:
-			if (key < 0x38)
-				break;
-			
-			/* Specifier dependent key/value pair. */
-			for (i = 0; i < ARRAY_LENGTH(specifiers); i++) {
-				if (specifiers[i].specifier_id == specifier_id &&
-				    specifiers[i].version == version) {
-					specifiers[i].decode_entry (d, key, value);
-					break;
-				}
-			}
-		}
-	}
-	
 	if (specifier_id == 0x00609e && version == 0x010483) {
 		hal_device_add_capability (d, "ieee1394_unit.sbp2");
 	} else if (specifier_id == 0x00a02d) {
@@ -2424,127 +2311,28 @@ firewire_unit_parse_config_rom (HalDevic
 		hal_device_add_capability (d, "ieee1394_unit.iidc");
 	}
 
-#if 0
-	/* TODO */
-
-	/* In the AV/C case we should send a unit info command to the
-	 * device to see what kind of AV/C device it is (audio, camcorder,
-	 * etc).  We might want to do this in a helper app.  And we need
-	 * the device file for this...  This will be another 200 lines of
-	 * code.
-	 */
-	if (specifier_id == 0x00a02d && (version & 0xff0001) == 0x010001) {
-		query_unit_info("/dev/fw1.0");
-	}
-#endif
+	return d;
 }
 
-
 static HalDevice *
 firewire_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
 {
-	HalDevice *d;
 	int device_id;
 	int unit_id;
 	const char *bus_id;
-	gboolean is_device = FALSE;
-	gboolean is_unit = FALSE;
-	char rom[256];
-	ssize_t rom_size;
-	char *str;
-	int fd;
-
-	d = NULL;
 
 	if (parent_dev == NULL)
-		goto out;
+		return NULL;
 
 	bus_id = hal_util_get_last_element (sysfs_path);
 
 	if (sscanf (bus_id, "fw%d.%d", &device_id, &unit_id) == 2 ) {
-		is_unit = TRUE;
+		return firewire_add_unit (sysfs_path, unit_id, parent_dev);
 	} else if (sscanf (bus_id, "fw%d", &device_id) == 1) {
-		is_device = TRUE;
+		return firewire_add_device (sysfs_path, device_file, parent_dev);
 	} else {
-		goto out;
+		return NULL;
 	}
-
-	if (is_device) {
-
-		if (device_file == NULL)
-			goto out;
-
-		str = g_strdup_printf ("%s/config_rom", sysfs_path);
-		fd = open (str, O_RDONLY);
-		if (fd < 0) {
-			HAL_ERROR (("Cannot open firewire config rom at %s", str));
-			g_free (str);
-			goto out;
-		}
-		if ((rom_size = read (fd, rom, sizeof (rom))) < 0) {
-			HAL_ERROR (("Cannot read firewire config rom at %s", str));
-			g_free (str);
-			close (fd);
-			goto out;
-		}
-		g_free (str);
-		close (fd);
-
-		HAL_INFO (("firewire config rom is %d bytes", rom_size));
-
-		d = hal_device_new ();
-		hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
-		hal_device_property_set_string (d, "info.subsystem", "ieee1394");
-		hal_device_property_set_string (d, "info.bus", "ieee1394");
-		hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
-		hal_device_add_capability (d, "ieee1394");
-		hal_device_property_set_string (d, "ieee1394.device", device_file);
-		hal_util_set_driver (d, "info.linux.driver", sysfs_path);
-
-		firewire_parse_config_rom (d, (uint32_t *) rom);
-	} else {
-		int rom_index;
-
-		str = g_strdup_printf ("%s/../config_rom", sysfs_path);
-		fd = open (str, O_RDONLY);
-		if (fd < 0) {
-			HAL_ERROR (("Cannot open firewire config rom at %s", str));
-			g_free (str);
-			goto out;
-		}
-		if ((rom_size = read (fd, rom, sizeof (rom))) < 0) {
-			HAL_ERROR (("Cannot read firewire config rom at %s", str));
-			g_free (str);
-			close (fd);
-			goto out;
-		}
-		g_free (str);
-		close (fd);
-
-		if (!hal_util_get_int_from_file (sysfs_path, "rom_index", &rom_index, 0)) {
-			HAL_ERROR (("Cannot read get %s/rom_index", sysfs_path));
-			goto out;
-		}
-
-		HAL_INFO (("firewire config rom is %d bytes - unit rom index is %d", rom_size, rom_index));
-
-		d = hal_device_new ();
-		hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
-		hal_device_property_set_string (d, "info.subsystem", "ieee1394_unit");
-		hal_device_property_set_string (d, "info.bus", "ieee1394_unit");
-		hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
-		hal_device_property_set_string (d, "ieee1394_unit.originating_device", 
-						hal_device_get_udi (parent_dev));
-		hal_device_property_set_int (d, "ieee1394_unit.unit_index", unit_id);
-		hal_device_add_capability (d, "ieee1394_unit");
-		hal_util_set_driver (d, "info.linux.driver", sysfs_path);
-
-		firewire_unit_parse_config_rom (d, (uint32_t *) rom, rom_index);
-	}
-
-
-out:
-	return d;
 }
 
 static const gchar *
@@ -2630,7 +2418,7 @@ ccw_add_tape_properties (HalDevice *d, c
 	const gchar *state_text[3] = {"unknown", "loaded", "no medium"};
 
 	hal_util_set_string_from_file (d, "ccw.tape.state", sysfs_path, "state");
-	hal_util_set_string_from_file (d, "ccw.tape.operation", sysfs_path,
+    	hal_util_set_string_from_file (d, "ccw.tape.operation", sysfs_path,
 				       "operation");
 	/* The following properties are only valid for online devices. */
 	if (!hal_util_get_int_from_file (sysfs_path, "online", &online, 2))
diff-tree 7eec6d10132bb48f890a66816f9fecc703a22ae4 (from 550ff2dd124d31c0fb2b9517e725ecfea0df1067)
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Tue Mar 27 13:24:32 2007 -0400

    report AV/C subunits instead of AV/C unit in ieee1394 probe.
    
    Listing the AV/C subunits as capabilities make a lot more sense,
    since the unit type is typically just one of the subunits picked
    more or less at random.  This way we expose all the interfaces of the
    AV/C device.
    
    Signed-off-by: Kristian Høgsberg <krh at redhat.com>

diff --git a/hald/linux/probing/probe-ieee1394-unit.c b/hald/linux/probing/probe-ieee1394-unit.c
index 11a6290..bfa3ed0 100644
--- a/hald/linux/probing/probe-ieee1394-unit.c
+++ b/hald/linux/probing/probe-ieee1394-unit.c
@@ -209,6 +209,7 @@ static const char * const unit_names[] =
 
 enum {
 	AVC_OPCODE_UNIT_INFO = 0x30,
+	AVC_OPCODE_SUBUNIT_INFO = 0x31,
 };
 
 enum {
@@ -244,6 +245,7 @@ handle_request (int fd, struct fw_cdev_e
 	} *response;
 	unsigned int unit_type;
 	char capname[256];
+	int i;
 
 	if (request->tcode != TCODE_WRITE_BLOCK_REQUEST ||
 	    request->offset != CSR_FCP_RESPONSE) {
@@ -262,20 +264,27 @@ handle_request (int fd, struct fw_cdev_e
 
 	if (response->frame.ctype == AVC_RESPONSE_INTERIM) {
 		HAL_ERROR (("got interim"));
-		/* Returning -1 here will make get_unit_info() go back into
+		/* Returning -1 here will make get_subunit_info() go back into
 		 * poll() and wait for up to 200ms. */
 		return -1;
 	}
 	
-	unit_type = response->operands[0] >> 3;
-	if (unit_type > ARRAY_LENGTH(unit_names) || unit_names[unit_type] == NULL) {
-		HAL_ERROR (("unknown unit type"));
-		return -1;
+	for (i = 0; i < 4; i++) {
+		if (response->operands[i] == 0xff)
+			break;
+
+		unit_type = response->operands[i] >> 3;
+		if (unit_type > ARRAY_LENGTH(unit_names) ||
+		    unit_names[unit_type] == NULL) {
+			HAL_ERROR (("unknown unit type"));
+			return -1;
+		}
+
+		snprintf (capname, sizeof (capname),
+			  "ieee1394_unit.avc.%s", unit_names[unit_type]);
+		libhal_device_add_capability (ctx, udi, capname, NULL);
 	}
 
-	snprintf (capname, sizeof (capname), "ieee1394_unit.avc.%s", unit_names[unit_type]);
-	libhal_device_add_capability (ctx, udi, capname, NULL);
-	
 	return 0;
 }
 
@@ -283,7 +292,7 @@ handle_request (int fd, struct fw_cdev_e
 #define AVC_TIMEOUT 200
 
 static int
-get_unit_info (int fd, int generation)
+get_subunit_info (int fd, int generation)
 {
 	struct {
 		struct avc_frame frame;
@@ -307,7 +316,7 @@ get_unit_info (int fd, int generation)
 	payload.frame.ctype = AVC_COMMAND_STATUS;
 	payload.frame.subunit_type = AVC_SUBUNIT_UNIT;
 	payload.frame.subunit_id = AVC_SUBUNIT_ID_UNIT;
-	payload.frame.opcode = AVC_OPCODE_UNIT_INFO;
+	payload.frame.opcode = AVC_OPCODE_SUBUNIT_INFO;
 	payload.frame.operand0 = 0xff;
 	payload.operands[0] = 0xff;
 	payload.operands[1] = 0xff;
@@ -426,7 +435,7 @@ int main (int argc, char *argv[])
 
 	/* Retry the command three times. */
 	for (i = 0; i < 3; i++) {
-		if (get_unit_info(fd, bus_reset.generation) == 0)
+		if (get_subunit_info(fd, bus_reset.generation) == 0)
 			break;
 		poll (NULL, 0, 500); /* take a 500ms nap */
 	}
diff-tree 550ff2dd124d31c0fb2b9517e725ecfea0df1067 (from 935e9b8e8d0003c1bf41e26764fae277b48d97e0)
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Tue Mar 27 13:24:20 2007 -0400

    update ieee1394 prober to ioctl interface changes.
    
    Signed-off-by: Kristian Høgsberg <krh at redhat.com>

diff --git a/hald/linux/probing/probe-ieee1394-unit.c b/hald/linux/probing/probe-ieee1394-unit.c
index dbfb8a3..11a6290 100644
--- a/hald/linux/probing/probe-ieee1394-unit.c
+++ b/hald/linux/probing/probe-ieee1394-unit.c
@@ -54,27 +54,58 @@
 #define FW_CDEV_EVENT_REQUEST		0x02
 #define FW_CDEV_EVENT_ISO_INTERRUPT	0x03
 
+struct fw_cdev_event_bus_reset {
+	__u64 closure;
+	__u32 type;
+	__u32 node_id;
+	__u32 local_node_id;
+	__u32 bm_node_id;
+	__u32 irm_node_id;
+	__u32 root_node_id;
+	__u32 generation;
+};
+
 struct fw_cdev_event_response {
+	__u64 closure;
 	__u32 type;
 	__u32 rcode;
-	__u64 closure;
 	__u32 length;
 	__u32 data[0];
 };
 
 struct fw_cdev_event_request {
+	__u64 closure;
 	__u32 type;
 	__u32 tcode;
 	__u64 offset;
-	__u64 closure;
-	__u32 serial;
+	__u32 handle;
 	__u32 length;
 	__u32 data[0];
 };
 
+#define FW_CDEV_IOC_GET_INFO		_IO('#', 0x00)
 #define FW_CDEV_IOC_SEND_REQUEST	_IO('#', 0x01)
 #define FW_CDEV_IOC_ALLOCATE		_IO('#', 0x02)
-#define FW_CDEV_IOC_SEND_RESPONSE	_IO('#', 0x03)
+#define FW_CDEV_IOC_DEALLOCATE		_IO('#', 0x03)
+#define FW_CDEV_IOC_SEND_RESPONSE	_IO('#', 0x04)
+#define FW_CDEV_IOC_INITIATE_BUS_RESET	_IO('#', 0x05)
+#define FW_CDEV_IOC_ADD_DESCRIPTOR	_IO('#', 0x06)
+#define FW_CDEV_IOC_REMOVE_DESCRIPTOR	_IO('#', 0x07)
+
+/* FW_CDEV_VERSION History
+ *
+ * 1	Feb 18, 2007:  Initial version.
+ */
+#define FW_CDEV_VERSION		1
+
+struct fw_cdev_get_info {
+	__u32 version;
+	__u32 rom_length;
+	__u64 rom;
+	__u64 bus_reset;
+	__u64 bus_reset_closure;
+	__u32 card;
+};
 
 struct fw_cdev_send_request {
 	__u32 tcode;
@@ -82,19 +113,25 @@ struct fw_cdev_send_request {
 	__u64 offset;
 	__u64 closure;
 	__u64 data;
+	__u32 generation;
 };
 
 struct fw_cdev_send_response {
 	__u32 rcode;
 	__u32 length;
 	__u64 data;
-	__u32 serial;
+	__u32 handle;
 };
 
 struct fw_cdev_allocate {
 	__u64 offset;
 	__u64 closure;
 	__u32 length;
+	__u32 handle;
+};
+
+struct fw_cdev_deallocate {
+	__u32 handle;
 };
 
 /* end of code from fw-device-cdev.h */
@@ -183,12 +220,12 @@ static LibHalContext *ctx = NULL;
 
 
 static void
-send_response (int fd, __u32 serial, int rcode, void *data, size_t length)
+send_response (int fd, __u32 handle, int rcode, void *data, size_t length)
 {
 	struct fw_cdev_send_response response;
 	
 	response.length = length;
-	response.serial = serial;
+	response.handle = handle;
 	response.rcode  = rcode;
 	response.data   = ptr_to_u64(data);
 	
@@ -210,12 +247,12 @@ handle_request (int fd, struct fw_cdev_e
 
 	if (request->tcode != TCODE_WRITE_BLOCK_REQUEST ||
 	    request->offset != CSR_FCP_RESPONSE) {
-		send_response (fd, request->serial, RCODE_TYPE_ERROR, NULL, 0);
+		send_response (fd, request->handle, RCODE_TYPE_ERROR, NULL, 0);
 		HAL_ERROR (("AVC response to wrong address"));
 		return -1;
 	}
 	
-	send_response (fd, request->serial, RCODE_COMPLETE, NULL, 0);
+	send_response (fd, request->handle, RCODE_COMPLETE, NULL, 0);
 	
 	response = (void *) request->data;
 	if (response->frame.cts != CTS_AVC) {
@@ -246,7 +283,7 @@ handle_request (int fd, struct fw_cdev_e
 #define AVC_TIMEOUT 200
 
 static int
-get_unit_info (int fd)
+get_unit_info (int fd, int generation)
 {
 	struct {
 		struct avc_frame frame;
@@ -263,6 +300,7 @@ get_unit_info (int fd)
 	request.tcode = TCODE_WRITE_BLOCK_REQUEST;
 	request.offset = CSR_FCP_COMMAND;
 	request.length = 8;
+	request.generation = generation;
 	request.data = ptr_to_u64(&payload);
 	
 	payload.frame.cts = CTS_AVC;
@@ -332,6 +370,8 @@ int main (int argc, char *argv[])
 	int i;
 	int fd;
 	int ret;
+	struct fw_cdev_get_info get_info;
+	struct fw_cdev_event_bus_reset bus_reset;
 	struct fw_cdev_allocate request;
 	const char *device_file;
 	const char *ieee1394_udi;
@@ -362,21 +402,31 @@ int main (int argc, char *argv[])
 
 	fd = open (device_file, O_RDWR);
 	if (fd < 0) {
-		HAL_ERROR (("failed to open %s: %d", device_file, strerror (errno)));
+		HAL_ERROR (("failed to open %s: %s", device_file, strerror (errno)));
+		goto out;
+	}
+
+	get_info.version = FW_CDEV_VERSION;
+	get_info.rom = 0;
+	get_info.rom_length = 0;
+	get_info.bus_reset = ptr_to_u64(&bus_reset);
+	if (ioctl(fd, FW_CDEV_IOC_GET_INFO, &get_info) < 0) {
+		HAL_ERROR (("get config rom ioctl: %s", strerror(errno)));
 		goto out;
 	}
 
 	request.offset = CSR_FCP_RESPONSE;
 	request.length = 0x200;
-	request.closure = (__u64) NULL;
+	request.closure = 0;
 	if (ioctl (fd, FW_CDEV_IOC_ALLOCATE, &request) < 0) {
-		HAL_ERROR (("failed to allocate fcp response area: %s", device_file, strerror (errno)));
+		HAL_ERROR (("failed to allocate fcp response area: %s",
+			    strerror (errno)));
 		goto out;
 	}
 
 	/* Retry the command three times. */
 	for (i = 0; i < 3; i++) {
-		if (get_unit_info(fd) == 0)
+		if (get_unit_info(fd, bus_reset.generation) == 0)
 			break;
 		poll (NULL, 0, 500); /* take a 500ms nap */
 	}
diff-tree 935e9b8e8d0003c1bf41e26764fae277b48d97e0 (from 9c288cbfe84cbe0bda3827b7e0e5537eb7d1a224)
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Tue Mar 27 18:05:10 2007 -0400

    initialize pollfd array correctly.
    
    Signed-off-by: Kristian Høgsberg <krh at redhat.com>

diff --git a/hald/linux/probing/probe-ieee1394-unit.c b/hald/linux/probing/probe-ieee1394-unit.c
index ea64814..dbfb8a3 100644
--- a/hald/linux/probing/probe-ieee1394-unit.c
+++ b/hald/linux/probing/probe-ieee1394-unit.c
@@ -282,7 +282,7 @@ get_unit_info (int fd)
 	}
 	
 	fds[0].fd = fd;
-	fds[1].events = POLLIN;
+	fds[0].events = POLLIN;
 	
 	while (TRUE) {
 		if (poll (fds, 1, AVC_TIMEOUT) < 0) {


More information about the hal-commit mailing list