Lines Matching full:user
780 static void sbefifo_release_command(struct sbefifo_user *user) in sbefifo_release_command() argument
782 if (is_vmalloc_addr(user->pending_cmd)) in sbefifo_release_command()
783 vfree(user->pending_cmd); in sbefifo_release_command()
784 user->pending_cmd = NULL; in sbefifo_release_command()
785 user->pending_len = 0; in sbefifo_release_command()
791 struct sbefifo_user *user; in sbefifo_user_open() local
793 user = kzalloc(sizeof(struct sbefifo_user), GFP_KERNEL); in sbefifo_user_open()
794 if (!user) in sbefifo_user_open()
797 file->private_data = user; in sbefifo_user_open()
798 user->sbefifo = sbefifo; in sbefifo_user_open()
799 user->cmd_page = (void *)__get_free_page(GFP_KERNEL); in sbefifo_user_open()
800 if (!user->cmd_page) { in sbefifo_user_open()
801 kfree(user); in sbefifo_user_open()
804 mutex_init(&user->file_lock); in sbefifo_user_open()
805 user->read_timeout_ms = SBEFIFO_TIMEOUT_START_RSP; in sbefifo_user_open()
813 struct sbefifo_user *user = file->private_data; in sbefifo_user_read() local
820 if (!user) in sbefifo_user_read()
822 sbefifo = user->sbefifo; in sbefifo_user_read()
826 mutex_lock(&user->file_lock); in sbefifo_user_read()
829 if (user->pending_len == 0) { in sbefifo_user_read()
833 if (user->pending_len < 8) { in sbefifo_user_read()
837 cmd_len = user->pending_len >> 2; in sbefifo_user_read()
848 sbefifo->timeout_start_rsp_ms = user->read_timeout_ms; in sbefifo_user_read()
849 rc = __sbefifo_submit(sbefifo, user->pending_cmd, cmd_len, &resp_iter); in sbefifo_user_read()
858 sbefifo_release_command(user); in sbefifo_user_read()
859 mutex_unlock(&user->file_lock); in sbefifo_user_read()
866 struct sbefifo_user *user = file->private_data; in sbefifo_user_write() local
870 if (!user) in sbefifo_user_write()
872 sbefifo = user->sbefifo; in sbefifo_user_write()
878 mutex_lock(&user->file_lock); in sbefifo_user_write()
882 user->pending_cmd = user->cmd_page; in sbefifo_user_write()
884 user->pending_cmd = vmalloc(len); in sbefifo_user_write()
885 if (!user->pending_cmd) { in sbefifo_user_write()
891 if (copy_from_user(user->pending_cmd, buf, len)) { in sbefifo_user_write()
897 if (len == 4 && be32_to_cpu(*(__be32 *)user->pending_cmd) == in sbefifo_user_write()
901 user->pending_len = 0; in sbefifo_user_write()
907 rc = sbefifo_request_reset(user->sbefifo); in sbefifo_user_write()
915 user->pending_len = len; in sbefifo_user_write()
917 if (!user->pending_len) in sbefifo_user_write()
918 sbefifo_release_command(user); in sbefifo_user_write()
920 mutex_unlock(&user->file_lock); in sbefifo_user_write()
928 struct sbefifo_user *user = file->private_data; in sbefifo_user_release() local
930 if (!user) in sbefifo_user_release()
933 sbefifo_release_command(user); in sbefifo_user_release()
934 free_page((unsigned long)user->cmd_page); in sbefifo_user_release()
935 kfree(user); in sbefifo_user_release()
940 static int sbefifo_read_timeout(struct sbefifo_user *user, void __user *argp) in sbefifo_read_timeout() argument
942 struct device *dev = &user->sbefifo->dev; in sbefifo_read_timeout()
949 user->read_timeout_ms = SBEFIFO_TIMEOUT_START_RSP; in sbefifo_read_timeout()
950 dev_dbg(dev, "Timeout reset to %d\n", user->read_timeout_ms); in sbefifo_read_timeout()
957 user->read_timeout_ms = timeout * 1000; /* user timeout is in sec */ in sbefifo_read_timeout()
959 dev_dbg(dev, "Timeout set to %d\n", user->read_timeout_ms); in sbefifo_read_timeout()
966 struct sbefifo_user *user = file->private_data; in sbefifo_user_ioctl() local
969 if (!user) in sbefifo_user_ioctl()
972 mutex_lock(&user->file_lock); in sbefifo_user_ioctl()
975 rc = sbefifo_read_timeout(user, (void __user *)arg); in sbefifo_user_ioctl()
978 mutex_unlock(&user->file_lock); in sbefifo_user_ioctl()