diff options
author | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2012-01-11 15:22:46 +0000 |
---|---|---|
committer | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2012-01-11 15:22:46 +0000 |
commit | dc228a61f57f12f036ae8b993aa3dc286493de67 (patch) | |
tree | 23c098b100a3b7b2a1630fc08e5790ae97060f00 /drivers/dahdi/xpp/card_fxo.c | |
parent | f968cd418bf89bd1c5e97bb2655b76c74f45541c (diff) |
xpp: style - Run Lindent
* Here it is:
KERNEL_STYLE="-npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1"
TYPEDEFS='
-T gfp_t
-T __user
-T u_char
-T __u8
-T byte
-T bool
-T charp
-T xusb_t
-T xbus_t
-T xpd_t
-T xproto_table_t
-T xproto_entry_t
-T xframe_t
-T xpacket_t
-T reg_cmd_t
'
indent $TYPEDEFS $KERNEL_STYLE \
--ignore-newlines \
--indent-label0 \
--no-space-after-function-call-names \
"$@"
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@10428 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/xpp/card_fxo.c')
-rw-r--r-- | drivers/dahdi/xpp/card_fxo.c | 726 |
1 files changed, 396 insertions, 330 deletions
diff --git a/drivers/dahdi/xpp/card_fxo.c b/drivers/dahdi/xpp/card_fxo.c index 1eaa215..213aba9 100644 --- a/drivers/dahdi/xpp/card_fxo.c +++ b/drivers/dahdi/xpp/card_fxo.c @@ -34,21 +34,29 @@ static const char rcsid[] = "$Id$"; static DEF_PARM(int, debug, 0, 0644, "Print DBG statements"); -static DEF_PARM(uint, poll_battery_interval, 500, 0644, "Poll battery interval in milliseconds (0 - disable)"); +static DEF_PARM(uint, poll_battery_interval, 500, 0644, + "Poll battery interval in milliseconds (0 - disable)"); #ifdef WITH_METERING -static DEF_PARM(uint, poll_metering_interval, 500, 0644, "Poll metering interval in milliseconds (0 - disable)"); +static DEF_PARM(uint, poll_metering_interval, 500, 0644, + "Poll metering interval in milliseconds (0 - disable)"); #endif -static DEF_PARM(int, ring_debounce, 50, 0644, "Number of ticks to debounce a false RING indication"); -static DEF_PARM(int, caller_id_style, 0, 0444, "Caller-Id detection style: 0 - [BELL], 1 - [ETSI_FSK], 2 - [ETSI_DTMF]"); -static DEF_PARM(int, power_denial_safezone, 650, 0644, "msec after offhook to ignore power-denial ( (0 - disable power-denial)"); -static DEF_PARM(int, power_denial_minlen, 80, 0644, "Minimal detected power-denial length (msec) (0 - disable power-denial)"); -static DEF_PARM(uint, battery_threshold, 3, 0644, "Minimum voltage that shows there is battery"); -static DEF_PARM(uint, battery_debounce, 1000, 0644, "Minimum interval (msec) for detection of battery off"); +static DEF_PARM(int, ring_debounce, 50, 0644, + "Number of ticks to debounce a false RING indication"); +static DEF_PARM(int, caller_id_style, 0, 0444, + "Caller-Id detection style: 0 - [BELL], 1 - [ETSI_FSK], 2 - [ETSI_DTMF]"); +static DEF_PARM(int, power_denial_safezone, 650, 0644, + "msec after offhook to ignore power-denial ( (0 - disable power-denial)"); +static DEF_PARM(int, power_denial_minlen, 80, 0644, + "Minimal detected power-denial length (msec) (0 - disable power-denial)"); +static DEF_PARM(uint, battery_threshold, 3, 0644, + "Minimum voltage that shows there is battery"); +static DEF_PARM(uint, battery_debounce, 1000, 0644, + "Minimum interval (msec) for detection of battery off"); enum cid_style { - CID_STYLE_BELL = 0, /* E.g: US (Bellcore) */ - CID_STYLE_ETSI_FSK = 1, /* E.g: UK (British Telecom) */ - CID_STYLE_ETSI_DTMF = 2, /* E.g: DK, Russia */ + CID_STYLE_BELL = 0, /* E.g: US (Bellcore) */ + CID_STYLE_ETSI_FSK = 1, /* E.g: UK (British Telecom) */ + CID_STYLE_ETSI_DTMF = 2, /* E.g: DK, Russia */ }; /* Signaling is opposite (fxs signalling for fxo card) */ @@ -86,9 +94,11 @@ enum fxo_leds { static bool fxo_packet_is_valid(xpacket_t *pack); static void fxo_packet_dump(const char *msg, xpacket_t *pack); #ifdef CONFIG_PROC_FS -static int proc_fxo_info_read(char *page, char **start, off_t off, int count, int *eof, void *data); +static int proc_fxo_info_read(char *page, char **start, off_t off, int count, + int *eof, void *data); #ifdef WITH_METERING -static int proc_xpd_metering_read(char *page, char **start, off_t off, int count, int *eof, void *data); +static int proc_xpd_metering_read(char *page, char **start, off_t off, + int count, int *eof, void *data); #endif #endif static void dahdi_report_battery(xpd_t *xpd, lineno_t chan); @@ -99,57 +109,57 @@ static void dahdi_report_battery(xpd_t *xpd, lineno_t chan); #define PROC_METERING_FNAME "metering_read" #endif -#define REG_DAA_CONTROL1 0x05 /* 5 - DAA Control 1 */ -#define REG_DAA_CONTROL1_OH BIT(0) /* Off-Hook. */ -#define REG_DAA_CONTROL1_ONHM BIT(3) /* On-Hook Line Monitor */ +#define REG_DAA_CONTROL1 0x05 /* 5 - DAA Control 1 */ +#define REG_DAA_CONTROL1_OH BIT(0) /* Off-Hook. */ +#define REG_DAA_CONTROL1_ONHM BIT(3) /* On-Hook Line Monitor */ #define DAA_REG_METERING 0x11 /* 17 */ #define DAA_REG_CURRENT 0x1C /* 28 */ #define DAA_REG_VBAT 0x1D /* 29 */ enum battery_state { - BATTERY_UNKNOWN = 0, - BATTERY_ON = 1, - BATTERY_OFF = -1 + BATTERY_UNKNOWN = 0, + BATTERY_ON = 1, + BATTERY_OFF = -1 }; enum polarity_state { - POL_UNKNOWN = 0, - POL_POSITIVE = 1, - POL_NEGATIVE = -1 + POL_UNKNOWN = 0, + POL_POSITIVE = 1, + POL_NEGATIVE = -1 }; enum power_state { - POWER_UNKNOWN = 0, - POWER_ON = 1, - POWER_OFF = -1 + POWER_UNKNOWN = 0, + POWER_ON = 1, + POWER_OFF = -1 }; struct FXO_priv_data { #ifdef WITH_METERING - struct proc_dir_entry *meteringfile; + struct proc_dir_entry *meteringfile; #endif - struct proc_dir_entry *fxo_info; - uint poll_counter; - signed char battery_voltage[CHANNELS_PERXPD]; - signed char battery_current[CHANNELS_PERXPD]; - enum battery_state battery[CHANNELS_PERXPD]; - ushort nobattery_debounce[CHANNELS_PERXPD]; - enum polarity_state polarity[CHANNELS_PERXPD]; - ushort polarity_debounce[CHANNELS_PERXPD]; - enum power_state power[CHANNELS_PERXPD]; - ushort power_denial_delay[CHANNELS_PERXPD]; - ushort power_denial_length[CHANNELS_PERXPD]; - ushort power_denial_safezone[CHANNELS_PERXPD]; - xpp_line_t cidfound; /* 0 - OFF, 1 - ON */ - unsigned int cidtimer[CHANNELS_PERXPD]; - xpp_line_t ledstate[NUM_LEDS]; /* 0 - OFF, 1 - ON */ - xpp_line_t ledcontrol[NUM_LEDS]; /* 0 - OFF, 1 - ON */ - int led_counter[NUM_LEDS][CHANNELS_PERXPD]; - atomic_t ring_debounce[CHANNELS_PERXPD]; + struct proc_dir_entry *fxo_info; + uint poll_counter; + signed char battery_voltage[CHANNELS_PERXPD]; + signed char battery_current[CHANNELS_PERXPD]; + enum battery_state battery[CHANNELS_PERXPD]; + ushort nobattery_debounce[CHANNELS_PERXPD]; + enum polarity_state polarity[CHANNELS_PERXPD]; + ushort polarity_debounce[CHANNELS_PERXPD]; + enum power_state power[CHANNELS_PERXPD]; + ushort power_denial_delay[CHANNELS_PERXPD]; + ushort power_denial_length[CHANNELS_PERXPD]; + ushort power_denial_safezone[CHANNELS_PERXPD]; + xpp_line_t cidfound; /* 0 - OFF, 1 - ON */ + unsigned int cidtimer[CHANNELS_PERXPD]; + xpp_line_t ledstate[NUM_LEDS]; /* 0 - OFF, 1 - ON */ + xpp_line_t ledcontrol[NUM_LEDS]; /* 0 - OFF, 1 - ON */ + int led_counter[NUM_LEDS][CHANNELS_PERXPD]; + atomic_t ring_debounce[CHANNELS_PERXPD]; #ifdef WITH_METERING - uint metering_count[CHANNELS_PERXPD]; - xpp_line_t metering_tone_state; + uint metering_count[CHANNELS_PERXPD]; + xpp_line_t metering_tone_state; #endif }; @@ -170,50 +180,53 @@ struct FXO_priv_data { static const char *power2str(enum power_state pw) { switch (pw) { - case POWER_UNKNOWN: return "UNKNOWN"; - case POWER_OFF: return "OFF"; - case POWER_ON: return "ON"; + case POWER_UNKNOWN: + return "UNKNOWN"; + case POWER_OFF: + return "OFF"; + case POWER_ON: + return "ON"; } return NULL; } static void power_change(xpd_t *xpd, int portno, enum power_state pw) { - struct FXO_priv_data *priv; + struct FXO_priv_data *priv; priv = xpd->priv; LINE_DBG(SIGNAL, xpd, portno, "power: %s -> %s\n", - power2str(priv->power[portno]), - power2str(pw)); + power2str(priv->power[portno]), power2str(pw)); priv->power[portno] = pw; } static void reset_battery_readings(xpd_t *xpd, lineno_t pos) { - struct FXO_priv_data *priv = xpd->priv; + struct FXO_priv_data *priv = xpd->priv; priv->nobattery_debounce[pos] = 0; priv->power_denial_delay[pos] = 0; power_change(xpd, pos, POWER_UNKNOWN); } -static const int led_register_mask[] = { BIT(7), BIT(6), BIT(5) }; +static const int led_register_mask[] = { BIT(7), BIT(6), BIT(5) }; /* * LED control is done via DAA register 0x20 */ static int do_led(xpd_t *xpd, lineno_t chan, __u8 which, bool on) { - int ret = 0; - struct FXO_priv_data *priv; - xbus_t *xbus; - __u8 value; + int ret = 0; + struct FXO_priv_data *priv; + xbus_t *xbus; + __u8 value; BUG_ON(!xpd); xbus = xpd->xbus; priv = xpd->priv; which = which % NUM_LEDS; - if (IS_SET(PHONEDEV(xpd).digital_outputs, chan) || IS_SET(PHONEDEV(xpd).digital_inputs, chan)) + if (IS_SET(PHONEDEV(xpd).digital_outputs, chan) + || IS_SET(PHONEDEV(xpd).digital_inputs, chan)) goto out; if (chan == PORT_BROADCAST) { priv->ledstate[which] = (on) ? ~0 : 0; @@ -228,7 +241,8 @@ static int do_led(xpd_t *xpd, lineno_t chan, __u8 which, bool on) value |= ((BIT(5) | BIT(6) | BIT(7)) & ~led_register_mask[which]); value |= (on) ? BIT(0) : 0; value |= (on) ? BIT(1) : 0; - LINE_DBG(LEDS, xpd, chan, "LED: which=%d -- %s\n", which, (on) ? "on" : "off"); + LINE_DBG(LEDS, xpd, chan, "LED: which=%d -- %s\n", which, + (on) ? "on" : "off"); ret = DAA_DIRECT_REQUEST(xbus, xpd, chan, DAA_WRITE, 0x20, value); out: return ret; @@ -236,12 +250,12 @@ out: static void handle_fxo_leds(xpd_t *xpd) { - int i; - unsigned long flags; - const enum fxo_leds colors[] = { LED_GREEN, LED_RED }; - enum fxo_leds color; - unsigned int timer_count; - struct FXO_priv_data *priv; + int i; + unsigned long flags; + const enum fxo_leds colors[] = { LED_GREEN, LED_RED }; + enum fxo_leds color; + unsigned int timer_count; + struct FXO_priv_data *priv; BUG_ON(!xpd); spin_lock_irqsave(&xpd->lock, flags); @@ -249,25 +263,31 @@ static void handle_fxo_leds(xpd_t *xpd) timer_count = xpd->timer_count; for (color = 0; color < ARRAY_SIZE(colors); color++) { for_each_line(xpd, i) { - if (IS_SET(PHONEDEV(xpd).digital_outputs, i) || IS_SET(PHONEDEV(xpd).digital_inputs, i)) + if (IS_SET(PHONEDEV(xpd).digital_outputs, i) + || IS_SET(PHONEDEV(xpd).digital_inputs, i)) continue; - if ((xpd->blink_mode & BIT(i)) || IS_BLINKING(priv, i, color)) { // Blinking - int mod_value = LED_COUNTER(priv, i, color); + if ((xpd->blink_mode & BIT(i)) || IS_BLINKING(priv, i, color)) { // Blinking + int mod_value = LED_COUNTER(priv, i, color); if (!mod_value) - mod_value = DEFAULT_LED_PERIOD; /* safety value */ + mod_value = DEFAULT_LED_PERIOD; /* safety value */ // led state is toggled if ((timer_count % mod_value) == 0) { - LINE_DBG(LEDS, xpd, i, "ledstate=%s\n", (IS_SET(priv->ledstate[color], i))?"ON":"OFF"); + LINE_DBG(LEDS, xpd, i, "ledstate=%s\n", + (IS_SET + (priv->ledstate[color], + i)) ? "ON" : "OFF"); if (!IS_SET(priv->ledstate[color], i)) { do_led(xpd, i, color, 1); } else { do_led(xpd, i, color, 0); } } - } else if (IS_SET(priv->ledcontrol[color], i) && !IS_SET(priv->ledstate[color], i)) { + } else if (IS_SET(priv->ledcontrol[color], i) + && !IS_SET(priv->ledstate[color], i)) { do_led(xpd, i, color, 1); - } else if (!IS_SET(priv->ledcontrol[color], i) && IS_SET(priv->ledstate[color], i)) { + } else if (!IS_SET(priv->ledcontrol[color], i) + && IS_SET(priv->ledstate[color], i)) { do_led(xpd, i, color, 0); } } @@ -290,7 +310,7 @@ static void update_dahdi_ring(xpd_t *xpd, int pos, bool on) static void mark_ring(xpd_t *xpd, lineno_t pos, bool on, bool update_dahdi) { - struct FXO_priv_data *priv; + struct FXO_priv_data *priv; priv = xpd->priv; BUG_ON(!priv); @@ -320,32 +340,36 @@ static void mark_ring(xpd_t *xpd, lineno_t pos, bool on, bool update_dahdi) static int do_sethook(xpd_t *xpd, int pos, bool to_offhook) { - unsigned long flags; - xbus_t *xbus; - struct FXO_priv_data *priv; - int ret = 0; - __u8 value; + unsigned long flags; + xbus_t *xbus; + struct FXO_priv_data *priv; + int ret = 0; + __u8 value; BUG_ON(!xpd); - BUG_ON(PHONEDEV(xpd).direction == TO_PHONE); // We can SETHOOK state only on PSTN + BUG_ON(PHONEDEV(xpd).direction == TO_PHONE); // We can SETHOOK state only on PSTN xbus = xpd->xbus; priv = xpd->priv; BUG_ON(!priv); if (priv->battery[pos] != BATTERY_ON && to_offhook) { - LINE_NOTICE(xpd, pos, "Cannot take offhook while battery is off!\n"); + LINE_NOTICE(xpd, pos, + "Cannot take offhook while battery is off!\n"); return -EINVAL; } spin_lock_irqsave(&xpd->lock, flags); - mark_ring(xpd, pos, 0, 0); // No more rings - value = REG_DAA_CONTROL1_ONHM; /* Bit 3 is for CID */ + mark_ring(xpd, pos, 0, 0); // No more rings + value = REG_DAA_CONTROL1_ONHM; /* Bit 3 is for CID */ if (to_offhook) value |= REG_DAA_CONTROL1_OH; - LINE_DBG(SIGNAL, xpd, pos, "SETHOOK: value=0x%02X %s\n", value, (to_offhook)?"OFFHOOK":"ONHOOK"); + LINE_DBG(SIGNAL, xpd, pos, "SETHOOK: value=0x%02X %s\n", value, + (to_offhook) ? "OFFHOOK" : "ONHOOK"); if (to_offhook) MARK_ON(priv, pos, LED_GREEN); else MARK_OFF(priv, pos, LED_GREEN); - ret = DAA_DIRECT_REQUEST(xbus, xpd, pos, DAA_WRITE, REG_DAA_CONTROL1, value); + ret = + DAA_DIRECT_REQUEST(xbus, xpd, pos, DAA_WRITE, REG_DAA_CONTROL1, + value); mark_offhook(xpd, pos, to_offhook); if (caller_id_style != CID_STYLE_ETSI_DTMF) oht_pcm(xpd, pos, 0); @@ -370,7 +394,7 @@ static int do_sethook(xpd_t *xpd, int pos, bool to_offhook) static void fxo_proc_remove(xbus_t *xbus, xpd_t *xpd) { - struct FXO_priv_data *priv; + struct FXO_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; @@ -394,25 +418,30 @@ static void fxo_proc_remove(xbus_t *xbus, xpd_t *xpd) static int fxo_proc_create(xbus_t *xbus, xpd_t *xpd) { - struct FXO_priv_data *priv; + struct FXO_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; #ifdef CONFIG_PROC_FS XPD_DBG(PROC, xpd, "Creating FXO_INFO file\n"); - priv->fxo_info = create_proc_read_entry(PROC_FXO_INFO_FNAME, 0444, xpd->proc_xpd_dir, proc_fxo_info_read, xpd); + priv->fxo_info = + create_proc_read_entry(PROC_FXO_INFO_FNAME, 0444, xpd->proc_xpd_dir, + proc_fxo_info_read, xpd); if (!priv->fxo_info) { - XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_FXO_INFO_FNAME); + XPD_ERR(xpd, "Failed to create proc file '%s'\n", + PROC_FXO_INFO_FNAME); fxo_proc_remove(xbus, xpd); return -EINVAL; } SET_PROC_DIRENTRY_OWNER(priv->fxo_info); #ifdef WITH_METERING XPD_DBG(PROC, xpd, "Creating Metering tone file\n"); - priv->meteringfile = create_proc_read_entry(PROC_METERING_FNAME, 0444, xpd->proc_xpd_dir, - proc_xpd_metering_read, xpd); + priv->meteringfile = + create_proc_read_entry(PROC_METERING_FNAME, 0444, xpd->proc_xpd_dir, + proc_xpd_metering_read, xpd); if (!priv->meteringfile) { - XPD_ERR(xpd, "Failed to create proc file '%s'\n", PROC_METERING_FNAME); + XPD_ERR(xpd, "Failed to create proc file '%s'\n", + PROC_METERING_FNAME); fxo_proc_remove(xbus, xpd); return -EINVAL; } @@ -422,23 +451,26 @@ static int fxo_proc_create(xbus_t *xbus, xpd_t *xpd) return 0; } -static xpd_t *FXO_card_new(xbus_t *xbus, int unit, int subunit, const xproto_table_t *proto_table, - __u8 subtype, int subunits, int subunit_ports, bool to_phone) +static xpd_t *FXO_card_new(xbus_t *xbus, int unit, int subunit, + const xproto_table_t *proto_table, __u8 subtype, + int subunits, int subunit_ports, bool to_phone) { - xpd_t *xpd = NULL; - int channels; + xpd_t *xpd = NULL; + int channels; if (to_phone) { XBUS_NOTICE(xbus, - "XPD=%d%d: try to instanciate FXO with reverse direction\n", - unit, subunit); + "XPD=%d%d: try to instanciate FXO with reverse direction\n", + unit, subunit); return NULL; } if (subtype == 2) channels = min(2, subunit_ports); else channels = min(8, subunit_ports); - xpd = xpd_alloc(xbus, unit, subunit, subtype, subunits, sizeof(struct FXO_priv_data), proto_table, channels); + xpd = + xpd_alloc(xbus, unit, subunit, subtype, subunits, + sizeof(struct FXO_priv_data), proto_table, channels); if (!xpd) return NULL; PHONEDEV(xpd).direction = TO_PSTN; @@ -453,8 +485,8 @@ err: static int FXO_card_init(xbus_t *xbus, xpd_t *xpd) { - struct FXO_priv_data *priv; - int i; + struct FXO_priv_data *priv; + int i; BUG_ON(!xpd); priv = xpd->priv; @@ -494,10 +526,10 @@ static int FXO_card_remove(xbus_t *xbus, xpd_t *xpd) static int FXO_card_dahdi_preregistration(xpd_t *xpd, bool on) { - xbus_t *xbus; - struct FXO_priv_data *priv; - int i; - unsigned int timer_count; + xbus_t *xbus; + struct FXO_priv_data *priv; + int i; + unsigned int timer_count; BUG_ON(!xpd); xbus = xpd->xbus; @@ -505,14 +537,14 @@ static int FXO_card_dahdi_preregistration(xpd_t *xpd, bool on) priv = xpd->priv; BUG_ON(!priv); timer_count = xpd->timer_count; - XPD_DBG(GENERAL, xpd, "%s\n", (on)?"ON":"OFF"); + XPD_DBG(GENERAL, xpd, "%s\n", (on) ? "ON" : "OFF"); PHONEDEV(xpd).span.spantype = "FXO"; for_each_line(xpd, i) { - struct dahdi_chan *cur_chan = XPD_CHAN(xpd, i); + struct dahdi_chan *cur_chan = XPD_CHAN(xpd, i); XPD_DBG(GENERAL, xpd, "setting FXO channel %d\n", i); snprintf(cur_chan->name, MAX_CHANNAME, "XPP_FXO/%02d/%1d%1d/%d", - xbus->num, xpd->addr.unit, xpd->addr.subunit, i); + xbus->num, xpd->addr.unit, xpd->addr.subunit, i); cur_chan->chanpos = i + 1; cur_chan->pvt = xpd; cur_chan->sigcap = FXO_DEFAULT_SIGCAP; @@ -530,16 +562,16 @@ static int FXO_card_dahdi_preregistration(xpd_t *xpd, bool on) static int FXO_card_dahdi_postregistration(xpd_t *xpd, bool on) { - xbus_t *xbus; - struct FXO_priv_data *priv; - int i; + xbus_t *xbus; + struct FXO_priv_data *priv; + int i; BUG_ON(!xpd); xbus = xpd->xbus; BUG_ON(!xbus); priv = xpd->priv; BUG_ON(!priv); - XPD_DBG(GENERAL, xpd, "%s\n", (on)?"ON":"OFF"); + XPD_DBG(GENERAL, xpd, "%s\n", (on) ? "ON" : "OFF"); for_each_line(xpd, i) { dahdi_report_battery(xpd, i); MARK_OFF(priv, i, LED_GREEN); @@ -552,8 +584,8 @@ static int FXO_card_dahdi_postregistration(xpd_t *xpd, bool on) static int FXO_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig) { - struct FXO_priv_data *priv; - int ret = 0; + struct FXO_priv_data *priv; + int ret = 0; priv = xpd->priv; BUG_ON(!priv); @@ -561,40 +593,42 @@ static int FXO_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig) BUG_ON(PHONEDEV(xpd).direction != TO_PSTN); /* XXX Enable hooksig for FXO XXX */ switch (txsig) { - case DAHDI_TXSIG_START: - case DAHDI_TXSIG_OFFHOOK: - ret = do_sethook(xpd, pos, 1); - break; - case DAHDI_TXSIG_ONHOOK: - ret = do_sethook(xpd, pos, 0); - break; - default: - XPD_NOTICE(xpd, "Can't set tx state to %s (%d)\n", - txsig2str(txsig), txsig); - return -EINVAL; + case DAHDI_TXSIG_START: + case DAHDI_TXSIG_OFFHOOK: + ret = do_sethook(xpd, pos, 1); + break; + case DAHDI_TXSIG_ONHOOK: + ret = do_sethook(xpd, pos, 0); + break; + default: + XPD_NOTICE(xpd, "Can't set tx state to %s (%d)\n", + txsig2str(txsig), txsig); + return -EINVAL; } return ret; } static void dahdi_report_battery(xpd_t *xpd, lineno_t chan) { - struct FXO_priv_data *priv; + struct FXO_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; if (SPAN_REGISTERED(xpd)) { switch (priv->battery[chan]) { - case BATTERY_UNKNOWN: - /* no-op */ - break; - case BATTERY_OFF: - LINE_DBG(SIGNAL, xpd, chan, "Send DAHDI_ALARM_RED\n"); - dahdi_alarm_channel(XPD_CHAN(xpd, chan), DAHDI_ALARM_RED); - break; - case BATTERY_ON: - LINE_DBG(SIGNAL, xpd, chan, "Send DAHDI_ALARM_NONE\n"); - dahdi_alarm_channel(XPD_CHAN(xpd, chan), DAHDI_ALARM_NONE); - break; + case BATTERY_UNKNOWN: + /* no-op */ + break; + case BATTERY_OFF: + LINE_DBG(SIGNAL, xpd, chan, "Send DAHDI_ALARM_RED\n"); + dahdi_alarm_channel(XPD_CHAN(xpd, chan), + DAHDI_ALARM_RED); + break; + case BATTERY_ON: + LINE_DBG(SIGNAL, xpd, chan, "Send DAHDI_ALARM_NONE\n"); + dahdi_alarm_channel(XPD_CHAN(xpd, chan), + DAHDI_ALARM_NONE); + break; } } } @@ -607,7 +641,7 @@ static int FXO_card_open(xpd_t *xpd, lineno_t chan) static void poll_battery(xbus_t *xbus, xpd_t *xpd) { - int i; + int i; for_each_line(xpd, i) { DAA_DIRECT_REQUEST(xbus, xpd, i, DAA_READ, DAA_REG_VBAT, 0); @@ -617,19 +651,20 @@ static void poll_battery(xbus_t *xbus, xpd_t *xpd) #ifdef WITH_METERING static void poll_metering(xbus_t *xbus, xpd_t *xpd) { - int i; + int i; for_each_line(xpd, i) { if (IS_OFFHOOK(xpd, i)) - DAA_DIRECT_REQUEST(xbus, xpd, i, DAA_READ, DAA_REG_METERING, 0); + DAA_DIRECT_REQUEST(xbus, xpd, i, DAA_READ, + DAA_REG_METERING, 0); } } #endif static void handle_fxo_ring(xpd_t *xpd) { - struct FXO_priv_data *priv; - int i; + struct FXO_priv_data *priv; + int i; priv = xpd->priv; for_each_line(xpd, i) { @@ -647,8 +682,8 @@ static void handle_fxo_ring(xpd_t *xpd) static void handle_fxo_power_denial(xpd_t *xpd) { - struct FXO_priv_data *priv; - int i; + struct FXO_priv_data *priv; + int i; if (!power_denial_safezone) return; /* Ignore power denials */ @@ -663,7 +698,8 @@ static void handle_fxo_power_denial(xpd_t *xpd) /* * Poll current, previous answers are meaningless */ - DAA_DIRECT_REQUEST(xpd->xbus, xpd, i, DAA_READ, DAA_REG_CURRENT, 0); + DAA_DIRECT_REQUEST(xpd->xbus, xpd, i, DAA_READ, + DAA_REG_CURRENT, 0); } continue; } @@ -675,8 +711,10 @@ static void handle_fxo_power_denial(xpd_t *xpd) * detected it yet). This would cause false power denials. * So we just flag it and schedule more ticks to wait. */ - LINE_DBG(SIGNAL, xpd, i, "Possible Power Denial Hangup\n"); - priv->power_denial_delay[i] = POWER_DENIAL_DELAY; + LINE_DBG(SIGNAL, xpd, i, + "Possible Power Denial Hangup\n"); + priv->power_denial_delay[i] = + POWER_DENIAL_DELAY; } continue; } @@ -688,7 +726,8 @@ static void handle_fxo_power_denial(xpd_t *xpd) */ priv->power_denial_delay[i]--; if (priv->power_denial_delay[i] <= 0) { - LINE_DBG(SIGNAL, xpd, i, "Power Denial Hangup\n"); + LINE_DBG(SIGNAL, xpd, i, + "Power Denial Hangup\n"); priv->power_denial_delay[i] = 0; /* * Let Asterisk decide what to do @@ -708,9 +747,9 @@ static void handle_fxo_power_denial(xpd_t *xpd) */ static void check_etsi_dtmf(xpd_t *xpd) { - struct FXO_priv_data *priv; - int portno; - unsigned int timer_count; + struct FXO_priv_data *priv; + int portno; + unsigned int timer_count; if (!SPAN_REGISTERED(xpd)) return; @@ -726,22 +765,25 @@ static void check_etsi_dtmf(xpd_t *xpd) /* reset flags if it's been a while */ priv->cidtimer[portno] = timer_count; BIT_CLR(priv->cidfound, portno); - LINE_DBG(SIGNAL, xpd, portno, "Reset CID flag\n"); + LINE_DBG(SIGNAL, xpd, portno, + "Reset CID flag\n"); } continue; } if (timer_count > priv->cidtimer[portno] + 400) { - struct dahdi_chan *chan = XPD_CHAN(xpd, portno); - int sample; - int i; + struct dahdi_chan *chan = XPD_CHAN(xpd, portno); + int sample; + int i; for (i = 0; i < DAHDI_CHUNKSIZE; i++) { sample = DAHDI_XLAW(chan->readchunk[i], chan); if (sample > 16000 || sample < -16000) { priv->cidtimer[portno] = timer_count; BIT_SET(priv->cidfound, portno); - LINE_DBG(SIGNAL, xpd, portno, "Found DTMF CLIP (%d)\n", i); - dahdi_qevent_lock(chan, DAHDI_EVENT_POLARITY); + LINE_DBG(SIGNAL, xpd, portno, + "Found DTMF CLIP (%d)\n", i); + dahdi_qevent_lock(chan, + DAHDI_EVENT_POLARITY); break; } } @@ -751,15 +793,17 @@ static void check_etsi_dtmf(xpd_t *xpd) static int FXO_card_tick(xbus_t *xbus, xpd_t *xpd) { - struct FXO_priv_data *priv; + struct FXO_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; BUG_ON(!priv); - if (poll_battery_interval != 0 && (priv->poll_counter % poll_battery_interval) == 0) + if (poll_battery_interval != 0 + && (priv->poll_counter % poll_battery_interval) == 0) poll_battery(xbus, xpd); #ifdef WITH_METERING - if (poll_metering_interval != 0 && (priv->poll_counter % poll_metering_interval) == 0) + if (poll_metering_interval != 0 + && (priv->poll_counter % poll_metering_interval) == 0) poll_metering(xbus, xpd); #endif handle_fxo_leds(xpd); @@ -777,47 +821,55 @@ static int FXO_card_tick(xbus_t *xbus, xpd_t *xpd) * We define the array size explicitly to track possible inconsistencies * if the struct is modified. */ -static const char echotune_regs[sizeof(struct wctdm_echo_coefs)] = {30, 45, 46, 47, 48, 49, 50, 51, 52}; +static const char echotune_regs[sizeof(struct wctdm_echo_coefs)] = + { 30, 45, 46, 47, 48, 49, 50, 51, 52 }; -static int FXO_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long arg) +static int FXO_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, + unsigned long arg) { - int i, ret; - unsigned char echotune_data[ARRAY_SIZE(echotune_regs)]; + int i, ret; + unsigned char echotune_data[ARRAY_SIZE(echotune_regs)]; BUG_ON(!xpd); if (!XBUS_IS(xpd->xbus, READY)) return -ENODEV; switch (cmd) { - case WCTDM_SET_ECHOTUNE: - XPD_DBG(GENERAL, xpd, "-- Setting echo registers: \n"); - /* first off: check if this span is fxs. If not: -EINVALID */ - if (copy_from_user(&echotune_data, (void __user *)arg, sizeof(echotune_data))) - return -EFAULT; - - for (i = 0; i < ARRAY_SIZE(echotune_regs); i++) { - XPD_DBG(REGS, xpd, "Reg=0x%02X, data=0x%02X\n", echotune_regs[i], echotune_data[i]); - ret = DAA_DIRECT_REQUEST(xpd->xbus, xpd, pos, DAA_WRITE, echotune_regs[i], echotune_data[i]); - if (ret < 0) { - LINE_NOTICE(xpd, pos, "Couldn't write %0x02X to register %0x02X\n", - echotune_data[i], echotune_regs[i]); - return ret; - } - msleep(1); + case WCTDM_SET_ECHOTUNE: + XPD_DBG(GENERAL, xpd, "-- Setting echo registers: \n"); + /* first off: check if this span is fxs. If not: -EINVALID */ + if (copy_from_user + (&echotune_data, (void __user *)arg, sizeof(echotune_data))) + return -EFAULT; + + for (i = 0; i < ARRAY_SIZE(echotune_regs); i++) { + XPD_DBG(REGS, xpd, "Reg=0x%02X, data=0x%02X\n", + echotune_regs[i], echotune_data[i]); + ret = + DAA_DIRECT_REQUEST(xpd->xbus, xpd, pos, DAA_WRITE, + echotune_regs[i], + echotune_data[i]); + if (ret < 0) { + LINE_NOTICE(xpd, pos, + "Couldn't write %0x02X to register %0x02X\n", + echotune_data[i], echotune_regs[i]); + return ret; } + msleep(1); + } - XPD_DBG(GENERAL, xpd, "-- Set echo registers successfully\n"); - break; - case DAHDI_TONEDETECT: - /* - * Asterisk call all span types with this (FXS specific) - * call. Silently ignore it. - */ - LINE_DBG(GENERAL, xpd, pos, - "DAHDI_TONEDETECT (FXO: NOTIMPLEMENTED)\n"); - return -ENOTTY; - default: - report_bad_ioctl(THIS_MODULE->name, xpd, pos, cmd); - return -ENOTTY; + XPD_DBG(GENERAL, xpd, "-- Set echo registers successfully\n"); + break; + case DAHDI_TONEDETECT: + /* + * Asterisk call all span types with this (FXS specific) + * call. Silently ignore it. + */ + LINE_DBG(GENERAL, xpd, pos, + "DAHDI_TONEDETECT (FXO: NOTIMPLEMENTED)\n"); + return -ENOTTY; + default: + report_bad_ioctl(THIS_MODULE->name, xpd, pos, cmd); + return -ENOTTY; } return 0; } @@ -828,11 +880,13 @@ static int FXO_card_ioctl(xpd_t *xpd, int pos, unsigned int cmd, unsigned long a HANDLER_DEF(FXO, SIG_CHANGED) { - xpp_line_t sig_status = RPACKET_FIELD(pack, FXO, SIG_CHANGED, sig_status); - xpp_line_t sig_toggles = RPACKET_FIELD(pack, FXO, SIG_CHANGED, sig_toggles); - unsigned long flags; - int i; - struct FXO_priv_data *priv; + xpp_line_t sig_status = + RPACKET_FIELD(pack, FXO, SIG_CHANGED, sig_status); + xpp_line_t sig_toggles = + RPACKET_FIELD(pack, FXO, SIG_CHANGED, sig_toggles); + unsigned long flags; + int i; + struct FXO_priv_data *priv; if (!xpd) { notify_bad_xpd(__func__, xbus, XPACKET_ADDR(pack), cmd->name); @@ -840,10 +894,11 @@ HANDLER_DEF(FXO, SIG_CHANGED) } priv = xpd->priv; BUG_ON(!priv); - XPD_DBG(SIGNAL, xpd, "(PSTN) sig_toggles=0x%04X sig_status=0x%04X\n", sig_toggles, sig_status); + XPD_DBG(SIGNAL, xpd, "(PSTN) sig_toggles=0x%04X sig_status=0x%04X\n", + sig_toggles, sig_status); spin_lock_irqsave(&xpd->lock, flags); for_each_line(xpd, i) { - int debounce; + int debounce; if (IS_SET(sig_toggles, i)) { if (priv->battery[i] == BATTERY_OFF) { @@ -851,18 +906,23 @@ HANDLER_DEF(FXO, SIG_CHANGED) * With poll_battery_interval==0 we cannot have BATTERY_OFF * so we won't get here */ - LINE_NOTICE(xpd, i, "SIG_CHANGED while battery is off. Ignored.\n"); + LINE_NOTICE(xpd, i, + "SIG_CHANGED while battery is off. Ignored.\n"); continue; } /* First report false ring alarms */ debounce = atomic_read(&priv->ring_debounce[i]); if (debounce) - LINE_NOTICE(xpd, i, "debounced false ring (only %d ticks)\n", debounce); + LINE_NOTICE(xpd, i, + "debounced false ring (only %d ticks)\n", + debounce); /* * Now set a new ring alarm. * It will be checked in handle_fxo_ring() */ - debounce = (IS_SET(sig_status, i)) ? ring_debounce : -ring_debounce; + debounce = + (IS_SET(sig_status, i)) ? ring_debounce : + -ring_debounce; atomic_set(&priv->ring_debounce[i], debounce); } } @@ -872,10 +932,10 @@ HANDLER_DEF(FXO, SIG_CHANGED) static void update_battery_voltage(xpd_t *xpd, __u8 data_low, xportno_t portno) { - struct FXO_priv_data *priv; - enum polarity_state pol; - int msec; - signed char volts = (signed char)data_low; + struct FXO_priv_data *priv; + enum polarity_state pol; + int msec; + signed char volts = (signed char)data_low; priv = xpd->priv; BUG_ON(!priv); @@ -887,12 +947,14 @@ static void update_battery_voltage(xpd_t *xpd, __u8 data_low, xportno_t portno) * Check for battery voltage fluctuations */ if (priv->battery[portno] != BATTERY_OFF) { - int milliseconds; + int milliseconds; - milliseconds = priv->nobattery_debounce[portno]++ * - poll_battery_interval; + milliseconds = + priv->nobattery_debounce[portno]++ * + poll_battery_interval; if (milliseconds > battery_debounce) { - LINE_DBG(SIGNAL, xpd, portno, "BATTERY OFF voltage=%d\n", volts); + LINE_DBG(SIGNAL, xpd, portno, + "BATTERY OFF voltage=%d\n", volts); priv->battery[portno] = BATTERY_OFF; dahdi_report_battery(xpd, portno); /* What's the polarity ? */ @@ -910,7 +972,8 @@ static void update_battery_voltage(xpd_t *xpd, __u8 data_low, xportno_t portno) } else { priv->nobattery_debounce[portno] = 0; if (priv->battery[portno] != BATTERY_ON) { - LINE_DBG(SIGNAL, xpd, portno, "BATTERY ON voltage=%d\n", volts); + LINE_DBG(SIGNAL, xpd, portno, "BATTERY ON voltage=%d\n", + volts); priv->battery[portno] = BATTERY_ON; dahdi_report_battery(xpd, portno); } @@ -952,7 +1015,7 @@ static void update_battery_voltage(xpd_t *xpd, __u8 data_low, xportno_t portno) if (msec >= POLREV_THRESHOLD) { priv->polarity_debounce[portno] = 0; if (pol != POL_UNKNOWN && priv->polarity[portno] != POL_UNKNOWN) { - char *polname = NULL; + char *polname = NULL; if (pol == POL_POSITIVE) polname = "Positive"; @@ -961,7 +1024,7 @@ static void update_battery_voltage(xpd_t *xpd, __u8 data_low, xportno_t portno) else BUG(); LINE_DBG(SIGNAL, xpd, portno, - "Polarity changed to %s\n", polname); + "Polarity changed to %s\n", polname); /* * Inform dahdi/Asterisk: * 1. Maybe used for hangup detection during offhook @@ -972,8 +1035,10 @@ static void update_battery_voltage(xpd_t *xpd, __u8 data_low, xportno_t portno) oht_pcm(xpd, portno, 1); /* will be cleared on ring/offhook */ if (SPAN_REGISTERED(xpd)) { LINE_DBG(SIGNAL, xpd, portno, - "Send DAHDI_EVENT_POLARITY: %s\n", polname); - dahdi_qevent_lock(XPD_CHAN(xpd, portno), DAHDI_EVENT_POLARITY); + "Send DAHDI_EVENT_POLARITY: %s\n", + polname); + dahdi_qevent_lock(XPD_CHAN(xpd, portno), + DAHDI_EVENT_POLARITY); } } priv->polarity[portno] = pol; @@ -988,7 +1053,7 @@ ignore_reading: static void update_battery_current(xpd_t *xpd, __u8 data_low, xportno_t portno) { - struct FXO_priv_data *priv; + struct FXO_priv_data *priv; priv = xpd->priv; BUG_ON(!priv); @@ -1030,16 +1095,16 @@ ignore_it: static void update_metering_state(xpd_t *xpd, __u8 data_low, lineno_t portno) { - struct FXO_priv_data *priv; - bool metering_tone = data_low & BTD_BIT; - bool old_metering_tone; + struct FXO_priv_data *priv; + bool metering_tone = data_low & BTD_BIT; + bool old_metering_tone; priv = xpd->priv; BUG_ON(!priv); old_metering_tone = IS_SET(priv->metering_tone_state, portno); LINE_DBG(SIGNAL, xpd, portno, "METERING: %s [dL=0x%X] (%d)\n", - (metering_tone) ? "ON" : "OFF", - data_low, priv->metering_count[portno]); + (metering_tone) ? "ON" : "OFF", data_low, + priv->metering_count[portno]); if (metering_tone && !old_metering_tone) { /* Rising edge */ priv->metering_count[portno]++; @@ -1049,42 +1114,42 @@ static void update_metering_state(xpd_t *xpd, __u8 data_low, lineno_t portno) if (metering_tone) { /* Clear the BTD bit */ data_low &= ~BTD_BIT; - DAA_DIRECT_REQUEST(xpd->xbus, xpd, portno, DAA_WRITE, DAA_REG_METERING, data_low); + DAA_DIRECT_REQUEST(xpd->xbus, xpd, portno, DAA_WRITE, + DAA_REG_METERING, data_low); } } #endif static int FXO_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info) { - struct FXO_priv_data *priv; - lineno_t portno; + struct FXO_priv_data *priv; + lineno_t portno; priv = xpd->priv; BUG_ON(!priv); portno = info->portnum; switch (REG_FIELD(info, regnum)) { - case DAA_REG_VBAT: - update_battery_voltage(xpd, REG_FIELD(info, data_low), portno); - break; - case DAA_REG_CURRENT: - update_battery_current(xpd, REG_FIELD(info, data_low), portno); - break; + case DAA_REG_VBAT: + update_battery_voltage(xpd, REG_FIELD(info, data_low), portno); + break; + case DAA_REG_CURRENT: + update_battery_current(xpd, REG_FIELD(info, data_low), portno); + break; #ifdef WITH_METERING - case DAA_REG_METERING: - update_metering_state(xpd, REG_FIELD(info, data_low), portno); - break; + case DAA_REG_METERING: + update_metering_state(xpd, REG_FIELD(info, data_low), portno); + break; #endif } LINE_DBG(REGS, xpd, portno, "%c reg_num=0x%X, dataL=0x%X dataH=0x%X\n", - ((info->bytes == 3)?'I':'D'), - REG_FIELD(info, regnum), - REG_FIELD(info, data_low), - REG_FIELD(info, data_high)); + ((info->bytes == 3) ? 'I' : 'D'), REG_FIELD(info, regnum), + REG_FIELD(info, data_low), REG_FIELD(info, data_high)); /* Update /proc info only if reply relate to the last slic read request */ - if ( - REG_FIELD(&xpd->requested_reply, regnum) == REG_FIELD(info, regnum) && - REG_FIELD(&xpd->requested_reply, do_subreg) == REG_FIELD(info, do_subreg) && - REG_FIELD(&xpd->requested_reply, subreg) == REG_FIELD(info, subreg)) { + if (REG_FIELD(&xpd->requested_reply, regnum) == REG_FIELD(info, regnum) + && REG_FIELD(&xpd->requested_reply, do_subreg) == REG_FIELD(info, + do_subreg) + && REG_FIELD(&xpd->requested_reply, subreg) == REG_FIELD(info, + subreg)) { xpd->last_reply = *info; } return 0; @@ -1092,8 +1157,8 @@ static int FXO_card_register_reply(xbus_t *xbus, xpd_t *xpd, reg_cmd_t *info) static int FXO_card_state(xpd_t *xpd, bool on) { - int ret = 0; - struct FXO_priv_data *priv; + int ret = 0; + struct FXO_priv_data *priv; BUG_ON(!xpd); priv = xpd->priv; @@ -1102,47 +1167,40 @@ static int FXO_card_state(xpd_t *xpd, bool on) return ret; } -static const struct xops fxo_xops = { - .card_new = FXO_card_new, - .card_init = FXO_card_init, - .card_remove = FXO_card_remove, - .card_tick = FXO_card_tick, - .card_register_reply = FXO_card_register_reply, +static const struct xops fxo_xops = { + .card_new = FXO_card_new, + .card_init = FXO_card_init, + .card_remove = FXO_card_remove, + .card_tick = FXO_card_tick, + .card_register_reply = FXO_card_register_reply, }; -static const struct phoneops fxo_phoneops = { - .card_dahdi_preregistration = FXO_card_dahdi_preregistration, - .card_dahdi_postregistration = FXO_card_dahdi_postregistration, - .card_hooksig = FXO_card_hooksig, - .card_pcm_recompute = generic_card_pcm_recompute, - .card_pcm_fromspan = generic_card_pcm_fromspan, - .card_pcm_tospan = generic_card_pcm_tospan, - .card_timing_priority = generic_timing_priority, - .echocancel_timeslot = generic_echocancel_timeslot, - .echocancel_setmask = generic_echocancel_setmask, - .card_ioctl = FXO_card_ioctl, - .card_open = FXO_card_open, - .card_state = FXO_card_state, +static const struct phoneops fxo_phoneops = { + .card_dahdi_preregistration = FXO_card_dahdi_preregistration, + .card_dahdi_postregistration = FXO_card_dahdi_postregistration, + .card_hooksig = FXO_card_hooksig, + .card_pcm_recompute = generic_card_pcm_recompute, + .card_pcm_fromspan = generic_card_pcm_fromspan, + .card_pcm_tospan = generic_card_pcm_tospan, + .card_timing_priority = generic_timing_priority, + .echocancel_timeslot = generic_echocancel_timeslot, + .echocancel_setmask = generic_echocancel_setmask, + .card_ioctl = FXO_card_ioctl, + .card_open = FXO_card_open, + .card_state = FXO_card_state, }; static xproto_table_t PROTO_TABLE(FXO) = { - .owner = THIS_MODULE, - .entries = { - /* Prototable Card Opcode */ - XENTRY( FXO, FXO, SIG_CHANGED ), - }, - .name = "FXO", /* protocol name */ - .ports_per_subunit = 8, - .type = XPD_TYPE_FXO, - .xops = &fxo_xops, - .phoneops = &fxo_phoneops, - .packet_is_valid = fxo_packet_is_valid, - .packet_dump = fxo_packet_dump, -}; + .owner = THIS_MODULE,.entries = { + /* Prototable Card Opcode */ + XENTRY(FXO, FXO, SIG_CHANGED),},.name = "FXO", /* protocol name */ +.ports_per_subunit = 8,.type = XPD_TYPE_FXO,.xops = + &fxo_xops,.phoneops = &fxo_phoneops,.packet_is_valid = + fxo_packet_is_valid,.packet_dump = fxo_packet_dump,}; static bool fxo_packet_is_valid(xpacket_t *pack) { - const xproto_entry_t *xe; + const xproto_entry_t *xe; //DBG(GENERAL, "\n"); xe = xproto_card_entry(&PROTO_TABLE(FXO), XPACKET_OP(pack)); @@ -1157,13 +1215,14 @@ static void fxo_packet_dump(const char *msg, xpacket_t *pack) /*------------------------- DAA Handling --------------------------*/ #ifdef CONFIG_PROC_FS -static int proc_fxo_info_read(char *page, char **start, off_t off, int count, int *eof, void *data) +static int proc_fxo_info_read(char *page, char **start, off_t off, int count, + int *eof, void *data) { - int len = 0; - unsigned long flags; - xpd_t *xpd = data; - struct FXO_priv_data *priv; - int i; + int len = 0; + unsigned long flags; + xpd_t *xpd = data; + struct FXO_priv_data *priv; + int i; if (!xpd) return -ENODEV; @@ -1172,23 +1231,28 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in BUG_ON(!priv); len += sprintf(page + len, "\t%-17s: ", "Channel"); for_each_line(xpd, i) { - if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(xpd).digital_inputs, i)) + if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) + && !IS_SET(PHONEDEV(xpd).digital_inputs, i)) len += sprintf(page + len, "%4d ", i % 10); } len += sprintf(page + len, "\nLeds:"); len += sprintf(page + len, "\n\t%-17s: ", "state"); for_each_line(xpd, i) { - if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(xpd).digital_inputs, i)) - len += sprintf(page + len, " %d%d ", - IS_SET(priv->ledstate[LED_GREEN], i), - IS_SET(priv->ledstate[LED_RED], i)); + if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) + && !IS_SET(PHONEDEV(xpd).digital_inputs, i)) + len += + sprintf(page + len, " %d%d ", + IS_SET(priv->ledstate[LED_GREEN], i), + IS_SET(priv->ledstate[LED_RED], i)); } len += sprintf(page + len, "\n\t%-17s: ", "blinking"); for_each_line(xpd, i) { - if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) && !IS_SET(PHONEDEV(xpd).digital_inputs, i)) - len += sprintf(page + len, " %d%d ", - IS_BLINKING(priv, i, LED_GREEN), - IS_BLINKING(priv, i, LED_RED)); + if (!IS_SET(PHONEDEV(xpd).digital_outputs, i) + && !IS_SET(PHONEDEV(xpd).digital_inputs, i)) + len += + sprintf(page + len, " %d%d ", + IS_BLINKING(priv, i, LED_GREEN), + IS_BLINKING(priv, i, LED_RED)); } len += sprintf(page + len, "\nBattery-Data:"); len += sprintf(page + len, "\n\t%-17s: ", "voltage"); @@ -1202,7 +1266,7 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in len += sprintf(page + len, "\nBattery:"); len += sprintf(page + len, "\n\t%-17s: ", "on"); for_each_line(xpd, i) { - char *bat; + char *bat; if (priv->battery[i] == BATTERY_ON) bat = "+"; @@ -1219,7 +1283,7 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in len += sprintf(page + len, "\nPolarity-Reverse:"); len += sprintf(page + len, "\n\t%-17s: ", "polarity"); for_each_line(xpd, i) { - char *polname; + char *polname; if (priv->polarity[i] == POL_POSITIVE) polname = "+"; @@ -1236,7 +1300,7 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in len += sprintf(page + len, "\nPower-Denial:"); len += sprintf(page + len, "\n\t%-17s: ", "power"); for_each_line(xpd, i) { - char *curr; + char *curr; if (priv->power[i] == POWER_ON) curr = "+"; @@ -1248,7 +1312,8 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in } len += sprintf(page + len, "\n\t%-17s: ", "safezone"); for_each_line(xpd, i) { - len += sprintf(page + len, "%4d ", priv->power_denial_safezone[i]); + len += + sprintf(page + len, "%4d ", priv->power_denial_safezone[i]); } len += sprintf(page + len, "\n\t%-17s: ", "delay"); for_each_line(xpd, i) { @@ -1263,7 +1328,7 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in #endif len += sprintf(page + len, "\n"); spin_unlock_irqrestore(&xpd->lock, flags); - if (len <= off+count) + if (len <= off + count) *eof = 1; *start = page + off; len -= off; @@ -1276,13 +1341,14 @@ static int proc_fxo_info_read(char *page, char **start, off_t off, int count, in #endif #ifdef WITH_METERING -static int proc_xpd_metering_read(char *page, char **start, off_t off, int count, int *eof, void *data) +static int proc_xpd_metering_read(char *page, char **start, off_t off, + int count, int *eof, void *data) { - int len = 0; - unsigned long flags; - xpd_t *xpd = data; - struct FXO_priv_data *priv; - int i; + int len = 0; + unsigned long flags; + xpd_t *xpd = data; + struct FXO_priv_data *priv; + int i; if (!xpd) return -ENODEV; @@ -1291,11 +1357,11 @@ static int proc_xpd_metering_read(char *page, char **start, off_t off, int count spin_lock_irqsave(&xpd->lock, flags); len += sprintf(page + len, "# Chan\tMeter (since last read)\n"); for_each_line(xpd, i) { - len += sprintf(page + len, "%d\t%d\n", - i, priv->metering_count[i]); + len += + sprintf(page + len, "%d\t%d\n", i, priv->metering_count[i]); } spin_unlock_irqrestore(&xpd->lock, flags); - if (len <= off+count) + if (len <= off + count) *eof = 1; *start = page + off; len -= off; @@ -1305,18 +1371,18 @@ static int proc_xpd_metering_read(char *page, char **start, off_t off, int count len = 0; /* Zero meters */ for_each_line(xpd, i) - priv->metering_count[i] = 0; + priv->metering_count[i] = 0; return len; } #endif static DEVICE_ATTR_READER(fxo_battery_show, dev, buf) { - xpd_t *xpd; - struct FXO_priv_data *priv; - unsigned long flags; - int len = 0; - int i; + xpd_t *xpd; + struct FXO_priv_data *priv; + unsigned long flags; + int len = 0; + int i; BUG_ON(!dev); xpd = dev_to_xpd(dev); @@ -1326,7 +1392,7 @@ static DEVICE_ATTR_READER(fxo_battery_show, dev, buf) BUG_ON(!priv); spin_lock_irqsave(&xpd->lock, flags); for_each_line(xpd, i) { - char bat; + char bat; if (priv->battery[i] == BATTERY_ON) bat = '+'; @@ -1341,25 +1407,25 @@ static DEVICE_ATTR_READER(fxo_battery_show, dev, buf) return len; } -static DEVICE_ATTR(fxo_battery, S_IRUGO, fxo_battery_show, NULL); - +static DEVICE_ATTR(fxo_battery, S_IRUGO, fxo_battery_show, NULL); static int fxo_xpd_probe(struct device *dev) { - xpd_t *xpd; - int ret; + xpd_t *xpd; + int ret; xpd = dev_to_xpd(dev); /* Is it our device? */ if (xpd->type != XPD_TYPE_FXO) { - XPD_ERR(xpd, "drop suggestion for %s (%d)\n", - dev_name(dev), xpd->type); + XPD_ERR(xpd, "drop suggestion for %s (%d)\n", dev_name(dev), + xpd->type); return -EINVAL; } XPD_DBG(DEVICES, xpd, "SYSFS\n"); ret = device_create_file(dev, &dev_attr_fxo_battery); if (ret) { - XPD_ERR(xpd, "%s: device_create_file(fxo_battery) failed: %d\n", __func__, ret); + XPD_ERR(xpd, "%s: device_create_file(fxo_battery) failed: %d\n", + __func__, ret); goto fail_fxo_battery; } return 0; @@ -1369,7 +1435,7 @@ fail_fxo_battery: static int fxo_xpd_remove(struct device *dev) { - xpd_t *xpd; + xpd_t *xpd; xpd = dev_to_xpd(dev); XPD_DBG(DEVICES, xpd, "SYSFS\n"); @@ -1377,24 +1443,24 @@ static int fxo_xpd_remove(struct device *dev) return 0; } -static struct xpd_driver fxo_driver = { - .type = XPD_TYPE_FXO, - .driver = { - .name = "fxo", +static struct xpd_driver fxo_driver = { + .type = XPD_TYPE_FXO, + .driver = { + .name = "fxo", #ifndef OLD_HOTPLUG_SUPPORT - .owner = THIS_MODULE, + .owner = THIS_MODULE, #endif - .probe = fxo_xpd_probe, - .remove = fxo_xpd_remove - } + .probe = fxo_xpd_probe, + .remove = fxo_xpd_remove} }; static int __init card_fxo_startup(void) { - int ret; + int ret; if (ring_debounce <= 0) { - ERR("ring_debounce=%d. Must be positive number of ticks\n", ring_debounce); + ERR("ring_debounce=%d. Must be positive number of ticks\n", + ring_debounce); return -EINVAL; } if ((ret = xpd_driver_register(&fxo_driver.driver)) < 0) |