Lines Matching refs:user
777 static void sbefifo_release_command(struct sbefifo_user *user) in sbefifo_release_command() argument
779 if (is_vmalloc_addr(user->pending_cmd)) in sbefifo_release_command()
780 vfree(user->pending_cmd); in sbefifo_release_command()
781 user->pending_cmd = NULL; in sbefifo_release_command()
782 user->pending_len = 0; in sbefifo_release_command()
788 struct sbefifo_user *user; in sbefifo_user_open() local
790 user = kzalloc(sizeof(struct sbefifo_user), GFP_KERNEL); in sbefifo_user_open()
791 if (!user) in sbefifo_user_open()
794 file->private_data = user; in sbefifo_user_open()
795 user->sbefifo = sbefifo; in sbefifo_user_open()
796 user->cmd_page = (void *)__get_free_page(GFP_KERNEL); in sbefifo_user_open()
797 if (!user->cmd_page) { in sbefifo_user_open()
798 kfree(user); in sbefifo_user_open()
801 mutex_init(&user->file_lock); in sbefifo_user_open()
802 user->read_timeout_ms = SBEFIFO_TIMEOUT_START_RSP; in sbefifo_user_open()
810 struct sbefifo_user *user = file->private_data; in sbefifo_user_read() local
817 if (!user) in sbefifo_user_read()
819 sbefifo = user->sbefifo; in sbefifo_user_read()
823 mutex_lock(&user->file_lock); in sbefifo_user_read()
826 if (user->pending_len == 0) { in sbefifo_user_read()
830 if (user->pending_len < 8) { in sbefifo_user_read()
834 cmd_len = user->pending_len >> 2; in sbefifo_user_read()
845 sbefifo->timeout_start_rsp_ms = user->read_timeout_ms; in sbefifo_user_read()
846 rc = __sbefifo_submit(sbefifo, user->pending_cmd, cmd_len, &resp_iter); in sbefifo_user_read()
855 sbefifo_release_command(user); in sbefifo_user_read()
856 mutex_unlock(&user->file_lock); in sbefifo_user_read()
863 struct sbefifo_user *user = file->private_data; in sbefifo_user_write() local
867 if (!user) in sbefifo_user_write()
869 sbefifo = user->sbefifo; in sbefifo_user_write()
875 mutex_lock(&user->file_lock); in sbefifo_user_write()
879 user->pending_cmd = user->cmd_page; in sbefifo_user_write()
881 user->pending_cmd = vmalloc(len); in sbefifo_user_write()
882 if (!user->pending_cmd) { in sbefifo_user_write()
888 if (copy_from_user(user->pending_cmd, buf, len)) { in sbefifo_user_write()
894 if (len == 4 && be32_to_cpu(*(__be32 *)user->pending_cmd) == in sbefifo_user_write()
898 user->pending_len = 0; in sbefifo_user_write()
904 rc = sbefifo_request_reset(user->sbefifo); in sbefifo_user_write()
912 user->pending_len = len; in sbefifo_user_write()
914 if (!user->pending_len) in sbefifo_user_write()
915 sbefifo_release_command(user); in sbefifo_user_write()
917 mutex_unlock(&user->file_lock); in sbefifo_user_write()
925 struct sbefifo_user *user = file->private_data; in sbefifo_user_release() local
927 if (!user) in sbefifo_user_release()
930 sbefifo_release_command(user); in sbefifo_user_release()
931 free_page((unsigned long)user->cmd_page); in sbefifo_user_release()
932 kfree(user); in sbefifo_user_release()
937 static int sbefifo_read_timeout(struct sbefifo_user *user, void __user *argp) in sbefifo_read_timeout() argument
939 struct device *dev = &user->sbefifo->dev; in sbefifo_read_timeout()
946 user->read_timeout_ms = SBEFIFO_TIMEOUT_START_RSP; in sbefifo_read_timeout()
947 dev_dbg(dev, "Timeout reset to %d\n", user->read_timeout_ms); in sbefifo_read_timeout()
954 user->read_timeout_ms = timeout * 1000; /* user timeout is in sec */ in sbefifo_read_timeout()
956 dev_dbg(dev, "Timeout set to %d\n", user->read_timeout_ms); in sbefifo_read_timeout()
963 struct sbefifo_user *user = file->private_data; in sbefifo_user_ioctl() local
966 if (!user) in sbefifo_user_ioctl()
969 mutex_lock(&user->file_lock); in sbefifo_user_ioctl()
972 rc = sbefifo_read_timeout(user, (void __user *)arg); in sbefifo_user_ioctl()
975 mutex_unlock(&user->file_lock); in sbefifo_user_ioctl()