Commit 39a3a90c authored by spiiroin's avatar spiiroin

[usb_moded] Move connect/disconnect signaling to udev

Cable connect/disconnect is detected at udev module - handling the
related dbus signaling in the same place allows simplifying the usb
mode related logic.
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent b1c56ebf
......@@ -44,6 +44,7 @@
#include "usb_moded-udev.h"
#include "usb_moded.h"
#include "usb_moded-modes.h"
#include "usb_moded-dbus-private.h"
/* ========================================================================= *
* Types
......@@ -202,10 +203,12 @@ static void cable_state_changed(void)
break;
case CABLE_STATE_CHARGER_CONNECTED:
log_debug("*** HANDLE CHARGER DISCONNECT");
umdbus_send_state_signal(CHARGER_DISCONNECTED);
usbmoded_set_charger_connected(false);
break;
case CABLE_STATE_PC_CONNECTED:
log_debug("*** HANDLE PC DISCONNECT");
umdbus_send_state_signal(USB_DISCONNECTED);
usbmoded_set_usb_connected(false);
break;
}
......@@ -221,10 +224,12 @@ static void cable_state_changed(void)
break;
case CABLE_STATE_CHARGER_CONNECTED:
log_debug("*** HANDLE CHARGER CONNECT");
umdbus_send_state_signal(CHARGER_CONNECTED);
usbmoded_set_charger_connected(true);
break;
case CABLE_STATE_PC_CONNECTED:
log_debug("*** HANDLE PC CONNECT");
umdbus_send_state_signal(USB_CONNECTED);
usbmoded_set_usb_connected(true);
break;
}
......
......@@ -763,26 +763,14 @@ EXIT:
*/
void usbmoded_set_usb_connected(bool connected)
{
/* Do not go through the routine if already connected to avoid
* spurious load/unloads due to faulty signalling
* NOKIA: careful with devicelock
*/
if( !usbmoded_set_connection_state(connected) )
goto EXIT;
if( usbmoded_get_connection_state() ) {
log_debug("usb connected\n");
/* signal usb connected */
umdbus_send_state_signal(USB_CONNECTED);
/* choose mode, then call usbmoded_set_usb_mode(chosen_mode)
*/
/* choose mode + call usbmoded_set_usb_mode() */
usbmoded_set_usb_connected_state();
}
else {
log_debug("usb disconnected\n");
umdbus_send_state_signal(USB_DISCONNECTED);
usbmoded_set_usb_mode(MODE_UNDEFINED);
}
EXIT:
......@@ -800,11 +788,9 @@ void usbmoded_set_charger_connected(bool state)
goto EXIT;
if( usbmoded_get_connection_state() ) {
umdbus_send_state_signal(CHARGER_CONNECTED);
usbmoded_set_usb_mode(MODE_CHARGER);
}
else {
umdbus_send_state_signal(CHARGER_DISCONNECTED);
usbmoded_set_usb_mode(MODE_UNDEFINED);
}
EXIT:
......
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