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

[PATCH] megaraid annotation

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fb59806b
...@@ -130,9 +130,9 @@ typedef struct uioc { ...@@ -130,9 +130,9 @@ typedef struct uioc {
uint8_t reserved[128]; uint8_t reserved[128];
/* Driver Data: */ /* Driver Data: */
caddr_t user_data; void __user * user_data;
uint32_t user_data_len; uint32_t user_data_len;
mraid_passthru_t *user_pthru; mraid_passthru_t __user *user_pthru;
mraid_passthru_t *pthru32; mraid_passthru_t *pthru32;
dma_addr_t pthru32_h; dma_addr_t pthru32_h;
......
...@@ -24,17 +24,17 @@ static int mraid_mm_ioctl(struct inode *, struct file *, uint, unsigned long); ...@@ -24,17 +24,17 @@ static int mraid_mm_ioctl(struct inode *, struct file *, uint, unsigned long);
// routines to convert to and from the old the format // routines to convert to and from the old the format
static int mimd_to_kioc(mimd_t *, mraid_mmadp_t *, uioc_t *); static int mimd_to_kioc(mimd_t __user *, mraid_mmadp_t *, uioc_t *);
static int kioc_to_mimd(uioc_t *, mimd_t *); static int kioc_to_mimd(uioc_t *, mimd_t __user *);
// Helper functions // Helper functions
static int handle_drvrcmd(unsigned long, uint8_t, int *); static int handle_drvrcmd(void __user *, uint8_t, int *);
static int lld_ioctl(mraid_mmadp_t *, uioc_t *); static int lld_ioctl(mraid_mmadp_t *, uioc_t *);
static void ioctl_done(uioc_t *); static void ioctl_done(uioc_t *);
static void lld_timedout(unsigned long); static void lld_timedout(unsigned long);
static void hinfo_to_cinfo(mraid_hba_info_t *, mcontroller_t *); static void hinfo_to_cinfo(mraid_hba_info_t *, mcontroller_t *);
static mraid_mmadp_t *mraid_mm_get_adapter(mimd_t *, int *); static mraid_mmadp_t *mraid_mm_get_adapter(mimd_t __user *, int *);
static uioc_t *mraid_mm_alloc_kioc(mraid_mmadp_t *); static uioc_t *mraid_mm_alloc_kioc(mraid_mmadp_t *);
static void mraid_mm_dealloc_kioc(mraid_mmadp_t *, uioc_t *); static void mraid_mm_dealloc_kioc(mraid_mmadp_t *, uioc_t *);
static int mraid_mm_attach_buf(mraid_mmadp_t *, uioc_t *, int); static int mraid_mm_attach_buf(mraid_mmadp_t *, uioc_t *, int);
...@@ -108,6 +108,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -108,6 +108,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
mraid_mmadp_t *adp; mraid_mmadp_t *adp;
uint8_t old_ioctl; uint8_t old_ioctl;
int drvrcmd_rval; int drvrcmd_rval;
void __user *argp = (void __user *)arg;
/* /*
* Make sure only USCSICMD are issued through this interface. * Make sure only USCSICMD are issued through this interface.
...@@ -121,7 +122,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -121,7 +122,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
/* /*
* Look for signature to see if this is the new or old ioctl format. * Look for signature to see if this is the new or old ioctl format.
*/ */
if (copy_from_user(signature, (char *)arg, EXT_IOCTL_SIGN_SZ)) { if (copy_from_user(signature, argp, EXT_IOCTL_SIGN_SZ)) {
con_log(CL_ANN, (KERN_WARNING con_log(CL_ANN, (KERN_WARNING
"megaraid cmm: copy from usr addr failed\n")); "megaraid cmm: copy from usr addr failed\n"));
return (-EFAULT); return (-EFAULT);
...@@ -142,7 +143,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -142,7 +143,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
* If it is a driver ioctl (as opposed to fw ioctls), then we can * If it is a driver ioctl (as opposed to fw ioctls), then we can
* handle the command locally. rval > 0 means it is not a drvr cmd * handle the command locally. rval > 0 means it is not a drvr cmd
*/ */
rval = handle_drvrcmd(arg, old_ioctl, &drvrcmd_rval); rval = handle_drvrcmd(argp, old_ioctl, &drvrcmd_rval);
if (rval < 0) if (rval < 0)
return rval; return rval;
...@@ -150,7 +151,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -150,7 +151,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
return drvrcmd_rval; return drvrcmd_rval;
rval = 0; rval = 0;
if ((adp = mraid_mm_get_adapter((mimd_t*)arg, &rval)) == NULL) { if ((adp = mraid_mm_get_adapter(argp, &rval)) == NULL) {
return rval; return rval;
} }
...@@ -162,7 +163,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -162,7 +163,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
/* /*
* User sent the old mimd_t ioctl packet. Convert it to uioc_t. * User sent the old mimd_t ioctl packet. Convert it to uioc_t.
*/ */
if ((rval = mimd_to_kioc((mimd_t*)arg, adp, kioc))) { if ((rval = mimd_to_kioc(argp, adp, kioc))) {
mraid_mm_dealloc_kioc(adp, kioc); mraid_mm_dealloc_kioc(adp, kioc);
return rval; return rval;
} }
...@@ -180,7 +181,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -180,7 +181,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
/* /*
* Convert the kioc back to user space * Convert the kioc back to user space
*/ */
rval = kioc_to_mimd(kioc, (mimd_t *)arg); rval = kioc_to_mimd(kioc, argp);
/* /*
* Return the kioc to free pool * Return the kioc to free pool
...@@ -197,7 +198,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, ...@@ -197,7 +198,7 @@ mraid_mm_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
* @adapter : pointer to the adapter (OUT) * @adapter : pointer to the adapter (OUT)
*/ */
static mraid_mmadp_t * static mraid_mmadp_t *
mraid_mm_get_adapter(mimd_t *umimd, int *rval) mraid_mm_get_adapter(mimd_t __user *umimd, int *rval)
{ {
mraid_mmadp_t *adapter; mraid_mmadp_t *adapter;
mimd_t mimd; mimd_t mimd;
...@@ -239,9 +240,9 @@ mraid_mm_get_adapter(mimd_t *umimd, int *rval) ...@@ -239,9 +240,9 @@ mraid_mm_get_adapter(mimd_t *umimd, int *rval)
* @old_ioctl : mimd if 1; uioc otherwise * @old_ioctl : mimd if 1; uioc otherwise
*/ */
static int static int
handle_drvrcmd(unsigned long arg, uint8_t old_ioctl, int *rval) handle_drvrcmd(void __user *arg, uint8_t old_ioctl, int *rval)
{ {
mimd_t *umimd; mimd_t __user *umimd;
mimd_t kmimd; mimd_t kmimd;
uint8_t opcode; uint8_t opcode;
uint8_t subopcode; uint8_t subopcode;
...@@ -256,7 +257,7 @@ handle_drvrcmd(unsigned long arg, uint8_t old_ioctl, int *rval) ...@@ -256,7 +257,7 @@ handle_drvrcmd(unsigned long arg, uint8_t old_ioctl, int *rval)
old_packet: old_packet:
*rval = 0; *rval = 0;
umimd = (mimd_t*) arg; umimd = arg;
if (copy_from_user(&kmimd, umimd, sizeof(mimd_t))) if (copy_from_user(&kmimd, umimd, sizeof(mimd_t)))
return (-EFAULT); return (-EFAULT);
...@@ -312,7 +313,7 @@ handle_drvrcmd(unsigned long arg, uint8_t old_ioctl, int *rval) ...@@ -312,7 +313,7 @@ handle_drvrcmd(unsigned long arg, uint8_t old_ioctl, int *rval)
*/ */
static int static int
mimd_to_kioc(mimd_t *umimd, mraid_mmadp_t *adp, uioc_t *kioc) mimd_to_kioc(mimd_t __user *umimd, mraid_mmadp_t *adp, uioc_t *kioc)
{ {
mbox64_t *mbox64; mbox64_t *mbox64;
mbox_t *mbox; mbox_t *mbox;
...@@ -436,7 +437,7 @@ mimd_to_kioc(mimd_t *umimd, mraid_mmadp_t *adp, uioc_t *kioc) ...@@ -436,7 +437,7 @@ mimd_to_kioc(mimd_t *umimd, mraid_mmadp_t *adp, uioc_t *kioc)
kioc->user_pthru = &umimd->pthru; kioc->user_pthru = &umimd->pthru;
mbox->xferaddr = (uint32_t)kioc->pthru32_h; mbox->xferaddr = (uint32_t)kioc->pthru32_h;
if (copy_from_user(pthru32, (caddr_t)kioc->user_pthru, if (copy_from_user(pthru32, kioc->user_pthru,
sizeof(mraid_passthru_t))) { sizeof(mraid_passthru_t))) {
return (-EFAULT); return (-EFAULT);
} }
...@@ -719,14 +720,14 @@ lld_timedout(unsigned long ptr) ...@@ -719,14 +720,14 @@ lld_timedout(unsigned long ptr)
* @mimd : User space MIMD packet * @mimd : User space MIMD packet
*/ */
static int static int
kioc_to_mimd(uioc_t *kioc, mimd_t *mimd) kioc_to_mimd(uioc_t *kioc, mimd_t __user *mimd)
{ {
mimd_t kmimd; mimd_t kmimd;
uint8_t opcode; uint8_t opcode;
uint8_t subopcode; uint8_t subopcode;
mbox64_t *mbox64; mbox64_t *mbox64;
mraid_passthru_t *upthru32; mraid_passthru_t __user *upthru32;
mraid_passthru_t *kpthru32; mraid_passthru_t *kpthru32;
mcontroller_t cinfo; mcontroller_t cinfo;
mraid_hba_info_t *hinfo; mraid_hba_info_t *hinfo;
...@@ -767,8 +768,8 @@ kioc_to_mimd(uioc_t *kioc, mimd_t *mimd) ...@@ -767,8 +768,8 @@ kioc_to_mimd(uioc_t *kioc, mimd_t *mimd)
upthru32 = kioc->user_pthru; upthru32 = kioc->user_pthru;
kpthru32 = kioc->pthru32; kpthru32 = kioc->pthru32;
if (copy_to_user((void *)&upthru32->scsistatus, if (copy_to_user(&upthru32->scsistatus,
(void *)&kpthru32->scsistatus, &kpthru32->scsistatus,
sizeof(uint8_t))) { sizeof(uint8_t))) {
return (-EFAULT); return (-EFAULT);
} }
...@@ -781,8 +782,8 @@ kioc_to_mimd(uioc_t *kioc, mimd_t *mimd) ...@@ -781,8 +782,8 @@ kioc_to_mimd(uioc_t *kioc, mimd_t *mimd)
} }
} }
if (copy_to_user((void *)&mimd->mbox[17], if (copy_to_user(&mimd->mbox[17],
(void *)&mbox64->mbox32.status, sizeof(uint8_t))) { &mbox64->mbox32.status, sizeof(uint8_t))) {
return (-EFAULT); return (-EFAULT);
} }
......
...@@ -74,11 +74,11 @@ typedef struct mimd { ...@@ -74,11 +74,11 @@ typedef struct mimd {
uint8_t subopcode; uint8_t subopcode;
uint16_t adapno; uint16_t adapno;
#if BITS_PER_LONG == 32 #if BITS_PER_LONG == 32
uint8_t *buffer; uint8_t __user *buffer;
uint8_t pad[4]; uint8_t pad[4];
#endif #endif
#if BITS_PER_LONG == 64 #if BITS_PER_LONG == 64
uint8_t *buffer; uint8_t __user *buffer;
#endif #endif
uint32_t length; uint32_t length;
} __attribute__ ((packed)) fcs; } __attribute__ ((packed)) fcs;
...@@ -88,11 +88,11 @@ typedef struct mimd { ...@@ -88,11 +88,11 @@ typedef struct mimd {
mraid_passthru_t pthru; mraid_passthru_t 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))mimd_t; } __attribute__ ((packed))mimd_t;
......
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