diff options
author | Hans de Goede <hdegoede@redhat.com> | 2010-12-31 03:05:56 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-01-19 08:44:58 -0500 |
commit | ee3629914b2b115f00f4197e80b1e7cb12881059 (patch) | |
tree | e3234e9d6c17dceec91e604782adb0e796364b1a /drivers/media | |
parent | d642de2ed472df308f8ee49417e29030f69b2095 (diff) |
[media] gspca_main: Simplify read mode memory type checks
gspca_dev->memory == GSPCA_MEMORY_NO implies gspca_dev->nframes == 0,
so there is no need to check for both in dev_poll. The check in
dev_read also is more complex then needed, as dqbuf which dev_read
calls already does all necessary checks. Moreover dqbuf is holding
the proper locks while checking where as dev_read itself is not.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/gspca/gspca.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index adab34f91a68..244fb76eaead 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -2019,9 +2019,7 @@ static unsigned int dev_poll(struct file *file, poll_table *wait) | |||
2019 | poll_wait(file, &gspca_dev->wq, wait); | 2019 | poll_wait(file, &gspca_dev->wq, wait); |
2020 | 2020 | ||
2021 | /* if reqbufs is not done, the user would use read() */ | 2021 | /* if reqbufs is not done, the user would use read() */ |
2022 | if (gspca_dev->nframes == 0) { | 2022 | if (gspca_dev->memory == GSPCA_MEMORY_NO) { |
2023 | if (gspca_dev->memory != GSPCA_MEMORY_NO) | ||
2024 | return POLLERR; /* not the 1st time */ | ||
2025 | ret = read_alloc(gspca_dev, file); | 2023 | ret = read_alloc(gspca_dev, file); |
2026 | if (ret != 0) | 2024 | if (ret != 0) |
2027 | return POLLERR; | 2025 | return POLLERR; |
@@ -2053,18 +2051,10 @@ static ssize_t dev_read(struct file *file, char __user *data, | |||
2053 | PDEBUG(D_FRAM, "read (%zd)", count); | 2051 | PDEBUG(D_FRAM, "read (%zd)", count); |
2054 | if (!gspca_dev->present) | 2052 | if (!gspca_dev->present) |
2055 | return -ENODEV; | 2053 | return -ENODEV; |
2056 | switch (gspca_dev->memory) { | 2054 | if (gspca_dev->memory == GSPCA_MEMORY_NO) { /* first time ? */ |
2057 | case GSPCA_MEMORY_NO: /* first time */ | ||
2058 | ret = read_alloc(gspca_dev, file); | 2055 | ret = read_alloc(gspca_dev, file); |
2059 | if (ret != 0) | 2056 | if (ret != 0) |
2060 | return ret; | 2057 | return ret; |
2061 | break; | ||
2062 | case GSPCA_MEMORY_READ: | ||
2063 | if (gspca_dev->capt_file == file) | ||
2064 | break; | ||
2065 | /* fall thru */ | ||
2066 | default: | ||
2067 | return -EINVAL; | ||
2068 | } | 2058 | } |
2069 | 2059 | ||
2070 | /* get a frame */ | 2060 | /* get a frame */ |