if (v >> (dev->keycodesize * 8)) return -EINVAL; 
if (dev->keycodesize < sizeof(v) && (v >> (dev->keycodesize * 8))) return -EINVAL; 
static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg){	struct evdev_list *list = file->private_data;	struct evdev *evdev = list->evdev;	struct input_dev *dev = evdev->handle.dev;	struct input_absinfo abs;	void __user *p = (void __user *)arg;	int __user *ip = (int __user *)arg;	int i, t, u, v;	if (!evdev->exist) return -ENODEV;	switch (cmd) {		case EVIOCGVERSION:			return put_user(EV_VERSION, ip);		case EVIOCGID:			return copy_to_user(p, &dev->id, sizeof(struct input_id)) ? -EFAULT : 0;		case EVIOCGKEYCODE:			if (get_user(t, ip)) return -EFAULT;			if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) return -EINVAL;			if (put_user(INPUT_KEYCODE(dev, t), ip + 1)) return -EFAULT;			return 0;		case EVIOCSKEYCODE:			if (get_user(t, ip)) return -EFAULT;			if (t < 0 || t >= dev->keycodemax || !dev->keycodesize) return -EINVAL;			if (get_user(v, ip + 1)) return -EFAULT;			if (v < 0 || v > KEY_MAX) return -EINVAL;			if (v >> (dev->keycodesize * 8)) return -EINVAL;			u = SET_INPUT_KEYCODE(dev, t, v);			clear_bit(u, dev->keybit);			set_bit(v, dev->keybit);			for (i = 0; i < dev->keycodemax; i++)				if (INPUT_KEYCODE(dev,i) == u)					set_bit(u, dev->keybit);			return 0;		case EVIOCSFF:			if (dev->upload_effect) {				struct ff_effect effect;				int err;				if (copy_from_user(&effect, p, sizeof(effect)))					return -EFAULT;				err = dev->upload_effect(dev, &effect);				if (put_user(effect.id, &(((struct ff_effect __user *)arg)->id)))					return -EFAULT;				return err;			}			else return -ENOSYS;		case EVIOCRMFF:			if (dev->erase_effect) {				return dev->erase_effect(dev, (int)arg);			}			else return -ENOSYS;		case EVIOCGEFFECTS:			if (put_user(dev->ff_effects_max, ip))				return -EFAULT;			return 0;		case EVIOCGRAB:			if (arg) {				if (evdev->grab)					return -EBUSY;				if (input_grab_device(&evdev->handle))					return -EBUSY;				evdev->grab = list;				return 0;			} else {				if (evdev->grab != list)					return -EINVAL;				input_release_device(&evdev->handle);				evdev->grab = NULL;				return 0;			}		default:			if (_IOC_TYPE(cmd) != 'E')				return -EINVAL;			if (_IOC_DIR(cmd) == _IOC_READ) {				if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0,0))) {					long *bits;					int len;					switch (_IOC_NR(cmd) & EV_MAX) {						case      0: bits = dev->evbit;  len = EV_MAX;  break;						case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;						case EV_REL: bits = dev->relbit; len = REL_MAX; break;						case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;						case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;						case EV_LED: bits = dev->ledbit; len = LED_MAX; break;						case EV_SND: bits = dev->sndbit; len = SND_MAX; break;						case EV_FF:  bits = dev->ffbit;  len = FF_MAX;  break;						default: return -EINVAL;					}					len = NBITS(len) * sizeof(long);					if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd);					return copy_to_user(p, bits, len) ? -EFAULT : len;				}				if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0))) {					int len;					len = NBITS(KEY_MAX) * sizeof(long);					if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd);					return copy_to_user(p, dev->key, len) ? -EFAULT : len;				}				if (_IOC_NR(cmd) == _IOC_NR(EVIOCGLED(0))) {					int len;					len = NBITS(LED_MAX) * sizeof(long);					if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd);					return copy_to_user(p, dev->led, len) ? -EFAULT : len;				}				if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSND(0))) {					int len;					len = NBITS(SND_MAX) * sizeof(long);					if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd);					return copy_to_user(p, dev->snd, len) ? -EFAULT : len;				}				if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) {					int len;					if (!dev->name) return -ENOENT;					len = strlen(dev->name) + 1;					if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd);					return copy_to_user(p, dev->name, len) ? -EFAULT : len;				}				if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0))) {					int len;					if (!dev->phys) return -ENOENT;					len = strlen(dev->phys) + 1;					if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd);					return copy_to_user(p, dev->phys, len) ? -EFAULT : len;				}				if (_IOC_NR(cmd) == _IOC_NR(EVIOCGUNIQ(0))) {					int len;					if (!dev->uniq) return -ENOENT;					len = strlen(dev->uniq) + 1;					if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd);					return copy_to_user(p, dev->uniq, len) ? -EFAULT : len;				}				if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCGABS(0))) {					int t = _IOC_NR(cmd) & ABS_MAX;					abs.value = dev->abs[t];					abs.minimum = dev->absmin[t];					abs.maximum = dev->absmax[t];					abs.fuzz = dev->absfuzz[t];					abs.flat = dev->absflat[t];					if (copy_to_user(p, &abs, sizeof(struct input_absinfo)))						return -EFAULT;					return 0;				}			}			if (_IOC_DIR(cmd) == _IOC_WRITE) {				if ((_IOC_NR(cmd) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0))) {					int t = _IOC_NR(cmd) & ABS_MAX;					if (copy_from_user(&abs, p, sizeof(struct input_absinfo)))						return -EFAULT;					dev->abs[t] = abs.value;					dev->absmin[t] = abs.minimum;					dev->absmax[t] = abs.maximum;					dev->absfuzz[t] = abs.fuzz;					dev->absflat[t] = abs.flat;					return 0;				}			}	}	return -EINVAL;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/4cee99564db7f65a6f88e4b752da52768cde3802/evdev.c/clean/drivers/input/evdev.c