[asterisk-dev] [Code Review] a driver for single-port FXO cards based on Si3052 chip + Si3011/17/18 DAA (Motorola 52-6116-2A, PM560MS etc.)
Tzafrir Cohen
tzafrir.cohen at xorcom.com
Sun Oct 17 12:21:42 CDT 2010
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/977/#review2844
-----------------------------------------------------------
Hi,
First-off, it's good to see an extra driver.
Before I look into the code, I figure I'd start with the obvious checks:
$ make
drivers/dahdi/fxo_si3052.c: In function ‘si3052_irq’:
drivers/dahdi/fxo_si3052.c:660: warning: passing argument 1 of ‘si3052_dma_buffers’ makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c:671: warning: passing argument 1 of ‘si3052_dma_buffers’ makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c:681: warning: passing argument 1 of ‘si3052_dma_buffers’ makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c: In function ‘si3052_probe’:
drivers/dahdi/fxo_si3052.c:1063: warning: passing argument 3 of ‘tasklet_init’ makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c:1072: warning: assignment makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c:1075: warning: assignment makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c:1078: warning: assignment makes integer from pointer without a cast
If that cast is really needed (looks so, at first glance), make it explicit.
Then there are the petty styling issues. I checked your patch with the checkpatch.pl script (see build_tools/kernel-cp). There are tons of errors. Almost all of them are "over 80 characters in a line". The rest are "suspect code indent for conditional statements" (8,12 instead of 8,16).
Next I tried sparse (make C=1, with the package sparse installed. In Debian it is in non-free).
drivers/dahdi/fxo_si3052.c:55:35: warning: incorrect type in argument 1 (different address spaces)
drivers/dahdi/fxo_si3052.c:55:35: expected void [noderef] <asn:2>*<noident>
drivers/dahdi/fxo_si3052.c:55:35: got void *
drivers/dahdi/fxo_si3052.c:60:36: warning: incorrect type in argument 2 (different address spaces)
drivers/dahdi/fxo_si3052.c:60:36: expected void [noderef] <asn:2>*<noident>
drivers/dahdi/fxo_si3052.c:60:36: got void *
drivers/dahdi/fxo_si3052.c:76:34: warning: incorrect type in argument 1 (different address spaces)
drivers/dahdi/fxo_si3052.c:681:22: got struct si3052_dev [usertype] *dev
drivers/dahdi/fxo_si3052.c:961:19: warning: incorrect type in assignment (different address spaces)
drivers/dahdi/fxo_si3052.c:961:19: expected void *[usertype] mmio_ptr
drivers/dahdi/fxo_si3052.c:961:19: got void [noderef] <asn:2>*
drivers/dahdi/fxo_si3052.c:1015:16: warning: incorrect type in argument 1 (different address spaces)
drivers/dahdi/fxo_si3052.c:1015:16: expected void volatile [noderef] <asn:2>*addr
drivers/dahdi/fxo_si3052.c:1015:16: got void *[usertype] mmio_ptr
drivers/dahdi/fxo_si3052.c:1063:64: warning: incorrect type in argument 3 (different base types)
drivers/dahdi/fxo_si3052.c:1063:64: expected unsigned long [unsigned] data
drivers/dahdi/fxo_si3052.c:1063:64: got struct si3052_dev [usertype] *[assigned] dev
drivers/dahdi/fxo_si3052.c:1072:28: warning: incorrect type in assignment (different base types)
drivers/dahdi/fxo_si3052.c:1072:28: expected unsigned long [unsigned] [usertype] data
drivers/dahdi/fxo_si3052.c:1072:28: got struct si3052_dev [usertype] *[assigned] dev
drivers/dahdi/fxo_si3052.c:1075:28: warning: incorrect type in assignment (different base types)
drivers/dahdi/fxo_si3052.c:1075:28: expected unsigned long [unsigned] [usertype] data
drivers/dahdi/fxo_si3052.c:1075:28: got struct si3052_dev [usertype] *[assigned] dev
drivers/dahdi/fxo_si3052.c:1078:29: warning: incorrect type in assignment (different base types)
drivers/dahdi/fxo_si3052.c:1078:29: expected unsigned long [unsigned] [usertype] data
drivers/dahdi/fxo_si3052.c:1078:29: got struct si3052_dev [usertype] *[assigned] dev
drivers/dahdi/fxo_si3052.c:1183:16: warning: incorrect type in argument 1 (different address spaces)
drivers/dahdi/fxo_si3052.c:1183:16: expected void volatile [noderef] <asn:2>*addr
drivers/dahdi/fxo_si3052.c:1183:16: got void *[usertype] mmio_ptr
drivers/dahdi/fxo_si3052.c:726:12: warning: context imbalance in 'si3052_irq': wrong count at exit
drivers/dahdi/fxo_si3052.c:726:12: context 'lock': wanted 0, got 1
Though honestly, regarding sparse, wcfxo and wctdm are not much better.
Oh, and it fails to build with kernel 2.6.18 (note: this is with stock 2.6.18, not with any later distro variant)
drivers/dahdi/fxo_si3052.c: In function ‘si3052_irq’:
drivers/dahdi/fxo_si3052.c:660: warning: passing argument 1 of ‘si3052_dma_buffers’ makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c:290: note: expected ‘long unsigned int’ but argument is of type ‘struct si3052_dev *’
drivers/dahdi/fxo_si3052.c:671: warning: passing argument 1 of ‘si3052_dma_buffers’ makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c:290: note: expected ‘long unsigned int’ but argument is of type ‘struct si3052_dev *’
drivers/dahdi/fxo_si3052.c:681: warning: passing argument 1 of ‘si3052_dma_buffers’ makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c:290: note: expected ‘long unsigned int’ but argument is of type ‘struct si3052_dev *’
drivers/dahdi/fxo_si3052.c: In function ‘si3052_init’:
drivers/dahdi/fxo_si3052.c:1003: warning: passing argument 2 of ‘request_irq’ from incompatible pointer type
‘irqreturn_t (*)(int, void *, struct pt_regs *)’ but argument is of type ‘irqreturn_t (*)(int, void *)’
drivers/dahdi/fxo_si3052.c: In function ‘si3052_probe’:
drivers/dahdi/fxo_si3052.c:1063: warning: passing argument 3 of ‘tasklet_init’ makes integer from pointer without a cast
d ‘long unsigned int’ but argument is of type ‘struct si3052_dev *’
drivers/dahdi/fxo_si3052.c:1068:51: error: macro "INIT_WORK" requires 3 arguments, but only 2 given
drivers/dahdi/fxo_si3052.c:1068: error: ‘INIT_WORK’ undeclared (first use in this function)
drivers/dahdi/fxo_si3052.c:1068: error: (Each undeclared identifier is reported only once
drivers/dahdi/fxo_si3052.c:1068: error: for each function it appears in.)
drivers/dahdi/fxo_si3052.c:1072: warning: assignment makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c:1075: warning: assignment makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c:1078: warning: assignment makes integer from pointer without a cast
drivers/dahdi/fxo_si3052.c:1131: warning: implicit declaration of function ‘cancel_work_sync’
Note that this is stock 2.6.18 . I haven't yet tested it with distro kernels.
- Tzafrir
On 2010-10-14 16:30:27, mhej wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/977/
> -----------------------------------------------------------
>
> (Updated 2010-10-14 16:30:27)
>
>
> Review request for Asterisk Developers.
>
>
> Summary
> -------
>
> Attached here is a driver for single-port FXO cards based on Si3052 chip + Si3011/17/18 DAA. They are marketed as Motorola 52-6116-2A, PM560MS and many others.
> Driver is written from scratch to take advantage of international features some of the DAAs have. There is also patch for wcfxo module to support these cards circulating on Net, but it runs the card in backwards-compatible mode and doesn't allow most of the POTS settings to be tweaked.
>
> Usage:
> * DAHDI-tools need a simple patch from bug https://issues.asterisk.org/view.php?id=18138 (dahdi-gencfg.patch) for dahdi_genconf to recognize new driver.
> * You have to set the region name to one of those listed in fxo_modes.h file (this file is also used for wctdm driver, so region names are the same). For example: "modprobe fxo_si3052 region_param=ARGENTINA" (w/o quotes) would load the module with proper settings for Argentina. Also add "use_ulaw=1" if you plan to use ULAW instead of ALAW (default setting is ALAW).
> * Generate config file for the card with dahdi_genconf, configure with dahdi_cfg, write config files for Asterisk, all just like with the wcfxo driver.
>
> If CallerID detection doesn't work the problem might be with too long minimum ringer time. Default is 512ms, but sometimes first ring signal is shorter and is not detected as ring, so CallerID detection is not started by Asterisk. In this case check ringer length and add appropriate "min_ringer_time" parameter (for example "min_ringer_time=150" for 150ms). Valid values are 100, 150, 200, 256, 384, 512 and 1024 ms.
>
> Comments and suggestions are welcome.
>
>
> This addresses bug 18138.
> http://issues.asterisk.org/view.php?id=18138
>
>
> Diffs
> -----
>
> /linux/trunk/drivers/dahdi/Kbuild 9425
> /linux/trunk/drivers/dahdi/fxo_modes.h 9425
> /linux/trunk/drivers/dahdi/fxo_si3052.h PRE-CREATION
> /linux/trunk/drivers/dahdi/fxo_si3052.c PRE-CREATION
>
> Diff: https://reviewboard.asterisk.org/r/977/diff
>
>
> Testing
> -------
>
> Tested features:
> * Sending and receiving voice,
> * Ringer detection and validation,
> * DTMF detection,
> * Caller ID reception (only ETSI FSK mode tested, but different ones should work too in principle),
> * ULAW/ALAW mode,
> * Busy pattern hangup detecion,
> * Line disconnection detection (only when offhook due to hardware limitation).
> * No errors were indicated by checkpatch.pl.
>
>
> Thanks,
>
> mhej
>
>
More information about the asterisk-dev
mailing list