Skip to contentSkip to conversation

Prevent i2c-dev oops with debug

PATCH New Jean Delvare 2 participants 4 messages May 19, 2005 I2C

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Prevent i2c-dev oops with debug

Hi Greg,

Looks like i2c-dev suffers the same problem with dev_dbg as i2c-core did twice. Here is a patch that fixed a oops I and another user were experiencing when running sensors-detect.

Please note that I have no idea if this is the correct way to fix the problem. I mostly copied the fix from i2c-core. I don't quite understand what we are supposed to pass to dev_dbg.

BTW, I read that you don't plan to send any i2c patch to Linus before 2.6.4. I agree that we need to calm down a bit ;) but there are a several oops preventing patches in my list (i2c-core, i2c-i801, i2c-sis5595, i2c-ali1535 and now i2c-dev). Shouldn't these simple but important fixes be sent to Linus?

Also, I sent a mail to you some times ago about classes. The fact that 3 bus drivers are unusable at the moment sounds like an important issue to me, and we would need to decide about what should be done.

Thanks a lot for your precious help.

drivers/i2c/i2c-dev.c renamed from drivers/i2c/i2c-dev.c.orig +4 -4
@@ -187,7 +187,7 @@
 	int i,datasize,res;
 	unsigned long funcs;
 
-	dev_dbg(&client->dev, "i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n",
+	dev_dbg(&client->adapter->dev, "i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n",
 		iminor(inode),cmd, arg);
 
 	switch ( cmd ) {
@@ -308,7 +308,7 @@
 		    (data_arg.size != I2C_SMBUS_BLOCK_DATA) &&
 		    (data_arg.size != I2C_SMBUS_I2C_BLOCK_DATA) &&
 		    (data_arg.size != I2C_SMBUS_BLOCK_PROC_CALL)) {
-			dev_dbg(&client->dev,
+			dev_dbg(&client->adapter->dev,
 				"size out of range (%x) in ioctl I2C_SMBUS.\n",
 				data_arg.size);
 			return -EINVAL;
@@ -317,7 +317,7 @@
 		   so the check is valid if size=I2C_SMBUS_QUICK too. */
 		if ((data_arg.read_write != I2C_SMBUS_READ) && 
 		    (data_arg.read_write != I2C_SMBUS_WRITE)) {
-			dev_dbg(&client->dev, 
+			dev_dbg(&client->adapter->dev, 
 				"read_write out of range (%x) in ioctl I2C_SMBUS.\n",
 				data_arg.read_write);
 			return -EINVAL;
@@ -336,7 +336,7 @@
 					      data_arg.size, NULL);
 
 		if (data_arg.data = NULL) {
-			dev_dbg(&client->dev,
+			dev_dbg(&client->adapter->dev,
 				"data is NULL pointer in ioctl I2C_SMBUS.\n");
 			return -EINVAL;
 		}
Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#1 lore raw

PATCH 1/1 Prevent i2c-dev oops with debug

Quoting Greg KH <[email protected]>:

Quoted 7 lines
Quoted 4 lines

I agree that we need to calm down a bit ;) but there are a several oops preventing patches in my list (i2c-core, i2c-i801, i2c-sis5595, i2c-ali1535 and now i2c-dev). Shouldn't these simple but important fixes be sent to Linus?

They only happen when people enable debugging, right? That's a pretty simple fix :)

This is correct for i2c-core and i2c-dev (that said, you wouldn't figure how many people actually enable these options...), but the issue with the three bus drivers is different. The oops occur when unloading the modules if the corresponding hardware has not been detected. I agree that this is a not-so-common case, but it still can occur, and isn't related to debugging.

(BTW, why do these modules accept to load if no hardware matches? Just in case the hardware is hot-plugged later?)

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#2 lore raw

PATCH 1/1 Prevent i2c-dev oops with debug

In reply to Jean Delvare
Quoted 9 lines · Jean Delvare

Hi Greg,

Looks like i2c-dev suffers the same problem with dev_dbg as i2c-core did twice. Here is a patch that fixed a oops I and another user were experiencing when running sensors-detect.

Please note that I have no idea if this is the correct way to fix the problem. I mostly copied the fix from i2c-core. I don't quite understand what we are supposed to pass to dev_dbg.

Hm, I'll apply this for now. I'm working on fixing the i2c-dev driver up a bunch more, but this is good for now.

Quoted 5 lines

BTW, I read that you don't plan to send any i2c patch to Linus before 2.6.4. I agree that we need to calm down a bit ;) but there are a several oops preventing patches in my list (i2c-core, i2c-i801, i2c-sis5595, i2c-ali1535 and now i2c-dev). Shouldn't these simple but important fixes be sent to Linus?

They only happen when people enable debugging, right? That's a pretty simple fix :)

Quoted 3 lines

Also, I sent a mail to you some times ago about classes. The fact that 3 bus drivers are unusable at the moment sounds like an important issue to me, and we would need to decide about what should be done.

Sorry, getting behind these days... I saw your recent patch and that looks good for now. I'll put it in the queue to apply.

thanks,

greg k-h

#3 lore raw

PATCH 1/1 Prevent i2c-dev oops with debug

In reply to Jean Delvare
Quoted 3 lines · Jean Delvare

(BTW, why do these modules accept to load if no hardware matches? Just in case the hardware is hot-plugged later?)

Because that is how drivers now work. We don't fail to load if there is no hardware present at this point in time, as it could be added at any point in the future.

thanks,

greg k-h