Lines Matching refs:fp
55 static int hmcdrv_dev_open(struct inode *inode, struct file *fp);
56 static int hmcdrv_dev_release(struct inode *inode, struct file *fp);
57 static loff_t hmcdrv_dev_seek(struct file *fp, loff_t pos, int whence);
58 static ssize_t hmcdrv_dev_read(struct file *fp, char __user *ubuf,
60 static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
113 static int hmcdrv_dev_open(struct inode *inode, struct file *fp) in hmcdrv_dev_open() argument
119 if (fp->f_flags & O_NONBLOCK) in hmcdrv_dev_open()
125 if ((fp->f_flags & O_ACCMODE) == O_RDONLY) in hmcdrv_dev_open()
134 fp->private_data = NULL; /* no command yet */ in hmcdrv_dev_open()
139 pr_debug("open file '/dev/%pD' with return code %d\n", fp, rc); in hmcdrv_dev_open()
146 static int hmcdrv_dev_release(struct inode *inode, struct file *fp) in hmcdrv_dev_release() argument
148 pr_debug("closing file '/dev/%pD'\n", fp); in hmcdrv_dev_release()
149 kfree(fp->private_data); in hmcdrv_dev_release()
150 fp->private_data = NULL; in hmcdrv_dev_release()
159 static loff_t hmcdrv_dev_seek(struct file *fp, loff_t pos, int whence) in hmcdrv_dev_seek() argument
163 pos += fp->f_pos; /* new position stored in 'pos' */ in hmcdrv_dev_seek()
174 if (fp->private_data) { in hmcdrv_dev_seek()
175 kfree(fp->private_data); in hmcdrv_dev_seek()
176 fp->private_data = NULL; in hmcdrv_dev_seek()
188 if (fp->f_pos != pos) in hmcdrv_dev_seek()
189 ++fp->f_version; in hmcdrv_dev_seek()
191 fp->f_pos = pos; in hmcdrv_dev_seek()
220 static ssize_t hmcdrv_dev_read(struct file *fp, char __user *ubuf, in hmcdrv_dev_read() argument
225 if (((fp->f_flags & O_ACCMODE) == O_WRONLY) || in hmcdrv_dev_read()
226 (fp->private_data == NULL)) { /* no FTP cmd defined ? */ in hmcdrv_dev_read()
230 retlen = hmcdrv_dev_transfer((char *) fp->private_data, in hmcdrv_dev_read()
234 fp, (long long) *pos, retlen, len); in hmcdrv_dev_read()
245 static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf, in hmcdrv_dev_write() argument
251 fp, (long long) *pos, len); in hmcdrv_dev_write()
253 if (!fp->private_data) { /* first expect a cmd write */ in hmcdrv_dev_write()
254 fp->private_data = kmalloc(len + 1, GFP_KERNEL); in hmcdrv_dev_write()
256 if (!fp->private_data) in hmcdrv_dev_write()
259 if (!copy_from_user(fp->private_data, ubuf, len)) { in hmcdrv_dev_write()
260 ((char *)fp->private_data)[len] = '\0'; in hmcdrv_dev_write()
264 kfree(fp->private_data); in hmcdrv_dev_write()
265 fp->private_data = NULL; in hmcdrv_dev_write()
269 retlen = hmcdrv_dev_transfer((char *) fp->private_data, in hmcdrv_dev_write()
274 pr_debug("write to file '/dev/%pD' returned %zd\n", fp, retlen); in hmcdrv_dev_write()