Commit fe91397f authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] applicom warnings and usercopy-in-cli fix

drivers/char/applicom.c: In function `ac_write':
drivers/char/applicom.c:363: warning: int format, different type arg (arg 2)
drivers/char/applicom.c:363: warning: int format, different type arg (arg 3)
drivers/char/applicom.c:363: warning: int format, different type arg (arg 2)
drivers/char/applicom.c:363: warning: int format, different type arg (arg 3)
drivers/char/applicom.c:523:2: warning: #warning "Je suis stupide. DW. - copy*user in cli"
drivers/char/applicom.c: In function `ac_read':
drivers/char/applicom.c:546: warning: int format, different type arg (arg 2)
drivers/char/applicom.c:546: warning: int format, different type arg (arg 3)
drivers/char/applicom.c:546: warning: int format, different type arg (arg 2)
drivers/char/applicom.c:546: warning: int format, different type arg (arg 3)
parent c40853f2
...@@ -359,7 +359,7 @@ static ssize_t ac_write(struct file *file, const char *buf, size_t count, loff_t ...@@ -359,7 +359,7 @@ static ssize_t ac_write(struct file *file, const char *buf, size_t count, loff_t
if (count != sizeof(struct st_ram_io) + sizeof(struct mailbox)) { if (count != sizeof(struct st_ram_io) + sizeof(struct mailbox)) {
static int warncount = 5; static int warncount = 5;
if (warncount) { if (warncount) {
printk(KERN_INFO "Hmmm. write() of Applicom card, length %d != expected %d\n", printk(KERN_INFO "Hmmm. write() of Applicom card, length %zd != expected %zd\n",
count, sizeof(struct st_ram_io) + sizeof(struct mailbox)); count, sizeof(struct st_ram_io) + sizeof(struct mailbox));
warncount--; warncount--;
} }
...@@ -467,18 +467,17 @@ static ssize_t ac_write(struct file *file, const char *buf, size_t count, loff_t ...@@ -467,18 +467,17 @@ static ssize_t ac_write(struct file *file, const char *buf, size_t count, loff_t
return 0; return 0;
} }
static int do_ac_read(int IndexCard, char *buf) static int do_ac_read(int IndexCard, char *buf,
struct st_ram_io *st_loc, struct mailbox *mailbox)
{ {
struct st_ram_io st_loc;
struct mailbox tmpmailbox; /* bounce buffer - can't copy to user space with cli() */
unsigned long from = (unsigned long)apbs[IndexCard].RamIO + RAM_TO_PC; unsigned long from = (unsigned long)apbs[IndexCard].RamIO + RAM_TO_PC;
unsigned char *to = (unsigned char *)&tmpmailbox; unsigned char *to = (unsigned char *)&mailbox;
#ifdef DEBUG #ifdef DEBUG
int c; int c;
#endif #endif
st_loc.tic_owner_to_pc = readb(apbs[IndexCard].RamIO + TIC_OWNER_TO_PC); st_loc->tic_owner_to_pc = readb(apbs[IndexCard].RamIO + TIC_OWNER_TO_PC);
st_loc.numcard_owner_to_pc = readb(apbs[IndexCard].RamIO + NUMCARD_OWNER_TO_PC); st_loc->numcard_owner_to_pc = readb(apbs[IndexCard].RamIO + NUMCARD_OWNER_TO_PC);
{ {
...@@ -501,32 +500,24 @@ static int do_ac_read(int IndexCard, char *buf) ...@@ -501,32 +500,24 @@ static int do_ac_read(int IndexCard, char *buf)
printk("Read from applicom card #%d. struct st_ram_io follows:", NumCard); printk("Read from applicom card #%d. struct st_ram_io follows:", NumCard);
for (c = 0; c < sizeof(struct st_ram_io);) { for (c = 0; c < sizeof(struct st_ram_io);) {
printk("\n%5.5X: %2.2X", c, ((unsigned char *) &st_loc)[c]); printk("\n%5.5X: %2.2X", c, ((unsigned char *)st_loc)[c]);
for (c++; c % 8 && c < sizeof(struct st_ram_io); c++) { for (c++; c % 8 && c < sizeof(struct st_ram_io); c++) {
printk(" %2.2X", ((unsigned char *) &st_loc)[c]); printk(" %2.2X", ((unsigned char *)st_loc)[c]);
} }
} }
printk("\nstruct mailbox follows:"); printk("\nstruct mailbox follows:");
for (c = 0; c < sizeof(struct mailbox);) { for (c = 0; c < sizeof(struct mailbox);) {
printk("\n%5.5X: %2.2X", c, ((unsigned char *) &tmpmailbox)[c]); printk("\n%5.5X: %2.2X", c, ((unsigned char *)mailbox)[c]);
for (c++; c % 8 && c < sizeof(struct mailbox); c++) { for (c++; c % 8 && c < sizeof(struct mailbox); c++) {
printk(" %2.2X", ((unsigned char *) &tmpmailbox)[c]); printk(" %2.2X", ((unsigned char *)mailbox)[c]);
} }
} }
printk("\n"); printk("\n");
#endif #endif
#warning "Je suis stupide. DW. - copy*user in cli"
if (copy_to_user(buf, &st_loc, sizeof(struct st_ram_io)))
return -EFAULT;
if (copy_to_user(&buf[sizeof(struct st_ram_io)], &tmpmailbox, sizeof(struct mailbox)))
return -EFAULT;
return (sizeof(struct st_ram_io) + sizeof(struct mailbox)); return (sizeof(struct st_ram_io) + sizeof(struct mailbox));
} }
...@@ -542,7 +533,7 @@ static ssize_t ac_read (struct file *filp, char *buf, size_t count, loff_t *ptr) ...@@ -542,7 +533,7 @@ static ssize_t ac_read (struct file *filp, char *buf, size_t count, loff_t *ptr)
#endif #endif
/* No need to ratelimit this. Only root can trigger it anyway */ /* No need to ratelimit this. Only root can trigger it anyway */
if (count != sizeof(struct st_ram_io) + sizeof(struct mailbox)) { if (count != sizeof(struct st_ram_io) + sizeof(struct mailbox)) {
printk( KERN_WARNING "Hmmm. read() of Applicom card, length %d != expected %d\n", printk( KERN_WARNING "Hmmm. read() of Applicom card, length %zd != expected %zd\n",
count,sizeof(struct st_ram_io) + sizeof(struct mailbox)); count,sizeof(struct st_ram_io) + sizeof(struct mailbox));
return -EINVAL; return -EINVAL;
} }
...@@ -561,11 +552,19 @@ static ssize_t ac_read (struct file *filp, char *buf, size_t count, loff_t *ptr) ...@@ -561,11 +552,19 @@ static ssize_t ac_read (struct file *filp, char *buf, size_t count, loff_t *ptr)
tmp = readb(apbs[i].RamIO + DATA_TO_PC_READY); tmp = readb(apbs[i].RamIO + DATA_TO_PC_READY);
if (tmp == 2) { if (tmp == 2) {
struct st_ram_io st_loc;
struct mailbox mailbox;
/* Got a packet for us */ /* Got a packet for us */
ret = do_ac_read(i, buf); ret = do_ac_read(i, buf, &st_loc, &mailbox);
spin_unlock_irqrestore(&apbs[i].mutex, flags); spin_unlock_irqrestore(&apbs[i].mutex, flags);
set_current_state(TASK_RUNNING); set_current_state(TASK_RUNNING);
remove_wait_queue(&FlagSleepRec, &wait); remove_wait_queue(&FlagSleepRec, &wait);
if (copy_to_user(buf, &st_loc, sizeof(st_loc)))
return -EFAULT;
if (copy_to_user(buf + sizeof(st_loc), &mailbox, sizeof(mailbox)))
return -EFAULT;
return tmp; return tmp;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment