792
793raise_submit:
794raise_badaddr:
795 usb_unanchor_urb(writeurb);
796 usb_free_urb(writeurb);
797raise_urb:
798raise_wait:
799collect_error:
800 mutex_unlock(&usblp->wmut);
801raise_biglock:
802 return writecount ? writecount : rv;
803}
804
805
806
807
808
809
810static ssize_t usblp_read(struct file *file, char __user *buffer, size_t len, loff_t *ppos)
811{
812 struct usblp *usblp = file->private_data;
813 ssize_t count;
814 ssize_t avail;
815 int rv;
816
817 if (!usblp->bidir)
818 return -EINVAL;
819
820 rv = usblp_rwait_and_lock(usblp, !!(file->f_flags & O_NONBLOCK));
821 if (rv < 0)
822 return rv;
823
824 if ((avail = usblp->rstatus) < 0) {
825 printk(KERN_ERR "usblp%d: error %d reading from printer\n",
826 usblp->minor, (int)avail);
827 usblp_submit_read(usblp);
828 count = -EIO;
829 goto done;
830 }
831
832 count = len < avail - usblp->readcount ? len : avail - usblp->readcount;