Commit a37ddced authored by Patrick Boettcher's avatar Patrick Boettcher Committed by Mauro Carvalho Chehab

V4L/DVB (4657): Power control of the device for dual board

Corrected power control of the device for dual boards
Signed-off-by: default avatarPatrick Boettcher <pb@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 1d574360
...@@ -136,7 +136,7 @@ static int dvb_usb_init(struct dvb_usb_device *d) ...@@ -136,7 +136,7 @@ static int dvb_usb_init(struct dvb_usb_device *d)
if (d->priv == NULL) { if (d->priv == NULL) {
err("no memory for priv in 'struct dvb_usb_device'"); err("no memory for priv in 'struct dvb_usb_device'");
return -ENOMEM; return -ENOMEM;
} }
} }
/* check the capabilities and set appropriate variables */ /* check the capabilities and set appropriate variables */
...@@ -197,8 +197,13 @@ static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device ...@@ -197,8 +197,13 @@ static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device
int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff) int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff)
{ {
if (d->powered == !onoff) { if (onoff)
d->powered = onoff; d->powered++;
else
d->powered--;
if (d->powered == 0 || (onoff && d->powered == 1)) { // when switching from 1 to 0 or from 0 to 1
deb_info("power control: %d\n", onoff);
if (d->props.power_ctrl) if (d->props.power_ctrl)
return d->props.power_ctrl(d, onoff); return d->props.power_ctrl(d, onoff);
} }
......
...@@ -325,6 +325,8 @@ struct dvb_usb_adapter { ...@@ -325,6 +325,8 @@ struct dvb_usb_adapter {
* @desc: pointer to the device's struct dvb_usb_device_description. * @desc: pointer to the device's struct dvb_usb_device_description.
* @state: initialization and runtime state of the device. * @state: initialization and runtime state of the device.
* *
* @powered: indicated whether the device is power or not.
* Powered is in/decremented for each call to modify the state.
* @udev: pointer to the device's struct usb_device. * @udev: pointer to the device's struct usb_device.
* *
* @usb_mutex: semaphore of USB control messages (reading needs two messages) * @usb_mutex: semaphore of USB control messages (reading needs two messages)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment