All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] PATCH: f71882fg move some io access from the detect to
@ 2008-10-21 14:24 Hans de Goede
  2008-10-21 16:23 ` [lm-sensors] PATCH: f71882fg move some io access from the Jean Delvare
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Hans de Goede @ 2008-10-21 14:24 UTC (permalink / raw)
  To: lm-sensors

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

The f71882fg driver did some io to ioports it hadn't reserved yet in its
find (detect) function, this patches moves this io to the probe function
where these ports are reserved and this io belongs.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>

[-- Attachment #2: f71882fg-no-io-to-unreserverd-ports.patch --]
[-- Type: text/plain, Size: 2758 bytes --]

The f71882fg driver did some io to ioports it hadn't reserved yet in its
find (detect) function, this patches moves this io to the probe function
where these ports are reserved and this io belongs.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
--- linux/drivers/hwmon/f71882fg.c.f71862fg	2008-10-21 15:34:41.000000000 +0200
+++ linux/drivers/hwmon/f71882fg.c	2008-10-21 15:50:34.000000000 +0200
@@ -1495,7 +1495,7 @@
 {
 	struct f71882fg_data *data;
 	struct f71882fg_sio_data *sio_data = pdev->dev.platform_data;
-	int err;
+	int err = 0;
 	u8 start_reg;
 
 	data = kzalloc(sizeof(struct f71882fg_data), GFP_KERNEL);
@@ -1507,12 +1507,31 @@
 	mutex_init(&data->update_lock);
 	platform_set_drvdata(pdev, data);
 
+	start_reg = f71882fg_read8(data, F71882FG_REG_START);
+	if (!(start_reg & 0x03)) {
+		printk(KERN_WARNING DRVNAME
+			": Hardware monitoring not activated\n");
+		goto exit_free;
+	}
+
+	/* If it is a 71862 and the fan / pwm part is enabled sanity check
+	   the pwm settings */
+	if (data->type == f71862fg && (start_reg & 0x02)) {
+		u8 reg = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE);
+		if ((reg & 0x15) != 0x15) {
+			printk(KERN_ERR DRVNAME
+				": Invalid (reserved) pwm settings: 0x%02x\n",
+				(unsigned int)reg);
+			err = -EIO;
+			goto exit_free;
+		}
+	}
+
 	/* Register sysfs interface files */
 	err = device_create_file(&pdev->dev, &dev_attr_name);
 	if (err)
 		goto exit_unregister_sysfs;
 
-	start_reg = f71882fg_read8(data, F71882FG_REG_START);
 	if (start_reg & 0x01) {
 		err = f71882fg_create_sysfs_files(pdev, f718x2fg_in_temp_attr,
 					ARRAY_SIZE(f718x2fg_in_temp_attr));
@@ -1558,7 +1577,9 @@
 
 exit_unregister_sysfs:
 	f71882fg_remove(pdev); /* Will unregister the sysfs files for us */
-
+	return err; /* f71882fg_remove() also frees our data */
+exit_free:
+	kfree(data);
 	return err;
 }
 
@@ -1600,8 +1621,6 @@
 {
 	int err = -ENODEV;
 	u16 devid;
-	u8 reg;
-	struct f71882fg_data data;
 
 	superio_enter(sioaddr);
 
@@ -1638,25 +1657,6 @@
 	}
 	*address &= ~(REGION_LENGTH - 1);	/* Ignore 3 LSB */
 
-	data.addr = *address;
-	reg = f71882fg_read8(&data, F71882FG_REG_START);
-	if (!(reg & 0x03)) {
-		printk(KERN_WARNING DRVNAME
-			": Hardware monitoring not activated\n");
-		goto exit;
-	}
-
-	/* If it is a 71862 and the fan / pwm part is enabled sanity check
-	   the pwm settings */
-	if (sio_data->type == f71862fg && (reg & 0x02)) {
-		reg = f71882fg_read8(&data, F71882FG_REG_PWM_ENABLE);
-		if ((reg & 0x15) != 0x15) {
-			printk(KERN_ERR DRVNAME
-				": Invalid (reserved) pwm settings: 0x%02x\n",
-				(unsigned int)reg);
-			goto exit;
-		}
-	}
 	err = 0;
 	printk(KERN_INFO DRVNAME ": Found %s chip at %#x, revision %d\n",
 		f71882fg_names[sio_data->type],	(unsigned int)*address,

[-- Attachment #3: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-10-22  7:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-21 14:24 [lm-sensors] PATCH: f71882fg move some io access from the detect to Hans de Goede
2008-10-21 16:23 ` [lm-sensors] PATCH: f71882fg move some io access from the Jean Delvare
2008-10-21 18:14 ` Hans de Goede
2008-10-21 20:16 ` Jean Delvare
2008-10-22  7:34 ` Hans de Goede
2008-10-22  7:42 ` Jean Delvare

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.