err("usblp%d: failed reading printer status", usblp->minor); 
if (printk_ratelimit()) err("usblp%d: failed reading printer status", usblp->minor); 
static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg){	struct usblp *usblp = file->private_data;	int length, err, i;	unsigned char newChannel;	int status;	int twoints[2];	int retval = 0;	down (&usblp->sem);	if (!usblp->present) {		retval = -ENODEV;		goto done;	}	dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd),		_IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) );	if (_IOC_TYPE(cmd) == 'P')	/* new-style ioctl number */		switch (_IOC_NR(cmd)) {			case IOCNR_GET_DEVICE_ID: /* get the DEVICE_ID string */				if (_IOC_DIR(cmd) != _IOC_READ) {					retval = -EINVAL;					goto done;				}				length = usblp_cache_device_id_string(usblp);				if (length < 0) {					retval = length;					goto done;				}				if (length > _IOC_SIZE(cmd))					length = _IOC_SIZE(cmd); /* truncate */				if (copy_to_user((void __user *) arg,						usblp->device_id_string,						(unsigned long) length)) {					retval = -EFAULT;					goto done;				}				break;			case IOCNR_GET_PROTOCOLS:				if (_IOC_DIR(cmd) != _IOC_READ ||				    _IOC_SIZE(cmd) < sizeof(twoints)) {					retval = -EINVAL;					goto done;				}				twoints[0] = usblp->current_protocol;				twoints[1] = 0;				for (i = USBLP_FIRST_PROTOCOL;				     i <= USBLP_LAST_PROTOCOL; i++) {					if (usblp->protocol[i].alt_setting >= 0)						twoints[1] |= (1<<i);				}				if (copy_to_user((void __user *)arg,						(unsigned char *)twoints,						sizeof(twoints))) {					retval = -EFAULT;					goto done;				}				break;			case IOCNR_SET_PROTOCOL:				if (_IOC_DIR(cmd) != _IOC_WRITE) {					retval = -EINVAL;					goto done;				}#ifdef DEBUG				if (arg == -10) {					usblp_dump(usblp);					break;				}#endif				usblp_unlink_urbs(usblp);				retval = usblp_set_protocol(usblp, arg);				if (retval < 0) {					usblp_set_protocol(usblp,						usblp->current_protocol);				}				break;			case IOCNR_HP_SET_CHANNEL:				if (_IOC_DIR(cmd) != _IOC_WRITE ||				    le16_to_cpu(usblp->dev->descriptor.idVendor) != 0x03F0 ||				    usblp->quirks & USBLP_QUIRK_BIDIR) {					retval = -EINVAL;					goto done;				}				err = usblp_hp_channel_change_request(usblp,					arg, &newChannel);				if (err < 0) {					err("usblp%d: error = %d setting "						"HP channel",						usblp->minor, err);					retval = -EIO;					goto done;				}				dbg("usblp%d requested/got HP channel %ld/%d",					usblp->minor, arg, newChannel);				break;			case IOCNR_GET_BUS_ADDRESS:				if (_IOC_DIR(cmd) != _IOC_READ ||				    _IOC_SIZE(cmd) < sizeof(twoints)) {					retval = -EINVAL;					goto done;				}				twoints[0] = usblp->dev->bus->busnum;				twoints[1] = usblp->dev->devnum;				if (copy_to_user((void __user *)arg,						(unsigned char *)twoints,						sizeof(twoints))) {					retval = -EFAULT;					goto done;				}				dbg("usblp%d is bus=%d, device=%d",					usblp->minor, twoints[0], twoints[1]);				break;			case IOCNR_GET_VID_PID:				if (_IOC_DIR(cmd) != _IOC_READ ||				    _IOC_SIZE(cmd) < sizeof(twoints)) {					retval = -EINVAL;					goto done;				}				twoints[0] = le16_to_cpu(usblp->dev->descriptor.idVendor);				twoints[1] = le16_to_cpu(usblp->dev->descriptor.idProduct);				if (copy_to_user((void __user *)arg,						(unsigned char *)twoints,						sizeof(twoints))) {					retval = -EFAULT;					goto done;				}				dbg("usblp%d is VID=0x%4.4X, PID=0x%4.4X",					usblp->minor, twoints[0], twoints[1]);				break;			case IOCNR_SOFT_RESET:				if (_IOC_DIR(cmd) != _IOC_NONE) {					retval = -EINVAL;					goto done;				}				retval = usblp_reset(usblp);				break;			default:				retval = -ENOTTY;		}	else	/* old-style ioctl value */		switch (cmd) {			case LPGETSTATUS:				if (usblp_read_status(usblp, usblp->statusbuf)) {					err("usblp%d: failed reading printer status", usblp->minor);					retval = -EIO;					goto done;				}				status = *usblp->statusbuf;				if (copy_to_user ((void __user *)arg, &status, sizeof(int)))					retval = -EFAULT;				break;			default:				retval = -ENOTTY;		}done:	up (&usblp->sem);	return retval;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/0bc8e009a2d5106183ea31a2b83035e790778cab/usblp.c/buggy/drivers/usb/class/usblp.c