removed find_type_entry. we can use 2 static variables instead, these keep also track of cards with fewer ports than originally designed

This commit is contained in:
Chrisian Richter 2006-11-14 14:55:41 +00:00
parent 8d515d2fdf
commit 6e66a0fb06
2 changed files with 24 additions and 31 deletions

View File

@ -130,7 +130,7 @@ extern const char *CardType[];
static const char *hfcmulti_revision = "$Revision$";
static int HFC_cnt, HFC_idx;
static int HFC_cnt;
static mISDNobject_t HFCM_obj;
@ -3730,25 +3730,6 @@ bugtest
return(0);
}
static void find_type_entry(int hfc_type, int *card, int *port)
{
int i, j = 0;
for(i=0;i<MAX_CARDS;i++)
{
//#warning remove
// printk(KERN_DEBUG "i=%d type[i]=%d hfc_type=%d allocated[i]=%d\n", i, type[i]&0xff,hfc_type,allocated[i]);
if((type[i]&0xff)==hfc_type && !allocated[i])
{
*card = i;
*port = j;
return;
}
j = j + (type[i]&0xff);
}
*card = -1;
}
static int find_idlist_entry(int vendor,int subvendor, int device, int subdevice)
{
int cnt;
@ -3766,7 +3747,9 @@ static int find_idlist_entry(int vendor,int subvendor, int device, int subdevice
static int __devinit hfcpci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
int i, ret_err=0, port_idx;
int i, ret_err=0;
static int HFC_idx=0, HFC_port_idx=0;
int port_idx;
int bchperport, card_type, pt;
int ch, ch2;
int id_idx; // index to id_list
@ -3779,7 +3762,6 @@ static int __devinit hfcpci_probe(struct pci_dev *pdev, const struct pci_device_
u_long flags;
u_char dips=0, pmj=0; // dip settings, port mode Jumpers
id_idx = find_idlist_entry(ent->vendor,ent->subvendor,ent->device,ent->subdevice);
if (id_idx == -1) {
if (ent->vendor == CCAG_VID)
@ -3820,7 +3802,8 @@ static int __devinit hfcpci_probe(struct pci_dev *pdev, const struct pci_device_
goto free_object;
}
find_type_entry(hfc_type, &HFC_idx, &port_idx);
port_idx=HFC_port_idx;
if(HFC_idx == -1) {
printk( KERN_ERR "HFC-MULTI: Card '%s' found, but not given by module's options, ignoring...\n",
id_list[id_idx].card_name);
@ -3852,6 +3835,8 @@ static int __devinit hfcpci_probe(struct pci_dev *pdev, const struct pci_device_
hc->type = card_type;
hc->ports = hfc_ports;
printk( KERN_NOTICE "type:%d ports:%d HFC_idx:%d port_idx:%d\n",card_type, hfc_ports, HFC_idx, port_idx);
if (type[HFC_idx] & 0x100) {
test_and_set_bit(HFC_CHIP_ULAW, &hc->chip);
silence = 0xff; /* ulaw silence */
@ -4231,6 +4216,9 @@ free_delstack:
allocated[HFC_idx] = 1;
HFC_cnt++;
spin_unlock_irqrestore(&hc->lock, flags);
HFC_idx++;
HFC_port_idx+=hc->ports;
return(0);
/* if an error ocurred */
@ -4456,7 +4444,7 @@ HFCmulti_init(void)
printk(KERN_DEBUG "%s: new mISDN object (refcnt = %d)\n", __FUNCTION__, HFCM_obj.refcnt);
for(i=0;i<MAX_CARDS;i++) allocated[i]=0;
HFC_cnt = HFC_idx = 0;
HFC_cnt = 0;
#if 1
err = pci_register_driver(&hfcmultipci_driver);

View File

@ -111,7 +111,9 @@ function load_card_modules {
case "${var}" in
card)
nr=`echo "${val}" | sed -e "s/^\([0-9]*\),.*/\1/"`
mod=`echo "${val}" | sed -e "s/^[^,]*,\([^,]*\).*/\1/"`
ports=`echo "${val}" | sed -e "s/^[^,]*,\([^,]*\),.*/\1/"`
mod=`echo "${val}" | sed -e "s/^[^,]*,[^,]*,\([^,]*\).*/\1/"`
#echo "nr $nr ports $ports mod $mod"
if [ ${#val} -gt $(echo "obase=10;${#nr}+${#mod}+1" | ${BC}) ]; then
opns=`echo "${val}" | sed -e "s/^[^,]*,[^,]*,\(.*\)/\1/"`
else
@ -120,7 +122,7 @@ function load_card_modules {
case "${mod}" in
0x*)
hfcmulti[${nr}]=$(echo ${mod} | sed -e "s/^0x\([0-9]*\)/\1/")
let "hfcports = ${hfcports} + ${hfcmulti[${nr}]}"
let "hfcports = ${hfcports} + ${ports}"
IFS=$','
for li in ${opns}; do
hfcmulti[${nr}]=$(echo "obase=10;2^(${!li}-1)+${hfcmulti[${nr}]}" | ${BC})
@ -342,7 +344,8 @@ function unload_card_modules {
case "${var}" in
card)
nr=`echo "${val}" | sed -e "s/^\([0-9]*\),.*/\1/"`
mod=`echo "${val}" | sed -e "s/^[^,]*,\([^,]*\).*/\1/"`
ports=`echo "${val}" | sed -e "s/^[^,]*,\([^,]*\),.*/\1/"`
mod=`echo "${val}" | sed -e "s/^[^,]*,[^,]*,\([^,]*\).*/\1/"`
case "${mod}" in
0x*)
modulelist[${nr}]=hfcmulti
@ -403,28 +406,30 @@ function create_misdn_init_conf {
portcount=0
for line in $(${LSPCI} -n -d 0xd161:b410); do
addcard "0x4"
addcard "4,0x4"
addport 4
done
for line in $(${LSPCI} -n | sed -n 's/^\(0000:\|\)\([0-9a-f]\{2\}:[0-9a-f]\{2\}.[0-9a-f]\{1\}\)\( Class \| \)[0-9a-f]\{4\}: 1397:\([0-9a-f]\{4\}\).*$/\4 \2/p'); do
case "${line}" in
30b1*)
addcard "0x1"
addcard "1,0x1"
addport 1
;;
16b8*)
addcard "0x8"
addcard "8,0x8"
addport 8
;;
08b4*)
addcard "0x4"
if ${LSPCI} -n -v -s "${line:5}" | grep "Subsystem" | grep "1397:b567" > /dev/null ; then
addcard "1,0x4"
addport 1
elif ${LSPCI} -n -v -s "${line:5}" | grep "Subsystem" | grep "1397:b566\|1397:b569" > /dev/null ; then
addcard "2,0x4"
addport 2
else
addcard "4,0x4"
addport 4
fi
;;