hotplug: call handle_device.d/ actions for remove

* Original actions didn't care about remove (10-span-types, 20-span-assignments)
* But others need to know about removals too.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
registration-order: Added dahdi_auto_assign_compat

Maintains the original registration order as was before span
assignments. Should allow seemless trannsition to
dahdi.auto_assign_spans=0

* The idea:
  - We stop handling in udev the case of missing
    /etc/dahdi/assigned-spans.conf
  - Instead we rely on "registration_time" dahdi_device attribute from
    DAHDI-linux
  - Then, we can sort the devices and assign their spans in
    /etc/init.d/dahdi
* Mechanics:
  - From /etc/init.d/dahdi, we run a new 'dahdi_auto_assign_compat'
    script (after "waitfor_xpds" etc.)
  - In this script we "auto" assign spans of non-Astribank devices
  - In the end of the script we run "dahdi_registration" which
    does the same for Astribank devices.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
improved dahdi_span_types dumpconfig

* Better defaults:
  - A wildcard match:
    - If '--line-mode' option is given, generate a wildcard entry.
      (existing behavior).

    - Otherwise, if *all spans* are of the same type (E1/T1),
      generate a wildcard entry for this type.
      This is the most common use-case and now it work without
      any command line flags.

    - Otherwise (mixed E1/T1 spans), do not generate a wildcard entry.
      This isn't common case (except from our labs), but regardless
      without '--line-mode' any guess could be wrong.

  - Specific device matches:
    - If all spans are of the same type, generate commented out
      specific entries (for manual overrides).

    - If spans have mixed E1/T1 types, generate specific entries
      In this case, specific entries MUST NOT be commented out
      otherwise, the configuration file is wrong!

* Generated header with better organization:
  - Shows what is generated:
    - Generating wildcard / Not generating wildcard
    - Generating specific lines / Generating *commented-out* specific lines

  - For each decision, show *why* it was taken.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
xpp: dahdi_registration: force re-assignment

* The system state causing the bug:
  - DAHDI has auto_assign_spans==1
  - No /etc/dahdi/assigned-spans.conf

* The bug scenario:
  - During initial device detection, they are assigned by
    DAHDI driver.
  - Later we run "dahdi_span_assignment remove"
  - Then, a "dahdi_registration on" would not assign any span.

* The fix:
  - Using the '-R' option, force "dahdi_registration on" to also
    do "dahdi_span_assignment auto" on relevant devices.
  - This is the way it's called by /usr/share/dahdi/dahdi_auto_assign_compat

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
xpp: waitfor_xpds: handle missing serial numbers

Fixes a regression since 949ea4ca9f9c9050811af9e80d44530beb10fd8f
(2.7.0) - allows using an Astribank with no serial.

* Some of the olderst Astribanks don't have a serial number burned in
  them. Thus there is no serial attribute for the sysfs USB device node.

* waitfor_xpds identifies the Astribanks by their serial numbers.

* An lone Astribank without serial number would thus block waitfor_xpds
  (until timeout).

* Now we warn about them.

* We also try to handle it gracefully. As long as there's only one
  of thease, it would be counted as "NO-SERIAL".

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
dahdi_genconf: remove hard-coded E1 default

* The "spantypes" generator had E1 default if no 'line-mode' parameter
  was passed.

* As a result the new logic in "dahdi_span_types dumpconfig" had no
  effect when called from dahdi_genconf, as it was always called
  with "--line-mode=" argument.

* Now "dahdi_genconf spantype" behaves just like
  "dahdi_span_types dumpconfig":
  - The "--line-mode=" forces generation of provided line-mode (E1/J1/T1)
  - Without this option, the generated config matches the current spans
    state according to new dahd_span_types default logic:
    - Wildcard rule if all spans have same line-mode.
    - Uncommented specific matches if spans have different line-modes.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
system.conf.sample: Remove reference to single frequency signalling.

Single frequency signalling has not been supported in dahdi_cfg since the switch
to DAHDI. Before DAHDI, in the Zaptel days, it was only suported in the
ztcfg_dude utility which wasn't mainlined. So this removes references to those
signalling modes unless support is added back into the driver.

Internal-Issue-ID: DAHLIN-335
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
xpp: safer compilation

* Compile with "-Wall -Werror"
* Better dependency calculation:
  - Explicit listing of sources, don't use wildcards.
  - Pass various CFLAGS to dependency calculation as well.
  - Make sure a failure is propagated

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: fix usb "clear_halt" problem

 * Don't use "usb_clear_halt" by default anymore
   - It caused problems with specific devices in the past
   - Now it cause problems with specific servers as well (64 bits, USB3)

 * Add an "XTALK_OPTIONS" environment variable to pass options:
   - Use it to implement a "use-clear-halt" boolean option that
     restore original behavior.
   - Also use it for "no-lock" option which replace the legacy
     environment variable "XUSB_NOLOCK".
xpp: better error checking (echo_loader)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: Don't generate .depends if there's no libusb

Creating the The .depends file requires libusb support.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>