Changeset 160
- Timestamp:
- 01/13/99 20:07:57 (10 years ago)
- Files:
-
- lm-sensors/trunk/TODO (modified) (1 diff)
- lm-sensors/trunk/kernel/i2c-dev.c (modified) (14 diffs)
- lm-sensors/trunk/kernel/include/i2c-dev.h (modified) (4 diffs)
- lm-sensors/trunk/src/i2c-dev.c (modified) (14 diffs)
- lm-sensors/trunk/src/i2c-dev.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lm-sensors/trunk/TODO
r159 r160 1 1 Many, many things. Most notably: 2 2 3 * Check for block read/writes in smbus-on-i2c emulation code 3 4 * Merge newest Simon Vogl archive 4 5 * Merge man-pages lm-sensors/trunk/kernel/i2c-dev.c
r158 r160 29 29 #include "compat.h" 30 30 #include "i2c.h" 31 #include "smbus.h" 31 32 #include "isa.h" 32 33 #include "sensors.h" 33 34 #include "version.h" 35 #include "i2c-dev.h" 34 36 35 37 #ifdef MODULE … … 145 147 #endif 146 148 { 149 #ifdef DEBUG 150 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,56)) 151 struct inode *inode = file->f_dentry->d_inode; 152 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) */ 153 printk("i2c_dev,o: i2c-%d lseek to %ld bytes relative to %d.\n", 154 MINOR(inode->i_rdev),offset,origin); 155 #endif /* DEBUG */ 147 156 return -ESPIPE; 148 157 } … … 162 171 int ret; 163 172 173 #ifdef DEBUG 174 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) 175 struct inode *inode = file->f_dentry->d_inode; 176 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) */ 177 #endif /* DEBUG */ 178 164 179 struct i2c_client *client = (struct i2c_client *)file->private_data; 165 166 #ifdef DEBUG167 printk("i2cdev_read: i2c%d reading %d bytes from %d.\n",minor,count,168 client->addr);169 #endif170 180 171 181 /* copy user space data to kernel space. */ … … 173 183 if (tmp==NULL) 174 184 return -ENOMEM; 185 186 #ifdef DEBUG 187 printk("i2c_dev,o: i2c-%d reading %d bytes.\n",MINOR(inode->i_rdev),count); 188 #endif 189 175 190 ret = i2c_master_recv(client,tmp,count); 176 191 copy_to_user(buf,tmp,count); … … 194 209 struct i2c_client *client = (struct i2c_client *)file->private_data; 195 210 211 #ifdef DEBUG 212 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) 213 struct inode *inode = file->f_dentry->d_inode; 214 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) */ 215 #endif /* DEBUG */ 216 196 217 /* copy user space data to kernel space. */ 197 218 tmp = kmalloc(count,GFP_KERNEL); … … 201 222 202 223 #ifdef DEBUG 203 printk("i2c_ write: i2c%d writing %d bytes.\n",minor,count);224 printk("i2c_dev,o: i2c-%d writing %d bytes.\n",MINOR(inode->i_rdev),count); 204 225 #endif 205 226 ret = i2c_master_send(client,tmp,count); … … 208 229 } 209 230 210 231 int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd, 232 unsigned long arg) 233 { 234 struct i2c_client *client = (struct i2c_client *)file->private_data; 235 struct i2c_smbus_data *data_arg; 236 union smbus_data temp; 237 int ver,datasize,res; 238 239 #ifdef DEBUG 240 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) 241 struct inode *inode = file->f_dentry->d_inode; 242 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) */ 243 printk("i2c_dev.o: i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n", 244 MINOR(inode->i_rdev),cmd, arg); 245 #endif /* DEBUG */ 246 247 switch ( cmd ) { 248 case I2C_SLAVE: 249 if (arg > 0x7f) 250 return -EINVAL; 251 client->addr = arg; 252 return 0; 253 case I2C_TENBIT: 254 printk("i2c-dev.o: ioctl I2C_TENBIT not (yet) supported!\n"); 255 return -EINVAL; 256 case I2C_SMBUS: 257 if (! (data_arg = (struct i2c_smbus_data *) arg)) { 258 #ifdef DEBUG 259 printk("i2c-dev.o: NULL argument pointer in ioctl I2C_SMBUS.\n"); 260 #endif 261 return -EINVAL; 262 } 263 if (verify_area(VERIFY_READ,data_arg,sizeof(struct i2c_smbus_data))) { 264 #ifdef DEBUG 265 printk("i2c-dev.o: invalid argument pointer (%p) " 266 "in IOCTL I2C_SMBUS.\n", data_arg); 267 #endif 268 return -EINVAL; 269 } 270 if ((data_arg->size != SMBUS_BYTE) && 271 (data_arg->size != SMBUS_QUICK) && 272 (data_arg->size != SMBUS_BYTE_DATA) && 273 (data_arg->size != SMBUS_WORD_DATA) && 274 (data_arg->size != SMBUS_PROC_CALL) && 275 (data_arg->size != SMBUS_BLOCK_DATA)) { 276 #ifdef DEBUG 277 printk("i2c-dev.o: size out of range (%x) in ioctl I2C_SMBUS.\n", 278 data_arg->size); 279 #endif 280 return -EINVAL; 281 } 282 /* Note that SMBUS_READ and SMBUS_WRITE are 0 and 1, so the check is 283 valid if size==SMBUS_QUICK too. */ 284 if ((data_arg->read_write != SMBUS_READ) && 285 (data_arg->read_write != SMBUS_WRITE)) { 286 #ifdef DEBUG 287 printk("i2c-dev.o: read_write out of range (%x) in ioctl I2C_SMBUS.\n", 288 data_arg->read_write); 289 #endif 290 return -EINVAL; 291 } 292 293 /* Note that command values are always valid! */ 294 295 if ((data_arg->size == SMBUS_QUICK) || 296 ((data_arg->size == SMBUS_BYTE) && 297 (data_arg->read_write == SMBUS_WRITE))) 298 /* These are special: we do not use data */ 299 return smbus_access(client->adapter, client->addr, 300 data_arg->read_write, data_arg->command, 301 data_arg->size, NULL); 302 303 if (data_arg->data == NULL) { 304 #ifdef DEBUG 305 printk("i2c-dev.o: data is NULL pointer in ioctl I2C_SMBUS.\n"); 306 #endif 307 return -EINVAL; 308 } 309 310 /* This seems unlogical but it is not: if the user wants to read a 311 value, we must write that value to user memory! */ 312 ver = (data_arg->read_write == SMBUS_WRITE)?VERIFY_READ:VERIFY_WRITE; 313 314 if ((data_arg->size == SMBUS_BYTE_DATA) || (data_arg->size == SMBUS_BYTE)) 315 datasize = sizeof(data_arg->data->byte); 316 else if (data_arg->size == SMBUS_WORD_DATA) 317 datasize = sizeof(data_arg->data->word); 318 else /* size == SMBUS_BLOCK_DATA */ 319 datasize = sizeof(data_arg->data->block); 320 321 if (verify_area(ver,data_arg->data,datasize)) { 322 #ifdef DEBUG 323 printk("i2c-dev.o: invalid pointer data (%p) in ioctl I2C_SMBUS.\n", 324 data_arg->data); 325 #endif 326 return -EINVAL; 327 } 328 if (data_arg->read_write == SMBUS_WRITE) { 329 copy_from_user(&temp,data_arg->data,datasize); 330 return smbus_access(client->adapter,client->addr,data_arg->read_write, 331 data_arg->command,data_arg->size,&temp); 332 } else { 333 res = smbus_access(client->adapter,client->addr,data_arg->read_write, 334 data_arg->command,data_arg->size,&temp); 335 if (!res) 336 copy_to_user(data_arg->data,&temp,datasize); 337 return res; 338 } 339 default: 340 return i2c_control(client,cmd,arg); 341 } 342 return 0; 343 } 344 211 345 int i2cdev_open (struct inode *inode, struct file *file) 212 346 { … … 216 350 if (! i2cdev_clients[minor]) { 217 351 #ifdef DEBUG 218 printk("i2c dev: trying to open unattached adapter i2c-%d\n",minor);352 printk("i2c-dev.o: Trying to open unattached adapter i2c-%d\n",minor); 219 353 #endif 220 354 return -ENODEV; … … 232 366 233 367 #ifdef DEBUG 234 printk("i2c dev_open:i2c-%d\n",minor);368 printk("i2c-dev.o: opened i2c-%d\n",minor); 235 369 #endif 236 370 return 0; … … 246 380 file->private_data=NULL; 247 381 #ifdef DEBUG 248 printk("i2c _close: i2c-%d\n", MINOR(inode->i_rdev));382 printk("i2c-dev.o: Closed: i2c-%d\n", MINOR(inode->i_rdev)); 249 383 #endif 250 384 MOD_DEC_USE_COUNT; … … 260 394 261 395 if ((i = i2c_adapter_id(adap)) < 0) { 262 printk("i2c dev_attach_adapter: unknown adapter?!?\n");396 printk("i2c-dev.o: Unknown adapter to attach?!?\n"); 263 397 return -ENODEV; 264 398 } 265 399 if (i >= I2CDEV_CLIENTS_MAX) { 266 printk("i2c dev_attach_adapter: adapter numbertoo large?!? (%d)\n",i);400 printk("i2c-dev.o: Adapter number to attach too large?!? (%d)\n",i); 267 401 return -ENODEV; 268 402 } 269 403 if (i2cdev_clients[i]) { 270 printk("i2c dev_attach_adapter: adapteralready in use?!? (%d)\n",i);404 printk("i2c-dev.o: Adapter to attach already in use?!? (%d)\n",i); 271 405 return -EBUSY; 272 406 } 273 407 if (i2c_is_isa_adapter(adap)) { 274 printk("i2cdev_attach_adapter: Can't open ISA adapter!\n"); 275 return -ENODEV; 408 #ifdef DEBUG 409 printk("i2c-dev.o: Can't open ISA adapter!\n"); 410 #endif 411 return 0; 276 412 } 277 413 … … 282 418 client->adapter = adap; 283 419 if ((res = i2c_attach_client(client))) { 284 printk("i2c dev_attach_adapter: attaching client failed.\n");420 printk("i2c-dev.o: Attaching client failed.\n"); 285 421 kfree(client); 286 422 return res; 287 423 } 288 424 i2cdev_clients[i] = client; 289 printk("i2cdev : registered '%s' as minor %d\n",adap->name,i);425 printk("i2cdev.o: Registered '%s' as minor %d\n",adap->name,i); 290 426 return 0; 291 427 } … … 297 433 298 434 if ((i = i2c_adapter_id(adap)) < 0) { 299 printk("i2c dev_detach_adapter:unknown adapter?!?\n");435 printk("i2c-dev.o: Detaching unknown adapter?!?\n"); 300 436 return -ENODEV; 301 437 } 302 438 if (i >= I2CDEV_CLIENTS_MAX) { 303 printk("i2c dev_detach_adapter: adapter numbertoo large?!? (%d)\n",i);439 printk("i2c-dev.o: Adapter number to detach too large?!? (%d)\n",i); 304 440 return -ENODEV; 305 441 } 306 442 if (!i2cdev_clients[i]) { 307 printk("i2c dev_detach_adapter: adapternot in use?!? (%d)\n",i);443 printk("i2c-dev.o: Adapter to detach not in use?!? (%d)\n",i); 308 444 return -ENODEV; 309 445 } 310 446 311 447 if ((res = i2c_detach_client(client))) { 312 printk("i2c dev_detach_adapter: detaching client failed.\n");448 printk("i2c-dev.o: detaching client %d failed.\n",i); 313 449 return res; 314 450 } … … 318 454 319 455 #ifdef DEBUG 320 printk("i2c (char): adapter unregistered: %s\n",adap->name);456 printk("i2c-dev.o: Adapter unregistered: %s\n",adap->name); 321 457 #endif 322 458 return 0; lm-sensors/trunk/kernel/include/i2c-dev.h
r159 r160 24 24 #ifdef LM_SENSORS 25 25 #include "i2c.h" 26 #include "smbus.h" 26 27 #else /* ndef LM_SENSORS */ 27 28 #include <linux/i2c.h> 29 #include <linux/smbus.h> 28 30 #endif /* def LM_SENSORS */ 29 31 … … 35 37 /* This is the structure as used in the I2C_SMBUS ioctl call */ 36 38 struct i2c_smbus_data { 37 char read_write ,38 u8 command ,39 int size ,40 union smbus_data data39 char read_write; 40 u8 command; 41 int size; 42 union smbus_data *data; 41 43 }; 44 45 #ifndef __KERNEL__ 46 47 #include <linux/ioctl.h> 42 48 43 49 extern inline s32 i2c_smbus_access(int file, char read_write, u8 command, … … 50 56 args.command = command; 51 57 args.size = size; 52 if (data) 53 memcpy(&args.data,data,sizeof(union smbus_data)); 54 res = ioctl(f,I2C_SMBUS,&args); 55 if (data) 56 memcpy(data,&args,sizeof(union smbus_data)); 57 return res; 58 args.data = data; 59 return ioctl(file,I2C_SMBUS,&args); 58 60 } 59 61 … … 148 150 } 149 151 152 #endif /* ndef __KERNEL__ */ 153 150 154 #endif lm-sensors/trunk/src/i2c-dev.c
r158 r160 29 29 #include "compat.h" 30 30 #include "i2c.h" 31 #include "smbus.h" 31 32 #include "isa.h" 32 33 #include "sensors.h" 33 34 #include "version.h" 35 #include "i2c-dev.h" 34 36 35 37 #ifdef MODULE … … 145 147 #endif 146 148 { 149 #ifdef DEBUG 150 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,56)) 151 struct inode *inode = file->f_dentry->d_inode; 152 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) */ 153 printk("i2c_dev,o: i2c-%d lseek to %ld bytes relative to %d.\n", 154 MINOR(inode->i_rdev),offset,origin); 155 #endif /* DEBUG */ 147 156 return -ESPIPE; 148 157 } … … 162 171 int ret; 163 172 173 #ifdef DEBUG 174 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) 175 struct inode *inode = file->f_dentry->d_inode; 176 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) */ 177 #endif /* DEBUG */ 178 164 179 struct i2c_client *client = (struct i2c_client *)file->private_data; 165 166 #ifdef DEBUG167 printk("i2cdev_read: i2c%d reading %d bytes from %d.\n",minor,count,168 client->addr);169 #endif170 180 171 181 /* copy user space data to kernel space. */ … … 173 183 if (tmp==NULL) 174 184 return -ENOMEM; 185 186 #ifdef DEBUG 187 printk("i2c_dev,o: i2c-%d reading %d bytes.\n",MINOR(inode->i_rdev),count); 188 #endif 189 175 190 ret = i2c_master_recv(client,tmp,count); 176 191 copy_to_user(buf,tmp,count); … … 194 209 struct i2c_client *client = (struct i2c_client *)file->private_data; 195 210 211 #ifdef DEBUG 212 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) 213 struct inode *inode = file->f_dentry->d_inode; 214 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) */ 215 #endif /* DEBUG */ 216 196 217 /* copy user space data to kernel space. */ 197 218 tmp = kmalloc(count,GFP_KERNEL); … … 201 222 202 223 #ifdef DEBUG 203 printk("i2c_ write: i2c%d writing %d bytes.\n",minor,count);224 printk("i2c_dev,o: i2c-%d writing %d bytes.\n",MINOR(inode->i_rdev),count); 204 225 #endif 205 226 ret = i2c_master_send(client,tmp,count); … … 208 229 } 209 230 210 231 int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd, 232 unsigned long arg) 233 { 234 struct i2c_client *client = (struct i2c_client *)file->private_data; 235 struct i2c_smbus_data *data_arg; 236 union smbus_data temp; 237 int ver,datasize,res; 238 239 #ifdef DEBUG 240 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) 241 struct inode *inode = file->f_dentry->d_inode; 242 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,70)) */ 243 printk("i2c_dev.o: i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n", 244 MINOR(inode->i_rdev),cmd, arg); 245 #endif /* DEBUG */ 246 247 switch ( cmd ) { 248 case I2C_SLAVE: 249 if (arg > 0x7f) 250 return -EINVAL; 251 client->addr = arg; 252 return 0; 253 case I2C_TENBIT: 254 printk("i2c-dev.o: ioctl I2C_TENBIT not (yet) supported!\n"); 255 return -EINVAL; 256 case I2C_SMBUS: 257 if (! (data_arg = (struct i2c_smbus_data *) arg)) { 258 #ifdef DEBUG 259 printk("i2c-dev.o: NULL argument pointer in ioctl I2C_SMBUS.\n"); 260 #endif 261 return -EINVAL; 262 } 263 if (verify_area(VERIFY_READ,data_arg,sizeof(struct i2c_smbus_data))) { 264 #ifdef DEBUG 265 printk("i2c-dev.o: invalid argument pointer (%p) " 266 "in IOCTL I2C_SMBUS.\n", data_arg); 267 #endif 268 return -EINVAL; 269 } 270 if ((data_arg->size != SMBUS_BYTE) && 271 (data_arg->size != SMBUS_QUICK) && 272 (data_arg->size != SMBUS_BYTE_DATA) && 273 (data_arg->size != SMBUS_WORD_DATA) && 274 (data_arg->size != SMBUS_PROC_CALL) && 275 (data_arg->size != SMBUS_BLOCK_DATA)) { 276 #ifdef DEBUG 277 printk("i2c-dev.o: size out of range (%x) in ioctl I2C_SMBUS.\n", 278 data_arg->size); 279 #endif 280 return -EINVAL; 281 } 282 /* Note that SMBUS_READ and SMBUS_WRITE are 0 and 1, so the check is 283 valid if size==SMBUS_QUICK too. */ 284 if ((data_arg->read_write != SMBUS_READ) && 285 (data_arg->read_write != SMBUS_WRITE)) { 286 #ifdef DEBUG 287 printk("i2c-dev.o: read_write out of range (%x) in ioctl I2C_SMBUS.\n", 288 data_arg->read_write); 289 #endif 290 return -EINVAL; 291 } 292 293 /* Note that command values are always valid! */ 294 295 if ((data_arg->size == SMBUS_QUICK) || 296 ((data_arg->size == SMBUS_BYTE) && 297 (data_arg->read_write == SMBUS_WRITE))) 298 /* These are special: we do not use data */ 299 return smbus_access(client->adapter, client->addr, 300 data_arg->read_write, data_arg->command, 301 data_arg->size, NULL); 302 303 if (data_arg->data == NULL) { 304 #ifdef DEBUG 305 printk("i2c-dev.o: data is NULL pointer in ioctl I2C_SMBUS.\n"); 306 #endif 307 return -EINVAL; 308 } 309 310 /* This seems unlogical but it is not: if the user wants to read a 311 value, we must write that value to user memory! */ 312 ver = (data_arg->read_write == SMBUS_WRITE)?VERIFY_READ:VERIFY_WRITE; 313 314 if ((data_arg->size == SMBUS_BYTE_DATA) || (data_arg->size == SMBUS_BYTE)) 315 datasize = sizeof(data_arg->data->byte); 316 else if (data_arg->size == SMBUS_WORD_DATA) 317 datasize = sizeof(data_arg->data->word); 318 else /* size == SMBUS_BLOCK_DATA */ 319 datasize = sizeof(data_arg->data->block); 320 321 if (verify_area(ver,data_arg->data,datasize)) { 322 #ifdef DEBUG 323 printk("i2c-dev.o: invalid pointer data (%p) in ioctl I2C_SMBUS.\n", 324 data_arg->data); 325 #endif 326 return -EINVAL; 327 } 328 if (data_arg->read_write == SMBUS_WRITE) { 329 copy_from_user(&temp,data_arg->data,datasize); 330 return smbus_access(client->adapter,client->addr,data_arg->read_write, 331 data_arg->command,data_arg->size,&temp); 332 } else { 333 res = smbus_access(client->adapter,client->addr,data_arg->read_write, 334 data_arg->command,data_arg->size,&temp); 335 if (!res) 336 copy_to_user(data_arg->data,&temp,datasize); 337 return res; 338 } 339 default: 340 return i2c_control(client,cmd,arg); 341 } 342 return 0; 343 } 344 211 345 int i2cdev_open (struct inode *inode, struct file *file) 212 346 { … … 216 350 if (! i2cdev_clients[minor]) { 217 351 #ifdef DEBUG 218 printk("i2c dev: trying to open unattached adapter i2c-%d\n",minor);352 printk("i2c-dev.o: Trying to open unattached adapter i2c-%d\n",minor); 219 353 #endif 220 354 return -ENODEV; … … 232 366 233 367 #ifdef DEBUG 234 printk("i2c dev_open:i2c-%d\n",minor);368 printk("i2c-dev.o: opened i2c-%d\n",minor); 235 369 #endif 236 370 return 0; … … 246 380 file->private_data=NULL; 247 381 #ifdef DEBUG 248 printk("i2c _close: i2c-%d\n", MINOR(inode->i_rdev));382 printk("i2c-dev.o: Closed: i2c-%d\n", MINOR(inode->i_rdev)); 249 383 #endif 250 384 MOD_DEC_USE_COUNT; … … 260 394 261 395 if ((i = i2c_adapter_id(adap)) < 0) { 262 printk("i2c dev_attach_adapter: unknown adapter?!?\n");396 printk("i2c-dev.o: Unknown adapter to attach?!?\n"); 263 397 return -ENODEV; 264 398 } 265 399 if (i >= I2CDEV_CLIENTS_MAX) { 266 printk("i2c dev_attach_adapter: adapter numbertoo large?!? (%d)\n",i);400 printk("i2c-dev.o: Adapter number to attach too large?!? (%d)\n",i); 267 401 return -ENODEV; 268 402 } 269 403 if (i2cdev_clients[i]) { 270 printk("i2c dev_attach_adapter: adapteralready in use?!? (%d)\n",i);404 printk("i2c-dev.o: Adapter to attach already in use?!? (%d)\n",i); 271 405 return -EBUSY; 272 406 } 273 407 if (i2c_is_isa_adapter(adap)) { 274 printk("i2cdev_attach_adapter: Can't open ISA adapter!\n"); 275 return -ENODEV; 408 #ifdef DEBUG 409 printk("i2c-dev.o: Can't open ISA adapter!\n"); 410 #endif 411 return 0; 276 412 } 277 413 … … 282 418 client->adapter = adap; 283 419 if ((res = i2c_attach_client(client))) { 284 printk("i2c dev_attach_adapter: attaching client failed.\n");420 printk("i2c-dev.o: Attaching client failed.\n"); 285 421 kfree(client); 286 422 return res; 287 423 } 288 424 i2cdev_clients[i] = client; 289 printk("i2cdev : registered '%s' as minor %d\n",adap->name,i);425 printk("i2cdev.o: Registered '%s' as minor %d\n",adap->name,i); 290 426 return 0; 291 427 } … … 297 433 298 434 if ((i = i2c_adapter_id(adap)) < 0) { 299 printk("i2c dev_detach_adapter:unknown adapter?!?\n");435 printk("i2c-dev.o: Detaching unknown adapter?!?\n"); 300 436 return -ENODEV; 301 437 } 302 438 if (i >= I2CDEV_CLIENTS_MAX) { 303 printk("i2c dev_detach_adapter: adapter numbertoo large?!? (%d)\n",i);439 printk("i2c-dev.o: Adapter number to detach too large?!? (%d)\n",i); 304 440 return -ENODEV; 305 441 } 306 442 if (!i2cdev_clients[i]) { 307 printk("i2c dev_detach_adapter: adapternot in use?!? (%d)\n",i);443 printk("i2c-dev.o: Adapter to detach not in use?!? (%d)\n",i); 308 444 return -ENODEV; 309 445 } 310 446 311 447 if ((res = i2c_detach_client(client))) { 312 printk("i2c dev_detach_adapter: detaching client failed.\n");448 printk("i2c-dev.o: detaching client %d failed.\n",i); 313 449 return res; 314 450 } … … 318 454 319 455 #ifdef DEBUG 320 printk("i2c (char): adapter unregistered: %s\n",adap->name);456 printk("i2c-dev.o: Adapter unregistered: %s\n",adap->name); 321 457 #endif 322 458 return 0; lm-sensors/trunk/src/i2c-dev.h
r159 r160 24 24 #ifdef LM_SENSORS 25 25 #include "i2c.h" 26 #include "smbus.h" 26 27 #else /* ndef LM_SENSORS */ 27 28 #include <linux/i2c.h> 29 #include <linux/smbus.h> 28 30 #endif /* def LM_SENSORS */ 29 31 … … 35 37 /* This is the structure as used in the I2C_SMBUS ioctl call */ 36 38 struct i2c_smbus_data { 37 char read_write ,38 u8 command ,39 int size ,40 union smbus_data data39 char read_write; 40 u8 command; 41 int size; 42 union smbus_data *data; 41 43 }; 44 45 #ifndef __KERNEL__ 46 47 #include <linux/ioctl.h> 42 48 43 49 extern inline s32 i2c_smbus_access(int file, char read_write, u8 command, … … 50 56 args.command = command; 51 57 args.size = size; 52 if (data) 53 memcpy(&args.data,data,sizeof(union smbus_data)); 54 res = ioctl(f,I2C_SMBUS,&args); 55 if (data) 56 memcpy(data,&args,sizeof(union smbus_data)); 57 return res; 58 args.data = data; 59 return ioctl(file,I2C_SMBUS,&args); 58 60 } 59 61 … … 148 150 } 149 151 152 #endif /* ndef __KERNEL__ */ 153 150 154 #endif
