Skip to content

Commit

Permalink
Merge branch 'rio.b19' of git://git.kernel.org/pub/scm/linux/kernel/g…
Browse files Browse the repository at this point in the history
…it/viro/bird

* 'rio.b19' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/bird:
  [PATCH] missing readb/readw in rio
  [PATCH] copy_to_user() from iomem is a bad thing
  [PATCH] forgotten swap of copyout() arguments
  [PATCH] handling rio MEMDUMP
  [PATCH] fix rio_copy_to_card() for OLDPCI case
  [PATCH] uses of ->Copy() in rioroute are bogus
  [PATCH] bogus order of copy_from_user() arguments
  [PATCH] rio ->Copy() expects the sourse as first argument
  [PATCH] trivial annotations in rio
  • Loading branch information
Linus Torvalds committed Jun 20, 2006
2 parents d9eaec9 + 92af11c commit 077e989
Show file tree
Hide file tree
Showing 17 changed files with 283 additions and 261 deletions.
12 changes: 6 additions & 6 deletions drivers/char/rio/daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct Error {
};

struct DownLoad {
char *DataP;
char __user *DataP;
unsigned int Count;
unsigned int ProductCode;
};
Expand Down Expand Up @@ -83,18 +83,18 @@ struct PortSetup {
struct LpbReq {
unsigned int Host;
unsigned int Link;
struct LPB *LpbP;
struct LPB __user *LpbP;
};

struct RupReq {
unsigned int HostNum;
unsigned int RupNum;
struct RUP *RupP;
struct RUP __user *RupP;
};

struct PortReq {
unsigned int SysPort;
struct Port *PortP;
struct Port __user *PortP;
};

struct StreamInfo {
Expand All @@ -105,12 +105,12 @@ struct StreamInfo {

struct HostReq {
unsigned int HostNum;
struct Host *HostP;
struct Host __user *HostP;
};

struct HostDpRam {
unsigned int HostNum;
struct DpRam *DpRamP;
struct DpRam __user *DpRamP;
};

struct DebugCtrl {
Expand Down
25 changes: 13 additions & 12 deletions drivers/char/rio/func.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int RIOBootCodeRTA(struct rio_info *, struct DownLoad *);
int RIOBootCodeHOST(struct rio_info *, struct DownLoad *);
int RIOBootCodeUNKNOWN(struct rio_info *, struct DownLoad *);
void msec_timeout(struct Host *);
int RIOBootRup(struct rio_info *, unsigned int, struct Host *, struct PKT *);
int RIOBootRup(struct rio_info *, unsigned int, struct Host *, struct PKT __iomem *);
int RIOBootOk(struct rio_info *, struct Host *, unsigned long);
int RIORtaBound(struct rio_info *, unsigned int);
void rio_fill_host_slot(int, int, unsigned int, struct Host *);
Expand All @@ -55,8 +55,8 @@ void rio_fill_host_slot(int, int, unsigned int, struct Host *);
int RIOFoadRta(struct Host *, struct Map *);
int RIOZombieRta(struct Host *, struct Map *);
int RIOCommandRta(struct rio_info *, unsigned long, int (*func) (struct Host *, struct Map *));
int RIOIdentifyRta(struct rio_info *, void *);
int RIOKillNeighbour(struct rio_info *, void *);
int RIOIdentifyRta(struct rio_info *, void __user *);
int RIOKillNeighbour(struct rio_info *, void __user *);
int RIOSuspendBootRta(struct Host *, int, int);
int RIOFoadWakeup(struct rio_info *);
struct CmdBlk *RIOGetCmdBlk(void);
Expand All @@ -68,7 +68,8 @@ int RIORFlushEnable(unsigned long, struct CmdBlk *);
int RIOUnUse(unsigned long, struct CmdBlk *);

/* rioctrl.c */
int riocontrol(struct rio_info *, dev_t, int, caddr_t, int);
int riocontrol(struct rio_info *, dev_t, int, unsigned long, int);

int RIOPreemptiveCmd(struct rio_info *, struct Port *, unsigned char);

/* rioinit.c */
Expand All @@ -77,13 +78,13 @@ void RIOInitHosts(struct rio_info *, struct RioHostInfo *);
void RIOISAinit(struct rio_info *, int);
int RIODoAT(struct rio_info *, int, int);
caddr_t RIOCheckForATCard(int);
int RIOAssignAT(struct rio_info *, int, caddr_t, int);
int RIOBoardTest(unsigned long, caddr_t, unsigned char, int);
int RIOAssignAT(struct rio_info *, int, void __iomem *, int);
int RIOBoardTest(unsigned long, void __iomem *, unsigned char, int);
void RIOAllocDataStructs(struct rio_info *);
void RIOSetupDataStructs(struct rio_info *);
int RIODefaultName(struct rio_info *, struct Host *, unsigned int);
struct rioVersion *RIOVersid(void);
void RIOHostReset(unsigned int, struct DpRam *, unsigned int);
void RIOHostReset(unsigned int, struct DpRam __iomem *, unsigned int);

/* riointr.c */
void RIOTxEnable(char *);
Expand All @@ -95,14 +96,14 @@ int RIOParam(struct Port *, int, int, int);
int RIODelay(struct Port *PortP, int);
int RIODelay_ni(struct Port *PortP, int);
void ms_timeout(struct Port *);
int can_add_transmit(struct PKT **, struct Port *);
int can_add_transmit(struct PKT __iomem **, struct Port *);
void add_transmit(struct Port *);
void put_free_end(struct Host *, struct PKT *);
int can_remove_receive(struct PKT **, struct Port *);
void put_free_end(struct Host *, struct PKT __iomem *);
int can_remove_receive(struct PKT __iomem **, struct Port *);
void remove_receive(struct Port *);

/* rioroute.c */
int RIORouteRup(struct rio_info *, unsigned int, struct Host *, struct PKT *);
int RIORouteRup(struct rio_info *, unsigned int, struct Host *, struct PKT __iomem *);
void RIOFixPhbs(struct rio_info *, struct Host *, unsigned int);
unsigned int GetUnitType(unsigned int);
int RIOSetChange(struct rio_info *);
Expand Down Expand Up @@ -139,7 +140,7 @@ int rio_isr_thread(char *);
struct rio_info *rio_info_store(int cmd, struct rio_info *p);
#endif

extern void rio_copy_to_card(void *to, void *from, int len);
extern void rio_copy_to_card(void *from, void __iomem *to, int len);
extern int rio_minor(struct tty_struct *tty);
extern int rio_ismodem(struct tty_struct *tty);

Expand Down
16 changes: 8 additions & 8 deletions drivers/char/rio/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ struct Host {
unsigned char Ivec; /* POLLED or ivec number */
unsigned char Mode; /* Control stuff */
unsigned char Slot; /* Slot */
caddr_t Caddr; /* KV address of DPRAM */
struct DpRam *CardP; /* KV address of DPRAM, with overlay */
void __iomem *Caddr; /* KV address of DPRAM */
struct DpRam __iomem *CardP; /* KV address of DPRAM, with overlay */
unsigned long PaddrP; /* Phys. address of DPRAM */
char Name[MAX_NAME_LEN]; /* The name of the host */
unsigned int UniqueNum; /* host unique number */
spinlock_t HostLock; /* Lock structure for MPX */
unsigned int WorkToBeDone; /* set to true each interrupt */
unsigned int InIntr; /* Being serviced? */
unsigned int IntSrvDone; /* host's interrupt has been serviced */
void (*Copy) (void *, void *, int); /* copy func */
void (*Copy) (void *, void __iomem *, int); /* copy func */
struct timer_list timer;
/*
** I M P O R T A N T !
Expand All @@ -83,11 +83,11 @@ struct Host {

struct Top Topology[LINKS_PER_UNIT]; /* one per link */
struct Map Mapping[MAX_RUP]; /* Mappings for host */
struct PHB *PhbP; /* Pointer to the PHB array */
unsigned short *PhbNumP; /* Ptr to Number of PHB's */
struct LPB *LinkStrP; /* Link Structure Array */
struct RUP *RupP; /* Sixteen real rups here */
struct PARM_MAP *ParmMapP; /* points to the parmmap */
struct PHB __iomem *PhbP; /* Pointer to the PHB array */
unsigned short __iomem *PhbNumP; /* Ptr to Number of PHB's */
struct LPB __iomem *LinkStrP; /* Link Structure Array */
struct RUP __iomem *RupP; /* Sixteen real rups here */
struct PARM_MAP __iomem *ParmMapP; /* points to the parmmap */
unsigned int ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */
unsigned int NumExtraBooted; /* how many of the above */
/*
Expand Down
16 changes: 8 additions & 8 deletions drivers/char/rio/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct Port {
struct gs_port gs;
int PortNum; /* RIO port no., 0-511 */
struct Host *HostP;
caddr_t Caddr;
void __iomem *Caddr;
unsigned short HostPort; /* Port number on host card */
unsigned char RupNum; /* Number of RUP for port */
unsigned char ID2; /* Second ID of RTA for port */
Expand Down Expand Up @@ -92,13 +92,13 @@ struct Port {
#define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */


struct PHB *PhbP; /* pointer to PHB for port */
u16 *TxAdd; /* Add packets here */
u16 *TxStart; /* Start of add array */
u16 *TxEnd; /* End of add array */
u16 *RxRemove; /* Remove packets here */
u16 *RxStart; /* Start of remove array */
u16 *RxEnd; /* End of remove array */
struct PHB __iomem *PhbP; /* pointer to PHB for port */
u16 __iomem *TxAdd; /* Add packets here */
u16 __iomem *TxStart; /* Start of add array */
u16 __iomem *TxEnd; /* End of add array */
u16 __iomem *RxRemove; /* Remove packets here */
u16 __iomem *RxStart; /* Start of remove array */
u16 __iomem *RxEnd; /* End of remove array */
unsigned int RtaUniqueNum; /* Unique number of RTA */
unsigned short PortState; /* status of port */
unsigned short ModemState; /* status of modem lines */
Expand Down
4 changes: 2 additions & 2 deletions drivers/char/rio/rio.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@
** RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and
** returns the offset into the DP RAM area.
*/
#define RIO_PTR(C,O) (((unsigned char *)(C))+(0xFFFF&(O)))
#define RIO_OFF(C,O) ((long)(O)-(long)(C))
#define RIO_PTR(C,O) (((unsigned char __iomem *)(C))+(0xFFFF&(O)))
#define RIO_OFF(C,O) ((unsigned char __iomem *)(O)-(unsigned char __iomem *)(C))

/*
** How to convert from various different device number formats:
Expand Down
31 changes: 16 additions & 15 deletions drivers/char/rio/rio_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ int RIODelay_ni(struct Port *PortP, int njiffies)
return !RIO_FAIL;
}

void rio_copy_to_card(void *to, void *from, int len)
void rio_copy_to_card(void *from, void __iomem *to, int len)
{
rio_memcpy_toio(NULL, to, from, len);
rio_copy_toio(to, from, len);
}

int rio_minor(struct tty_struct *tty)
Expand Down Expand Up @@ -573,7 +573,7 @@ static int rio_fw_ioctl(struct inode *inode, struct file *filp, unsigned int cmd
func_enter();

/* The "dev" argument isn't used. */
rc = riocontrol(p, 0, cmd, (void *) arg, capable(CAP_SYS_ADMIN));
rc = riocontrol(p, 0, cmd, arg, capable(CAP_SYS_ADMIN));

func_exit();
return rc;
Expand All @@ -583,6 +583,7 @@ extern int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command,

static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg)
{
void __user *argp = (void __user *)arg;
int rc;
struct Port *PortP;
int ival;
Expand All @@ -594,14 +595,14 @@ static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd
rc = 0;
switch (cmd) {
case TIOCSSOFTCAR:
if ((rc = get_user(ival, (unsigned int *) arg)) == 0) {
if ((rc = get_user(ival, (unsigned __user *) argp)) == 0) {
tty->termios->c_cflag = (tty->termios->c_cflag & ~CLOCAL) | (ival ? CLOCAL : 0);
}
break;
case TIOCGSERIAL:
rc = -EFAULT;
if (access_ok(VERIFY_WRITE, (void *) arg, sizeof(struct serial_struct)))
rc = gs_getserial(&PortP->gs, (struct serial_struct *) arg);
if (access_ok(VERIFY_WRITE, argp, sizeof(struct serial_struct)))
rc = gs_getserial(&PortP->gs, argp);
break;
case TCSBRK:
if (PortP->State & RIO_DELETED) {
Expand Down Expand Up @@ -631,8 +632,8 @@ static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd
break;
case TIOCSSERIAL:
rc = -EFAULT;
if (access_ok(VERIFY_READ, (void *) arg, sizeof(struct serial_struct)))
rc = gs_setserial(&PortP->gs, (struct serial_struct *) arg);
if (access_ok(VERIFY_READ, argp, sizeof(struct serial_struct)))
rc = gs_setserial(&PortP->gs, argp);
break;
default:
rc = -ENOIOCTLCMD;
Expand Down Expand Up @@ -919,7 +920,7 @@ static void __exit rio_release_drivers(void)
static void fix_rio_pci(struct pci_dev *pdev)
{
unsigned long hwbase;
unsigned char *rebase;
unsigned char __iomem *rebase;
unsigned int t;

#define CNTRL_REG_OFFSET 0x50
Expand Down Expand Up @@ -999,7 +1000,7 @@ static int __init rio_init(void)
if (((1 << hp->Ivec) & rio_irqmask) == 0)
hp->Ivec = 0;
hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
hp->CardP = (struct DpRam *) hp->Caddr;
hp->CardP = (struct DpRam __iomem *) hp->Caddr;
hp->Type = RIO_PCI;
hp->Copy = rio_copy_to_card;
hp->Mode = RIO_PCI_BOOT_FROM_RAM;
Expand All @@ -1021,7 +1022,7 @@ static int __init rio_init(void)
p->RIONumHosts++;
found++;
} else {
iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr));
iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
}
}

Expand All @@ -1047,7 +1048,7 @@ static int __init rio_init(void)
hp->Ivec = 0;
hp->Ivec |= 0x8000; /* Mark as non-sharable */
hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
hp->CardP = (struct DpRam *) hp->Caddr;
hp->CardP = (struct DpRam __iomem *) hp->Caddr;
hp->Type = RIO_PCI;
hp->Copy = rio_copy_to_card;
hp->Mode = RIO_PCI_BOOT_FROM_RAM;
Expand All @@ -1070,7 +1071,7 @@ static int __init rio_init(void)
p->RIONumHosts++;
found++;
} else {
iounmap((char *) (p->RIOHosts[p->RIONumHosts].Caddr));
iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
}
#else
printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n");
Expand All @@ -1085,7 +1086,7 @@ static int __init rio_init(void)
/* There was something about the IRQs of these cards. 'Forget what.--REW */
hp->Ivec = 0;
hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
hp->CardP = (struct DpRam *) hp->Caddr;
hp->CardP = (struct DpRam __iomem *) hp->Caddr;
hp->Type = RIO_AT;
hp->Copy = rio_copy_to_card; /* AT card PCI???? - PVDL
* -- YES! this is now a normal copy. Only the
Expand All @@ -1111,7 +1112,7 @@ static int __init rio_init(void)
}

if (!okboard)
iounmap((char *) (hp->Caddr));
iounmap(hp->Caddr);
}
}

Expand Down
20 changes: 16 additions & 4 deletions drivers/char/rio/rio_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ struct vpd_prom {


#ifdef CONFIG_RIO_OLDPCI
static inline void *rio_memcpy_toio(void *dummy, void *dest, void *source, int n)
static inline void __iomem *rio_memcpy_toio(void __iomem *dummy, void __iomem *dest, void *source, int n)
{
char *dst = dest;
char __iomem *dst = dest;
char *src = source;

while (n--) {
Expand All @@ -144,11 +144,22 @@ static inline void *rio_memcpy_toio(void *dummy, void *dest, void *source, int n
return dest;
}

static inline void __iomem *rio_copy_toio(void __iomem *dest, void *source, int n)
{
char __iomem *dst = dest;
char *src = source;

while (n--)
writeb(*src++, dst++);

static inline void *rio_memcpy_fromio(void *dest, void *source, int n)
return dest;
}


static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n)
{
char *dst = dest;
char *src = source;
char __iomem *src = source;

while (n--)
*dst++ = readb(src++);
Expand All @@ -158,6 +169,7 @@ static inline void *rio_memcpy_fromio(void *dest, void *source, int n)

#else
#define rio_memcpy_toio(dummy,dest,source,n) memcpy_toio(dest, source, n)
#define rio_copy_toio memcpy_toio
#define rio_memcpy_fromio memcpy_fromio
#endif

Expand Down
Loading

0 comments on commit 077e989

Please sign in to comment.