Corrected power control of the device for dual boards
Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
if (d->priv == NULL) {
err("no memory for priv in 'struct dvb_usb_device'");
return -ENOMEM;
- }
+ }
}
/* check the capabilities and set appropriate variables */
int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff)
{
- if (d->powered == !onoff) {
- d->powered = onoff;
+ if (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)
return d->props.power_ctrl(d, onoff);
}
* @desc: pointer to the device's struct dvb_usb_device_description.
* @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.
*
* @usb_mutex: semaphore of USB control messages (reading needs two messages)