hal/hald/linux block_class_device.c, 1.20, 1.21 net_class_device.c, 1.4, 1.5

Joe Shaw joe at pdx.freedesktop.org
Thu May 13 10:27:18 PDT 2004


Update of /cvs/hal/hal/hald/linux
In directory pdx:/tmp/cvs-serv9297/hald/linux

Modified Files:
	block_class_device.c net_class_device.c 
Log Message:
2004-05-13  Joe Shaw  <joe at ximian.com>

	* hald/linux/block_class_device.c (detect_media): Connect to the
	"callouts_finished" signal and call the callouts rather than
	removing the volume from the GDL here.  Patch from Sjoerd Simons
	<sjoerd at luon.net>

	* hald/linux/net_class_device.c (mdio_read): Make the result an
	out parameter and return 0 on success and -1 on failure.
	(mii_get_rate): Check the result of mdio_read().  Put the check
	for whether it's 10mbit in an else-if.
	(mii_get_link): Check the result of mdio_read().  Based on a patch
	from Sjoerd Simons <sjoerd at luon.net>

Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- a/block_class_device.c	5 May 2004 20:46:34 -0000	1.20
+++ b/block_class_device.c	13 May 2004 17:27:15 -0000	1.21
@@ -377,6 +377,15 @@
 					      user_data);
 }
 
+static void
+disc_remove_from_gdl (HalDevice *device, gpointer user_data)
+{
+	hal_device_store_remove (hald_get_gdl (), device);
+	g_signal_handlers_disconnect_by_func (device, disc_remove_from_gdl, 
+					      user_data);
+	g_object_unref (device);
+}
+
 /** Check for media on a block device that is not a volume
  *
  *  @param  d                   Device to inspect; can be any device, but
@@ -467,8 +476,9 @@
 
 			if (child != NULL) {
 				HAL_INFO (("Removing volume for optical device %s", device_file));
-				hal_device_store_remove (hald_get_gdl (), child);
-				g_object_unref (child);
+				g_signal_connect (child, "callouts_finished",
+						  G_CALLBACK (disc_remove_from_gdl), NULL);
+				hal_callout_device (child, FALSE);
 
 				close (fd);
 

Index: net_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/net_class_device.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/net_class_device.c	30 Apr 2004 20:59:08 -0000	1.4
+++ b/net_class_device.c	13 May 2004 17:27:16 -0000	1.5
@@ -115,11 +115,11 @@
  *
  *  @param  iface               Which interface
  *  @param  location            Which register
- *  @return                     Word that is read
+ *  @return                     0 on success, -1 on failure
  */
-static guint16
+static int
 mdio_read (int sockfd, struct ifreq *ifr, int location,
-	   gboolean new_ioctl_nums)
+	   gboolean new_ioctl_nums, guint16 *result)
 {
 	guint16 *data = (guint16 *) &(ifr->ifr_data);
 
@@ -132,7 +132,9 @@
 			    ifr->ifr_name, strerror (errno)));
 		return -1;
 	}
-	return data[3];
+	*result = data[3];
+	
+	return 0;
 }
 
 static void
@@ -142,6 +144,7 @@
 	int sockfd;
 	struct ifreq ifr;
 	gboolean new_ioctl_nums;
+	int res;
 	guint16 link_word;
 
 	ifname = hal_device_property_get_string (d, "net.interface");
@@ -179,14 +182,14 @@
 	 * 0x0020  10baseT supported
 	 * 0x001F  Protocol selection bits, always 0x0001 for Ethernet.
 	 */
-	link_word = mdio_read (sockfd, &ifr, 5, new_ioctl_nums);
+	res = mdio_read (sockfd, &ifr, 5, new_ioctl_nums, &link_word);
 
-	if (link_word & 0x380) {
+	if (res < 0) {
+		HAL_WARNING (("Error reading rate info"));
+	} else if (link_word & 0x380) {
 		hal_device_property_set_int (d, "net.ethernet.rate",
 					     100 * 1000 * 1000);
-	}
-
-	if (link_word & 0x60) {
+	} else if (link_word & 0x60) {
 		hal_device_property_set_int (d, "net.ethernet.rate",
 					     10 * 1000 * 1000);
 	}
@@ -201,6 +204,7 @@
 	int sockfd;
 	struct ifreq ifr;
 	gboolean new_ioctl_nums;
+	int res;
 	guint16 status_word;
 
 	ifname = hal_device_property_get_string (d, "net.interface");
@@ -241,10 +245,12 @@
 	 */
 
 	/* We have to read it twice to clear any "sticky" bits */
-	status_word = mdio_read (sockfd, &ifr, 1, new_ioctl_nums);
-	status_word = mdio_read (sockfd, &ifr, 1, new_ioctl_nums);
+	res = mdio_read (sockfd, &ifr, 1, new_ioctl_nums, &status_word);
+	res = mdio_read (sockfd, &ifr, 1, new_ioctl_nums, &status_word);
 
-	if ((status_word & 0x0016) == 0x0004)
+	if (res < 0)
+		HAL_WARNING (("Error reading link info"));
+	else if ((status_word & 0x0016) == 0x0004)
 		hal_device_property_set_bool (d, "net.ethernet.link", TRUE);
 	else
 		hal_device_property_set_bool (d, "net.ethernet.link", FALSE);





More information about the hal-commit mailing list