Commit e2b2e3e3 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: megaraid annotation

parent 8e363726
...@@ -3366,13 +3366,13 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3366,13 +3366,13 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
nitioctl_t uioc; nitioctl_t uioc;
int adapno; int adapno;
int rval; int rval;
mega_passthru *upthru; /* user address for passthru */ mega_passthru __user *upthru; /* user address for passthru */
mega_passthru *pthru; /* copy user passthru here */ mega_passthru *pthru; /* copy user passthru here */
dma_addr_t pthru_dma_hndl; dma_addr_t pthru_dma_hndl;
void *data = NULL; /* data to be transferred */ void *data = NULL; /* data to be transferred */
dma_addr_t data_dma_hndl; /* dma handle for data xfer area */ dma_addr_t data_dma_hndl; /* dma handle for data xfer area */
megacmd_t mc; megacmd_t mc;
megastat_t *ustats; megastat_t __user *ustats;
int num_ldrv; int num_ldrv;
u32 uxferaddr = 0; u32 uxferaddr = 0;
struct pci_dev *pdev; struct pci_dev *pdev;
...@@ -3397,20 +3397,20 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3397,20 +3397,20 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
* addresses. * addresses.
*/ */
memset(&uioc, 0, sizeof(nitioctl_t)); memset(&uioc, 0, sizeof(nitioctl_t));
if( (rval = mega_m_to_n( (void *)arg, &uioc)) != 0 ) if( (rval = mega_m_to_n( (void __user *)arg, &uioc)) != 0 )
return rval; return rval;
switch( uioc.opcode ) { switch( uioc.opcode ) {
case GET_DRIVER_VER: case GET_DRIVER_VER:
if( put_user(driver_ver, (u32 *)uioc.uioc_uaddr) ) if( put_user(driver_ver, (u32 __user *)uioc.uioc_uaddr) )
return (-EFAULT); return (-EFAULT);
break; break;
case GET_N_ADAP: case GET_N_ADAP:
if( put_user(hba_count, (u32 *)uioc.uioc_uaddr) ) if( put_user(hba_count, (u32 __user *)uioc.uioc_uaddr) )
return (-EFAULT); return (-EFAULT);
/* /*
...@@ -3444,7 +3444,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3444,7 +3444,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
adapter = hba_soft_state[adapno]; adapter = hba_soft_state[adapno];
ustats = (megastat_t *)uioc.uioc_uaddr; ustats = uioc.uioc_uaddr;
if( copy_from_user(&num_ldrv, &ustats->num_ldrv, sizeof(int)) ) if( copy_from_user(&num_ldrv, &ustats->num_ldrv, sizeof(int)) )
return (-EFAULT); return (-EFAULT);
...@@ -3515,7 +3515,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3515,7 +3515,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
mc.status = rval; mc.status = rval;
rval = mega_n_to_m((void *)arg, &mc); rval = mega_n_to_m((void __user *)arg, &mc);
} }
return rval; return rval;
...@@ -3555,12 +3555,12 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3555,12 +3555,12 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
/* /*
* The user passthru structure * The user passthru structure
*/ */
upthru = (mega_passthru *)MBOX(uioc)->xferaddr; upthru = (mega_passthru __user *)MBOX(uioc)->xferaddr;
/* /*
* Copy in the user passthru here. * Copy in the user passthru here.
*/ */
if( copy_from_user(pthru, (char *)upthru, if( copy_from_user(pthru, upthru,
sizeof(mega_passthru)) ) { sizeof(mega_passthru)) ) {
pci_free_consistent(pdev, pci_free_consistent(pdev,
...@@ -3607,7 +3607,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3607,7 +3607,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
/* /*
* Get the user data * Get the user data
*/ */
if( copy_from_user(data, (char *)uxferaddr, if( copy_from_user(data, (char __user *)uxferaddr,
pthru->dataxferlen) ) { pthru->dataxferlen) ) {
rval = (-EFAULT); rval = (-EFAULT);
goto freemem_and_return; goto freemem_and_return;
...@@ -3624,7 +3624,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3624,7 +3624,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
*/ */
mega_internal_command(adapter, LOCK_INT, &mc, pthru); mega_internal_command(adapter, LOCK_INT, &mc, pthru);
rval = mega_n_to_m((void *)arg, &mc); rval = mega_n_to_m((void __user *)arg, &mc);
if( rval ) goto freemem_and_return; if( rval ) goto freemem_and_return;
...@@ -3633,7 +3633,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3633,7 +3633,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
* Is data going up-stream * Is data going up-stream
*/ */
if( pthru->dataxferlen && (uioc.flags & UIOC_RD) ) { if( pthru->dataxferlen && (uioc.flags & UIOC_RD) ) {
if( copy_to_user((char *)uxferaddr, data, if( copy_to_user((char __user *)uxferaddr, data,
pthru->dataxferlen) ) { pthru->dataxferlen) ) {
rval = (-EFAULT); rval = (-EFAULT);
} }
...@@ -3685,7 +3685,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3685,7 +3685,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
/* /*
* Get the user data * Get the user data
*/ */
if( copy_from_user(data, (char *)uxferaddr, if( copy_from_user(data, (char __user *)uxferaddr,
uioc.xferlen) ) { uioc.xferlen) ) {
pci_free_consistent(pdev, pci_free_consistent(pdev,
...@@ -3707,7 +3707,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3707,7 +3707,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
*/ */
mega_internal_command(adapter, LOCK_INT, &mc, NULL); mega_internal_command(adapter, LOCK_INT, &mc, NULL);
rval = mega_n_to_m((void *)arg, &mc); rval = mega_n_to_m((void __user *)arg, &mc);
if( rval ) { if( rval ) {
if( uioc.xferlen ) { if( uioc.xferlen ) {
...@@ -3725,7 +3725,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3725,7 +3725,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
* Is data going up-stream * Is data going up-stream
*/ */
if( uioc.xferlen && (uioc.flags & UIOC_RD) ) { if( uioc.xferlen && (uioc.flags & UIOC_RD) ) {
if( copy_to_user((char *)uxferaddr, data, if( copy_to_user((char __user *)uxferaddr, data,
uioc.xferlen) ) { uioc.xferlen) ) {
rval = (-EFAULT); rval = (-EFAULT);
...@@ -3761,7 +3761,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -3761,7 +3761,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
* Converts the older mimd ioctl structure to newer NIT structure * Converts the older mimd ioctl structure to newer NIT structure
*/ */
static int static int
mega_m_to_n(void *arg, nitioctl_t *uioc) mega_m_to_n(void __user *arg, nitioctl_t *uioc)
{ {
struct uioctl_t uioc_mimd; struct uioctl_t uioc_mimd;
char signature[8] = {0}; char signature[8] = {0};
...@@ -3776,7 +3776,7 @@ mega_m_to_n(void *arg, nitioctl_t *uioc) ...@@ -3776,7 +3776,7 @@ mega_m_to_n(void *arg, nitioctl_t *uioc)
* begining of the structure. * begining of the structure.
*/ */
if( copy_from_user(signature, (char *)arg, 7) ) if( copy_from_user(signature, arg, 7) )
return (-EFAULT); return (-EFAULT);
if( memcmp(signature, "MEGANIT", 7) == 0 ) { if( memcmp(signature, "MEGANIT", 7) == 0 ) {
...@@ -3789,7 +3789,7 @@ mega_m_to_n(void *arg, nitioctl_t *uioc) ...@@ -3789,7 +3789,7 @@ mega_m_to_n(void *arg, nitioctl_t *uioc)
*/ */
return -EINVAL; return -EINVAL;
#if 0 #if 0
if( copy_from_user(uioc, (char *)arg, sizeof(nitioctl_t)) ) if( copy_from_user(uioc, arg, sizeof(nitioctl_t)) )
return (-EFAULT); return (-EFAULT);
return 0; return 0;
#endif #endif
...@@ -3800,7 +3800,7 @@ mega_m_to_n(void *arg, nitioctl_t *uioc) ...@@ -3800,7 +3800,7 @@ mega_m_to_n(void *arg, nitioctl_t *uioc)
* *
* Get the user ioctl structure * Get the user ioctl structure
*/ */
if( copy_from_user(&uioc_mimd, (char *)arg, sizeof(struct uioctl_t)) ) if( copy_from_user(&uioc_mimd, arg, sizeof(struct uioctl_t)) )
return (-EFAULT); return (-EFAULT);
...@@ -3887,52 +3887,52 @@ mega_m_to_n(void *arg, nitioctl_t *uioc) ...@@ -3887,52 +3887,52 @@ mega_m_to_n(void *arg, nitioctl_t *uioc)
* conforms to older mimd ioctl interface or newer NIT ioctl interface * conforms to older mimd ioctl interface or newer NIT ioctl interface
*/ */
static int static int
mega_n_to_m(void *arg, megacmd_t *mc) mega_n_to_m(void __user *arg, megacmd_t *mc)
{ {
nitioctl_t *uiocp; nitioctl_t __user *uiocp;
megacmd_t *umc; megacmd_t __user *umc;
mega_passthru *upthru; mega_passthru __user *upthru;
struct uioctl_t *uioc_mimd; struct uioctl_t __user *uioc_mimd;
char signature[8] = {0}; char signature[8] = {0};
/* /*
* check is the application conforms to NIT. * check is the application conforms to NIT.
*/ */
if( copy_from_user(signature, (char *)arg, 7) ) if( copy_from_user(signature, arg, 7) )
return -EFAULT; return -EFAULT;
if( memcmp(signature, "MEGANIT", 7) == 0 ) { if( memcmp(signature, "MEGANIT", 7) == 0 ) {
uiocp = (nitioctl_t *)arg; uiocp = arg;
if( put_user(mc->status, (u8 *)&MBOX_P(uiocp)->status) ) if( put_user(mc->status, (u8 __user *)&MBOX_P(uiocp)->status) )
return (-EFAULT); return (-EFAULT);
if( mc->cmd == MEGA_MBOXCMD_PASSTHRU ) { if( mc->cmd == MEGA_MBOXCMD_PASSTHRU ) {
umc = MBOX_P(uiocp); umc = MBOX_P(uiocp);
if (get_user(upthru, (mega_passthru **)&umc->xferaddr)) if (get_user(upthru, (mega_passthru __user * __user *)&umc->xferaddr))
return (-EFAULT); return -EFAULT;
if( put_user(mc->status, (u8 *)&upthru->scsistatus) ) if( put_user(mc->status, (u8 __user *)&upthru->scsistatus))
return (-EFAULT); return (-EFAULT);
} }
} }
else { else {
uioc_mimd = (struct uioctl_t *)arg; uioc_mimd = arg;
if( put_user(mc->status, (u8 *)&uioc_mimd->mbox[17]) ) if( put_user(mc->status, (u8 __user *)&uioc_mimd->mbox[17]) )
return (-EFAULT); return (-EFAULT);
if( mc->cmd == MEGA_MBOXCMD_PASSTHRU ) { if( mc->cmd == MEGA_MBOXCMD_PASSTHRU ) {
umc = (megacmd_t *)uioc_mimd->mbox; umc = (megacmd_t __user *)uioc_mimd->mbox;
if (get_user(upthru, (mega_passthru **)&umc->xferaddr)) if (get_user(upthru, (mega_passthru __user * __user *)&umc->xferaddr))
return (-EFAULT); return (-EFAULT);
if( put_user(mc->status, (u8 *)&upthru->scsistatus) ) if( put_user(mc->status, (u8 __user *)&upthru->scsistatus) )
return (-EFAULT); return (-EFAULT);
} }
} }
......
...@@ -522,11 +522,11 @@ struct uioctl_t { ...@@ -522,11 +522,11 @@ struct uioctl_t {
u8 mbox[18]; /* 16 bytes + 2 status bytes */ u8 mbox[18]; /* 16 bytes + 2 status bytes */
mega_passthru pthru; mega_passthru pthru;
#if BITS_PER_LONG == 32 #if BITS_PER_LONG == 32
char *data; /* buffer <= 4096 for 0x80 commands */ char __user *data; /* buffer <= 4096 for 0x80 commands */
char pad[4]; char pad[4];
#endif #endif
#if BITS_PER_LONG == 64 #if BITS_PER_LONG == 64
char *data; char __user *data;
#endif #endif
} __attribute__ ((packed)); } __attribute__ ((packed));
...@@ -622,12 +622,12 @@ typedef struct { ...@@ -622,12 +622,12 @@ typedef struct {
u32 adapno; /* adapter number */ u32 adapno; /* adapter number */
union { union {
u8 __raw_mbox[18]; u8 __raw_mbox[18];
caddr_t __uaddr; /* xferaddr for non-mbox cmds */ void __user *__uaddr; /* xferaddr for non-mbox cmds */
}__ua; }__ua;
#define uioc_rmbox __ua.__raw_mbox #define uioc_rmbox __ua.__raw_mbox
#define MBOX(uioc) ((megacmd_t *)&((uioc).__ua.__raw_mbox[0])) #define MBOX(uioc) ((megacmd_t *)&((uioc).__ua.__raw_mbox[0]))
#define MBOX_P(uioc) ((megacmd_t *)&((uioc)->__ua.__raw_mbox[0])) #define MBOX_P(uioc) ((megacmd_t __user *)&((uioc)->__ua.__raw_mbox[0]))
#define uioc_uaddr __ua.__uaddr #define uioc_uaddr __ua.__uaddr
u32 xferlen; /* xferlen for DCMD and non-mbox u32 xferlen; /* xferlen for DCMD and non-mbox
......
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