Changeset 165
- Timestamp:
- 01/13/99 21:47:52 (14 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 5 modified
-
kernel/i2c-dev.c (modified) (8 diffs)
-
kernel/i2c-proc.c (modified) (1 diff)
-
prog/dump/i2cdump.c (modified) (2 diffs)
-
src/i2c-dev.c (modified) (8 diffs)
-
src/i2c-proc.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/i2c-dev.c
r160 r165 233 233 { 234 234 struct i2c_client *client = (struct i2c_client *)file->private_data; 235 struct i2c_smbus_data *data_arg;235 struct i2c_smbus_data data_arg; 236 236 union smbus_data temp; 237 237 int ver,datasize,res; … … 255 255 return -EINVAL; 256 256 case I2C_SMBUS: 257 if (! (data_arg = (struct i2c_smbus_data *) arg)) {257 if (! arg) { 258 258 #ifdef DEBUG 259 259 printk("i2c-dev.o: NULL argument pointer in ioctl I2C_SMBUS.\n"); … … 261 261 return -EINVAL; 262 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)) { 263 if (verify_area(VERIFY_READ,(struct i2c_smbus_data *) arg, 264 sizeof(struct i2c_smbus_data))) { 265 #ifdef DEBUG 266 printk("i2c-dev.o: invalid argument pointer (%ld) " 267 "in IOCTL I2C_SMBUS.\n", arg); 268 #endif 269 return -EINVAL; 270 } 271 copy_from_user(&data_arg,(struct i2c_smbus_data *) arg, 272 sizeof(struct i2c_smbus_data)); 273 if ((data_arg.size != SMBUS_BYTE) && 274 (data_arg.size != SMBUS_QUICK) && 275 (data_arg.size != SMBUS_BYTE_DATA) && 276 (data_arg.size != SMBUS_WORD_DATA) && 277 (data_arg.size != SMBUS_PROC_CALL) && 278 (data_arg.size != SMBUS_BLOCK_DATA)) { 276 279 #ifdef DEBUG 277 280 printk("i2c-dev.o: size out of range (%x) in ioctl I2C_SMBUS.\n", 278 data_arg ->size);281 data_arg.size); 279 282 #endif 280 283 return -EINVAL; … … 282 285 /* Note that SMBUS_READ and SMBUS_WRITE are 0 and 1, so the check is 283 286 valid if size==SMBUS_QUICK too. */ 284 if ((data_arg ->read_write != SMBUS_READ) &&285 (data_arg ->read_write != SMBUS_WRITE)) {287 if ((data_arg.read_write != SMBUS_READ) && 288 (data_arg.read_write != SMBUS_WRITE)) { 286 289 #ifdef DEBUG 287 290 printk("i2c-dev.o: read_write out of range (%x) in ioctl I2C_SMBUS.\n", 288 data_arg ->read_write);291 data_arg.read_write); 289 292 #endif 290 293 return -EINVAL; … … 293 296 /* Note that command values are always valid! */ 294 297 295 if ((data_arg ->size == SMBUS_QUICK) ||296 ((data_arg ->size == SMBUS_BYTE) &&297 (data_arg ->read_write == SMBUS_WRITE)))298 if ((data_arg.size == SMBUS_QUICK) || 299 ((data_arg.size == SMBUS_BYTE) && 300 (data_arg.read_write == SMBUS_WRITE))) 298 301 /* These are special: we do not use data */ 299 302 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) {303 data_arg.read_write, data_arg.command, 304 data_arg.size, NULL); 305 306 if (data_arg.data == NULL) { 304 307 #ifdef DEBUG 305 308 printk("i2c-dev.o: data is NULL pointer in ioctl I2C_SMBUS.\n"); … … 310 313 /* This seems unlogical but it is not: if the user wants to read a 311 314 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);315 ver = (data_arg.read_write == SMBUS_WRITE)?VERIFY_READ:VERIFY_WRITE; 316 317 if ((data_arg.size == SMBUS_BYTE_DATA) || (data_arg.size == SMBUS_BYTE)) 318 datasize = sizeof(data_arg.data->byte); 319 else if (data_arg.size == SMBUS_WORD_DATA) 320 datasize = sizeof(data_arg.data->word); 318 321 else /* size == SMBUS_BLOCK_DATA */ 319 datasize = sizeof(data_arg ->data->block);320 321 if (verify_area(ver,data_arg ->data,datasize)) {322 datasize = sizeof(data_arg.data->block); 323 324 if (verify_area(ver,data_arg.data,datasize)) { 322 325 #ifdef DEBUG 323 326 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);327 data_arg.data); 328 #endif 329 return -EINVAL; 330 } 331 if (data_arg.read_write == SMBUS_WRITE) { 332 copy_from_user(&temp,data_arg.data,datasize); 333 return smbus_access(client->adapter,client->addr,data_arg.read_write, 334 data_arg.command,data_arg.size,&temp); 332 335 } else { 333 res = smbus_access(client->adapter,client->addr,data_arg ->read_write,334 data_arg ->command,data_arg->size,&temp);336 res = smbus_access(client->adapter,client->addr,data_arg.read_write, 337 data_arg.command,data_arg.size,&temp); 335 338 if (!res) 336 copy_to_user(data_arg ->data,&temp,datasize);339 copy_to_user(data_arg.data,&temp,datasize); 337 340 return res; 338 341 } … … 407 410 if (i2c_is_isa_adapter(adap)) { 408 411 #ifdef DEBUG 409 printk("i2c-dev.o: Can't openISA adapter!\n");412 printk("i2c-dev.o: Can't attach ISA adapter!\n"); 410 413 #endif 411 414 return 0; … … 423 426 } 424 427 i2cdev_clients[i] = client; 425 printk("i2c dev.o: Registered '%s' as minor %d\n",adap->name,i);428 printk("i2c-dev.o: Registered '%s' as minor %d\n",adap->name,i); 426 429 return 0; 427 430 } -
lm-sensors/trunk/kernel/i2c-proc.c
r158 r165 302 302 /* Filter out dummy clients */ 303 303 #ifndef DEBUG 304 if (client->driver->id != I2C_DRIVERID_I2CPROC) 304 if ((client->driver->id != I2C_DRIVERID_I2CPROC) && 305 (client->driver->id != I2C_DRIVERID_I2CDEV)) 305 306 #endif /* ndef DEBUG */ 306 307 len += sprintf(kbuf+len,"%x\t%-32s\t%-32s\n", -
lm-sensors/trunk/prog/dump/i2cdump.c
r163 r165 96 96 } 97 97 98 fprintf(stderr," WARNING! Running this program can confuse your I2C bus, "98 fprintf(stderr," WARNING! This program can confuse your I2C bus, " 99 99 "cause data loss and worse!\n"); 100 100 fprintf(stderr," I will probe file %s, address %x, mode %s\n", … … 121 121 printf("%02x: ",i); 122 122 for(j = 0; j < 8; j++) { 123 res = i2c_smbus_read_ byte_data(file,i+j);123 res = i2c_smbus_read_word_data(file,i+j); 124 124 if (res < 0) 125 125 printf("XXXX "); -
lm-sensors/trunk/src/i2c-dev.c
r160 r165 233 233 { 234 234 struct i2c_client *client = (struct i2c_client *)file->private_data; 235 struct i2c_smbus_data *data_arg;235 struct i2c_smbus_data data_arg; 236 236 union smbus_data temp; 237 237 int ver,datasize,res; … … 255 255 return -EINVAL; 256 256 case I2C_SMBUS: 257 if (! (data_arg = (struct i2c_smbus_data *) arg)) {257 if (! arg) { 258 258 #ifdef DEBUG 259 259 printk("i2c-dev.o: NULL argument pointer in ioctl I2C_SMBUS.\n"); … … 261 261 return -EINVAL; 262 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)) { 263 if (verify_area(VERIFY_READ,(struct i2c_smbus_data *) arg, 264 sizeof(struct i2c_smbus_data))) { 265 #ifdef DEBUG 266 printk("i2c-dev.o: invalid argument pointer (%ld) " 267 "in IOCTL I2C_SMBUS.\n", arg); 268 #endif 269 return -EINVAL; 270 } 271 copy_from_user(&data_arg,(struct i2c_smbus_data *) arg, 272 sizeof(struct i2c_smbus_data)); 273 if ((data_arg.size != SMBUS_BYTE) && 274 (data_arg.size != SMBUS_QUICK) && 275 (data_arg.size != SMBUS_BYTE_DATA) && 276 (data_arg.size != SMBUS_WORD_DATA) && 277 (data_arg.size != SMBUS_PROC_CALL) && 278 (data_arg.size != SMBUS_BLOCK_DATA)) { 276 279 #ifdef DEBUG 277 280 printk("i2c-dev.o: size out of range (%x) in ioctl I2C_SMBUS.\n", 278 data_arg ->size);281 data_arg.size); 279 282 #endif 280 283 return -EINVAL; … … 282 285 /* Note that SMBUS_READ and SMBUS_WRITE are 0 and 1, so the check is 283 286 valid if size==SMBUS_QUICK too. */ 284 if ((data_arg ->read_write != SMBUS_READ) &&285 (data_arg ->read_write != SMBUS_WRITE)) {287 if ((data_arg.read_write != SMBUS_READ) && 288 (data_arg.read_write != SMBUS_WRITE)) { 286 289 #ifdef DEBUG 287 290 printk("i2c-dev.o: read_write out of range (%x) in ioctl I2C_SMBUS.\n", 288 data_arg ->read_write);291 data_arg.read_write); 289 292 #endif 290 293 return -EINVAL; … … 293 296 /* Note that command values are always valid! */ 294 297 295 if ((data_arg ->size == SMBUS_QUICK) ||296 ((data_arg ->size == SMBUS_BYTE) &&297 (data_arg ->read_write == SMBUS_WRITE)))298 if ((data_arg.size == SMBUS_QUICK) || 299 ((data_arg.size == SMBUS_BYTE) && 300 (data_arg.read_write == SMBUS_WRITE))) 298 301 /* These are special: we do not use data */ 299 302 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) {303 data_arg.read_write, data_arg.command, 304 data_arg.size, NULL); 305 306 if (data_arg.data == NULL) { 304 307 #ifdef DEBUG 305 308 printk("i2c-dev.o: data is NULL pointer in ioctl I2C_SMBUS.\n"); … … 310 313 /* This seems unlogical but it is not: if the user wants to read a 311 314 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);315 ver = (data_arg.read_write == SMBUS_WRITE)?VERIFY_READ:VERIFY_WRITE; 316 317 if ((data_arg.size == SMBUS_BYTE_DATA) || (data_arg.size == SMBUS_BYTE)) 318 datasize = sizeof(data_arg.data->byte); 319 else if (data_arg.size == SMBUS_WORD_DATA) 320 datasize = sizeof(data_arg.data->word); 318 321 else /* size == SMBUS_BLOCK_DATA */ 319 datasize = sizeof(data_arg ->data->block);320 321 if (verify_area(ver,data_arg ->data,datasize)) {322 datasize = sizeof(data_arg.data->block); 323 324 if (verify_area(ver,data_arg.data,datasize)) { 322 325 #ifdef DEBUG 323 326 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);327 data_arg.data); 328 #endif 329 return -EINVAL; 330 } 331 if (data_arg.read_write == SMBUS_WRITE) { 332 copy_from_user(&temp,data_arg.data,datasize); 333 return smbus_access(client->adapter,client->addr,data_arg.read_write, 334 data_arg.command,data_arg.size,&temp); 332 335 } else { 333 res = smbus_access(client->adapter,client->addr,data_arg ->read_write,334 data_arg ->command,data_arg->size,&temp);336 res = smbus_access(client->adapter,client->addr,data_arg.read_write, 337 data_arg.command,data_arg.size,&temp); 335 338 if (!res) 336 copy_to_user(data_arg ->data,&temp,datasize);339 copy_to_user(data_arg.data,&temp,datasize); 337 340 return res; 338 341 } … … 407 410 if (i2c_is_isa_adapter(adap)) { 408 411 #ifdef DEBUG 409 printk("i2c-dev.o: Can't openISA adapter!\n");412 printk("i2c-dev.o: Can't attach ISA adapter!\n"); 410 413 #endif 411 414 return 0; … … 423 426 } 424 427 i2cdev_clients[i] = client; 425 printk("i2c dev.o: Registered '%s' as minor %d\n",adap->name,i);428 printk("i2c-dev.o: Registered '%s' as minor %d\n",adap->name,i); 426 429 return 0; 427 430 } -
lm-sensors/trunk/src/i2c-proc.c
r158 r165 302 302 /* Filter out dummy clients */ 303 303 #ifndef DEBUG 304 if (client->driver->id != I2C_DRIVERID_I2CPROC) 304 if ((client->driver->id != I2C_DRIVERID_I2CPROC) && 305 (client->driver->id != I2C_DRIVERID_I2CDEV)) 305 306 #endif /* ndef DEBUG */ 306 307 len += sprintf(kbuf+len,"%x\t%-32s\t%-32s\n",
