diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-05-21 11:26:35 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-05-21 18:31:29 -0400 |
commit | 82f3952c02add60b15eea9151d4d99b6b82066c6 (patch) | |
tree | 31a30c82aaea4472df7f40d98619cb3ae8016816 | |
parent | 4f0447b8184acb1d21b0fd71683d72ef2b83167b (diff) |
fix handling of offsets in cris eeprom.c, get rid of fake on-stack files
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | arch/cris/arch-v10/drivers/eeprom.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c index b04b22ba00d1..c3405507a3d1 100644 --- a/arch/cris/arch-v10/drivers/eeprom.c +++ b/arch/cris/arch-v10/drivers/eeprom.c | |||
@@ -437,10 +437,7 @@ static loff_t eeprom_lseek(struct file * file, loff_t offset, int orig) | |||
437 | 437 | ||
438 | static int eeprom_read_buf(loff_t addr, char * buf, int count) | 438 | static int eeprom_read_buf(loff_t addr, char * buf, int count) |
439 | { | 439 | { |
440 | struct file f; | 440 | return eeprom_read(NULL, buf, count, &addr); |
441 | |||
442 | f.f_pos = addr; | ||
443 | return eeprom_read(&f, buf, count, &addr); | ||
444 | } | 441 | } |
445 | 442 | ||
446 | 443 | ||
@@ -450,7 +447,7 @@ static int eeprom_read_buf(loff_t addr, char * buf, int count) | |||
450 | static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t *off) | 447 | static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t *off) |
451 | { | 448 | { |
452 | int read=0; | 449 | int read=0; |
453 | unsigned long p = file->f_pos; | 450 | unsigned long p = *off; |
454 | 451 | ||
455 | unsigned char page; | 452 | unsigned char page; |
456 | 453 | ||
@@ -495,7 +492,7 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t | |||
495 | 492 | ||
496 | if(read > 0) | 493 | if(read > 0) |
497 | { | 494 | { |
498 | file->f_pos += read; | 495 | *off += read; |
499 | } | 496 | } |
500 | 497 | ||
501 | mutex_unlock(&eeprom.lock); | 498 | mutex_unlock(&eeprom.lock); |
@@ -506,11 +503,7 @@ static ssize_t eeprom_read(struct file * file, char * buf, size_t count, loff_t | |||
506 | 503 | ||
507 | static int eeprom_write_buf(loff_t addr, const char * buf, int count) | 504 | static int eeprom_write_buf(loff_t addr, const char * buf, int count) |
508 | { | 505 | { |
509 | struct file f; | 506 | return eeprom_write(NULL, buf, count, &addr); |
510 | |||
511 | f.f_pos = addr; | ||
512 | |||
513 | return eeprom_write(&f, buf, count, &addr); | ||
514 | } | 507 | } |
515 | 508 | ||
516 | 509 | ||
@@ -534,7 +527,7 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count, | |||
534 | { | 527 | { |
535 | restart = 0; | 528 | restart = 0; |
536 | written = 0; | 529 | written = 0; |
537 | p = file->f_pos; | 530 | p = *off; |
538 | 531 | ||
539 | 532 | ||
540 | while( (written < count) && (p < eeprom.size)) | 533 | while( (written < count) && (p < eeprom.size)) |
@@ -660,10 +653,10 @@ static ssize_t eeprom_write(struct file * file, const char * buf, size_t count, | |||
660 | } /* for */ | 653 | } /* for */ |
661 | 654 | ||
662 | mutex_unlock(&eeprom.lock); | 655 | mutex_unlock(&eeprom.lock); |
663 | if (written == 0 && file->f_pos >= eeprom.size){ | 656 | if (written == 0 && p >= eeprom.size){ |
664 | return -ENOSPC; | 657 | return -ENOSPC; |
665 | } | 658 | } |
666 | file->f_pos += written; | 659 | *off = p; |
667 | return written; | 660 | return written; |
668 | } | 661 | } |
669 | 662 | ||