From a8ee0243ad52f8f406899a9f7180f35f7461792a Mon Sep 17 00:00:00 2001 From: Frodo Looijaard Date: Fri, 11 Dec 1998 15:07:29 +0000 Subject: [PATCH] Some small bug fixes * Somehow, i2c-proc did not yet use the i2c_adapter_id call. This must have slipped through. * isa.o and smbus.o changes I made to make them less noisy had a small error (no return value), which caused strange device detections. * Added /proc/bus/i2c module-count monitoring - somehow, this slipped through, too. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@68 7894878c-1315-0410-8ee3-d5d059ff63e0 --- kernel/busses/i2c-isa.c | 6 +++--- kernel/i2c-proc.c | 15 +++++++++------ kernel/smbus.c | 6 +++--- src/i2c-proc.c | 15 +++++++++------ src/isa.c | 6 +++--- src/smbus.c | 6 +++--- 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/kernel/busses/i2c-isa.c b/kernel/busses/i2c-isa.c index 176f54e8..7294f91c 100644 --- a/kernel/busses/i2c-isa.c +++ b/kernel/busses/i2c-isa.c @@ -79,8 +79,8 @@ int isa_master_xfer (struct isa_adapter *adap, struct i2c_msg msgs[], printk("isa.o: isa_master_xfer called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Algorithm slave_send call-back implementation. Can't do that... */ @@ -90,8 +90,8 @@ int isa_slave_send (struct isa_adapter *adap, char *data, int len) printk("isa.o: isa_slave_send called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Algorithm slave_recv call-back implementation. Can't do that... */ @@ -101,8 +101,8 @@ int isa_slave_recv (struct isa_adapter *adap, char *data, int len) printk("isa.o: isa_slave_recv called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Here we can put additional calls to modify the workings of the algorithm. diff --git a/kernel/i2c-proc.c b/kernel/i2c-proc.c index 8b298a0a..3d99dcbd 100644 --- a/kernel/i2c-proc.c +++ b/kernel/i2c-proc.c @@ -156,14 +156,16 @@ int i2cproc_init(void) return -ENOENT; } proc_bus_i2c = create_proc_entry("i2c",0,proc_bus); - if (proc_bus_i2c) - proc_bus_i2c->read_proc = &read_bus_i2c; - else { + if (!proc_bus_i2c) { printk("i2c-proc.o: Could not create /proc/bus/i2c, " "module not inserted.\n"); i2cproc_cleanup(); return -ENOENT; } + proc_bus_i2c->read_proc = &read_bus_i2c; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) + proc_bus_i2c->fill_inode = &monitor_bus_i2c; +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) */ i2cproc_initialized += 2; #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ /* In Linux 2.0.x, there is no /proc/bus! But I hope no other module @@ -252,7 +254,8 @@ int read_bus_i2c(char *buf, char **start, off_t offset, int len, int unused) len = 0; for (i = 0; i < I2C_ADAP_MAX; i++) if (i2cproc_adapters[i]) - len += sprintf(buf+len, "i2c-%d\t%s\t%-32s\t%-32s\n",i, + len += sprintf(buf+len, "i2c-%d\t%s\t%-32s\t%-32s\n", + i2c_adapter_id(i2cproc_adapters[i]), i2c_is_smbus_adapter(i2cproc_adapters[i])?"smbus": #ifdef DEBUG i2c_is_isa_adapter(i2cproc_adapters[i])?"isa": @@ -356,7 +359,7 @@ int i2cproc_attach_adapter(struct i2c_adapter *adapter) } i2cproc_adapters[i] = adapter; - sprintf(name,"i2c-%d",i); + sprintf(name,"i2c-%d",i2c_adapter_id(adapter)); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) proc_entry = create_proc_entry(name,0,proc_bus); @@ -413,7 +416,7 @@ int i2cproc_detach_client(struct i2c_client *client) for (i = 0; i < I2C_ADAP_MAX; i++) if (client->adapter == i2cproc_adapters[i]) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) - sprintf(name,"i2c-%d",i); + sprintf(name,"i2c-%d",i2c_adapter_id(i2cproc_adapters[i])); remove_proc_entry(name,proc_bus); #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ if ((res = proc_unregister(&proc_bus_dir, diff --git a/kernel/smbus.c b/kernel/smbus.c index 669e7416..d20bfccc 100644 --- a/kernel/smbus.c +++ b/kernel/smbus.c @@ -191,8 +191,8 @@ int smbus_master_xfer (struct smbus_adapter *adap, struct i2c_msg msgs[], printk("smbus.o: smbus_master_xfer called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Algorithm slave_send call-back implementation. Can't do that... */ @@ -202,8 +202,8 @@ int smbus_slave_send (struct smbus_adapter *adap, char *data, int len) printk("smbus.o: smbus_slave_send called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Algorithm slave_recv call-back implementation. Can't do that... */ @@ -213,8 +213,8 @@ int smbus_slave_recv (struct smbus_adapter *adap, char *data, int len) printk("smbus.o: smbus_slave_recv called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Here we can put additional calls to modify the workings of the algorithm. diff --git a/src/i2c-proc.c b/src/i2c-proc.c index 8b298a0a..3d99dcbd 100644 --- a/src/i2c-proc.c +++ b/src/i2c-proc.c @@ -156,14 +156,16 @@ int i2cproc_init(void) return -ENOENT; } proc_bus_i2c = create_proc_entry("i2c",0,proc_bus); - if (proc_bus_i2c) - proc_bus_i2c->read_proc = &read_bus_i2c; - else { + if (!proc_bus_i2c) { printk("i2c-proc.o: Could not create /proc/bus/i2c, " "module not inserted.\n"); i2cproc_cleanup(); return -ENOENT; } + proc_bus_i2c->read_proc = &read_bus_i2c; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) + proc_bus_i2c->fill_inode = &monitor_bus_i2c; +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) */ i2cproc_initialized += 2; #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ /* In Linux 2.0.x, there is no /proc/bus! But I hope no other module @@ -252,7 +254,8 @@ int read_bus_i2c(char *buf, char **start, off_t offset, int len, int unused) len = 0; for (i = 0; i < I2C_ADAP_MAX; i++) if (i2cproc_adapters[i]) - len += sprintf(buf+len, "i2c-%d\t%s\t%-32s\t%-32s\n",i, + len += sprintf(buf+len, "i2c-%d\t%s\t%-32s\t%-32s\n", + i2c_adapter_id(i2cproc_adapters[i]), i2c_is_smbus_adapter(i2cproc_adapters[i])?"smbus": #ifdef DEBUG i2c_is_isa_adapter(i2cproc_adapters[i])?"isa": @@ -356,7 +359,7 @@ int i2cproc_attach_adapter(struct i2c_adapter *adapter) } i2cproc_adapters[i] = adapter; - sprintf(name,"i2c-%d",i); + sprintf(name,"i2c-%d",i2c_adapter_id(adapter)); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) proc_entry = create_proc_entry(name,0,proc_bus); @@ -413,7 +416,7 @@ int i2cproc_detach_client(struct i2c_client *client) for (i = 0; i < I2C_ADAP_MAX; i++) if (client->adapter == i2cproc_adapters[i]) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) - sprintf(name,"i2c-%d",i); + sprintf(name,"i2c-%d",i2c_adapter_id(i2cproc_adapters[i])); remove_proc_entry(name,proc_bus); #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ if ((res = proc_unregister(&proc_bus_dir, diff --git a/src/isa.c b/src/isa.c index 176f54e8..7294f91c 100644 --- a/src/isa.c +++ b/src/isa.c @@ -79,8 +79,8 @@ int isa_master_xfer (struct isa_adapter *adap, struct i2c_msg msgs[], printk("isa.o: isa_master_xfer called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Algorithm slave_send call-back implementation. Can't do that... */ @@ -90,8 +90,8 @@ int isa_slave_send (struct isa_adapter *adap, char *data, int len) printk("isa.o: isa_slave_send called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Algorithm slave_recv call-back implementation. Can't do that... */ @@ -101,8 +101,8 @@ int isa_slave_recv (struct isa_adapter *adap, char *data, int len) printk("isa.o: isa_slave_recv called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Here we can put additional calls to modify the workings of the algorithm. diff --git a/src/smbus.c b/src/smbus.c index 669e7416..d20bfccc 100644 --- a/src/smbus.c +++ b/src/smbus.c @@ -191,8 +191,8 @@ int smbus_master_xfer (struct smbus_adapter *adap, struct i2c_msg msgs[], printk("smbus.o: smbus_master_xfer called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Algorithm slave_send call-back implementation. Can't do that... */ @@ -202,8 +202,8 @@ int smbus_slave_send (struct smbus_adapter *adap, char *data, int len) printk("smbus.o: smbus_slave_send called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Algorithm slave_recv call-back implementation. Can't do that... */ @@ -213,8 +213,8 @@ int smbus_slave_recv (struct smbus_adapter *adap, char *data, int len) printk("smbus.o: smbus_slave_recv called for adapter `%s' " "(no i2c level access possible!)\n", adap->name); - return -1; #endif + return -1; } /* Here we can put additional calls to modify the workings of the algorithm.