if ((cmd & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT)) == JSIOCGNAME(0)) { int len; if (!dev->name) return 0; len = strlen(dev->name) + 1; if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); if (copy_to_user(argp, dev->name, len)) return -EFAULT; return len; } 
return joydev_ioctl_common(joydev, cmd, argp); 
static int joydev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg){	struct joydev_list *list = file->private_data;	struct joydev *joydev = list->joydev;	struct input_dev *dev = joydev->handle.dev;	void __user *argp = (void __user *)arg;	int i, j;	if (!joydev->exist) return -ENODEV;	switch (cmd) {		case JS_SET_CAL:			return copy_from_user(&joydev->glue.JS_CORR, argp,				sizeof(struct JS_DATA_TYPE)) ? -EFAULT : 0;		case JS_GET_CAL:			return copy_to_user(argp, &joydev->glue.JS_CORR,				sizeof(struct JS_DATA_TYPE)) ? -EFAULT : 0;		case JS_SET_TIMEOUT:			return get_user(joydev->glue.JS_TIMEOUT, (int __user *) arg);		case JS_GET_TIMEOUT:			return put_user(joydev->glue.JS_TIMEOUT, (int __user *) arg);		case JS_SET_TIMELIMIT:			return get_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg);		case JS_GET_TIMELIMIT:			return put_user(joydev->glue.JS_TIMELIMIT, (long __user *) arg);		case JS_SET_ALL:			return copy_from_user(&joydev->glue, argp,						sizeof(struct JS_DATA_SAVE_TYPE)) ? -EFAULT : 0;		case JS_GET_ALL:			return copy_to_user(argp, &joydev->glue,						sizeof(struct JS_DATA_SAVE_TYPE)) ? -EFAULT : 0;		case JSIOCGVERSION:			return put_user(JS_VERSION, (__u32 __user *) arg);		case JSIOCGAXES:			return put_user(joydev->nabs, (__u8 __user *) arg);		case JSIOCGBUTTONS:			return put_user(joydev->nkey, (__u8 __user *) arg);		case JSIOCSCORR:			if (copy_from_user(joydev->corr, argp,				      sizeof(struct js_corr) * joydev->nabs))			    return -EFAULT;			for (i = 0; i < joydev->nabs; i++) {				j = joydev->abspam[i];			        joydev->abs[i] = joydev_correct(dev->abs[j], joydev->corr + i);			}			return 0;		case JSIOCGCORR:			return copy_to_user(argp, joydev->corr,						sizeof(struct js_corr) * joydev->nabs) ? -EFAULT : 0;		case JSIOCSAXMAP:			if (copy_from_user(joydev->abspam, argp, sizeof(__u8) * (ABS_MAX + 1)))				return -EFAULT;			for (i = 0; i < joydev->nabs; i++) {				if (joydev->abspam[i] > ABS_MAX) return -EINVAL;				joydev->absmap[joydev->abspam[i]] = i;			}			return 0;		case JSIOCGAXMAP:			return copy_to_user(argp, joydev->abspam,						sizeof(__u8) * (ABS_MAX + 1)) ? -EFAULT : 0;		case JSIOCSBTNMAP:			if (copy_from_user(joydev->keypam, argp, sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)))				return -EFAULT;			for (i = 0; i < joydev->nkey; i++) {				if (joydev->keypam[i] > KEY_MAX || joydev->keypam[i] < BTN_MISC) return -EINVAL;				joydev->keymap[joydev->keypam[i] - BTN_MISC] = i;			}			return 0;		case JSIOCGBTNMAP:			return copy_to_user(argp, joydev->keypam,						sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)) ? -EFAULT : 0;		default:			if ((cmd & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT)) == JSIOCGNAME(0)) {				int len;				if (!dev->name) return 0;				len = strlen(dev->name) + 1;				if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd);				if (copy_to_user(argp, dev->name, len)) return -EFAULT;				return len;			}	}	return -EINVAL;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/024ac44c701d43f5e2d34bd6a35b2813a36e6010/joydev.c/buggy/drivers/input/joydev.c