Lines Matching refs:fp
56 static int hmcdrv_dev_open(struct inode *inode, struct file *fp);
57 static int hmcdrv_dev_release(struct inode *inode, struct file *fp);
58 static loff_t hmcdrv_dev_seek(struct file *fp, loff_t pos, int whence);
59 static ssize_t hmcdrv_dev_read(struct file *fp, char __user *ubuf,
61 static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
114 static int hmcdrv_dev_open(struct inode *inode, struct file *fp) in hmcdrv_dev_open() argument
120 if (fp->f_flags & O_NONBLOCK) in hmcdrv_dev_open()
126 if ((fp->f_flags & O_ACCMODE) == O_RDONLY) in hmcdrv_dev_open()
135 fp->private_data = NULL; /* no command yet */ in hmcdrv_dev_open()
140 pr_debug("open file '/dev/%pD' with return code %d\n", fp, rc); in hmcdrv_dev_open()
147 static int hmcdrv_dev_release(struct inode *inode, struct file *fp) in hmcdrv_dev_release() argument
149 pr_debug("closing file '/dev/%pD'\n", fp); in hmcdrv_dev_release()
150 kfree(fp->private_data); in hmcdrv_dev_release()
151 fp->private_data = NULL; in hmcdrv_dev_release()
160 static loff_t hmcdrv_dev_seek(struct file *fp, loff_t pos, int whence) in hmcdrv_dev_seek() argument
164 pos += fp->f_pos; /* new position stored in 'pos' */ in hmcdrv_dev_seek()
175 if (fp->private_data) { in hmcdrv_dev_seek()
176 kfree(fp->private_data); in hmcdrv_dev_seek()
177 fp->private_data = NULL; in hmcdrv_dev_seek()
189 if (fp->f_pos != pos) in hmcdrv_dev_seek()
190 ++fp->f_version; in hmcdrv_dev_seek()
192 fp->f_pos = pos; in hmcdrv_dev_seek()
221 static ssize_t hmcdrv_dev_read(struct file *fp, char __user *ubuf, in hmcdrv_dev_read() argument
226 if (((fp->f_flags & O_ACCMODE) == O_WRONLY) || in hmcdrv_dev_read()
227 (fp->private_data == NULL)) { /* no FTP cmd defined ? */ in hmcdrv_dev_read()
231 retlen = hmcdrv_dev_transfer((char *) fp->private_data, in hmcdrv_dev_read()
235 fp, (long long) *pos, retlen, len); in hmcdrv_dev_read()
246 static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf, in hmcdrv_dev_write() argument
252 fp, (long long) *pos, len); in hmcdrv_dev_write()
254 if (!fp->private_data) { /* first expect a cmd write */ in hmcdrv_dev_write()
255 fp->private_data = kmalloc(len + 1, GFP_KERNEL); in hmcdrv_dev_write()
257 if (!fp->private_data) in hmcdrv_dev_write()
260 if (!copy_from_user(fp->private_data, ubuf, len)) { in hmcdrv_dev_write()
261 ((char *)fp->private_data)[len] = '\0'; in hmcdrv_dev_write()
265 kfree(fp->private_data); in hmcdrv_dev_write()
266 fp->private_data = NULL; in hmcdrv_dev_write()
270 retlen = hmcdrv_dev_transfer((char *) fp->private_data, in hmcdrv_dev_write()
275 pr_debug("write to file '/dev/%pD' returned %zd\n", fp, retlen); in hmcdrv_dev_write()