Commit Graph

25 Commits

Author SHA1 Message Date
Shaun Ruffell
1058502286 sysfs: refactor lineconfig string representation
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10685 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-05-23 12:36:42 +00:00
Shaun Ruffell
bb2c15c103 sysfs: add a linecompat span attribute
This way, dahdi_genconf may gather needed information without issuing
ioctl()'s

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10684 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-05-23 12:35:56 +00:00
Shaun Ruffell
579132bb89 convert span->spantype to enumerated type
* This is a minimal convertion -- everything compiles and looks OK.
* We print a warning for spans registering without a spantype.
* Low-level drivers may later want (but not required)
  to fold their internal representations to this canonical
  representation -- it will save code and make it more readable.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10683 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-05-23 12:20:23 +00:00
Shaun Ruffell
bf4919e46b Update Digium copyright on files changed since beginning of the year.
In addition to updating the year, this also adds some boilerplate to
dahdi-sysfs.c and dahdi-sysfs-chan.c that wasn't there previously.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10560 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-03-21 18:56:05 +00:00
Shaun Ruffell
07c9bcecf2 dahdi: Remove __exit annotation from dahdi_sysfs_exit().
This removes the following warning:

Section mismatch in reference from the function init_module() to the function .exit.text:dahdi_sysfs_exit()
The function __init init_module() references a function __exit
dahdi_sysfs_exit(). This is often seen when error handling in the init
function uses functionality in the exit path.  The fix is often to remove the
__exit annotation of dahdi_sysfs_exit() so it may be used outside an exit
section.

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

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10483 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-03-15 15:41:32 +00:00
Oron Peled
fc1824fd3c Remove support for kernels < 2.6.18
This patch removes support for kernel versions < 2.6.18, as those are
not actively supported in any major Linux distribution (except RHEL4,
which is in the "extended" support level of the product life cycle).

This removes much of the more #ifdef-rich parts of the code.

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Acked-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10472 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-03-13 20:09:12 +00:00
Oron Peled
308a773fb2 sysfs channels: cleanup device files handling
* Shortcut CLASS_DEV_CREATE/CLASS_DEV_DESTROY. No need to pass repetitive
  data (and NULL) on every call.

* Create/remove fixed device files (ctl, timer, channel, pseudo) via
  generic code (fixed_devfiles_create()/fixed_devfiles_remove()) instead
  of repetitive code and flags.

* Try to make all removal/cleanup functions idempotent, so we can
  safely call them on any failure without the need for multiple goto
  destinations.

* Rename 'device_state_flags' to 'should_cleanup' and its member
  flags to a better/consistent naming.

* Rename dahdi_sysfs_exit() to dahdi_sysfs_cleanup() and call it from
  a new proper dahdi_sysfs_exit()

* In dahdi_sysfs_init(), handle dahdi_sysfs_chan_init() failures

* Add dahdi_dbg() message before creating/removing all DEVICES
  objects.

* Also move two KERN_INFO messages to a more correct locations:
  - The version reporting should be first (in dahdi-base.c)
  - The "Telephony... on major" reporting should be at the end
    of dahdi_sysfs_init()

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10464 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-02-22 12:12:10 +00:00
Oron Peled
56a3c35273 sysfs channels: dahdi-sysfs-chan.c
* Move sysfs class and device files management into dahdi-sysfs-chan.c
* This does not change functionality, just a preparation for later
  code cleanups and improvements.

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10463 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-02-22 12:11:48 +00:00
Oron Peled
6b59211b3d sysfs channels: refactor compat macros
* Refactor all kernel version compatibility macros that relate
  to sysfs and device files to new header: dahdi-sysfs.h
* No functional change.
* Preparing for a refactor channel device file handling into a new
  source file.

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10462 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-02-22 12:11:23 +00:00
Oron Peled
3df0b7aedc sysfs: add 'lineconfig' attribute to span
This patch exposes the span 'lineconfig' via sysfs: textual representation
of the framing and coding of the span.

This is needed in order for the Dahdi perl classes (in tools) to get
the inforamtion for e.g. dahdi_genconf to work without the guesswork of
parsing /proc/dahdi .

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10461 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-02-22 12:10:59 +00:00
Oron Peled
9f37999c19 code cleanup - refactor module_printk()
* Remove multiple definitions
* Move canonical one to include/dahdi/kernel.h

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10458 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-02-09 15:24:40 +00:00
Oron Peled
8e22110bfd fix class_create() return value test
In case of error class_create check IS_ERR()/PTR_ERR() and not for NULL.

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10453 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-01-25 22:02:37 +00:00
Oron Peled
ed6def895b A channel-less span should not crash dahdi
* Always check span->channels before accessing span->chans[0]
* Clean one dev_notice() text that accessed span->chans[0]
* Check channels in basechan_show() sysfs attribute

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10450 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-01-25 21:18:25 +00:00
Oron Peled
b8b7b86332 A parent-less device should not crash dahdi
* A parent-less device should not crash dahdi:
  - Access span->parent->dev instead of span->parent-dev.parent
    in soem cases.
  - Access span->parent->dev via new inline span_device()
  - Use span_device() in all dahdi_dev_{dbg,info}()

* Allow low-level drivers to set their device name.
  - Drivers that don't use this feature get the default name
    based on the parent device name
  - Parent-less devices which don't set their name, fails
    to register with -EINVAL

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10449 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-01-25 21:18:00 +00:00
Oron Peled
57e827b2f4 remove a duplicate dev_set_name()
Remove duplicate definition from dahdi-sysfs.c

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10447 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-01-25 21:17:10 +00:00
Oron Peled
ad60b833e8 dahdi: style - checkpatch clean dahdi-sysfs.c
Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10439 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2012-01-12 18:40:15 +00:00
Oron Peled
09e46f2213 Extra debugging aids and messages
* Added dahdi_dev_dbg() macro to print when we don't (yet)
  have a span number.
* Added a new debug category: DAHDI_DBG_ASSIGN
* Made sure error return code paths prints helpfull messages
* Promote error messages from INFO to NOTICE
* Change some errno values from EINVAL to EFAULT (internal
  errors not caused by user input)

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10328 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2011-11-07 17:48:00 +00:00
Oron Peled
3fc23b4465 added 'basechan' and 'channels' attributes to spans
* So we can:
   - Generate 'pinned-spans.conf' from existing state
   - Run dahdi_cfg from udev (on specific span + its channels)

Signed-off-by: Oron Peled <oron.peled@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10286 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2011-10-26 19:08:33 +00:00
Shaun Ruffell
f9c52bb271 dahdi: Allow 'spantype' to be changed before span assignement via sysfs.
For some boards, the linemode (E1/T1/J1) is software selectable but
needs to be configured before the spans were historically registered
since the line mode determines the channel count available on the span.

This change exports a "spantype" attribute from the dahdi_device that
can be used to set E1/T1/J1 before the spans are assigned. When
userspace writes to this attribute (in a <span offset>:<span type
string> format), and if the board driver has implemented a set_spantype
function in it's dahdi_span_ops, then the board driver can optionally
change it's mode before registration.

Also part of this change is breaking out the raw data structure
initialization of the spans / channels via the dahdi_init_device_spans
function since the board drivers may need to reallocate channels / spans
as part of this callback. For example, changing from T1 to E1 mode will
require allocating 7 new channels.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10277 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2011-10-26 19:01:19 +00:00
Shaun Ruffell
8d23f878d4 dahdi: Remove dahdi_span.irq and move dahdi_span.irqmisses into dahdi_device.
'irqmisses' is more a function of the device and there are better ways
to get to IRQ for a device than storing it in any DAHDI structures.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10276 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2011-10-26 19:00:28 +00:00
Shaun Ruffell
a6824019fb dahdi: Expose dahdi devices in sysfs.
This exposes dahdi devices in sysfs and also exposes attributes that
will allow user space to control the registration order in spans. This
facilitates loading drivers out of order yet keeping consistent
span/channel numbering, which in turn will eventually allow the
blacklist for DAHDI drivers to be removed. The default behavior,
controlled with the auto_register module parameter on dahdi is to number
the spans / channels in order like is currently done. So this change
does not introduce any new behavior by default.

 * Writing (anything) to this attribute returns the span to its
   unassigned state
 * Fix dahdi_chan_unreg() echocan refcount
 * Add safeguard against duplicate unassignment to _dahdi_unregister_span()
 * Remove the span from device_node list, only in dahdi_unregister_device()
   and not in dahdi_unregister_span()
 * Free allocated span->span_device in span_sysfs_remove()
   [is it safe?, didn't cause problem so far...]

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

dahdi: Add "hardware_id" dahdi_device attribute.

- The "hardware_id" does not change with device location (e.g: when a PCI
  card is moved from one slot to another).
- Not all devices have this attribute. It is legal for it to be NULL (that
  is the default for all low-level drivers that do not set it explicitly).
- When "hardware_id" is NULL, the sysfs attribute value is "\n"

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10275 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2011-10-26 18:59:20 +00:00
Oron Peled
2794bb4937 dahdi: Expose spans in sysfs.
This change will facilitate creating rules that will allow spans and channels
to be accessed by named device files instead of by numbers.

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Shaun Ruffell <sruffell@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10274 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2011-10-26 18:58:50 +00:00
Shaun Ruffell
d43e2d3ade dahdi: Do not rebuild dahdi-base.c when only updating the version.
This moves the version string into dahdi-version.c that is then linked into
dahdi-base.c and dahdi-sysfs.c.  This speeds builds on slow computers since
dahdi-base.c and dahdi-sysfs.c does not need to be rebuilt if only the version
string is changing.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9777 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2011-02-28 14:19:09 +00:00
Tzafrir Cohen
cd595df1c3 dahdi-sysfs: include slab.h for newer kernels
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9633 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2011-01-16 21:12:20 +00:00
Tzafrir Cohen
69f3c96690 Refactor SysFS code to dahdi-sysfs.c
* Refactor SysFS and device-related code to drivers/dahdi/dahdi-sysfs.c .
* Move common headers to drivers/dahdi/dahdi.h .

This commit merely moves existing code and should have no functional
change.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>


git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9628 a0bf4364-ded3-4de4-8d8a-66a801d63aff
2011-01-16 14:18:18 +00:00