diff options
author | Frank Schaefer <fschaefer.oss@googlemail.com> | 2012-12-27 17:02:43 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-01-04 22:09:39 -0500 |
commit | 2665c2995d6a6026cfc9ec118908dfccb74fb5e0 (patch) | |
tree | ef731f712fc9c95dfdf869434c7ffd37abce892f | |
parent | d3829fadc4611e96aa360b8ead5adefdf61f45ea (diff) |
[media] em28xx: simplify device state tracking
DEV_INITIALIZED of enum em28xx_dev_state state is used nowhere and there is no
need for DEV_MISCONFIGURED, so remove this enum and use a boolean field
'disconnected' in the device struct instead.
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-cards.c | 5 | ||||
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-core.c | 4 | ||||
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-dvb.c | 4 | ||||
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-video.c | 12 | ||||
-rw-r--r-- | drivers/media/usb/em28xx/em28xx.h | 12 |
5 files changed, 11 insertions, 26 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index a4d11a46fd4f..99f2da661c32 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c | |||
@@ -3530,11 +3530,10 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) | |||
3530 | "deallocation are deferred on close.\n", | 3530 | "deallocation are deferred on close.\n", |
3531 | video_device_node_name(dev->vdev)); | 3531 | video_device_node_name(dev->vdev)); |
3532 | 3532 | ||
3533 | dev->state |= DEV_MISCONFIGURED; | ||
3534 | em28xx_uninit_usb_xfer(dev, dev->mode); | 3533 | em28xx_uninit_usb_xfer(dev, dev->mode); |
3535 | dev->state |= DEV_DISCONNECTED; | 3534 | dev->disconnected = 1; |
3536 | } else { | 3535 | } else { |
3537 | dev->state |= DEV_DISCONNECTED; | 3536 | dev->disconnected = 1; |
3538 | em28xx_release_resources(dev); | 3537 | em28xx_release_resources(dev); |
3539 | } | 3538 | } |
3540 | 3539 | ||
diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c index b10d959fefe5..6916e87bc624 100644 --- a/drivers/media/usb/em28xx/em28xx-core.c +++ b/drivers/media/usb/em28xx/em28xx-core.c | |||
@@ -77,7 +77,7 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg, | |||
77 | int ret; | 77 | int ret; |
78 | int pipe = usb_rcvctrlpipe(dev->udev, 0); | 78 | int pipe = usb_rcvctrlpipe(dev->udev, 0); |
79 | 79 | ||
80 | if (dev->state & DEV_DISCONNECTED) | 80 | if (dev->disconnected) |
81 | return -ENODEV; | 81 | return -ENODEV; |
82 | 82 | ||
83 | if (len > URB_MAX_CTRL_SIZE) | 83 | if (len > URB_MAX_CTRL_SIZE) |
@@ -153,7 +153,7 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | |||
153 | int ret; | 153 | int ret; |
154 | int pipe = usb_sndctrlpipe(dev->udev, 0); | 154 | int pipe = usb_sndctrlpipe(dev->udev, 0); |
155 | 155 | ||
156 | if (dev->state & DEV_DISCONNECTED) | 156 | if (dev->disconnected) |
157 | return -ENODEV; | 157 | return -ENODEV; |
158 | 158 | ||
159 | if ((len < 1) || (len > URB_MAX_CTRL_SIZE)) | 159 | if ((len < 1) || (len > URB_MAX_CTRL_SIZE)) |
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index 01bb8006f659..a81ec2e8cc9b 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c | |||
@@ -135,7 +135,7 @@ static inline int em28xx_dvb_urb_data_copy(struct em28xx *dev, struct urb *urb) | |||
135 | if (!dev) | 135 | if (!dev) |
136 | return 0; | 136 | return 0; |
137 | 137 | ||
138 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | 138 | if (dev->disconnected) |
139 | return 0; | 139 | return 0; |
140 | 140 | ||
141 | if (urb->status < 0) | 141 | if (urb->status < 0) |
@@ -1322,7 +1322,7 @@ static int em28xx_dvb_fini(struct em28xx *dev) | |||
1322 | if (dev->dvb) { | 1322 | if (dev->dvb) { |
1323 | struct em28xx_dvb *dvb = dev->dvb; | 1323 | struct em28xx_dvb *dvb = dev->dvb; |
1324 | 1324 | ||
1325 | if (dev->state & DEV_DISCONNECTED) { | 1325 | if (dev->disconnected) { |
1326 | /* We cannot tell the device to sleep | 1326 | /* We cannot tell the device to sleep |
1327 | * once it has been unplugged. */ | 1327 | * once it has been unplugged. */ |
1328 | if (dvb->fe[0]) | 1328 | if (dvb->fe[0]) |
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index 57510c0d383c..40b96d17ccf8 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c | |||
@@ -418,7 +418,7 @@ static inline int em28xx_urb_data_copy(struct em28xx *dev, struct urb *urb) | |||
418 | if (!dev) | 418 | if (!dev) |
419 | return 0; | 419 | return 0; |
420 | 420 | ||
421 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | 421 | if (dev->disconnected) |
422 | return 0; | 422 | return 0; |
423 | 423 | ||
424 | if (urb->status < 0) | 424 | if (urb->status < 0) |
@@ -801,16 +801,10 @@ const struct v4l2_ctrl_ops em28xx_ctrl_ops = { | |||
801 | 801 | ||
802 | static int check_dev(struct em28xx *dev) | 802 | static int check_dev(struct em28xx *dev) |
803 | { | 803 | { |
804 | if (dev->state & DEV_DISCONNECTED) { | 804 | if (dev->disconnected) { |
805 | em28xx_errdev("v4l2 ioctl: device not present\n"); | 805 | em28xx_errdev("v4l2 ioctl: device not present\n"); |
806 | return -ENODEV; | 806 | return -ENODEV; |
807 | } | 807 | } |
808 | |||
809 | if (dev->state & DEV_MISCONFIGURED) { | ||
810 | em28xx_errdev("v4l2 ioctl: device is misconfigured; " | ||
811 | "close and open it again\n"); | ||
812 | return -EIO; | ||
813 | } | ||
814 | return 0; | 808 | return 0; |
815 | } | 809 | } |
816 | 810 | ||
@@ -1708,7 +1702,7 @@ static int em28xx_v4l2_close(struct file *filp) | |||
1708 | if (dev->users == 1) { | 1702 | if (dev->users == 1) { |
1709 | /* the device is already disconnect, | 1703 | /* the device is already disconnect, |
1710 | free the remaining resources */ | 1704 | free the remaining resources */ |
1711 | if (dev->state & DEV_DISCONNECTED) { | 1705 | if (dev->disconnected) { |
1712 | em28xx_release_resources(dev); | 1706 | em28xx_release_resources(dev); |
1713 | kfree(dev->alt_max_pkt_size_isoc); | 1707 | kfree(dev->alt_max_pkt_size_isoc); |
1714 | mutex_unlock(&dev->lock); | 1708 | mutex_unlock(&dev->lock); |
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index bf0a790f7eb9..f891a28706f5 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h | |||
@@ -439,13 +439,6 @@ struct em28xx_eeprom { | |||
439 | u8 string_idx_table; | 439 | u8 string_idx_table; |
440 | }; | 440 | }; |
441 | 441 | ||
442 | /* device states */ | ||
443 | enum em28xx_dev_state { | ||
444 | DEV_INITIALIZED = 0x01, | ||
445 | DEV_DISCONNECTED = 0x02, | ||
446 | DEV_MISCONFIGURED = 0x04, | ||
447 | }; | ||
448 | |||
449 | #define EM28XX_AUDIO_BUFS 5 | 442 | #define EM28XX_AUDIO_BUFS 5 |
450 | #define EM28XX_NUM_AUDIO_PACKETS 64 | 443 | #define EM28XX_NUM_AUDIO_PACKETS 64 |
451 | #define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */ | 444 | #define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */ |
@@ -492,6 +485,8 @@ struct em28xx { | |||
492 | int devno; /* marks the number of this device */ | 485 | int devno; /* marks the number of this device */ |
493 | enum em28xx_chip_id chip_id; | 486 | enum em28xx_chip_id chip_id; |
494 | 487 | ||
488 | unsigned char disconnected:1; /* device has been diconnected */ | ||
489 | |||
495 | int audio_ifnum; | 490 | int audio_ifnum; |
496 | 491 | ||
497 | struct v4l2_device v4l2_dev; | 492 | struct v4l2_device v4l2_dev; |
@@ -563,9 +558,6 @@ struct em28xx { | |||
563 | 558 | ||
564 | struct em28xx_audio adev; | 559 | struct em28xx_audio adev; |
565 | 560 | ||
566 | /* states */ | ||
567 | enum em28xx_dev_state state; | ||
568 | |||
569 | /* capture state tracking */ | 561 | /* capture state tracking */ |
570 | int capture_type; | 562 | int capture_type; |
571 | unsigned char top_field:1; | 563 | unsigned char top_field:1; |