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