1. 05 Sep, 2018 2 commits
    • spiiroin's avatar
      [usb-moded] Remove redundant include statements · 176b53cf
      spiiroin authored
      Make all local header files self-sufficient.
      
      Normalize order of including header files, so that header corresponding with
      compilation module is included first, followed by local headers, system
      headers, standard headers, and finally headers from auxiliary libraries.
      
      Remove all include statements that are, or are made redundant by the above
      changes.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      176b53cf
    • spiiroin's avatar
      [usb-moded] Move synchronous mode switch to worker thread. Fixes JB#42757 · 57d404a3
      spiiroin authored
      Mode switching in usb-moded is done via synchronous ipc / otherwise
      blocking operations - which makes usb-moded mainloop unable to process
      for example udev events / dbus requests from clients during the swich
      and causes potentially stale events to be seen after the mode switch.
      
      Separate mode selection from mode activation so that the latter is
      executed from worker thread.
      
      Distribute existing code in manner that makes the selection vs activation,
      or mainloop / worker thread separation more apparent:
      - control.c: Mode selection logic
      - worker.c:  Mode activation logic
      
      And move miscellaneous functions that have accumulated into the main
      usb-moded module to:
      
      - common.c:  Generic helper functions
      - sigpipe.c: Asynchronous signal trapping
      
      Rename all moved functions so that they still have prefix indicating the
      containing module.
      
      Refuse synchronous sleeps in order to terminate ongoing mode switch
      if udev events / other inputs invalidate the target of transition.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      57d404a3
  2. 24 Aug, 2018 3 commits
    • spiiroin's avatar
      [usb_moded] Do not track pc / charger connect separately. JB#41748 · 8e469091
      spiiroin authored
      Handling "connected to pc" and "connected to charger" as separate boolean
      states just complicates things.
      
      Move cable_state_t enumeration values from udev module to usb_moded.h
      to make them generally available.
      
      Utilize cable_state_t also within usb_moded.c module.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      8e469091
    • spiiroin's avatar
      [usb_moded] Refactor entering/leaving usb mode. JB#41748 · 64350689
      spiiroin authored
      Split mode switching to three layers: Tracking cable connection state,
      choosing target mode, and performing required actions to activate
      the chosen mode.
      
      Try to minimize places where layer borders are crossed - which should
      work also as an enabler for moving blocking actions to separate thread
      later on.
      
      Arrange logic in such manner that usb gadget is always configured as
      being able to serve some function - fallback being the dummy mass_storage
      function used for charging.
      
      Deprecate command line options that serve no useful purpose after the
      changes.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      64350689
    • spiiroin's avatar
      [usb_moded] Add configfs support. Fixes JB#42083 · 692c2cb3
      spiiroin authored
      Add custom Makefile for faster smoke-test rebuilds without spending time
      in configure, autotools, document generation and/or rolling rpm packages.
      
      Add multiple include protection to all header files.
      
      Move function prototypes away from header files that included in the
      development package.
      
      Mass rename functions to have a prefix giving context for the function.
      For the most part the prefix is derived from the name of the compilation
      module containing the function.
      
      Mass normalize indentation to four spaces in all source files.
      
      Augment author lists on each source file based on git committers.
      
      Remove "inline" attributes from not-really-inlineable functions.
      
      Remove .gitignore.
      
      Remove unused modules-android.c source file.
      
      Define _GNU_SOURCE for whole build rather than in individual files.
      
      Fix resource leaks here and there.
      
      Try to avoid hard-coding android usb paths.
      
      Add configfs backend for usb cadget configuration.
      
      Probe supported backends (configfs, android usb, or kmod) on usb-moded
      startup and make them mutually exclusive with each other.
      
      Allow configfs and android usb control structures some time to show up
      if usb-moded is started during device bootup.
      
      Refactor udev event listener to utilize a state machine. Simplifies
      book keeping and makes pc/charger detection heuristics easier to control.
      
      Refactor mode selection to utilize three interconnected mini state machines.
      Allows separating logically wanted mode from mode programmed to usb and
      mode exposed over D-Bus.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      692c2cb3
  3. 05 Jun, 2018 1 commit
  4. 28 Mar, 2018 2 commits
  5. 17 Aug, 2017 1 commit
  6. 11 Aug, 2017 1 commit
  7. 07 Nov, 2016 4 commits
    • spiiroin's avatar
      [usb-moded] Fix issues on exit path. MER#1694 · b3e2f370
      spiiroin authored
      Exiting from mainloop does not work as intended, looks like handle_exit()
      is meant to be called from main() function after mainloop is stopped. What
      happens in practice is that handle_exit() gets called from signal handler
      and it makes exit() without ever returning to main() function - which
      means some cleanup tasks are skipped.
      
      In general: Make cleanup tasks happen on the same logical level where
      initialization is made, re-order init/cleanup tasks according to what
      functional inter dependencies exist and add comments describing why
      things are done when they are done.
      
      Remove handle_exit() function and distribute work it used to do among:
      - usb_moded_stop() - exiting from mainloop
      - usb_moded_cleanup() - releasing usb-mode related state/config data
      - main() - cleaning up init steps made from main()
      
      To make possible ordering issues more visible, refuse to send usb-moded
      dbus signals in situations where the service name is not owned by the
      ubs-moded process.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      b3e2f370
    • spiiroin's avatar
      [dsme] Make device state tracking asynchronous. MER#1694 · 4e7f9709
      spiiroin authored
      Usb-moded is making repeated blocking device state queries even when the
      component providing the service is not running.
      
      Use cached device state and keep it up to date fully asynchronously by
      tracking dsme service availability and state changes it signals.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      4e7f9709
    • spiiroin's avatar
      [dbus] Add helper function for making async name owner queries. MER#1694 · 14092c64
      spiiroin authored
      Enabler for making various dbus tracking activities asynchronous.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      14092c64
    • spiiroin's avatar
      [dbus] Improve SystemBus connection management. MER#1694 · 3e9e1817
      spiiroin authored
      D-Bus SystemBus connection is made from several places. Explicitly
      from the main() and implicitly from various modules that do ipc
      with other components. This makes it hard to tell when connection
      actually gets made, process wide dbus initialization happens in
      the wrong place and setting up signal matches is delayed by the
      synchronous initialization activity during startup.
      
      Move dbus_threads_init_default() to more appropriate place so that
      it actually is the first libdbus call that gets made.
      
      Handle connecting to SystemBus and installing signal listeners as early
      as possible and claim usb-moded service name separately when usb-moded
      is ready to process requests made over D-Bus.
      
      Add usb_moded_dbus_get_connection() function that other modules can
      use to get reference to the SystemBus connection when/if one has been
      made from the main logic.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      3e9e1817
  8. 03 Nov, 2016 1 commit
  9. 18 Oct, 2016 1 commit
  10. 07 Jul, 2016 2 commits
  11. 29 Apr, 2016 1 commit
    • spiiroin's avatar
      [dbus] Handle missing mode setting gracefully. Fixes MER#1576 · 1aadb958
      spiiroin authored
      If usb mode setting is not present in usb-moded.ini and override is not
      specified in kernel command line, get_mode_setting() will return null.
      The handler for "get_config" D-Bus method call does not check the return
      value and using the null value triggers abort from sanity checks at
      libdbus. Attempting to pass NULL as string via D-Bus causes abort.
      
      Use MODE_UNDEFINED as fallback in case the setting value is not defined.
      
      Also remove potential memory leaks in the code used for determining the
      mode setting value and use correct function for releasing the resulting
      dynamically allocated string.
      Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
      1aadb958
  12. 04 Apr, 2016 1 commit
  13. 15 Dec, 2015 2 commits
  14. 26 May, 2015 1 commit
  15. 21 Apr, 2015 1 commit
  16. 09 Mar, 2015 1 commit
  17. 07 Nov, 2014 1 commit
  18. 16 Sep, 2014 1 commit
  19. 15 Sep, 2014 1 commit
  20. 09 Sep, 2014 1 commit
  21. 26 Aug, 2014 1 commit
  22. 22 May, 2014 1 commit
  23. 21 Mar, 2014 1 commit
  24. 18 Mar, 2014 2 commits
  25. 29 Oct, 2013 1 commit
  26. 25 Oct, 2013 2 commits
  27. 24 Oct, 2013 1 commit
  28. 22 Oct, 2013 2 commits