From 12058f5c95e9dbfddea2c0dc8d1a9f32b6d431b5 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Thu, 16 Oct 2008 17:40:22 +0000 Subject: xpp: start migration from procfs to sysfs. * Sysfs representation for XPDs: /sys/bus/xpds/devices/:: * Astribanks sysfs directories now include the XPDs as subdirectories: e.g. /sys/bus/astribanks/devices/xbus-00/00:3:0 * procfs control interface deprecated: conditioned by OLD_PROC (defaults to off). Control functionality moved to sysfs: * xbus attributes: cls connector label status timing waitfor_xpds xbus_state * XPDs can have driver-specific attributes. Common attriubtes: blink chipregs span * PRI-specific attributes: pri_clocking pri_dchan pri_cas pri_alarms pri_layer1 pri_localloop pri_protocol * The Astribank attribute "xbus_state" is read/write. Reading it shows the current state of the Astribank. Writing "start" or "stop" allows a software equivalent of connect or disconnect respectively. * When an Astribank is ready it sends an "online" event. Whenever its not ready (e.g. at the time of disconnect) it sends an "offline" event. Use astribank_hook.sample to handle those. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@5097 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/xpp/init_card_1_30 | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'drivers/dahdi/xpp/init_card_1_30') diff --git a/drivers/dahdi/xpp/init_card_1_30 b/drivers/dahdi/xpp/init_card_1_30 index e1bbc1f..927b0e7 100755 --- a/drivers/dahdi/xpp/init_card_1_30 +++ b/drivers/dahdi/xpp/init_card_1_30 @@ -1,6 +1,9 @@ #! /usr/bin/perl -w use strict; +# Make warnings fatal +local $SIG{__WARN__} = sub { die @_ }; + # # Written by Oron Peled # Copyright (C) 2006, Xorcom @@ -48,16 +51,13 @@ BEGIN { $init_dir = dirname($0); unshift(@INC, "$init_dir", "$init_dir/zconf"); use XppConfig $init_dir; my $unit_id; my %opts; -$ENV{XPP_BASE} = '/proc/xpp'; getopts('o:', \%opts); my %settings; $settings{debug} = 0; $settings{fxs_skip_calib} = 0; - -my $xpd_name = sprintf("XPD-%1d0", $ENV{UNIT_NUMBER}); -my $chipregs = "$ENV{XPP_BASE}/$ENV{XBUS_NAME}/$xpd_name/chipregs"; +my $chipregs; sub logit { print STDERR "$unit_id: @_\n"; @@ -70,11 +70,34 @@ sub debug { # Arrange for error logging if (-t STDERR) { $unit_id = 'Interactive'; - logit "Interactive startup"; + main::debug "Interactive startup"; } else { $unit_id = "$ENV{XBUS_NAME}/UNIT-$ENV{UNIT_NUMBER}"; open (STDERR, "| logger -t $program -p kern.info") || die; - logit "Non Interactive startup"; + main::debug "Non Interactive startup"; + foreach my $k (qw( + XBUS_NAME + XBUS_NUMBER + UNIT_NUMBER + UNIT_TYPE + UNIT_SUBUNITS + UNIT_SUBUNITS_DIR + XBUS_REVISION + XBUS_CONNECTOR + XBUS_LABEL)) { + unless(defined $ENV{$k}) { + logit "Missing ENV{$k}\n"; + die; + } + } + $chipregs = sprintf "/sys/bus/xpds/devices/%02d:%1d:0/chipregs", + $ENV{XBUS_NUMBER}, $ENV{UNIT_NUMBER}; + if(! -f $chipregs) { + my $xpd_name = sprintf("XPD-%1d0", $ENV{UNIT_NUMBER}); + $chipregs = "/proc/xpp/$ENV{XBUS_NAME}/$xpd_name/chipregs"; + logit "OLD DRIVER: does not use /sys chipregs. Falling back to /proc" + if -f $chipregs; + } } sub set_output() { @@ -88,7 +111,7 @@ sub set_output() { } open(REG, ">$output") || die "Failed to open '$output': $!\n"; my $oldfh = select REG; - print "# Setting output\n" if $opts{o}; + main::logit "# Setting output" if $opts{o}; return $oldfh; } -- cgit v1.2.3