diff options
Diffstat (limited to 'drivers/isdn/capi')
| -rw-r--r-- | drivers/isdn/capi/Kconfig | 48 | ||||
| -rw-r--r-- | drivers/isdn/capi/Makefile | 1 | ||||
| -rw-r--r-- | drivers/isdn/capi/capi.c | 402 | ||||
| -rw-r--r-- | drivers/isdn/capi/capidrv.c | 1163 | ||||
| -rw-r--r-- | drivers/isdn/capi/capidrv.h | 42 | ||||
| -rw-r--r-- | drivers/isdn/capi/capifs.c | 239 | ||||
| -rw-r--r-- | drivers/isdn/capi/capifs.h | 28 | ||||
| -rw-r--r-- | drivers/isdn/capi/capilib.c | 16 | ||||
| -rw-r--r-- | drivers/isdn/capi/capiutil.c | 652 | ||||
| -rw-r--r-- | drivers/isdn/capi/kcapi.c | 148 | ||||
| -rw-r--r-- | drivers/isdn/capi/kcapi.h | 11 | ||||
| -rw-r--r-- | drivers/isdn/capi/kcapi_proc.c | 15 | 
12 files changed, 1198 insertions, 1567 deletions
diff --git a/drivers/isdn/capi/Kconfig b/drivers/isdn/capi/Kconfig index a168e8a891b..7641b3096ea 100644 --- a/drivers/isdn/capi/Kconfig +++ b/drivers/isdn/capi/Kconfig @@ -1,11 +1,3 @@ -config ISDN_DRV_AVMB1_VERBOSE_REASON -	bool "Verbose reason code reporting" -	default y -	help -	  If you say Y here, the CAPI drivers will give verbose reasons for -	  disconnecting. This will increase the size of the kernel by 7 KB. If -	  unsure, say Y. -  config CAPI_TRACE  	bool "CAPI trace support"  	default y @@ -16,37 +8,23 @@ config CAPI_TRACE  	  This will increase the size of the kernelcapi module by 20 KB.  	  If unsure, say Y. -config ISDN_CAPI_MIDDLEWARE -	bool "CAPI2.0 Middleware support" -	help -	  This option will enhance the capabilities of the /dev/capi20 -	  interface.  It will provide a means of moving a data connection, -	  established via the usual /dev/capi20 interface to a special tty -	  device.  If you want to use pppd with pppdcapiplugin to dial up to -	  your ISP, say Y here. -  config ISDN_CAPI_CAPI20 -	tristate "CAPI2.0 /dev/capi support" +	tristate "CAPI2.0 /dev/capi20 support"  	help  	  This option will provide the CAPI 2.0 interface to userspace  	  applications via /dev/capi20. Applications should use the  	  standardized libcapi20 to access this functionality.  You should say  	  Y/M here. -config ISDN_CAPI_CAPIFS_BOOL -	bool "CAPI2.0 filesystem support (DEPRECATED)" -	depends on ISDN_CAPI_MIDDLEWARE && ISDN_CAPI_CAPI20 +config ISDN_CAPI_MIDDLEWARE +	bool "CAPI2.0 Middleware support" +	depends on ISDN_CAPI_CAPI20 && TTY  	help -	  This option provides a special file system, similar to /dev/pts with -	  device nodes for the special ttys established by using the -	  middleware extension above. -	  You no longer need this, udev fully replaces it. This feature is -	  scheduled for removal. - -config ISDN_CAPI_CAPIFS -	tristate -	depends on ISDN_CAPI_CAPIFS_BOOL -	default ISDN_CAPI_CAPI20 +	  This option will enhance the capabilities of the /dev/capi20 +	  interface.  It will provide a means of moving a data connection, +	  established via the usual /dev/capi20 interface to a special tty +	  device.  If you want to use pppd with pppdcapiplugin to dial up to +	  your ISP, say Y here.  config ISDN_CAPI_CAPIDRV  	tristate "CAPI2.0 capidrv interface support" @@ -56,3 +34,11 @@ config ISDN_CAPI_CAPIDRV  	  the legacy isdn4linux link layer.  If you have a card which is  	  supported by a CAPI driver, but still want to use old features like  	  ippp interfaces or ttyI emulation, say Y/M here. + +config ISDN_CAPI_CAPIDRV_VERBOSE +	bool "Verbose reason code reporting" +	depends on ISDN_CAPI_CAPIDRV +	help +	  If you say Y here, the capidrv interface will give verbose reasons +	  for disconnecting. This will increase the size of the kernel by 7 KB. +	  If unsure, say N. diff --git a/drivers/isdn/capi/Makefile b/drivers/isdn/capi/Makefile index 57123e3e497..4d5b4b71db1 100644 --- a/drivers/isdn/capi/Makefile +++ b/drivers/isdn/capi/Makefile @@ -7,7 +7,6 @@  obj-$(CONFIG_ISDN_CAPI)			+= kernelcapi.o  obj-$(CONFIG_ISDN_CAPI_CAPI20)		+= capi.o   obj-$(CONFIG_ISDN_CAPI_CAPIDRV)		+= capidrv.o -obj-$(CONFIG_ISDN_CAPI_CAPIFS)		+= capifs.o  # Multipart objects. diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index f80a7c48a35..f9a87ed2392 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -25,7 +25,7 @@  #include <linux/tty.h>  #include <linux/netdevice.h>  #include <linux/ppp_defs.h> -#include <linux/if_ppp.h> +#include <linux/ppp-ioctl.h>  #include <linux/skbuff.h>  #include <linux/proc_fs.h>  #include <linux/seq_file.h> @@ -38,15 +38,10 @@  #include <linux/isdn/capiutil.h>  #include <linux/isdn/capicmd.h> -#include "capifs.h" -  MODULE_DESCRIPTION("CAPI4Linux: Userspace /dev/capi20 interface");  MODULE_AUTHOR("Carsten Paeth");  MODULE_LICENSE("GPL"); -#undef _DEBUG_TTYFUNCS		/* call to tty_driver */ -#undef _DEBUG_DATAFLOW		/* data flow */ -  /* -------- driver information -------------------------------------- */  static DEFINE_MUTEX(capi_mutex); @@ -82,10 +77,7 @@ struct ackqueue_entry {  };  struct capiminor { -	struct kref kref; -  	unsigned int      minor; -	struct dentry *capifs_dentry;  	struct capi20_appl	*ap;  	u32			ncci; @@ -170,7 +162,7 @@ static int capiminor_del_ack(struct capiminor *mp, u16 datahandle)  	spin_lock_bh(&mp->ackqlock);  	list_for_each_entry_safe(p, tmp, &mp->ackqueue, list) { - 		if (p->datahandle == datahandle) { +		if (p->datahandle == datahandle) {  			list_del(&p->list);  			mp->nack--;  			spin_unlock_bh(&mp->ackqlock); @@ -196,7 +188,20 @@ static void capiminor_del_all_ack(struct capiminor *mp)  /* -------- struct capiminor ---------------------------------------- */ -static const struct tty_port_operations capiminor_port_ops; /* we have none */ +static void capiminor_destroy(struct tty_port *port) +{ +	struct capiminor *mp = container_of(port, struct capiminor, port); + +	kfree_skb(mp->outskb); +	skb_queue_purge(&mp->inqueue); +	skb_queue_purge(&mp->outqueue); +	capiminor_del_all_ack(mp); +	kfree(mp); +} + +static const struct tty_port_operations capiminor_port_ops = { +	.destruct = capiminor_destroy, +};  static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)  { @@ -205,13 +210,11 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)  	unsigned int minor;  	mp = kzalloc(sizeof(*mp), GFP_KERNEL); -  	if (!mp) { -  		printk(KERN_ERR "capi: can't alloc capiminor\n"); +	if (!mp) { +		printk(KERN_ERR "capi: can't alloc capiminor\n");  		return NULL;  	} -	kref_init(&mp->kref); -  	mp->ap = ap;  	mp->ncci = ncci;  	INIT_LIST_HEAD(&mp->ackqueue); @@ -240,7 +243,8 @@ static struct capiminor *capiminor_alloc(struct capi20_appl *ap, u32 ncci)  	mp->minor = minor; -	dev = tty_register_device(capinc_tty_driver, minor, NULL); +	dev = tty_port_register_device(&mp->port, capinc_tty_driver, minor, +			NULL);  	if (IS_ERR(dev))  		goto err_out2; @@ -252,21 +256,10 @@ err_out2:  	spin_unlock(&capiminors_lock);  err_out1: -	kfree(mp); +	tty_port_put(&mp->port);  	return NULL;  } -static void capiminor_destroy(struct kref *kref) -{ -	struct capiminor *mp = container_of(kref, struct capiminor, kref); - -	kfree_skb(mp->outskb); -	skb_queue_purge(&mp->inqueue); -	skb_queue_purge(&mp->outqueue); -	capiminor_del_all_ack(mp); -	kfree(mp); -} -  static struct capiminor *capiminor_get(unsigned int minor)  {  	struct capiminor *mp; @@ -274,7 +267,7 @@ static struct capiminor *capiminor_get(unsigned int minor)  	spin_lock(&capiminors_lock);  	mp = capiminors[minor];  	if (mp) -		kref_get(&mp->kref); +		tty_port_get(&mp->port);  	spin_unlock(&capiminors_lock);  	return mp; @@ -282,7 +275,7 @@ static struct capiminor *capiminor_get(unsigned int minor)  static inline void capiminor_put(struct capiminor *mp)  { -	kref_put(&mp->kref, capiminor_destroy); +	tty_port_put(&mp->port);  }  static void capiminor_free(struct capiminor *mp) @@ -300,17 +293,8 @@ static void capiminor_free(struct capiminor *mp)  static void capincci_alloc_minor(struct capidev *cdev, struct capincci *np)  { -	struct capiminor *mp; -	dev_t device; - -	if (!(cdev->userflags & CAPIFLAG_HIGHJACKING)) -		return; - -	mp = np->minorp = capiminor_alloc(&cdev->ap, np->ncci); -	if (mp) { -		device = MKDEV(capinc_tty_driver->major, mp->minor); -		mp->capifs_dentry = capifs_new_ncci(mp->minor, device); -	} +	if (cdev->userflags & CAPIFLAG_HIGHJACKING) +		np->minorp = capiminor_alloc(&cdev->ap, np->ncci);  }  static void capincci_free_minor(struct capincci *np) @@ -319,8 +303,6 @@ static void capincci_free_minor(struct capincci *np)  	struct tty_struct *tty;  	if (mp) { -		capifs_free_ncci(mp->capifs_dentry); -  		tty = tty_port_tty_get(&mp->port);  		if (tty) {  			tty_vhangup(tty); @@ -353,11 +335,6 @@ static inline void  capincci_alloc_minor(struct capidev *cdev, struct capincci *np) { }  static inline void capincci_free_minor(struct capincci *np) { } -static inline unsigned int capincci_minor_opencount(struct capincci *np) -{ -	return 0; -} -  #endif /* !CONFIG_ISDN_CAPI_MIDDLEWARE */  static struct capincci *capincci_alloc(struct capidev *cdev, u32 ncci) @@ -389,6 +366,7 @@ static void capincci_free(struct capidev *cdev, u32 ncci)  		}  } +#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE  static struct capincci *capincci_find(struct capidev *cdev, u32 ncci)  {  	struct capincci *np; @@ -399,7 +377,6 @@ static struct capincci *capincci_find(struct capidev *cdev, u32 ncci)  	return NULL;  } -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE  /* -------- handle data queue --------------------------------------- */  static struct sk_buff * @@ -408,7 +385,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)  	struct sk_buff *nskb;  	nskb = alloc_skb(CAPI_DATA_B3_RESP_LEN, GFP_KERNEL);  	if (nskb) { -		u16 datahandle = CAPIMSG_U16(skb->data,CAPIMSG_BASELEN+4+4+2); +		u16 datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN + 4 + 4 + 2);  		unsigned char *s = skb_put(nskb, CAPI_DATA_B3_RESP_LEN);  		capimsg_setu16(s, 0, CAPI_DATA_B3_RESP_LEN);  		capimsg_setu16(s, 2, mp->ap->applid); @@ -432,12 +409,10 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb)  	tty = tty_port_tty_get(&mp->port);  	if (!tty) { -#ifdef _DEBUG_DATAFLOW -		printk(KERN_DEBUG "capi: currently no receiver\n"); -#endif +		pr_debug("capi: currently no receiver\n");  		return -1;  	} -	 +  	ld = tty_ldisc_ref(tty);  	if (!ld) {  		/* fatal error, do not requeue */ @@ -447,23 +422,17 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb)  	}  	if (ld->ops->receive_buf == NULL) { -#if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) -		printk(KERN_DEBUG "capi: ldisc has no receive_buf function\n"); -#endif +		pr_debug("capi: ldisc has no receive_buf function\n");  		/* fatal error, do not requeue */  		goto free_skb;  	}  	if (mp->ttyinstop) { -#if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) -		printk(KERN_DEBUG "capi: recv tty throttled\n"); -#endif +		pr_debug("capi: recv tty throttled\n");  		goto deref_ldisc;  	}  	if (tty->receive_room < datalen) { -#if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) -		printk(KERN_DEBUG "capi: no room in tty\n"); -#endif +		pr_debug("capi: no room in tty\n");  		goto deref_ldisc;  	} @@ -479,14 +448,12 @@ static int handle_recv_skb(struct capiminor *mp, struct sk_buff *skb)  	if (errcode == CAPI_NOERROR) {  		skb_pull(skb, CAPIMSG_LEN(skb->data)); -#ifdef _DEBUG_DATAFLOW -		printk(KERN_DEBUG "capi: DATA_B3_RESP %u len=%d => ldisc\n", -					datahandle, skb->len); -#endif +		pr_debug("capi: DATA_B3_RESP %u len=%d => ldisc\n", +			 datahandle, skb->len);  		ld->ops->receive_buf(tty, skb->data, NULL, skb->len);  	} else {  		printk(KERN_ERR "capi: send DATA_B3_RESP failed=%x\n", -				errcode); +		       errcode);  		kfree_skb(nskb);  		if (errcode == CAPI_SENDQUEUEFULL) @@ -529,9 +496,7 @@ static void handle_minor_send(struct capiminor *mp)  		return;  	if (mp->ttyoutstop) { -#if defined(_DEBUG_DATAFLOW) || defined(_DEBUG_TTYFUNCS) -		printk(KERN_DEBUG "capi: send: tty stopped\n"); -#endif +		pr_debug("capi: send: tty stopped\n");  		tty_kref_put(tty);  		return;  	} @@ -573,10 +538,8 @@ static void handle_minor_send(struct capiminor *mp)  		}  		errcode = capi20_put_message(mp->ap, skb);  		if (errcode == CAPI_NOERROR) { -#ifdef _DEBUG_DATAFLOW -			printk(KERN_DEBUG "capi: DATA_B3_REQ %u len=%u\n", -							datahandle, len); -#endif +			pr_debug("capi: DATA_B3_REQ %u len=%u\n", +				 datahandle, len);  			continue;  		}  		capiminor_del_ack(mp, datahandle); @@ -606,11 +569,10 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb)  {  	struct capidev *cdev = ap->private;  #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE -	struct tty_struct *tty;  	struct capiminor *mp;  	u16 datahandle; -#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */  	struct capincci *np; +#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */  	mutex_lock(&cdev->lock); @@ -628,6 +590,12 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb)  		goto unlock_out;  	} +#ifndef CONFIG_ISDN_CAPI_MIDDLEWARE +	skb_queue_tail(&cdev->recvqueue, skb); +	wake_up_interruptible(&cdev->recvwait); + +#else /* CONFIG_ISDN_CAPI_MIDDLEWARE */ +  	np = capincci_find(cdev, CAPIMSG_CONTROL(skb->data));  	if (!np) {  		printk(KERN_ERR "BUG: capi_signal: ncci not found\n"); @@ -636,12 +604,6 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb)  		goto unlock_out;  	} -#ifndef CONFIG_ISDN_CAPI_MIDDLEWARE -	skb_queue_tail(&cdev->recvqueue, skb); -	wake_up_interruptible(&cdev->recvwait); - -#else /* CONFIG_ISDN_CAPI_MIDDLEWARE */ -  	mp = np->minorp;  	if (!mp) {  		skb_queue_tail(&cdev->recvqueue, skb); @@ -649,30 +611,22 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb)  		goto unlock_out;  	}  	if (CAPIMSG_SUBCOMMAND(skb->data) == CAPI_IND) { -		datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4+4+2); -#ifdef _DEBUG_DATAFLOW -		printk(KERN_DEBUG "capi_signal: DATA_B3_IND %u len=%d\n", -				datahandle, skb->len-CAPIMSG_LEN(skb->data)); -#endif +		datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN + 4 + 4 + 2); +		pr_debug("capi_signal: DATA_B3_IND %u len=%d\n", +			 datahandle, skb->len-CAPIMSG_LEN(skb->data));  		skb_queue_tail(&mp->inqueue, skb);  		handle_minor_recv(mp);  	} else if (CAPIMSG_SUBCOMMAND(skb->data) == CAPI_CONF) { -		datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4); -#ifdef _DEBUG_DATAFLOW -		printk(KERN_DEBUG "capi_signal: DATA_B3_CONF %u 0x%x\n", -				datahandle, -				CAPIMSG_U16(skb->data, CAPIMSG_BASELEN+4+2)); -#endif +		datahandle = CAPIMSG_U16(skb->data, CAPIMSG_BASELEN + 4); +		pr_debug("capi_signal: DATA_B3_CONF %u 0x%x\n", +			 datahandle, +			 CAPIMSG_U16(skb->data, CAPIMSG_BASELEN + 4 + 2));  		kfree_skb(skb);  		capiminor_del_ack(mp, datahandle); -		tty = tty_port_tty_get(&mp->port); -		if (tty) { -			tty_wakeup(tty); -			tty_kref_put(tty); -		} +		tty_port_tty_wakeup(&mp->port);  		handle_minor_send(mp);  	} else { @@ -704,7 +658,7 @@ capi_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)  		if (file->f_flags & O_NONBLOCK)  			return -EAGAIN;  		err = wait_event_interruptible(cdev->recvwait, -				(skb = skb_dequeue(&cdev->recvqueue))); +					       (skb = skb_dequeue(&cdev->recvqueue)));  		if (err)  			return err;  	} @@ -771,7 +725,7 @@ capi_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos  }  static unsigned int -capi_poll(struct file *file, poll_table * wait) +capi_poll(struct file *file, poll_table *wait)  {  	struct capidev *cdev = file->private_data;  	unsigned int mask = 0; @@ -821,75 +775,69 @@ register_out:  		return retval;  	case CAPI_GET_VERSION: -		{ -			if (copy_from_user(&data.contr, argp, -						sizeof(data.contr))) -				return -EFAULT; -		        cdev->errcode = capi20_get_version(data.contr, &data.version); -			if (cdev->errcode) -				return -EIO; -			if (copy_to_user(argp, &data.version, -					 sizeof(data.version))) -				return -EFAULT; -		} +		if (copy_from_user(&data.contr, argp, +				   sizeof(data.contr))) +			return -EFAULT; +		cdev->errcode = capi20_get_version(data.contr, &data.version); +		if (cdev->errcode) +			return -EIO; +		if (copy_to_user(argp, &data.version, +				 sizeof(data.version))) +			return -EFAULT;  		return 0;  	case CAPI_GET_SERIAL: -		{ -			if (copy_from_user(&data.contr, argp, -					   sizeof(data.contr))) -				return -EFAULT; -			cdev->errcode = capi20_get_serial (data.contr, data.serial); -			if (cdev->errcode) -				return -EIO; -			if (copy_to_user(argp, data.serial, -					 sizeof(data.serial))) -				return -EFAULT; -		} +		if (copy_from_user(&data.contr, argp, +				   sizeof(data.contr))) +			return -EFAULT; +		cdev->errcode = capi20_get_serial(data.contr, data.serial); +		if (cdev->errcode) +			return -EIO; +		if (copy_to_user(argp, data.serial, +				 sizeof(data.serial))) +			return -EFAULT;  		return 0; +  	case CAPI_GET_PROFILE: -		{ -			if (copy_from_user(&data.contr, argp, -					   sizeof(data.contr))) -				return -EFAULT; +		if (copy_from_user(&data.contr, argp, +				   sizeof(data.contr))) +			return -EFAULT; -			if (data.contr == 0) { -				cdev->errcode = capi20_get_profile(data.contr, &data.profile); -				if (cdev->errcode) -					return -EIO; +		if (data.contr == 0) { +			cdev->errcode = capi20_get_profile(data.contr, &data.profile); +			if (cdev->errcode) +				return -EIO; -				retval = copy_to_user(argp, -				      &data.profile.ncontroller, -				       sizeof(data.profile.ncontroller)); +			retval = copy_to_user(argp, +					      &data.profile.ncontroller, +					      sizeof(data.profile.ncontroller)); -			} else { -				cdev->errcode = capi20_get_profile(data.contr, &data.profile); -				if (cdev->errcode) -					return -EIO; +		} else { +			cdev->errcode = capi20_get_profile(data.contr, &data.profile); +			if (cdev->errcode) +				return -EIO; -				retval = copy_to_user(argp, &data.profile, -						   sizeof(data.profile)); -			} -			if (retval) -				return -EFAULT; +			retval = copy_to_user(argp, &data.profile, +					      sizeof(data.profile));  		} +		if (retval) +			return -EFAULT;  		return 0;  	case CAPI_GET_MANUFACTURER: -		{ -			if (copy_from_user(&data.contr, argp, -					   sizeof(data.contr))) -				return -EFAULT; -			cdev->errcode = capi20_get_manufacturer(data.contr, data.manufacturer); -			if (cdev->errcode) -				return -EIO; +		if (copy_from_user(&data.contr, argp, +				   sizeof(data.contr))) +			return -EFAULT; +		cdev->errcode = capi20_get_manufacturer(data.contr, data.manufacturer); +		if (cdev->errcode) +			return -EIO; -			if (copy_to_user(argp, data.manufacturer, -					 sizeof(data.manufacturer))) -				return -EFAULT; +		if (copy_to_user(argp, data.manufacturer, +				 sizeof(data.manufacturer))) +			return -EFAULT; -		}  		return 0; +  	case CAPI_GET_ERRCODE:  		data.errcode = cdev->errcode;  		cdev->errcode = CAPI_NOERROR; @@ -905,17 +853,14 @@ register_out:  			return 0;  		return -ENXIO; -	case CAPI_MANUFACTURER_CMD: -		{ -			struct capi_manufacturer_cmd mcmd; -			if (!capable(CAP_SYS_ADMIN)) -				return -EPERM; -			if (copy_from_user(&mcmd, argp, sizeof(mcmd))) -				return -EFAULT; -			return capi20_manufacturer(mcmd.cmd, mcmd.data); -		} -		return 0; - +	case CAPI_MANUFACTURER_CMD: { +		struct capi_manufacturer_cmd mcmd; +		if (!capable(CAP_SYS_ADMIN)) +			return -EPERM; +		if (copy_from_user(&mcmd, argp, sizeof(mcmd))) +			return -EFAULT; +		return capi20_manufacturer(mcmd.cmd, mcmd.data); +	}  	case CAPI_SET_FLAGS:  	case CAPI_CLR_FLAGS: {  		unsigned userflags; @@ -937,6 +882,11 @@ register_out:  			return -EFAULT;  		return 0; +#ifndef CONFIG_ISDN_CAPI_MIDDLEWARE +	case CAPI_NCCI_OPENCOUNT: +		return 0; + +#else /* CONFIG_ISDN_CAPI_MIDDLEWARE */  	case CAPI_NCCI_OPENCOUNT: {  		struct capincci *nccip;  		unsigned ncci; @@ -953,7 +903,6 @@ register_out:  		return count;  	} -#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE  	case CAPI_NCCI_GETUNIT: {  		struct capincci *nccip;  		struct capiminor *mp; @@ -1048,16 +997,12 @@ static const struct file_operations capi_fops =  static int  capinc_tty_install(struct tty_driver *driver, struct tty_struct *tty)  { -	int idx = tty->index; -	struct capiminor *mp = capiminor_get(idx); -	int ret = tty_init_termios(tty); +	struct capiminor *mp = capiminor_get(tty->index); +	int ret = tty_standard_install(driver, tty); -	if (ret == 0) { -		tty_driver_kref_get(driver); -		tty->count++; +	if (ret == 0)  		tty->driver_data = mp; -		driver->ttys[idx] = tty; -	} else +	else  		capiminor_put(mp);  	return ret;  } @@ -1095,9 +1040,7 @@ static int capinc_tty_write(struct tty_struct *tty,  	struct capiminor *mp = tty->driver_data;  	struct sk_buff *skb; -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_write(count=%d)\n", count); -#endif +	pr_debug("capinc_tty_write(count=%d)\n", count);  	spin_lock_bh(&mp->outlock);  	skb = mp->outskb; @@ -1107,7 +1050,7 @@ static int capinc_tty_write(struct tty_struct *tty,  		mp->outbytes += skb->len;  	} -	skb = alloc_skb(CAPI_DATA_B3_REQ_LEN+count, GFP_ATOMIC); +	skb = alloc_skb(CAPI_DATA_B3_REQ_LEN + count, GFP_ATOMIC);  	if (!skb) {  		printk(KERN_ERR "capinc_tty_write: alloc_skb failed\n");  		spin_unlock_bh(&mp->outlock); @@ -1133,9 +1076,7 @@ static int capinc_tty_put_char(struct tty_struct *tty, unsigned char ch)  	struct sk_buff *skb;  	int ret = 1; -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_put_char(%u)\n", ch); -#endif +	pr_debug("capinc_put_char(%u)\n", ch);  	spin_lock_bh(&mp->outlock);  	skb = mp->outskb; @@ -1150,7 +1091,7 @@ static int capinc_tty_put_char(struct tty_struct *tty, unsigned char ch)  		invoke_send = true;  	} -	skb = alloc_skb(CAPI_DATA_B3_REQ_LEN+CAPI_MAX_BLKSIZE, GFP_ATOMIC); +	skb = alloc_skb(CAPI_DATA_B3_REQ_LEN + CAPI_MAX_BLKSIZE, GFP_ATOMIC);  	if (skb) {  		skb_reserve(skb, CAPI_DATA_B3_REQ_LEN);  		*(skb_put(skb, 1)) = ch; @@ -1174,9 +1115,7 @@ static void capinc_tty_flush_chars(struct tty_struct *tty)  	struct capiminor *mp = tty->driver_data;  	struct sk_buff *skb; -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_flush_chars\n"); -#endif +	pr_debug("capinc_tty_flush_chars\n");  	spin_lock_bh(&mp->outlock);  	skb = mp->outskb; @@ -1200,9 +1139,7 @@ static int capinc_tty_write_room(struct tty_struct *tty)  	room = CAPINC_MAX_SENDQUEUE-skb_queue_len(&mp->outqueue);  	room *= CAPI_MAX_BLKSIZE; -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_write_room = %d\n", room); -#endif +	pr_debug("capinc_tty_write_room = %d\n", room);  	return room;  } @@ -1210,40 +1147,28 @@ static int capinc_tty_chars_in_buffer(struct tty_struct *tty)  {  	struct capiminor *mp = tty->driver_data; -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_chars_in_buffer = %d nack=%d sq=%d rq=%d\n", -			mp->outbytes, mp->nack, -			skb_queue_len(&mp->outqueue), -			skb_queue_len(&mp->inqueue)); -#endif +	pr_debug("capinc_tty_chars_in_buffer = %d nack=%d sq=%d rq=%d\n", +		 mp->outbytes, mp->nack, +		 skb_queue_len(&mp->outqueue), +		 skb_queue_len(&mp->inqueue));  	return mp->outbytes;  } -static int capinc_tty_ioctl(struct tty_struct *tty, struct file * file, -		    unsigned int cmd, unsigned long arg) +static int capinc_tty_ioctl(struct tty_struct *tty, +			    unsigned int cmd, unsigned long arg)  { -	int error = 0; -	switch (cmd) { -	default: -		error = n_tty_ioctl_helper(tty, file, cmd, arg); -		break; -	} -	return error; +	return -ENOIOCTLCMD;  } -static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios * old) +static void capinc_tty_set_termios(struct tty_struct *tty, struct ktermios *old)  { -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_set_termios\n"); -#endif +	pr_debug("capinc_tty_set_termios\n");  }  static void capinc_tty_throttle(struct tty_struct *tty)  {  	struct capiminor *mp = tty->driver_data; -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_throttle\n"); -#endif +	pr_debug("capinc_tty_throttle\n");  	mp->ttyinstop = 1;  } @@ -1251,9 +1176,7 @@ static void capinc_tty_unthrottle(struct tty_struct *tty)  {  	struct capiminor *mp = tty->driver_data; -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_unthrottle\n"); -#endif +	pr_debug("capinc_tty_unthrottle\n");  	mp->ttyinstop = 0;  	handle_minor_recv(mp);  } @@ -1262,9 +1185,7 @@ static void capinc_tty_stop(struct tty_struct *tty)  {  	struct capiminor *mp = tty->driver_data; -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_stop\n"); -#endif +	pr_debug("capinc_tty_stop\n");  	mp->ttyoutstop = 1;  } @@ -1272,9 +1193,7 @@ static void capinc_tty_start(struct tty_struct *tty)  {  	struct capiminor *mp = tty->driver_data; -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_start\n"); -#endif +	pr_debug("capinc_tty_start\n");  	mp->ttyoutstop = 0;  	handle_minor_send(mp);  } @@ -1283,39 +1202,29 @@ static void capinc_tty_hangup(struct tty_struct *tty)  {  	struct capiminor *mp = tty->driver_data; -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_hangup\n"); -#endif +	pr_debug("capinc_tty_hangup\n");  	tty_port_hangup(&mp->port);  }  static int capinc_tty_break_ctl(struct tty_struct *tty, int state)  { -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_break_ctl(%d)\n", state); -#endif +	pr_debug("capinc_tty_break_ctl(%d)\n", state);  	return 0;  }  static void capinc_tty_flush_buffer(struct tty_struct *tty)  { -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_flush_buffer\n"); -#endif +	pr_debug("capinc_tty_flush_buffer\n");  }  static void capinc_tty_set_ldisc(struct tty_struct *tty)  { -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_set_ldisc\n"); -#endif +	pr_debug("capinc_tty_set_ldisc\n");  }  static void capinc_tty_send_xchar(struct tty_struct *tty, char ch)  { -#ifdef _DEBUG_TTYFUNCS -	printk(KERN_DEBUG "capinc_tty_send_xchar(%d)\n", ch); -#endif +	pr_debug("capinc_tty_send_xchar(%d)\n", ch);  }  static const struct tty_operations capinc_ops = { @@ -1361,9 +1270,8 @@ static int __init capinc_tty_init(void)  		kfree(capiminors);  		return -ENOMEM;  	} -	drv->owner = THIS_MODULE;  	drv->driver_name = "capi_nc"; -	drv->name = "capi"; +	drv->name = "capi!";  	drv->major = 0;  	drv->minor_start = 0;  	drv->type = TTY_DRIVER_TYPE_SERIAL; @@ -1415,18 +1323,18 @@ static inline void capinc_tty_exit(void) { }   */  static int capi20_proc_show(struct seq_file *m, void *v)  { -        struct capidev *cdev; +	struct capidev *cdev;  	struct list_head *l;  	mutex_lock(&capidev_list_lock);  	list_for_each(l, &capidev_list) {  		cdev = list_entry(l, struct capidev, list);  		seq_printf(m, "0 %d %lu %lu %lu %lu\n", -			cdev->ap.applid, -			cdev->ap.nrecvctlpkt, -			cdev->ap.nrecvdatapkt, -			cdev->ap.nsentctlpkt, -			cdev->ap.nsentdatapkt); +			   cdev->ap.applid, +			   cdev->ap.nrecvctlpkt, +			   cdev->ap.nrecvdatapkt, +			   cdev->ap.nsentctlpkt, +			   cdev->ap.nsentdatapkt);  	}  	mutex_unlock(&capidev_list_lock);  	return 0; @@ -1509,7 +1417,7 @@ static int __init capi_init(void)  		return PTR_ERR(capi_class);  	} -	device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi"); +	device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi20");  	if (capinc_tty_init() < 0) {  		device_destroy(capi_class, MKDEV(capi_major, 0)); @@ -1520,12 +1428,10 @@ static int __init capi_init(void)  	proc_init(); -#if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE) -        compileinfo = " (middleware+capifs)"; -#elif defined(CONFIG_ISDN_CAPI_MIDDLEWARE) -        compileinfo = " (no capifs)"; +#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE +	compileinfo = " (middleware)";  #else -        compileinfo = " (no middleware)"; +	compileinfo = " (no middleware)";  #endif  	printk(KERN_NOTICE "CAPI 2.0 started up with major %d%s\n",  	       capi_major, compileinfo); diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c index e54e79d4e2c..fd6d28f3fc3 100644 --- a/drivers/isdn/capi/capidrv.c +++ b/drivers/isdn/capi/capidrv.c @@ -40,7 +40,7 @@ static int debugmode = 0;  MODULE_DESCRIPTION("CAPI4Linux: Interface to ISDN4Linux");  MODULE_AUTHOR("Carsten Paeth");  MODULE_LICENSE("GPL"); -module_param(debugmode, uint, S_IRUGO|S_IWUSR); +module_param(debugmode, uint, S_IRUGO | S_IWUSR);  /* -------- type definitions ----------------------------------------- */ @@ -64,7 +64,7 @@ struct capidrv_contr {  	int state;  	u32 cipmask;  	u32 cipmask2; -        struct timer_list listentimer; +	struct timer_list listentimer;  	/*  	 * ID of capi message sent @@ -105,9 +105,9 @@ struct capidrv_contr {  				/* */  				u16 datahandle;  				struct ncci_datahandle_queue { -				    struct ncci_datahandle_queue *next; -				    u16                         datahandle; -				    int                           len; +					struct ncci_datahandle_queue *next; +					u16                         datahandle; +					int                           len;  				} *ackqueue;  			} *ncci_list;  		} *plcip; @@ -142,7 +142,7 @@ static capidrv_data global;  static DEFINE_SPINLOCK(global_lock);  static void handle_dtrace_data(capidrv_contr *card, -	int send, int level2, u8 *data, u16 len); +			       int send, int level2, u8 *data, u16 len);  /* -------- convert functions ---------------------------------------- */ @@ -158,11 +158,11 @@ static inline u32 b1prot(int l2, int l3)  		return 0;  	case ISDN_PROTO_L2_TRANS:  		return 1; -        case ISDN_PROTO_L2_V11096: -        case ISDN_PROTO_L2_V11019: -        case ISDN_PROTO_L2_V11038: +	case ISDN_PROTO_L2_V11096: +	case ISDN_PROTO_L2_V11019: +	case ISDN_PROTO_L2_V11038:  		return 2; -        case ISDN_PROTO_L2_FAX: +	case ISDN_PROTO_L2_FAX:  		return 4;  	case ISDN_PROTO_L2_MODEM:  		return 8; @@ -179,12 +179,12 @@ static inline u32 b2prot(int l2, int l3)  		return 0;  	case ISDN_PROTO_L2_HDLC:  	case ISDN_PROTO_L2_TRANS: -        case ISDN_PROTO_L2_V11096: -        case ISDN_PROTO_L2_V11019: -        case ISDN_PROTO_L2_V11038: +	case ISDN_PROTO_L2_V11096: +	case ISDN_PROTO_L2_V11019: +	case ISDN_PROTO_L2_V11038:  	case ISDN_PROTO_L2_MODEM:  		return 1; -        case ISDN_PROTO_L2_FAX: +	case ISDN_PROTO_L2_FAX:  		return 4;  	}  } @@ -197,13 +197,13 @@ static inline u32 b3prot(int l2, int l3)  	case ISDN_PROTO_L2_X75BUI:  	case ISDN_PROTO_L2_HDLC:  	case ISDN_PROTO_L2_TRANS: -        case ISDN_PROTO_L2_V11096: -        case ISDN_PROTO_L2_V11019: -        case ISDN_PROTO_L2_V11038: +	case ISDN_PROTO_L2_V11096: +	case ISDN_PROTO_L2_V11019: +	case ISDN_PROTO_L2_V11038:  	case ISDN_PROTO_L2_MODEM:  	default:  		return 0; -        case ISDN_PROTO_L2_FAX: +	case ISDN_PROTO_L2_FAX:  		return 4;  	}  } @@ -231,38 +231,38 @@ static _cstruct b1config(int l2, int l3)  	case ISDN_PROTO_L2_TRANS:  	default:  		return NULL; -        case ISDN_PROTO_L2_V11096: -	    return b1config_async_v110(9600); -        case ISDN_PROTO_L2_V11019: -	    return b1config_async_v110(19200); -        case ISDN_PROTO_L2_V11038: -	    return b1config_async_v110(38400); +	case ISDN_PROTO_L2_V11096: +		return b1config_async_v110(9600); +	case ISDN_PROTO_L2_V11019: +		return b1config_async_v110(19200); +	case ISDN_PROTO_L2_V11038: +		return b1config_async_v110(38400);  	}  }  static inline u16 si2cip(u8 si1, u8 si2)  {  	static const u8 cip[17][5] = -	{ -	/*  0  1  2  3  4  */ -		{0, 0, 0, 0, 0},	/*0 */ -		{16, 16, 4, 26, 16},	/*1 */ -		{17, 17, 17, 4, 4},	/*2 */ -		{2, 2, 2, 2, 2},	/*3 */ -		{18, 18, 18, 18, 18},	/*4 */ -		{2, 2, 2, 2, 2},	/*5 */ -		{0, 0, 0, 0, 0},	/*6 */ -		{2, 2, 2, 2, 2},	/*7 */ -		{2, 2, 2, 2, 2},	/*8 */ -		{21, 21, 21, 21, 21},	/*9 */ -		{19, 19, 19, 19, 19},	/*10 */ -		{0, 0, 0, 0, 0},	/*11 */ -		{0, 0, 0, 0, 0},	/*12 */ -		{0, 0, 0, 0, 0},	/*13 */ -		{0, 0, 0, 0, 0},	/*14 */ -		{22, 22, 22, 22, 22},	/*15 */ -		{27, 27, 27, 28, 27}	/*16 */ -	}; +		{ +			/*  0  1  2  3  4  */ +			{0, 0, 0, 0, 0},	/*0 */ +			{16, 16, 4, 26, 16},	/*1 */ +			{17, 17, 17, 4, 4},	/*2 */ +			{2, 2, 2, 2, 2},	/*3 */ +			{18, 18, 18, 18, 18},	/*4 */ +			{2, 2, 2, 2, 2},	/*5 */ +			{0, 0, 0, 0, 0},	/*6 */ +			{2, 2, 2, 2, 2},	/*7 */ +			{2, 2, 2, 2, 2},	/*8 */ +			{21, 21, 21, 21, 21},	/*9 */ +			{19, 19, 19, 19, 19},	/*10 */ +			{0, 0, 0, 0, 0},	/*11 */ +			{0, 0, 0, 0, 0},	/*12 */ +			{0, 0, 0, 0, 0},	/*13 */ +			{0, 0, 0, 0, 0},	/*14 */ +			{22, 22, 22, 22, 22},	/*15 */ +			{27, 27, 27, 28, 27}	/*16 */ +		};  	if (si1 > 16)  		si1 = 0;  	if (si2 > 4) @@ -274,10 +274,10 @@ static inline u16 si2cip(u8 si1, u8 si2)  static inline u8 cip2si1(u16 cipval)  {  	static const u8 si[32] = -	{7, 1, 7, 7, 1, 1, 7, 7,	/*0-7 */ -	 7, 1, 0, 0, 0, 0, 0, 0,	/*8-15 */ -	 1, 2, 4, 10, 9, 9, 15, 7,	/*16-23 */ -	 7, 7, 1, 16, 16, 0, 0, 0};	/*24-31 */ +		{7, 1, 7, 7, 1, 1, 7, 7,	/*0-7 */ +		 7, 1, 0, 0, 0, 0, 0, 0,	/*8-15 */ +		 1, 2, 4, 10, 9, 9, 15, 7,	/*16-23 */ +		 7, 7, 1, 16, 16, 0, 0, 0};	/*24-31 */  	if (cipval > 31)  		cipval = 0;	/* .... */ @@ -287,10 +287,10 @@ static inline u8 cip2si1(u16 cipval)  static inline u8 cip2si2(u16 cipval)  {  	static const u8 si[32] = -	{0, 0, 0, 0, 2, 3, 0, 0,	/*0-7 */ -	 0, 3, 0, 0, 0, 0, 0, 0,	/*8-15 */ -	 1, 2, 0, 0, 9, 0, 0, 0,	/*16-23 */ -	 0, 0, 3, 2, 3, 0, 0, 0};	/*24-31 */ +		{0, 0, 0, 0, 2, 3, 0, 0,	/*0-7 */ +		 0, 3, 0, 0, 0, 0, 0, 0,	/*8-15 */ +		 1, 2, 0, 0, 9, 0, 0, 0,	/*16-23 */ +		 0, 0, 3, 2, 3, 0, 0, 0};	/*24-31 */  	if (cipval > 31)  		cipval = 0;	/* .... */ @@ -302,7 +302,7 @@ static inline u8 cip2si2(u16 cipval)  static inline capidrv_contr *findcontrbydriverid(int driverid)  { -    	unsigned long flags; +	unsigned long flags;  	capidrv_contr *p;  	spin_lock_irqsave(&global_lock, flags); @@ -329,7 +329,7 @@ static capidrv_contr *findcontrbynumber(u32 contr)  /* -------- plci management ------------------------------------------ */ -static capidrv_plci *new_plci(capidrv_contr * card, int chan) +static capidrv_plci *new_plci(capidrv_contr *card, int chan)  {  	capidrv_plci *plcip; @@ -349,7 +349,7 @@ static capidrv_plci *new_plci(capidrv_contr * card, int chan)  	return plcip;  } -static capidrv_plci *find_plci_by_plci(capidrv_contr * card, u32 plci) +static capidrv_plci *find_plci_by_plci(capidrv_contr *card, u32 plci)  {  	capidrv_plci *p;  	for (p = card->plci_list; p; p = p->next) @@ -358,7 +358,7 @@ static capidrv_plci *find_plci_by_plci(capidrv_contr * card, u32 plci)  	return NULL;  } -static capidrv_plci *find_plci_by_msgid(capidrv_contr * card, u16 msgid) +static capidrv_plci *find_plci_by_msgid(capidrv_contr *card, u16 msgid)  {  	capidrv_plci *p;  	for (p = card->plci_list; p; p = p->next) @@ -367,7 +367,7 @@ static capidrv_plci *find_plci_by_msgid(capidrv_contr * card, u16 msgid)  	return NULL;  } -static capidrv_plci *find_plci_by_ncci(capidrv_contr * card, u32 ncci) +static capidrv_plci *find_plci_by_ncci(capidrv_contr *card, u32 ncci)  {  	capidrv_plci *p;  	for (p = card->plci_list; p; p = p->next) @@ -376,7 +376,7 @@ static capidrv_plci *find_plci_by_ncci(capidrv_contr * card, u32 ncci)  	return NULL;  } -static void free_plci(capidrv_contr * card, capidrv_plci * plcip) +static void free_plci(capidrv_contr *card, capidrv_plci *plcip)  {  	capidrv_plci **pp; @@ -396,8 +396,8 @@ static void free_plci(capidrv_contr * card, capidrv_plci * plcip)  /* -------- ncci management ------------------------------------------ */ -static inline capidrv_ncci *new_ncci(capidrv_contr * card, -				     capidrv_plci * plcip, +static inline capidrv_ncci *new_ncci(capidrv_contr *card, +				     capidrv_plci *plcip,  				     u32 ncci)  {  	capidrv_ncci *nccip; @@ -421,7 +421,7 @@ static inline capidrv_ncci *new_ncci(capidrv_contr * card,  	return nccip;  } -static inline capidrv_ncci *find_ncci(capidrv_contr * card, u32 ncci) +static inline capidrv_ncci *find_ncci(capidrv_contr *card, u32 ncci)  {  	capidrv_plci *plcip;  	capidrv_ncci *p; @@ -435,7 +435,7 @@ static inline capidrv_ncci *find_ncci(capidrv_contr * card, u32 ncci)  	return NULL;  } -static inline capidrv_ncci *find_ncci_by_msgid(capidrv_contr * card, +static inline capidrv_ncci *find_ncci_by_msgid(capidrv_contr *card,  					       u32 ncci, u16 msgid)  {  	capidrv_plci *plcip; @@ -450,7 +450,7 @@ static inline capidrv_ncci *find_ncci_by_msgid(capidrv_contr * card,  	return NULL;  } -static void free_ncci(capidrv_contr * card, struct capidrv_ncci *nccip) +static void free_ncci(capidrv_contr *card, struct capidrv_ncci *nccip)  {  	struct capidrv_ncci **pp; @@ -465,20 +465,19 @@ static void free_ncci(capidrv_contr * card, struct capidrv_ncci *nccip)  }  static int capidrv_add_ack(struct capidrv_ncci *nccip, -		           u16 datahandle, int len) +			   u16 datahandle, int len)  {  	struct ncci_datahandle_queue *n, **pp; -	n = (struct ncci_datahandle_queue *) -		kmalloc(sizeof(struct ncci_datahandle_queue), GFP_ATOMIC); +	n = kmalloc(sizeof(struct ncci_datahandle_queue), GFP_ATOMIC);  	if (!n) { -	   printk(KERN_ERR "capidrv: kmalloc ncci_datahandle failed\n"); -	   return -1; +		printk(KERN_ERR "capidrv: kmalloc ncci_datahandle failed\n"); +		return -1;  	}  	n->next = NULL;  	n->datahandle = datahandle;  	n->len = len; -	for (pp = &nccip->ackqueue; *pp; pp = &(*pp)->next) ; +	for (pp = &nccip->ackqueue; *pp; pp = &(*pp)->next);  	*pp = n;  	return 0;  } @@ -489,11 +488,11 @@ static int capidrv_del_ack(struct capidrv_ncci *nccip, u16 datahandle)  	int len;  	for (pp = &nccip->ackqueue; *pp; pp = &(*pp)->next) { - 		if ((*pp)->datahandle == datahandle) { +		if ((*pp)->datahandle == datahandle) {  			p = *pp;  			len = p->len;  			*pp = (*pp)->next; -		        kfree(p); +			kfree(p);  			return len;  		}  	} @@ -502,7 +501,7 @@ static int capidrv_del_ack(struct capidrv_ncci *nccip, u16 datahandle)  /* -------- convert and send capi message ---------------------------- */ -static void send_message(capidrv_contr * card, _cmsg * cmsg) +static void send_message(capidrv_contr *card, _cmsg *cmsg)  {  	struct sk_buff *skb;  	size_t len; @@ -529,18 +528,18 @@ struct listenstatechange {  static struct listenstatechange listentable[] =  { -  {ST_LISTEN_NONE, ST_LISTEN_WAIT_CONF, EV_LISTEN_REQ}, -  {ST_LISTEN_ACTIVE, ST_LISTEN_ACTIVE_WAIT_CONF, EV_LISTEN_REQ}, -  {ST_LISTEN_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_ERROR}, -  {ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_ERROR}, -  {ST_LISTEN_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_EMPTY}, -  {ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_EMPTY}, -  {ST_LISTEN_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_OK}, -  {ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_OK}, -  {}, +	{ST_LISTEN_NONE, ST_LISTEN_WAIT_CONF, EV_LISTEN_REQ}, +	{ST_LISTEN_ACTIVE, ST_LISTEN_ACTIVE_WAIT_CONF, EV_LISTEN_REQ}, +	{ST_LISTEN_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_ERROR}, +	{ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_ERROR}, +	{ST_LISTEN_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_EMPTY}, +	{ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_NONE, EV_LISTEN_CONF_EMPTY}, +	{ST_LISTEN_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_OK}, +	{ST_LISTEN_ACTIVE_WAIT_CONF, ST_LISTEN_ACTIVE, EV_LISTEN_CONF_OK}, +	{},  }; -static void listen_change_state(capidrv_contr * card, int event) +static void listen_change_state(capidrv_contr *card, int event)  {  	struct listenstatechange *p = listentable;  	while (p->event) { @@ -560,7 +559,7 @@ static void listen_change_state(capidrv_contr * card, int event)  /* ------------------------------------------------------------------ */ -static void p0(capidrv_contr * card, capidrv_plci * plci) +static void p0(capidrv_contr *card, capidrv_plci *plci)  {  	isdn_ctrl cmd; @@ -578,71 +577,71 @@ struct plcistatechange {  	int actstate;  	int nextstate;  	int event; -	void (*changefunc) (capidrv_contr * card, capidrv_plci * plci); +	void (*changefunc)(capidrv_contr *card, capidrv_plci *plci);  };  static struct plcistatechange plcitable[] =  { -  /* P-0 */ -  {ST_PLCI_NONE, ST_PLCI_OUTGOING, EV_PLCI_CONNECT_REQ, NULL}, -  {ST_PLCI_NONE, ST_PLCI_ALLOCATED, EV_PLCI_FACILITY_IND_UP, NULL}, -  {ST_PLCI_NONE, ST_PLCI_INCOMING, EV_PLCI_CONNECT_IND, NULL}, -  {ST_PLCI_NONE, ST_PLCI_RESUMEING, EV_PLCI_RESUME_REQ, NULL}, -  /* P-0.1 */ -  {ST_PLCI_OUTGOING, ST_PLCI_NONE, EV_PLCI_CONNECT_CONF_ERROR, p0}, -  {ST_PLCI_OUTGOING, ST_PLCI_ALLOCATED, EV_PLCI_CONNECT_CONF_OK, NULL}, -  /* P-1 */ -  {ST_PLCI_ALLOCATED, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, -  {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, -  {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, -  {ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, -  /* P-ACT */ -  {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, -  {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, -  {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, -  {ST_PLCI_ACTIVE, ST_PLCI_HELD, EV_PLCI_HOLD_IND, NULL}, -  {ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_SUSPEND_IND, NULL}, -  /* P-2 */ -  {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, NULL}, -  {ST_PLCI_INCOMING, ST_PLCI_FACILITY_IND, EV_PLCI_FACILITY_IND_UP, NULL}, -  {ST_PLCI_INCOMING, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_RESP, NULL}, -  {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, -  {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, -  {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, -  {ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CD_IND, NULL}, -  /* P-3 */ -  {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, NULL}, -  {ST_PLCI_FACILITY_IND, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, -  {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, -  {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, -  {ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, -  /* P-4 */ -  {ST_PLCI_ACCEPTING, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, -  {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, -  {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, -  {ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, -  /* P-5 */ -  {ST_PLCI_DISCONNECTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, -  /* P-6 */ -  {ST_PLCI_DISCONNECTED, ST_PLCI_NONE, EV_PLCI_DISCONNECT_RESP, p0}, -  /* P-0.Res */ -  {ST_PLCI_RESUMEING, ST_PLCI_NONE, EV_PLCI_RESUME_CONF_ERROR, p0}, -  {ST_PLCI_RESUMEING, ST_PLCI_RESUME, EV_PLCI_RESUME_CONF_OK, NULL}, -  /* P-RES */ -  {ST_PLCI_RESUME, ST_PLCI_ACTIVE, EV_PLCI_RESUME_IND, NULL}, -  /* P-HELD */ -  {ST_PLCI_HELD, ST_PLCI_ACTIVE, EV_PLCI_RETRIEVE_IND, NULL}, -  {}, +	/* P-0 */ +	{ST_PLCI_NONE, ST_PLCI_OUTGOING, EV_PLCI_CONNECT_REQ, NULL}, +	{ST_PLCI_NONE, ST_PLCI_ALLOCATED, EV_PLCI_FACILITY_IND_UP, NULL}, +	{ST_PLCI_NONE, ST_PLCI_INCOMING, EV_PLCI_CONNECT_IND, NULL}, +	{ST_PLCI_NONE, ST_PLCI_RESUMEING, EV_PLCI_RESUME_REQ, NULL}, +	/* P-0.1 */ +	{ST_PLCI_OUTGOING, ST_PLCI_NONE, EV_PLCI_CONNECT_CONF_ERROR, p0}, +	{ST_PLCI_OUTGOING, ST_PLCI_ALLOCATED, EV_PLCI_CONNECT_CONF_OK, NULL}, +	/* P-1 */ +	{ST_PLCI_ALLOCATED, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, +	{ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, +	{ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, +	{ST_PLCI_ALLOCATED, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, +	/* P-ACT */ +	{ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, +	{ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, +	{ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, +	{ST_PLCI_ACTIVE, ST_PLCI_HELD, EV_PLCI_HOLD_IND, NULL}, +	{ST_PLCI_ACTIVE, ST_PLCI_DISCONNECTING, EV_PLCI_SUSPEND_IND, NULL}, +	/* P-2 */ +	{ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, NULL}, +	{ST_PLCI_INCOMING, ST_PLCI_FACILITY_IND, EV_PLCI_FACILITY_IND_UP, NULL}, +	{ST_PLCI_INCOMING, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_RESP, NULL}, +	{ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, +	{ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, +	{ST_PLCI_INCOMING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, +	{ST_PLCI_INCOMING, ST_PLCI_DISCONNECTING, EV_PLCI_CD_IND, NULL}, +	/* P-3 */ +	{ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_CONNECT_REJECT, NULL}, +	{ST_PLCI_FACILITY_IND, ST_PLCI_ACCEPTING, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, +	{ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, +	{ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, +	{ST_PLCI_FACILITY_IND, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, +	/* P-4 */ +	{ST_PLCI_ACCEPTING, ST_PLCI_ACTIVE, EV_PLCI_CONNECT_ACTIVE_IND, NULL}, +	{ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_DISCONNECT_REQ, NULL}, +	{ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTING, EV_PLCI_FACILITY_IND_DOWN, NULL}, +	{ST_PLCI_ACCEPTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, +	/* P-5 */ +	{ST_PLCI_DISCONNECTING, ST_PLCI_DISCONNECTED, EV_PLCI_DISCONNECT_IND, NULL}, +	/* P-6 */ +	{ST_PLCI_DISCONNECTED, ST_PLCI_NONE, EV_PLCI_DISCONNECT_RESP, p0}, +	/* P-0.Res */ +	{ST_PLCI_RESUMEING, ST_PLCI_NONE, EV_PLCI_RESUME_CONF_ERROR, p0}, +	{ST_PLCI_RESUMEING, ST_PLCI_RESUME, EV_PLCI_RESUME_CONF_OK, NULL}, +	/* P-RES */ +	{ST_PLCI_RESUME, ST_PLCI_ACTIVE, EV_PLCI_RESUME_IND, NULL}, +	/* P-HELD */ +	{ST_PLCI_HELD, ST_PLCI_ACTIVE, EV_PLCI_RETRIEVE_IND, NULL}, +	{},  }; -static void plci_change_state(capidrv_contr * card, capidrv_plci * plci, int event) +static void plci_change_state(capidrv_contr *card, capidrv_plci *plci, int event)  {  	struct plcistatechange *p = plcitable;  	while (p->event) {  		if (plci->state == p->actstate && p->event == event) {  			if (debugmode)  				printk(KERN_DEBUG "capidrv-%d: plci_change_state:0x%x %d -> %d\n", -				  card->contrnr, plci->plci, plci->state, p->nextstate); +				       card->contrnr, plci->plci, plci->state, p->nextstate);  			plci->state = p->nextstate;  			if (p->changefunc)  				p->changefunc(card, plci); @@ -658,7 +657,7 @@ static void plci_change_state(capidrv_contr * card, capidrv_plci * plci, int eve  static _cmsg cmsg; -static void n0(capidrv_contr * card, capidrv_ncci * ncci) +static void n0(capidrv_contr *card, capidrv_ncci *ncci)  {  	isdn_ctrl cmd; @@ -670,7 +669,7 @@ static void n0(capidrv_contr * card, capidrv_ncci * ncci)  				 NULL,	/* Keypadfacility */  				 NULL,	/* Useruserdata */   /* $$$$ */  				 NULL	/* Facilitydataarray */ -	); +		);  	plci_change_state(card, ncci->plcip, EV_PLCI_DISCONNECT_REQ);  	send_message(card, &cmsg); @@ -687,51 +686,51 @@ struct nccistatechange {  	int actstate;  	int nextstate;  	int event; -	void (*changefunc) (capidrv_contr * card, capidrv_ncci * ncci); +	void (*changefunc)(capidrv_contr *card, capidrv_ncci *ncci);  };  static struct nccistatechange nccitable[] =  { -  /* N-0 */ -  {ST_NCCI_NONE, ST_NCCI_OUTGOING, EV_NCCI_CONNECT_B3_REQ, NULL}, -  {ST_NCCI_NONE, ST_NCCI_INCOMING, EV_NCCI_CONNECT_B3_IND, NULL}, -  /* N-0.1 */ -  {ST_NCCI_OUTGOING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_CONF_OK, NULL}, -  {ST_NCCI_OUTGOING, ST_NCCI_NONE, EV_NCCI_CONNECT_B3_CONF_ERROR, n0}, -  /* N-1 */ -  {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_CONNECT_B3_REJECT, NULL}, -  {ST_NCCI_INCOMING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_RESP, NULL}, -  {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, -  {ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, -  /* N-2 */ -  {ST_NCCI_ALLOCATED, ST_NCCI_ACTIVE, EV_NCCI_CONNECT_B3_ACTIVE_IND, NULL}, -  {ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, -  {ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, -  /* N-ACT */ -  {ST_NCCI_ACTIVE, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, NULL}, -  {ST_NCCI_ACTIVE, ST_NCCI_RESETING, EV_NCCI_RESET_B3_REQ, NULL}, -  {ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, -  {ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, -  /* N-3 */ -  {ST_NCCI_RESETING, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, NULL}, -  {ST_NCCI_RESETING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, -  {ST_NCCI_RESETING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, -  /* N-4 */ -  {ST_NCCI_DISCONNECTING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, -  {ST_NCCI_DISCONNECTING, ST_NCCI_PREVIOUS, EV_NCCI_DISCONNECT_B3_CONF_ERROR,NULL}, -  /* N-5 */ -  {ST_NCCI_DISCONNECTED, ST_NCCI_NONE, EV_NCCI_DISCONNECT_B3_RESP, n0}, -  {}, +	/* N-0 */ +	{ST_NCCI_NONE, ST_NCCI_OUTGOING, EV_NCCI_CONNECT_B3_REQ, NULL}, +	{ST_NCCI_NONE, ST_NCCI_INCOMING, EV_NCCI_CONNECT_B3_IND, NULL}, +	/* N-0.1 */ +	{ST_NCCI_OUTGOING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_CONF_OK, NULL}, +	{ST_NCCI_OUTGOING, ST_NCCI_NONE, EV_NCCI_CONNECT_B3_CONF_ERROR, n0}, +	/* N-1 */ +	{ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_CONNECT_B3_REJECT, NULL}, +	{ST_NCCI_INCOMING, ST_NCCI_ALLOCATED, EV_NCCI_CONNECT_B3_RESP, NULL}, +	{ST_NCCI_INCOMING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, +	{ST_NCCI_INCOMING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, +	/* N-2 */ +	{ST_NCCI_ALLOCATED, ST_NCCI_ACTIVE, EV_NCCI_CONNECT_B3_ACTIVE_IND, NULL}, +	{ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, +	{ST_NCCI_ALLOCATED, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, +	/* N-ACT */ +	{ST_NCCI_ACTIVE, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, NULL}, +	{ST_NCCI_ACTIVE, ST_NCCI_RESETING, EV_NCCI_RESET_B3_REQ, NULL}, +	{ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, +	{ST_NCCI_ACTIVE, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, +	/* N-3 */ +	{ST_NCCI_RESETING, ST_NCCI_ACTIVE, EV_NCCI_RESET_B3_IND, NULL}, +	{ST_NCCI_RESETING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, +	{ST_NCCI_RESETING, ST_NCCI_DISCONNECTING, EV_NCCI_DISCONNECT_B3_REQ, NULL}, +	/* N-4 */ +	{ST_NCCI_DISCONNECTING, ST_NCCI_DISCONNECTED, EV_NCCI_DISCONNECT_B3_IND, NULL}, +	{ST_NCCI_DISCONNECTING, ST_NCCI_PREVIOUS, EV_NCCI_DISCONNECT_B3_CONF_ERROR, NULL}, +	/* N-5 */ +	{ST_NCCI_DISCONNECTED, ST_NCCI_NONE, EV_NCCI_DISCONNECT_B3_RESP, n0}, +	{},  }; -static void ncci_change_state(capidrv_contr * card, capidrv_ncci * ncci, int event) +static void ncci_change_state(capidrv_contr *card, capidrv_ncci *ncci, int event)  {  	struct nccistatechange *p = nccitable;  	while (p->event) {  		if (ncci->state == p->actstate && p->event == event) {  			if (debugmode)  				printk(KERN_DEBUG "capidrv-%d: ncci_change_state:0x%x %d -> %d\n", -				  card->contrnr, ncci->ncci, ncci->state, p->nextstate); +				       card->contrnr, ncci->ncci, ncci->state, p->nextstate);  			if (p->nextstate == ST_NCCI_PREVIOUS) {  				ncci->state = ncci->oldstate;  				ncci->oldstate = p->actstate; @@ -751,7 +750,7 @@ static void ncci_change_state(capidrv_contr * card, capidrv_ncci * ncci, int eve  /* ------------------------------------------------------------------- */ -static inline int new_bchan(capidrv_contr * card) +static inline int new_bchan(capidrv_contr *card)  {  	int i;  	for (i = 0; i < card->nbchan; i++) { @@ -764,8 +763,203 @@ static inline int new_bchan(capidrv_contr * card)  }  /* ------------------------------------------------------------------- */ +static char *capi_info2str(u16 reason) +{ +#ifndef CONFIG_ISDN_CAPI_CAPIDRV_VERBOSE +	return ".."; +#else +	switch (reason) { + +/*-- informative values (corresponding message was processed) -----*/ +	case 0x0001: +		return "NCPI not supported by current protocol, NCPI ignored"; +	case 0x0002: +		return "Flags not supported by current protocol, flags ignored"; +	case 0x0003: +		return "Alert already sent by another application"; + +/*-- error information concerning CAPI_REGISTER -----*/ +	case 0x1001: +		return "Too many applications"; +	case 0x1002: +		return "Logical block size too small, must be at least 128 Bytes"; +	case 0x1003: +		return "Buffer exceeds 64 kByte"; +	case 0x1004: +		return "Message buffer size too small, must be at least 1024 Bytes"; +	case 0x1005: +		return "Max. number of logical connections not supported"; +	case 0x1006: +		return "Reserved"; +	case 0x1007: +		return "The message could not be accepted because of an internal busy condition"; +	case 0x1008: +		return "OS resource error (no memory ?)"; +	case 0x1009: +		return "CAPI not installed"; +	case 0x100A: +		return "Controller does not support external equipment"; +	case 0x100B: +		return "Controller does only support external equipment"; + +/*-- error information concerning message exchange functions -----*/ +	case 0x1101: +		return "Illegal application number"; +	case 0x1102: +		return "Illegal command or subcommand or message length less than 12 bytes"; +	case 0x1103: +		return "The message could not be accepted because of a queue full condition !! The error code does not imply that CAPI cannot receive messages directed to another controller, PLCI or NCCI"; +	case 0x1104: +		return "Queue is empty"; +	case 0x1105: +		return "Queue overflow, a message was lost !! This indicates a configuration error. The only recovery from this error is to perform a CAPI_RELEASE"; +	case 0x1106: +		return "Unknown notification parameter"; +	case 0x1107: +		return "The Message could not be accepted because of an internal busy condition"; +	case 0x1108: +		return "OS Resource error (no memory ?)"; +	case 0x1109: +		return "CAPI not installed"; +	case 0x110A: +		return "Controller does not support external equipment"; +	case 0x110B: +		return "Controller does only support external equipment"; + +/*-- error information concerning resource / coding problems -----*/ +	case 0x2001: +		return "Message not supported in current state"; +	case 0x2002: +		return "Illegal Controller / PLCI / NCCI"; +	case 0x2003: +		return "Out of PLCI"; +	case 0x2004: +		return "Out of NCCI"; +	case 0x2005: +		return "Out of LISTEN"; +	case 0x2006: +		return "Out of FAX resources (protocol T.30)"; +	case 0x2007: +		return "Illegal message parameter coding"; + +/*-- error information concerning requested services  -----*/ +	case 0x3001: +		return "B1 protocol not supported"; +	case 0x3002: +		return "B2 protocol not supported"; +	case 0x3003: +		return "B3 protocol not supported"; +	case 0x3004: +		return "B1 protocol parameter not supported"; +	case 0x3005: +		return "B2 protocol parameter not supported"; +	case 0x3006: +		return "B3 protocol parameter not supported"; +	case 0x3007: +		return "B protocol combination not supported"; +	case 0x3008: +		return "NCPI not supported"; +	case 0x3009: +		return "CIP Value unknown"; +	case 0x300A: +		return "Flags not supported (reserved bits)"; +	case 0x300B: +		return "Facility not supported"; +	case 0x300C: +		return "Data length not supported by current protocol"; +	case 0x300D: +		return "Reset procedure not supported by current protocol"; + +/*-- informations about the clearing of a physical connection -----*/ +	case 0x3301: +		return "Protocol error layer 1 (broken line or B-channel removed by signalling protocol)"; +	case 0x3302: +		return "Protocol error layer 2"; +	case 0x3303: +		return "Protocol error layer 3"; +	case 0x3304: +		return "Another application got that call"; +/*-- T.30 specific reasons -----*/ +	case 0x3311: +		return "Connecting not successful (remote station is no FAX G3 machine)"; +	case 0x3312: +		return "Connecting not successful (training error)"; +	case 0x3313: +		return "Disconnected before transfer (remote station does not support transfer mode, e.g. resolution)"; +	case 0x3314: +		return "Disconnected during transfer (remote abort)"; +	case 0x3315: +		return "Disconnected during transfer (remote procedure error, e.g. unsuccessful repetition of T.30 commands)"; +	case 0x3316: +		return "Disconnected during transfer (local tx data underrun)"; +	case 0x3317: +		return "Disconnected during transfer (local rx data overflow)"; +	case 0x3318: +		return "Disconnected during transfer (local abort)"; +	case 0x3319: +		return "Illegal parameter coding (e.g. SFF coding error)"; + +/*-- disconnect causes from the network according to ETS 300 102-1/Q.931 -----*/ +	case 0x3481: return "Unallocated (unassigned) number"; +	case 0x3482: return "No route to specified transit network"; +	case 0x3483: return "No route to destination"; +	case 0x3486: return "Channel unacceptable"; +	case 0x3487: +		return "Call awarded and being delivered in an established channel"; +	case 0x3490: return "Normal call clearing"; +	case 0x3491: return "User busy"; +	case 0x3492: return "No user responding"; +	case 0x3493: return "No answer from user (user alerted)"; +	case 0x3495: return "Call rejected"; +	case 0x3496: return "Number changed"; +	case 0x349A: return "Non-selected user clearing"; +	case 0x349B: return "Destination out of order"; +	case 0x349C: return "Invalid number format"; +	case 0x349D: return "Facility rejected"; +	case 0x349E: return "Response to STATUS ENQUIRY"; +	case 0x349F: return "Normal, unspecified"; +	case 0x34A2: return "No circuit / channel available"; +	case 0x34A6: return "Network out of order"; +	case 0x34A9: return "Temporary failure"; +	case 0x34AA: return "Switching equipment congestion"; +	case 0x34AB: return "Access information discarded"; +	case 0x34AC: return "Requested circuit / channel not available"; +	case 0x34AF: return "Resources unavailable, unspecified"; +	case 0x34B1: return "Quality of service unavailable"; +	case 0x34B2: return "Requested facility not subscribed"; +	case 0x34B9: return "Bearer capability not authorized"; +	case 0x34BA: return "Bearer capability not presently available"; +	case 0x34BF: return "Service or option not available, unspecified"; +	case 0x34C1: return "Bearer capability not implemented"; +	case 0x34C2: return "Channel type not implemented"; +	case 0x34C5: return "Requested facility not implemented"; +	case 0x34C6: return "Only restricted digital information bearer capability is available"; +	case 0x34CF: return "Service or option not implemented, unspecified"; +	case 0x34D1: return "Invalid call reference value"; +	case 0x34D2: return "Identified channel does not exist"; +	case 0x34D3: return "A suspended call exists, but this call identity does not"; +	case 0x34D4: return "Call identity in use"; +	case 0x34D5: return "No call suspended"; +	case 0x34D6: return "Call having the requested call identity has been cleared"; +	case 0x34D8: return "Incompatible destination"; +	case 0x34DB: return "Invalid transit network selection"; +	case 0x34DF: return "Invalid message, unspecified"; +	case 0x34E0: return "Mandatory information element is missing"; +	case 0x34E1: return "Message type non-existent or not implemented"; +	case 0x34E2: return "Message not compatible with call state or message type non-existent or not implemented"; +	case 0x34E3: return "Information element non-existent or not implemented"; +	case 0x34E4: return "Invalid information element contents"; +	case 0x34E5: return "Message not compatible with call state"; +	case 0x34E6: return "Recovery on timer expiry"; +	case 0x34EF: return "Protocol error, unspecified"; +	case 0x34FF: return "Interworking, unspecified"; + +	default: return "No additional information"; +	} +#endif +} -static void handle_controller(_cmsg * cmsg) +static void handle_controller(_cmsg *cmsg)  {  	capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f); @@ -791,54 +985,54 @@ static void handle_controller(_cmsg * cmsg)  		break;  	case CAPI_MANUFACTURER_IND:	/* Controller */ -		if (   cmsg->ManuID == 0x214D5641 +		if (cmsg->ManuID == 0x214D5641  		    && cmsg->Class == 0  		    && cmsg->Function == 1) { -		   u8  *data = cmsg->ManuData+3; -		   u16  len = cmsg->ManuData[0]; -		   u16 layer; -		   int direction; -		   if (len == 255) { -		      len = (cmsg->ManuData[1] | (cmsg->ManuData[2] << 8)); -		      data += 2; -		   } -		   len -= 2; -		   layer = ((*(data-1)) << 8) | *(data-2); -		   if (layer & 0x300) -			direction = (layer & 0x200) ? 0 : 1; -		   else direction = (layer & 0x800) ? 0 : 1; -		   if (layer & 0x0C00) { -		   	if ((layer & 0xff) == 0x80) { -		           handle_dtrace_data(card, direction, 1, data, len); -		           break; -		   	} -		   } else if ((layer & 0xff) < 0x80) { -		      handle_dtrace_data(card, direction, 0, data, len); -		      break; -		   } -	           printk(KERN_INFO "capidrv-%d: %s from controller 0x%x layer 0x%x, ignored\n", -                        card->contrnr,  -			capi_cmd2str(cmsg->Command, cmsg->Subcommand), -			cmsg->adr.adrController, layer); -                   break; +			u8  *data = cmsg->ManuData + 3; +			u16  len = cmsg->ManuData[0]; +			u16 layer; +			int direction; +			if (len == 255) { +				len = (cmsg->ManuData[1] | (cmsg->ManuData[2] << 8)); +				data += 2; +			} +			len -= 2; +			layer = ((*(data - 1)) << 8) | *(data - 2); +			if (layer & 0x300) +				direction = (layer & 0x200) ? 0 : 1; +			else direction = (layer & 0x800) ? 0 : 1; +			if (layer & 0x0C00) { +				if ((layer & 0xff) == 0x80) { +					handle_dtrace_data(card, direction, 1, data, len); +					break; +				} +			} else if ((layer & 0xff) < 0x80) { +				handle_dtrace_data(card, direction, 0, data, len); +				break; +			} +			printk(KERN_INFO "capidrv-%d: %s from controller 0x%x layer 0x%x, ignored\n", +			       card->contrnr, +			       capi_cmd2str(cmsg->Command, cmsg->Subcommand), +			       cmsg->adr.adrController, layer); +			break;  		}  		goto ignored;  	case CAPI_MANUFACTURER_CONF:	/* Controller */  		if (cmsg->ManuID == 0x214D5641) { -		   char *s = NULL; -		   switch (cmsg->Class) { -		      case 0: break; -		      case 1: s = "unknown class"; break; -		      case 2: s = "unknown function"; break; -		      default: s = "unknown error"; break; -		   } -		   if (s) -	           printk(KERN_INFO "capidrv-%d: %s from controller 0x%x function %d: %s\n", -			card->contrnr, -			capi_cmd2str(cmsg->Command, cmsg->Subcommand), -			cmsg->adr.adrController, -			cmsg->Function, s); -		   break; +			char *s = NULL; +			switch (cmsg->Class) { +			case 0: break; +			case 1: s = "unknown class"; break; +			case 2: s = "unknown function"; break; +			default: s = "unknown error"; break; +			} +			if (s) +				printk(KERN_INFO "capidrv-%d: %s from controller 0x%x function %d: %s\n", +				       card->contrnr, +				       capi_cmd2str(cmsg->Command, cmsg->Subcommand), +				       cmsg->adr.adrController, +				       cmsg->Function, s); +			break;  		}  		goto ignored;  	case CAPI_FACILITY_IND:	/* Controller/plci/ncci */ @@ -858,14 +1052,14 @@ static void handle_controller(_cmsg * cmsg)  	}  	return; -      ignored: +ignored:  	printk(KERN_INFO "capidrv-%d: %s from controller 0x%x ignored\n",  	       card->contrnr,  	       capi_cmd2str(cmsg->Command, cmsg->Subcommand),  	       cmsg->adr.adrController);  } -static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg) +static void handle_incoming_call(capidrv_contr *card, _cmsg *cmsg)  {  	capidrv_plci *plcip;  	capidrv_bchan *bchan; @@ -890,27 +1084,27 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg)  	cmd.arg = chan;  	memset(&cmd.parm.setup, 0, sizeof(cmd.parm.setup));  	strncpy(cmd.parm.setup.phone, -	        cmsg->CallingPartyNumber + 3, +		cmsg->CallingPartyNumber + 3,  		cmsg->CallingPartyNumber[0] - 2);  	strncpy(cmd.parm.setup.eazmsn, -	        cmsg->CalledPartyNumber + 2, +		cmsg->CalledPartyNumber + 2,  		cmsg->CalledPartyNumber[0] - 1);  	cmd.parm.setup.si1 = cip2si1(cmsg->CIPValue);  	cmd.parm.setup.si2 = cip2si2(cmsg->CIPValue);  	cmd.parm.setup.plan = cmsg->CallingPartyNumber[1];  	cmd.parm.setup.screen = cmsg->CallingPartyNumber[2]; -	printk(KERN_INFO "capidrv-%d: incoming call %s,%d,%d,%s\n",  -			card->contrnr, -			cmd.parm.setup.phone, -			cmd.parm.setup.si1, -			cmd.parm.setup.si2, -			cmd.parm.setup.eazmsn); +	printk(KERN_INFO "capidrv-%d: incoming call %s,%d,%d,%s\n", +	       card->contrnr, +	       cmd.parm.setup.phone, +	       cmd.parm.setup.si1, +	       cmd.parm.setup.si2, +	       cmd.parm.setup.eazmsn);  	if (cmd.parm.setup.si1 == 1 && cmd.parm.setup.si2 != 0) { -		printk(KERN_INFO "capidrv-%d: patching si2=%d to 0 for VBOX\n",  -			card->contrnr, -			cmd.parm.setup.si2); +		printk(KERN_INFO "capidrv-%d: patching si2=%d to 0 for VBOX\n", +		       card->contrnr, +		       cmd.parm.setup.si2);  		cmd.parm.setup.si2 = 0;  	} @@ -927,11 +1121,11 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg)  		plci_change_state(card, plcip, EV_PLCI_CONNECT_REJECT);  		send_message(card, cmsg);  		printk(KERN_INFO "capidrv-%d: incoming call %s,%d,%d,%s ignored\n", -			card->contrnr, -			cmd.parm.setup.phone, -			cmd.parm.setup.si1, -			cmd.parm.setup.si2, -			cmd.parm.setup.eazmsn); +		       card->contrnr, +		       cmd.parm.setup.phone, +		       cmd.parm.setup.si1, +		       cmd.parm.setup.si2, +		       cmd.parm.setup.eazmsn);  		break;  	case 1:  		/* At least one device matching this call (RING on ttyI) @@ -945,11 +1139,11 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg)  		 */  		if (plcip->state == ST_PLCI_INCOMING) {  			printk(KERN_INFO "capidrv-%d: incoming call %s,%d,%d,%s tty alerting\n", -				card->contrnr, -				cmd.parm.setup.phone, -				cmd.parm.setup.si1, -				cmd.parm.setup.si2, -				cmd.parm.setup.eazmsn); +			       card->contrnr, +			       cmd.parm.setup.phone, +			       cmd.parm.setup.si1, +			       cmd.parm.setup.si2, +			       cmd.parm.setup.eazmsn);  			capi_fill_ALERT_REQ(cmsg,  					    global.ap.applid,  					    card->msgid++, @@ -958,16 +1152,16 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg)  					    NULL,/* Keypadfacility */  					    NULL,/* Useruserdata */  					    NULL /* Facilitydataarray */ -			); +				);  			plcip->msgid = cmsg->Messagenumber;  			send_message(card, cmsg);  		} else {  			printk(KERN_INFO "capidrv-%d: incoming call %s,%d,%d,%s on netdev\n", -				card->contrnr, -				cmd.parm.setup.phone, -				cmd.parm.setup.si1, -				cmd.parm.setup.si2, -				cmd.parm.setup.eazmsn); +			       card->contrnr, +			       cmd.parm.setup.phone, +			       cmd.parm.setup.si1, +			       cmd.parm.setup.si2, +			       cmd.parm.setup.eazmsn);  		}  		break; @@ -990,7 +1184,7 @@ static void handle_incoming_call(capidrv_contr * card, _cmsg * cmsg)  	return;  } -static void handle_plci(_cmsg * cmsg) +static void handle_plci(_cmsg *cmsg)  {  	capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f);  	capidrv_plci *plcip; @@ -1008,8 +1202,8 @@ static void handle_plci(_cmsg * cmsg)  	case CAPI_DISCONNECT_IND:	/* plci */  		if (cmsg->Reason) {  			printk(KERN_INFO "capidrv-%d: %s reason 0x%x (%s) for plci 0x%x\n", -			   card->contrnr, -			   capi_cmd2str(cmsg->Command, cmsg->Subcommand), +			       card->contrnr, +			       capi_cmd2str(cmsg->Command, cmsg->Subcommand),  			       cmsg->Reason, capi_info2str(cmsg->Reason), cmsg->adr.adrPLCI);  		}  		if (!(plcip = find_plci_by_plci(card, cmsg->adr.adrPLCI))) { @@ -1027,9 +1221,9 @@ static void handle_plci(_cmsg * cmsg)  	case CAPI_DISCONNECT_CONF:	/* plci */  		if (cmsg->Info) {  			printk(KERN_INFO "capidrv-%d: %s info 0x%x (%s) for plci 0x%x\n", -			   card->contrnr, -			   capi_cmd2str(cmsg->Command, cmsg->Subcommand), -			       cmsg->Info, capi_info2str(cmsg->Info),  +			       card->contrnr, +			       capi_cmd2str(cmsg->Command, cmsg->Subcommand), +			       cmsg->Info, capi_info2str(cmsg->Info),  			       cmsg->adr.adrPLCI);  		}  		if (!(plcip = find_plci_by_plci(card, cmsg->adr.adrPLCI))) @@ -1041,9 +1235,9 @@ static void handle_plci(_cmsg * cmsg)  	case CAPI_ALERT_CONF:	/* plci */  		if (cmsg->Info) {  			printk(KERN_INFO "capidrv-%d: %s info 0x%x (%s) for plci 0x%x\n", -			   card->contrnr, -			   capi_cmd2str(cmsg->Command, cmsg->Subcommand), -			       cmsg->Info, capi_info2str(cmsg->Info),  +			       card->contrnr, +			       capi_cmd2str(cmsg->Command, cmsg->Subcommand), +			       cmsg->Info, capi_info2str(cmsg->Info),  			       cmsg->adr.adrPLCI);  		}  		break; @@ -1055,9 +1249,9 @@ static void handle_plci(_cmsg * cmsg)  	case CAPI_CONNECT_CONF:	/* plci */  		if (cmsg->Info) {  			printk(KERN_INFO "capidrv-%d: %s info 0x%x (%s) for plci 0x%x\n", -			   card->contrnr, -			   capi_cmd2str(cmsg->Command, cmsg->Subcommand), -			       cmsg->Info, capi_info2str(cmsg->Info),  +			       card->contrnr, +			       capi_cmd2str(cmsg->Command, cmsg->Subcommand), +			       cmsg->Info, capi_info2str(cmsg->Info),  			       cmsg->adr.adrPLCI);  		}  		if (!(plcip = find_plci_by_msgid(card, cmsg->Messagenumber))) @@ -1096,7 +1290,7 @@ static void handle_plci(_cmsg * cmsg)  						 card->msgid++,  						 plcip->plci,	/* adr */  						 NULL	/* NCPI */ -			); +				);  			nccip->msgid = cmsg->Messagenumber;  			plci_change_state(card, plcip,  					  EV_PLCI_CONNECT_ACTIVE_IND); @@ -1122,8 +1316,8 @@ static void handle_plci(_cmsg * cmsg)  				sprintf(cmd.parm.num, "%lu",  					(unsigned long)  					((u32) cmsg->InfoElement[1] -				  | ((u32) (cmsg->InfoElement[2]) << 8) -				 | ((u32) (cmsg->InfoElement[3]) << 16) +					 | ((u32) (cmsg->InfoElement[2]) << 8) +					 | ((u32) (cmsg->InfoElement[3]) << 16)  					 | ((u32) (cmsg->InfoElement[4]) << 24)));  				card->interface.statcallb(&cmd);  				break; @@ -1132,11 +1326,11 @@ static void handle_plci(_cmsg * cmsg)  		cdb = capi_cmsg2str(cmsg);  		if (cdb) {  			printk(KERN_WARNING "capidrv-%d: %s\n", -				card->contrnr, cdb->buf); +			       card->contrnr, cdb->buf);  			cdebbuf_free(cdb);  		} else  			printk(KERN_WARNING "capidrv-%d: CAPI_INFO_IND InfoNumber %x not handled\n", -				card->contrnr, cmsg->InfoNumber); +			       card->contrnr, cmsg->InfoNumber);  		break; @@ -1159,13 +1353,13 @@ static void handle_plci(_cmsg * cmsg)  		       cmsg->adr.adrPLCI);  	}  	return; -      ignored: +ignored:  	printk(KERN_INFO "capidrv-%d: %s for plci 0x%x ignored\n",  	       card->contrnr,  	       capi_cmd2str(cmsg->Command, cmsg->Subcommand),  	       cmsg->adr.adrPLCI);  	return; -      notfound: +notfound:  	printk(KERN_ERR "capidrv-%d: %s: plci 0x%x not found\n",  	       card->contrnr,  	       capi_cmd2str(cmsg->Command, cmsg->Subcommand), @@ -1173,7 +1367,7 @@ static void handle_plci(_cmsg * cmsg)  	return;  } -static void handle_ncci(_cmsg * cmsg) +static void handle_ncci(_cmsg *cmsg)  {  	capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f);  	capidrv_plci *plcip; @@ -1222,7 +1416,7 @@ static void handle_ncci(_cmsg * cmsg)  							  nccip->ncci,	/* adr */  							  0,	/* Reject */  							  NULL	/* NCPI */ -				); +					);  				ncci_change_state(card, nccip, EV_NCCI_CONNECT_B3_RESP);  				send_message(card, cmsg);  				break; @@ -1230,8 +1424,8 @@ static void handle_ncci(_cmsg * cmsg)  			printk(KERN_ERR "capidrv-%d: no mem for ncci, sorry\n",							card->contrnr);  		} else {  			printk(KERN_ERR "capidrv-%d: %s: plci for ncci 0x%x not found\n", -			   card->contrnr, -			   capi_cmd2str(cmsg->Command, cmsg->Subcommand), +			       card->contrnr, +			       capi_cmd2str(cmsg->Command, cmsg->Subcommand),  			       cmsg->adr.adrNCCI);  		}  		capi_fill_CONNECT_B3_RESP(cmsg, @@ -1240,7 +1434,7 @@ static void handle_ncci(_cmsg * cmsg)  					  cmsg->adr.adrNCCI,  					  2,	/* Reject */  					  NULL	/* NCPI */ -		); +			);  		send_message(card, cmsg);  		break; @@ -1254,9 +1448,9 @@ static void handle_ncci(_cmsg * cmsg)  		nccip->ncci = cmsg->adr.adrNCCI;  		if (cmsg->Info) {  			printk(KERN_INFO "capidrv-%d: %s info 0x%x (%s) for ncci 0x%x\n", -			   card->contrnr, -			   capi_cmd2str(cmsg->Command, cmsg->Subcommand), -			       cmsg->Info, capi_info2str(cmsg->Info),  +			       card->contrnr, +			       capi_cmd2str(cmsg->Command, cmsg->Subcommand), +			       cmsg->Info, capi_info2str(cmsg->Info),  			       cmsg->adr.adrNCCI);  		} @@ -1278,7 +1472,7 @@ static void handle_ncci(_cmsg * cmsg)  	case CAPI_DATA_B3_CONF:	/* ncci */  		if (cmsg->Info) {  			printk(KERN_WARNING "CAPI_DATA_B3_CONF: Info %x - %s\n", -				cmsg->Info, capi_info2str(cmsg->Info)); +			       cmsg->Info, capi_info2str(cmsg->Info));  		}  		if (!(nccip = find_ncci(card, cmsg->adr.adrNCCI)))  			goto notfound; @@ -1286,11 +1480,11 @@ static void handle_ncci(_cmsg * cmsg)  		len = capidrv_del_ack(nccip, cmsg->DataHandle);  		if (len < 0)  			break; -	        cmd.command = ISDN_STAT_BSENT; -	        cmd.driver = card->myid; -	        cmd.arg = nccip->chan; +		cmd.command = ISDN_STAT_BSENT; +		cmd.driver = card->myid; +		cmd.arg = nccip->chan;  		cmd.parm.length = len; -	        card->interface.statcallb(&cmd); +		card->interface.statcallb(&cmd);  		break;  	case CAPI_DISCONNECT_B3_IND:	/* ncci */ @@ -1309,9 +1503,9 @@ static void handle_ncci(_cmsg * cmsg)  			goto notfound;  		if (cmsg->Info) {  			printk(KERN_INFO "capidrv-%d: %s info 0x%x (%s) for ncci 0x%x\n", -			   card->contrnr, -			   capi_cmd2str(cmsg->Command, cmsg->Subcommand), -			       cmsg->Info, capi_info2str(cmsg->Info),  +			       card->contrnr, +			       capi_cmd2str(cmsg->Command, cmsg->Subcommand), +			       cmsg->Info, capi_info2str(cmsg->Info),  			       cmsg->adr.adrNCCI);  			ncci_change_state(card, nccip, EV_NCCI_DISCONNECT_B3_CONF_ERROR);  		} @@ -1340,13 +1534,13 @@ static void handle_ncci(_cmsg * cmsg)  		       cmsg->adr.adrNCCI);  	}  	return; -      ignored: +ignored:  	printk(KERN_INFO "capidrv-%d: %s for ncci 0x%x ignored\n",  	       card->contrnr,  	       capi_cmd2str(cmsg->Command, cmsg->Subcommand),  	       cmsg->adr.adrNCCI);  	return; -      notfound: +notfound:  	printk(KERN_ERR "capidrv-%d: %s: ncci 0x%x not found\n",  	       card->contrnr,  	       capi_cmd2str(cmsg->Command, cmsg->Subcommand), @@ -1354,7 +1548,7 @@ static void handle_ncci(_cmsg * cmsg)  } -static void handle_data(_cmsg * cmsg, struct sk_buff *skb) +static void handle_data(_cmsg *cmsg, struct sk_buff *skb)  {  	capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f);  	capidrv_ncci *nccip; @@ -1390,12 +1584,12 @@ static void capidrv_recv_message(struct capi20_appl *ap, struct sk_buff *skb)  		if (cdb) {  			printk(KERN_DEBUG "%s: applid=%d %s\n", __func__, -				ap->applid, cdb->buf); +			       ap->applid, cdb->buf);  			cdebbuf_free(cdb);  		} else  			printk(KERN_DEBUG "%s: applid=%d %s not traced\n", -				__func__, ap->applid, -				capi_cmd2str(s_cmsg.Command, s_cmsg.Subcommand)); +			       __func__, ap->applid, +			       capi_cmd2str(s_cmsg.Command, s_cmsg.Subcommand));  	}  	if (s_cmsg.Command == CAPI_DATA_B3  	    && s_cmsg.Subcommand == CAPI_IND) { @@ -1418,38 +1612,38 @@ static void capidrv_recv_message(struct capi20_appl *ap, struct sk_buff *skb)  /* ------------------------------------------------------------------- */ -#define PUTBYTE_TO_STATUS(card, byte) \ -	do { \ -		*(card)->q931_write++ = (byte); \ -        	if ((card)->q931_write > (card)->q931_end) \ -	  		(card)->q931_write = (card)->q931_buf; \ +#define PUTBYTE_TO_STATUS(card, byte)				\ +	do {							\ +		*(card)->q931_write++ = (byte);			\ +		if ((card)->q931_write > (card)->q931_end)	\ +			(card)->q931_write = (card)->q931_buf;	\  	} while (0)  static void handle_dtrace_data(capidrv_contr *card, -			     int send, int level2, u8 *data, u16 len) +			       int send, int level2, u8 *data, u16 len)  { -    	u8 *p, *end; -    	isdn_ctrl cmd; +	u8 *p, *end; +	isdn_ctrl cmd; -    	if (!len) { +	if (!len) {  		printk(KERN_DEBUG "capidrv-%d: avmb1_q931_data: len == %d\n", -				card->contrnr, len); +		       card->contrnr, len);  		return;  	}  	if (level2) {  		PUTBYTE_TO_STATUS(card, 'D');  		PUTBYTE_TO_STATUS(card, '2'); -        	PUTBYTE_TO_STATUS(card, send ? '>' : '<'); -        	PUTBYTE_TO_STATUS(card, ':'); +		PUTBYTE_TO_STATUS(card, send ? '>' : '<'); +		PUTBYTE_TO_STATUS(card, ':');  	} else { -        	PUTBYTE_TO_STATUS(card, 'D'); -        	PUTBYTE_TO_STATUS(card, '3'); -        	PUTBYTE_TO_STATUS(card, send ? '>' : '<'); -        	PUTBYTE_TO_STATUS(card, ':'); -    	} +		PUTBYTE_TO_STATUS(card, 'D'); +		PUTBYTE_TO_STATUS(card, '3'); +		PUTBYTE_TO_STATUS(card, send ? '>' : '<'); +		PUTBYTE_TO_STATUS(card, ':'); +	} -	for (p = data, end = data+len; p < end; p++) { +	for (p = data, end = data + len; p < end; p++) {  		PUTBYTE_TO_STATUS(card, ' ');  		PUTBYTE_TO_STATUS(card, hex_asc_hi(*p));  		PUTBYTE_TO_STATUS(card, hex_asc_lo(*p)); @@ -1458,7 +1652,7 @@ static void handle_dtrace_data(capidrv_contr *card,  	cmd.command = ISDN_STAT_STAVAIL;  	cmd.driver = card->myid; -	cmd.arg = len*3+5; +	cmd.arg = len * 3 + 5;  	card->interface.statcallb(&cmd);  } @@ -1466,17 +1660,17 @@ static void handle_dtrace_data(capidrv_contr *card,  static _cmsg cmdcmsg; -static int capidrv_ioctl(isdn_ctrl * c, capidrv_contr * card) +static int capidrv_ioctl(isdn_ctrl *c, capidrv_contr *card)  {  	switch (c->arg) {  	case 1:  		debugmode = (int)(*((unsigned int *)c->parm.num));  		printk(KERN_DEBUG "capidrv-%d: debugmode=%d\n", -				card->contrnr, debugmode); +		       card->contrnr, debugmode);  		return 0;  	default:  		printk(KERN_DEBUG "capidrv-%d: capidrv_ioctl(%ld) called ??\n", -				card->contrnr, c->arg); +		       card->contrnr, c->arg);  		return -EINVAL;  	}  	return -EINVAL; @@ -1487,9 +1681,9 @@ static int capidrv_ioctl(isdn_ctrl * c, capidrv_contr * card)   */  struct internal_bchannelinfo { -   unsigned short channelalloc; -   unsigned short operation; -   unsigned char  cmask[31]; +	unsigned short channelalloc; +	unsigned short operation; +	unsigned char  cmask[31];  };  static int decodeFVteln(char *teln, unsigned long *bmaskp, int *activep) @@ -1540,10 +1734,10 @@ static int decodeFVteln(char *teln, unsigned long *bmaskp, int *activep)  		if (digit2 <= 0 || digit2 > 30) return -4;  		if (*s == 0 || *s == ',' || *s == ' ') {  			if (digit1 > digit2) -				for (i = digit2; i <= digit1 ; i++) +				for (i = digit2; i <= digit1; i++)  					bmask |= (1 << i); -			else  -				for (i = digit1; i <= digit2 ; i++) +			else +				for (i = digit1; i <= digit2; i++)  					bmask |= (1 << i);  			digit1 = digit2 = 0;  			if (*s) s++; @@ -1556,131 +1750,131 @@ static int decodeFVteln(char *teln, unsigned long *bmaskp, int *activep)  	return 0;  } -static int FVteln2capi20(char *teln, u8 AdditionalInfo[1+2+2+31]) +static int FVteln2capi20(char *teln, u8 AdditionalInfo[1 + 2 + 2 + 31])  {  	unsigned long bmask;  	int active;  	int rc, i; -    +  	rc = decodeFVteln(teln, &bmask, &active);  	if (rc) return rc;  	/* Length */ -	AdditionalInfo[0] = 2+2+31; -        /* Channel: 3 => use channel allocation */ -        AdditionalInfo[1] = 3; AdditionalInfo[2] = 0; +	AdditionalInfo[0] = 2 + 2 + 31; +	/* Channel: 3 => use channel allocation */ +	AdditionalInfo[1] = 3; AdditionalInfo[2] = 0;  	/* Operation: 0 => DTE mode, 1 => DCE mode */ -        if (active) { -   		AdditionalInfo[3] = 0; AdditionalInfo[4] = 0; -   	} else { -   		AdditionalInfo[3] = 1; AdditionalInfo[4] = 0; +	if (active) { +		AdditionalInfo[3] = 0; AdditionalInfo[4] = 0; +	} else { +		AdditionalInfo[3] = 1; AdditionalInfo[4] = 0;  	}  	/* Channel mask array */  	AdditionalInfo[5] = 0; /* no D-Channel */ -	for (i=1; i <= 30; i++) -		AdditionalInfo[5+i] = (bmask & (1 << i)) ? 0xff : 0; +	for (i = 1; i <= 30; i++) +		AdditionalInfo[5 + i] = (bmask & (1 << i)) ? 0xff : 0;  	return 0;  } -static int capidrv_command(isdn_ctrl * c, capidrv_contr * card) +static int capidrv_command(isdn_ctrl *c, capidrv_contr *card)  {  	isdn_ctrl cmd;  	struct capidrv_bchan *bchan;  	struct capidrv_plci *plcip; -	u8 AdditionalInfo[1+2+2+31]; -        int rc, isleasedline = 0; +	u8 AdditionalInfo[1 + 2 + 2 + 31]; +	int rc, isleasedline = 0;  	if (c->command == ISDN_CMD_IOCTL)  		return capidrv_ioctl(c, card);  	switch (c->command) { -	case ISDN_CMD_DIAL:{ -			u8 calling[ISDN_MSNLEN + 3]; -			u8 called[ISDN_MSNLEN + 2]; +	case ISDN_CMD_DIAL: { +		u8 calling[ISDN_MSNLEN + 3]; +		u8 called[ISDN_MSNLEN + 2]; -			if (debugmode) -				printk(KERN_DEBUG "capidrv-%d: ISDN_CMD_DIAL(ch=%ld,\"%s,%d,%d,%s\")\n", -					card->contrnr, -					c->arg, -				        c->parm.setup.phone, -				        c->parm.setup.si1, -				        c->parm.setup.si2, -				        c->parm.setup.eazmsn); - -			bchan = &card->bchans[c->arg % card->nbchan]; - -			if (bchan->plcip) { -				printk(KERN_ERR "capidrv-%d: dail ch=%ld,\"%s,%d,%d,%s\" in use (plci=0x%x)\n", -					card->contrnr, -			        	c->arg,  -				        c->parm.setup.phone, -				        c->parm.setup.si1, -				        c->parm.setup.si2, -				        c->parm.setup.eazmsn, -				        bchan->plcip->plci); -				return 0; -			} -			bchan->si1 = c->parm.setup.si1; -			bchan->si2 = c->parm.setup.si2; - -			strncpy(bchan->num, c->parm.setup.phone, sizeof(bchan->num)); -			strncpy(bchan->mynum, c->parm.setup.eazmsn, sizeof(bchan->mynum)); -                        rc = FVteln2capi20(bchan->num, AdditionalInfo); -			isleasedline = (rc == 0); -			if (rc < 0) -				printk(KERN_ERR "capidrv-%d: WARNING: invalid leased linedefinition \"%s\"\n", card->contrnr, bchan->num); - -			if (isleasedline) { -				calling[0] = 0; -				called[0] = 0; -			        if (debugmode) -					printk(KERN_DEBUG "capidrv-%d: connecting leased line\n", card->contrnr); -			} else { -		        	calling[0] = strlen(bchan->mynum) + 2; -		        	calling[1] = 0; -		     		calling[2] = 0x80; -			   	strncpy(calling + 3, bchan->mynum, ISDN_MSNLEN); -				called[0] = strlen(bchan->num) + 1; -				called[1] = 0x80; -				strncpy(called + 2, bchan->num, ISDN_MSNLEN); -			} +		if (debugmode) +			printk(KERN_DEBUG "capidrv-%d: ISDN_CMD_DIAL(ch=%ld,\"%s,%d,%d,%s\")\n", +			       card->contrnr, +			       c->arg, +			       c->parm.setup.phone, +			       c->parm.setup.si1, +			       c->parm.setup.si2, +			       c->parm.setup.eazmsn); -			capi_fill_CONNECT_REQ(&cmdcmsg, -					      global.ap.applid, -					      card->msgid++, -					      card->contrnr,	/* adr */ -					  si2cip(bchan->si1, bchan->si2),	/* cipvalue */ -					      called,	/* CalledPartyNumber */ -					      calling,	/* CallingPartyNumber */ -					      NULL,	/* CalledPartySubaddress */ -					      NULL,	/* CallingPartySubaddress */ -					    b1prot(bchan->l2, bchan->l3),	/* B1protocol */ -					    b2prot(bchan->l2, bchan->l3),	/* B2protocol */ -					    b3prot(bchan->l2, bchan->l3),	/* B3protocol */ -					    b1config(bchan->l2, bchan->l3),	/* B1configuration */ -					      NULL,	/* B2configuration */ -					      NULL,	/* B3configuration */ -					      NULL,	/* BC */ -					      NULL,	/* LLC */ -					      NULL,	/* HLC */ -					      /* BChannelinformation */ -					      isleasedline ? AdditionalInfo : NULL, -					      NULL,	/* Keypadfacility */ -					      NULL,	/* Useruserdata */ -					      NULL	/* Facilitydataarray */ -			    ); -			if ((plcip = new_plci(card, (c->arg % card->nbchan))) == NULL) { -				cmd.command = ISDN_STAT_DHUP; -				cmd.driver = card->myid; -				cmd.arg = (c->arg % card->nbchan); -				card->interface.statcallb(&cmd); -				return -1; -			} -			plcip->msgid = cmdcmsg.Messagenumber; -			plcip->leasedline = isleasedline; -			plci_change_state(card, plcip, EV_PLCI_CONNECT_REQ); -			send_message(card, &cmdcmsg); +		bchan = &card->bchans[c->arg % card->nbchan]; + +		if (bchan->plcip) { +			printk(KERN_ERR "capidrv-%d: dail ch=%ld,\"%s,%d,%d,%s\" in use (plci=0x%x)\n", +			       card->contrnr, +			       c->arg, +			       c->parm.setup.phone, +			       c->parm.setup.si1, +			       c->parm.setup.si2, +			       c->parm.setup.eazmsn, +			       bchan->plcip->plci);  			return 0;  		} +		bchan->si1 = c->parm.setup.si1; +		bchan->si2 = c->parm.setup.si2; + +		strncpy(bchan->num, c->parm.setup.phone, sizeof(bchan->num)); +		strncpy(bchan->mynum, c->parm.setup.eazmsn, sizeof(bchan->mynum)); +		rc = FVteln2capi20(bchan->num, AdditionalInfo); +		isleasedline = (rc == 0); +		if (rc < 0) +			printk(KERN_ERR "capidrv-%d: WARNING: invalid leased linedefinition \"%s\"\n", card->contrnr, bchan->num); + +		if (isleasedline) { +			calling[0] = 0; +			called[0] = 0; +			if (debugmode) +				printk(KERN_DEBUG "capidrv-%d: connecting leased line\n", card->contrnr); +		} else { +			calling[0] = strlen(bchan->mynum) + 2; +			calling[1] = 0; +			calling[2] = 0x80; +			strncpy(calling + 3, bchan->mynum, ISDN_MSNLEN); +			called[0] = strlen(bchan->num) + 1; +			called[1] = 0x80; +			strncpy(called + 2, bchan->num, ISDN_MSNLEN); +		} + +		capi_fill_CONNECT_REQ(&cmdcmsg, +				      global.ap.applid, +				      card->msgid++, +				      card->contrnr,	/* adr */ +				      si2cip(bchan->si1, bchan->si2),	/* cipvalue */ +				      called,	/* CalledPartyNumber */ +				      calling,	/* CallingPartyNumber */ +				      NULL,	/* CalledPartySubaddress */ +				      NULL,	/* CallingPartySubaddress */ +				      b1prot(bchan->l2, bchan->l3),	/* B1protocol */ +				      b2prot(bchan->l2, bchan->l3),	/* B2protocol */ +				      b3prot(bchan->l2, bchan->l3),	/* B3protocol */ +				      b1config(bchan->l2, bchan->l3),	/* B1configuration */ +				      NULL,	/* B2configuration */ +				      NULL,	/* B3configuration */ +				      NULL,	/* BC */ +				      NULL,	/* LLC */ +				      NULL,	/* HLC */ +				      /* BChannelinformation */ +				      isleasedline ? AdditionalInfo : NULL, +				      NULL,	/* Keypadfacility */ +				      NULL,	/* Useruserdata */ +				      NULL	/* Facilitydataarray */ +			); +		if ((plcip = new_plci(card, (c->arg % card->nbchan))) == NULL) { +			cmd.command = ISDN_STAT_DHUP; +			cmd.driver = card->myid; +			cmd.arg = (c->arg % card->nbchan); +			card->interface.statcallb(&cmd); +			return -1; +		} +		plcip->msgid = cmdcmsg.Messagenumber; +		plcip->leasedline = isleasedline; +		plci_change_state(card, plcip, EV_PLCI_CONNECT_REQ); +		send_message(card, &cmdcmsg); +		return 0; +	}  	case ISDN_CMD_ACCEPTD: @@ -1708,7 +1902,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card)  				       NULL,	/* Keypadfacility */  				       NULL,	/* Useruserdata */  				       NULL	/* Facilitydataarray */ -		); +			);  		capi_cmsg2message(&cmdcmsg, cmdcmsg.buf);  		plci_change_state(card, bchan->plcip, EV_PLCI_CONNECT_RESP);  		send_message(card, &cmdcmsg); @@ -1742,7 +1936,7 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card)  						    card->msgid++,  						    bchan->nccip->ncci,  						    NULL	/* NCPI */ -			); +				);  			ncci_change_state(card, bchan->nccip, EV_NCCI_DISCONNECT_B3_REQ);  			send_message(card, &cmdcmsg);  			return 0; @@ -1761,12 +1955,12 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card)  				capi_fill_DISCONNECT_REQ(&cmdcmsg,  							 global.ap.applid,  							 card->msgid++, -						      bchan->plcip->plci, +							 bchan->plcip->plci,  							 NULL,	/* BChannelinformation */  							 NULL,	/* Keypadfacility */  							 NULL,	/* Useruserdata */  							 NULL	/* Facilitydataarray */ -				); +					);  				plci_change_state(card, bchan->plcip, EV_PLCI_DISCONNECT_REQ);  				send_message(card, &cmdcmsg);  				return 0; @@ -1778,8 +1972,8 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card)  			}  		}  		printk(KERN_ERR "capidrv-%d: chan %ld disconnect request on free channel\n", -				       card->contrnr, -				       c->arg); +		       card->contrnr, +		       c->arg);  		return -EINVAL;  /* ready */ @@ -1813,20 +2007,20 @@ static int capidrv_command(isdn_ctrl * c, capidrv_contr * card)  	case ISDN_CMD_CLREAZ:  		if (debugmode)  			printk(KERN_DEBUG "capidrv-%d: clearing EAZ on chan %ld\n", -					card->contrnr, c->arg); +			       card->contrnr, c->arg);  		bchan = &card->bchans[c->arg % card->nbchan];  		bchan->msn[0] = 0;  		return 0;  	default:  		printk(KERN_ERR "capidrv-%d: ISDN_CMD_%d, Huh?\n", -					card->contrnr, c->command); +		       card->contrnr, c->command);  		return -EINVAL;  	}  	return 0;  } -static int if_command(isdn_ctrl * c) +static int if_command(isdn_ctrl *c)  {  	capidrv_contr *card = findcontrbydriverid(c->driver); @@ -1834,8 +2028,8 @@ static int if_command(isdn_ctrl * c)  		return capidrv_command(c, card);  	printk(KERN_ERR -	     "capidrv: if_command %d called with invalid driverId %d!\n", -						c->command, c->driver); +	       "capidrv: if_command %d called with invalid driverId %d!\n", +	       c->command, c->driver);  	return -ENODEV;  } @@ -1859,7 +2053,7 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)  	}  	if (debugmode > 4)  		printk(KERN_DEBUG "capidrv-%d: sendbuf len=%d skb=%p doack=%d\n", -					card->contrnr, len, skb, doack); +		       card->contrnr, len, skb, doack);  	bchan = &card->bchans[channel % card->nbchan];  	nccip = bchan->nccip;  	if (!nccip || nccip->state != ST_NCCI_ACTIVE) { @@ -1891,10 +2085,10 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)  			      skb->len,		/* DataLength */  			      datahandle,	/* DataHandle */  			      0	/* Flags */ -	    ); +		);  	if (capidrv_add_ack(nccip, datahandle, doack ? (int)skb->len : -1) < 0) -	   return 0; +		return 0;  	capi_cmsg2message(&sendcmsg, sendcmsg.buf);  	msglen = CAPIMSG_LEN(sendcmsg.buf); @@ -1902,8 +2096,8 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)  		struct sk_buff *nskb = skb_realloc_headroom(skb, msglen);  		if (!nskb) {  			printk(KERN_ERR "capidrv-%d: if_sendbuf: no memory\n", -				card->contrnr); -		        (void)capidrv_del_ack(nccip, datahandle); +			       card->contrnr); +			(void)capidrv_del_ack(nccip, datahandle);  			return 0;  		}  		printk(KERN_DEBUG "capidrv-%d: only %d bytes headroom, need %d\n", @@ -1917,9 +2111,9 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)  		}  		if (debugmode > 3)  			printk(KERN_DEBUG "capidrv-%d: sendbuf putmsg ret(%x) - %s\n", -				card->contrnr, errcode, capi_info2str(errcode)); -	        (void)capidrv_del_ack(nccip, datahandle); -	        dev_kfree_skb(nskb); +			       card->contrnr, errcode, capi_info2str(errcode)); +		(void)capidrv_del_ack(nccip, datahandle); +		dev_kfree_skb(nskb);  		return errcode == CAPI_SENDQUEUEFULL ? 0 : -1;  	} else {  		memcpy(skb_push(skb, msglen), sendcmsg.buf, msglen); @@ -1930,9 +2124,9 @@ static int if_sendbuf(int id, int channel, int doack, struct sk_buff *skb)  		}  		if (debugmode > 3)  			printk(KERN_DEBUG "capidrv-%d: sendbuf putmsg ret(%x) - %s\n", -				card->contrnr, errcode, capi_info2str(errcode)); +			       card->contrnr, errcode, capi_info2str(errcode));  		skb_pull(skb, msglen); -	        (void)capidrv_del_ack(nccip, datahandle); +		(void)capidrv_del_ack(nccip, datahandle);  		return errcode == CAPI_SENDQUEUEFULL ? 0 : -1;  	}  } @@ -1949,11 +2143,11 @@ static int if_readstat(u8 __user *buf, int len, int id, int channel)  		return -ENODEV;  	} -	for (p=buf, count=0; count < len; p++, count++) { +	for (p = buf, count = 0; count < len; p++, count++) {  		if (put_user(*card->q931_read++, p))  			return -EFAULT; -	        if (card->q931_read > card->q931_end) -	                card->q931_read = card->q931_buf; +		if (card->q931_read > card->q931_end) +			card->q931_read = card->q931_buf;  	}  	return count; @@ -1961,35 +2155,35 @@ static int if_readstat(u8 __user *buf, int len, int id, int channel)  static void enable_dchannel_trace(capidrv_contr *card)  { -        u8 manufacturer[CAPI_MANUFACTURER_LEN]; -        capi_version version; +	u8 manufacturer[CAPI_MANUFACTURER_LEN]; +	capi_version version;  	u16 contr = card->contrnr;  	u16 errcode;  	u16 avmversion[3]; -        errcode = capi20_get_manufacturer(contr, manufacturer); -        if (errcode != CAPI_NOERROR) { -	   printk(KERN_ERR "%s: can't get manufacturer (0x%x)\n", -			card->name, errcode); -	   return; +	errcode = capi20_get_manufacturer(contr, manufacturer); +	if (errcode != CAPI_NOERROR) { +		printk(KERN_ERR "%s: can't get manufacturer (0x%x)\n", +		       card->name, errcode); +		return;  	}  	if (strstr(manufacturer, "AVM") == NULL) { -	   printk(KERN_ERR "%s: not from AVM, no d-channel trace possible (%s)\n", -			card->name, manufacturer); -	   return; +		printk(KERN_ERR "%s: not from AVM, no d-channel trace possible (%s)\n", +		       card->name, manufacturer); +		return;  	} -        errcode = capi20_get_version(contr, &version); -        if (errcode != CAPI_NOERROR) { -	   printk(KERN_ERR "%s: can't get version (0x%x)\n", -			card->name, errcode); -	   return; +	errcode = capi20_get_version(contr, &version); +	if (errcode != CAPI_NOERROR) { +		printk(KERN_ERR "%s: can't get version (0x%x)\n", +		       card->name, errcode); +		return;  	}  	avmversion[0] = (version.majormanuversion >> 4) & 0x0f;  	avmversion[1] = (version.majormanuversion << 4) & 0xf0;  	avmversion[1] |= (version.minormanuversion >> 4) & 0x0f;  	avmversion[2] |= version.minormanuversion & 0x0f; -        if (avmversion[0] > 3 || (avmversion[0] == 3 && avmversion[1] > 5)) { +	if (avmversion[0] > 3 || (avmversion[0] == 3 && avmversion[1] > 5)) {  		printk(KERN_INFO "%s: D2 trace enabled\n", card->name);  		capi_fill_MANUFACTURER_REQ(&cmdcmsg, global.ap.applid,  					   card->msgid++, @@ -2030,8 +2224,8 @@ static void listentimerfunc(unsigned long x)  	capidrv_contr *card = (capidrv_contr *)x;  	if (card->state != ST_LISTEN_NONE && card->state != ST_LISTEN_ACTIVE)  		printk(KERN_ERR "%s: controller dead ??\n", card->name); -        send_listen(card); -	mod_timer(&card->listentimer, jiffies + 60*HZ); +	send_listen(card); +	mod_timer(&card->listentimer, jiffies + 60 * HZ);  } @@ -2050,7 +2244,7 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp)  	}  	if (!(card = kzalloc(sizeof(capidrv_contr), GFP_ATOMIC))) {  		printk(KERN_WARNING -		 "capidrv: (%s) Could not allocate contr-struct.\n", id); +		       "capidrv: (%s) Could not allocate contr-struct.\n", id);  		return -1;  	}  	card->owner = THIS_MODULE; @@ -2061,7 +2255,7 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp)  	card->bchans = kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC);  	if (!card->bchans) {  		printk(KERN_WARNING -		"capidrv: (%s) Could not allocate bchan-structs.\n", id); +		       "capidrv: (%s) Could not allocate bchan-structs.\n", id);  		module_put(card->owner);  		kfree(card);  		return -1; @@ -2072,18 +2266,20 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp)  	card->interface.writebuf_skb = if_sendbuf;  	card->interface.writecmd = NULL;  	card->interface.readstat = if_readstat; -	card->interface.features = ISDN_FEATURE_L2_HDLC | -	    			   ISDN_FEATURE_L2_TRANS | -	    			   ISDN_FEATURE_L3_TRANS | -				   ISDN_FEATURE_P_UNKNOWN | -				   ISDN_FEATURE_L2_X75I | -				   ISDN_FEATURE_L2_X75UI | -				   ISDN_FEATURE_L2_X75BUI; -	if (profp->support1 & (1<<2)) -		card->interface.features |= ISDN_FEATURE_L2_V11096 | -	    				    ISDN_FEATURE_L2_V11019 | -	    				    ISDN_FEATURE_L2_V11038; -	if (profp->support1 & (1<<8)) +	card->interface.features = +		ISDN_FEATURE_L2_HDLC | +		ISDN_FEATURE_L2_TRANS | +		ISDN_FEATURE_L3_TRANS | +		ISDN_FEATURE_P_UNKNOWN | +		ISDN_FEATURE_L2_X75I | +		ISDN_FEATURE_L2_X75UI | +		ISDN_FEATURE_L2_X75BUI; +	if (profp->support1 & (1 << 2)) +		card->interface.features |= +			ISDN_FEATURE_L2_V11096 | +			ISDN_FEATURE_L2_V11019 | +			ISDN_FEATURE_L2_V11038; +	if (profp->support1 & (1 << 8))  		card->interface.features |= ISDN_FEATURE_L2_MODEM;  	card->interface.hl_hdrlen = 22; /* len of DATA_B3_REQ */  	strncpy(card->interface.id, id, sizeof(card->interface.id) - 1); @@ -2122,10 +2318,10 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp)  	card->listentimer.data = (unsigned long)card;  	card->listentimer.function = listentimerfunc;  	send_listen(card); -	mod_timer(&card->listentimer, jiffies + 60*HZ); +	mod_timer(&card->listentimer, jiffies + 60 * HZ);  	printk(KERN_INFO "%s: now up (%d B channels)\n", -		card->name, card->nbchan); +	       card->name, card->nbchan);  	enable_dchannel_trace(card); @@ -2158,7 +2354,7 @@ static int capidrv_delcontr(u16 contr)  	if (debugmode)  		printk(KERN_DEBUG "capidrv-%d: id=%d unloading\n", -					card->contrnr, card->myid); +		       card->contrnr, card->myid);  	cmd.command = ISDN_STAT_STOP;  	cmd.driver = card->myid; @@ -2168,17 +2364,17 @@ static int capidrv_delcontr(u16 contr)  		cmd.command = ISDN_STAT_DISCH;  		cmd.driver = card->myid; -		cmd.arg = card->nbchan-1; -	        cmd.parm.num[0] = 0; +		cmd.arg = card->nbchan - 1; +		cmd.parm.num[0] = 0;  		if (debugmode)  			printk(KERN_DEBUG "capidrv-%d: id=%d disable chan=%ld\n", -					card->contrnr, card->myid, cmd.arg); +			       card->contrnr, card->myid, cmd.arg);  		card->interface.statcallb(&cmd); -		if (card->bchans[card->nbchan-1].nccip) -			free_ncci(card, card->bchans[card->nbchan-1].nccip); -		if (card->bchans[card->nbchan-1].plcip) -			free_plci(card, card->bchans[card->nbchan-1].plcip); +		if (card->bchans[card->nbchan - 1].nccip) +			free_ncci(card, card->bchans[card->nbchan - 1].nccip); +		if (card->bchans[card->nbchan - 1].plcip) +			free_plci(card, card->bchans[card->nbchan - 1].plcip);  		if (card->plci_list)  			printk(KERN_ERR "capidrv: bug in free_plci()\n");  		card->nbchan--; @@ -2188,7 +2384,7 @@ static int capidrv_delcontr(u16 contr)  	if (debugmode)  		printk(KERN_DEBUG "capidrv-%d: id=%d isdn unload\n", -					card->contrnr, card->myid); +		       card->contrnr, card->myid);  	cmd.command = ISDN_STAT_UNLOAD;  	cmd.driver = card->myid; @@ -2196,7 +2392,7 @@ static int capidrv_delcontr(u16 contr)  	if (debugmode)  		printk(KERN_DEBUG "capidrv-%d: id=%d remove contr from list\n", -					card->contrnr, card->myid); +		       card->contrnr, card->myid);  	spin_lock_irqsave(&global_lock, flags);  	for (pp = &global.contr_list; *pp; pp = &(*pp)->next) { @@ -2243,10 +2439,10 @@ lower_callback(struct notifier_block *nb, unsigned long val, void *v)  static int capidrv_proc_show(struct seq_file *m, void *v)  {  	seq_printf(m, "%lu %lu %lu %lu\n", -			global.ap.nrecvctlpkt, -			global.ap.nrecvdatapkt, -			global.ap.nsentctlpkt, -			global.ap.nsentdatapkt); +		   global.ap.nrecvctlpkt, +		   global.ap.nrecvdatapkt, +		   global.ap.nsentctlpkt, +		   global.ap.nsentdatapkt);  	return 0;  } @@ -2297,6 +2493,7 @@ static int __init capidrv_init(void)  	errcode = capi20_get_profile(0, &profile);  	if (errcode != CAPI_NOERROR) { +		unregister_capictr_notifier(&capictr_nb);  		capi20_release(&global.ap);  		return -EIO;  	} diff --git a/drivers/isdn/capi/capidrv.h b/drivers/isdn/capi/capidrv.h index 1e698e1e269..4466b2e0176 100644 --- a/drivers/isdn/capi/capidrv.h +++ b/drivers/isdn/capi/capidrv.h @@ -34,7 +34,7 @@   * per plci state machine   */  #define ST_PLCI_NONE			0	/* P-0 */ -#define ST_PLCI_OUTGOING 		1	/* P-0.1 */ +#define ST_PLCI_OUTGOING		1	/* P-0.1 */  #define ST_PLCI_ALLOCATED		2	/* P-1 */  #define ST_PLCI_ACTIVE			3	/* P-ACT */  #define ST_PLCI_INCOMING		4	/* P-2 */ @@ -47,20 +47,20 @@  #define ST_PLCI_HELD			11	/* P-HELD */  #define EV_PLCI_CONNECT_REQ		1	/* P-0 -> P-0.1 -                                                 */ +						 */  #define EV_PLCI_CONNECT_CONF_ERROR	2	/* P-0.1 -> P-0 -                                                 */ +						 */  #define EV_PLCI_CONNECT_CONF_OK		3	/* P-0.1 -> P-1 -                                                 */ +						 */  #define EV_PLCI_FACILITY_IND_UP		4	/* P-0 -> P-1 -                                                 */ +						 */  #define EV_PLCI_CONNECT_IND		5	/* P-0 -> P-2 -                                                 */ +						 */  #define EV_PLCI_CONNECT_ACTIVE_IND	6	/* P-1 -> P-ACT -                                                 */ +						 */  #define EV_PLCI_CONNECT_REJECT		7	/* P-2 -> P-5  						   P-3 -> P-5 -						 */ +						*/  #define EV_PLCI_DISCONNECT_REQ		8	/* P-1 -> P-5  						   P-2 -> P-5  						   P-3 -> P-5 @@ -68,7 +68,7 @@  						   P-ACT -> P-5  						   P-Res -> P-5 (*)  						   P-HELD -> P-5 (*) -						   */ +						*/  #define EV_PLCI_DISCONNECT_IND		9	/* P-1 -> P-6  						   P-2 -> P-6  						   P-3 -> P-6 @@ -77,35 +77,35 @@  						   P-ACT -> P-6  						   P-Res -> P-6 (*)  						   P-HELD -> P-6 (*) -						   */ +						*/  #define EV_PLCI_FACILITY_IND_DOWN	10	/* P-0.1 -> P-5  						   P-1 -> P-5  						   P-ACT -> P-5  						   P-2 -> P-5  						   P-3 -> P-5  						   P-4 -> P-5 -						   */ +						*/  #define EV_PLCI_DISCONNECT_RESP		11	/* P-6 -> P-0 -                                                   */ +						 */  #define EV_PLCI_CONNECT_RESP		12	/* P-6 -> P-0 -                                                   */ +						 */  #define EV_PLCI_RESUME_REQ		13	/* P-0 -> P-0.Res -                                                 */ +						 */  #define EV_PLCI_RESUME_CONF_OK		14	/* P-0.Res -> P-Res -                                                 */ +						 */  #define EV_PLCI_RESUME_CONF_ERROR	15	/* P-0.Res -> P-0 -                                                 */ +						 */  #define EV_PLCI_RESUME_IND		16	/* P-Res -> P-ACT -                                                 */ +						 */  #define EV_PLCI_HOLD_IND		17	/* P-ACT -> P-HELD -                                                 */ +						 */  #define EV_PLCI_RETRIEVE_IND		18	/* P-HELD -> P-ACT -                                                 */ +						 */  #define EV_PLCI_SUSPEND_IND		19	/* P-ACT -> P-5 -                                                 */ +						 */  #define EV_PLCI_CD_IND			20	/* P-2 -> P-5 -                                                 */ +						 */  /*   * per ncci state machine diff --git a/drivers/isdn/capi/capifs.c b/drivers/isdn/capi/capifs.c deleted file mode 100644 index b4faed7fe0d..00000000000 --- a/drivers/isdn/capi/capifs.c +++ /dev/null @@ -1,239 +0,0 @@ -/* $Id: capifs.c,v 1.1.2.3 2004/01/16 21:09:26 keil Exp $ - *  - * Copyright 2000 by Carsten Paeth <calle@calle.de> - * - * Heavily based on devpts filesystem from H. Peter Anvin - *  - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include <linux/fs.h> -#include <linux/mount.h> -#include <linux/slab.h> -#include <linux/namei.h> -#include <linux/module.h> -#include <linux/init.h> -#include <linux/ctype.h> -#include <linux/sched.h>	/* current */ - -#include "capifs.h" - -MODULE_DESCRIPTION("CAPI4Linux: /dev/capi/ filesystem"); -MODULE_AUTHOR("Carsten Paeth"); -MODULE_LICENSE("GPL"); - -/* ------------------------------------------------------------------ */ - -#define CAPIFS_SUPER_MAGIC (('C'<<8)|'N') - -static struct vfsmount *capifs_mnt; -static int capifs_mnt_count; - -static struct { -	int setuid; -	int setgid; -	uid_t   uid; -	gid_t   gid; -	umode_t mode; -} config = {.mode = 0600}; - -/* ------------------------------------------------------------------ */ - -static int capifs_remount(struct super_block *s, int *flags, char *data) -{ -	int setuid = 0; -	int setgid = 0; -	uid_t uid = 0; -	gid_t gid = 0; -	umode_t mode = 0600; -	char *this_char; -	char *new_opt = kstrdup(data, GFP_KERNEL); - -	this_char = NULL; -	while ((this_char = strsep(&data, ",")) != NULL) { -		int n; -		char dummy; -		if (!*this_char) -			continue; -		if (sscanf(this_char, "uid=%i%c", &n, &dummy) == 1) { -			setuid = 1; -			uid = n; -		} else if (sscanf(this_char, "gid=%i%c", &n, &dummy) == 1) { -			setgid = 1; -			gid = n; -		} else if (sscanf(this_char, "mode=%o%c", &n, &dummy) == 1) -			mode = n & ~S_IFMT; -		else { -			kfree(new_opt); -			printk("capifs: called with bogus options\n"); -			return -EINVAL; -		} -	} - -	mutex_lock(&s->s_root->d_inode->i_mutex); - -	replace_mount_options(s, new_opt); -	config.setuid  = setuid; -	config.setgid  = setgid; -	config.uid     = uid; -	config.gid     = gid; -	config.mode    = mode; - -	mutex_unlock(&s->s_root->d_inode->i_mutex); - -	return 0; -} - -static const struct super_operations capifs_sops = -{ -	.statfs		= simple_statfs, -	.remount_fs	= capifs_remount, -	.show_options	= generic_show_options, -}; - - -static int -capifs_fill_super(struct super_block *s, void *data, int silent) -{ -	struct inode * inode; - -	s->s_blocksize = 1024; -	s->s_blocksize_bits = 10; -	s->s_magic = CAPIFS_SUPER_MAGIC; -	s->s_op = &capifs_sops; -	s->s_time_gran = 1; - -	inode = new_inode(s); -	if (!inode) -		goto fail; -	inode->i_ino = 1; -	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; -	inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; -	inode->i_op = &simple_dir_inode_operations; -	inode->i_fop = &simple_dir_operations; -	inode->i_nlink = 2; - -	s->s_root = d_alloc_root(inode); -	if (s->s_root) -		return 0; -	 -	printk("capifs: get root dentry failed\n"); -	iput(inode); -fail: -	return -ENOMEM; -} - -static struct dentry *capifs_mount(struct file_system_type *fs_type, -	int flags, const char *dev_name, void *data) -{ -	return mount_single(fs_type, flags, data, capifs_fill_super); -} - -static struct file_system_type capifs_fs_type = { -	.owner		= THIS_MODULE, -	.name		= "capifs", -	.mount		= capifs_mount, -	.kill_sb	= kill_anon_super, -}; - -static struct dentry *new_ncci(unsigned int number, dev_t device) -{ -	struct super_block *s = capifs_mnt->mnt_sb; -	struct dentry *root = s->s_root; -	struct dentry *dentry; -	struct inode *inode; -	char name[10]; -	int namelen; - -	mutex_lock(&root->d_inode->i_mutex); - -	namelen = sprintf(name, "%d", number); -	dentry = lookup_one_len(name, root, namelen); -	if (IS_ERR(dentry)) { -		dentry = NULL; -		goto unlock_out; -	} - -	if (dentry->d_inode) { -		dput(dentry); -		dentry = NULL; -		goto unlock_out; -	} - -	inode = new_inode(s); -	if (!inode) { -		dput(dentry); -		dentry = NULL; -		goto unlock_out; -	} - -	/* config contents is protected by root's i_mutex */ -	inode->i_uid = config.setuid ? config.uid : current_fsuid(); -	inode->i_gid = config.setgid ? config.gid : current_fsgid(); -	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; -	inode->i_ino = number + 2; -	init_special_inode(inode, S_IFCHR|config.mode, device); - -	d_instantiate(dentry, inode); -	dget(dentry); - -unlock_out: -	mutex_unlock(&root->d_inode->i_mutex); - -	return dentry; -} - -struct dentry *capifs_new_ncci(unsigned int number, dev_t device) -{ -	struct dentry *dentry; - -	if (simple_pin_fs(&capifs_fs_type, &capifs_mnt, &capifs_mnt_count) < 0) -		return NULL; - -	dentry = new_ncci(number, device); -	if (!dentry) -		simple_release_fs(&capifs_mnt, &capifs_mnt_count); - -	return dentry; -} - -void capifs_free_ncci(struct dentry *dentry) -{ -	struct dentry *root = capifs_mnt->mnt_sb->s_root; -	struct inode *inode; - -	if (!dentry) -		return; - -	mutex_lock(&root->d_inode->i_mutex); - -	inode = dentry->d_inode; -	if (inode) { -		drop_nlink(inode); -		d_delete(dentry); -		dput(dentry); -	} -	dput(dentry); - -	mutex_unlock(&root->d_inode->i_mutex); - -	simple_release_fs(&capifs_mnt, &capifs_mnt_count); -} - -static int __init capifs_init(void) -{ -	return register_filesystem(&capifs_fs_type); -} - -static void __exit capifs_exit(void) -{ -	unregister_filesystem(&capifs_fs_type); -} - -EXPORT_SYMBOL(capifs_new_ncci); -EXPORT_SYMBOL(capifs_free_ncci); - -module_init(capifs_init); -module_exit(capifs_exit); diff --git a/drivers/isdn/capi/capifs.h b/drivers/isdn/capi/capifs.h deleted file mode 100644 index e193d118953..00000000000 --- a/drivers/isdn/capi/capifs.h +++ /dev/null @@ -1,28 +0,0 @@ -/* $Id: capifs.h,v 1.1.2.2 2004/01/16 21:09:26 keil Exp $ - *  - * Copyright 2000 by Carsten Paeth <calle@calle.de> - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - */ - -#include <linux/dcache.h> - -#if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE) - -struct dentry *capifs_new_ncci(unsigned int num, dev_t device); -void capifs_free_ncci(struct dentry *dentry); - -#else - -static inline struct dentry *capifs_new_ncci(unsigned int num, dev_t device) -{ -	return NULL; -} - -static inline void capifs_free_ncci(struct dentry *dentry) -{ -} - -#endif diff --git a/drivers/isdn/capi/capilib.c b/drivers/isdn/capi/capilib.c index 0b041df2108..33361f833c0 100644 --- a/drivers/isdn/capi/capilib.c +++ b/drivers/isdn/capi/capilib.c @@ -4,9 +4,9 @@  #include <linux/module.h>  #include <linux/isdn/capilli.h> -#define DBG(format, arg...) do { \ -printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ -} while (0) +#define DBG(format, arg...) do {					\ +		printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ +	} while (0)  struct capilib_msgidqueue {  	struct capilib_msgidqueue *next; @@ -28,7 +28,7 @@ struct capilib_ncci {  // ---------------------------------------------------------------------------  // NCCI Handling -static inline void mq_init(struct capilib_ncci * np) +static inline void mq_init(struct capilib_ncci *np)  {  	u_int i;  	np->msgidqueue = NULL; @@ -42,7 +42,7 @@ static inline void mq_init(struct capilib_ncci * np)  	}  } -static inline int mq_enqueue(struct capilib_ncci * np, u16 msgid) +static inline int mq_enqueue(struct capilib_ncci *np, u16 msgid)  {  	struct capilib_msgidqueue *mq;  	if ((mq = np->msgidfree) == NULL) @@ -59,7 +59,7 @@ static inline int mq_enqueue(struct capilib_ncci * np, u16 msgid)  	return 1;  } -static inline int mq_dequeue(struct capilib_ncci * np, u16 msgid) +static inline int mq_dequeue(struct capilib_ncci *np, u16 msgid)  {  	struct capilib_msgidqueue **pp;  	for (pp = &np->msgidqueue; *pp; pp = &(*pp)->next) { @@ -165,7 +165,7 @@ u16 capilib_data_b3_req(struct list_head *head, u16 applid, u32 ncci, u16 msgid)  			continue;  		if (np->ncci != ncci)  			continue; -		 +  		if (mq_enqueue(np, msgid) == 0)  			return CAPI_SENDQUEUEFULL; @@ -188,7 +188,7 @@ void capilib_data_b3_conf(struct list_head *head, u16 applid, u32 ncci, u16 msgi  			continue;  		if (np->ncci != ncci)  			continue; -		 +  		if (mq_dequeue(np, msgid) == 0) {  			printk(KERN_ERR "kcapi: msgid %hu ncci 0x%x not on queue\n",  			       msgid, ncci); diff --git a/drivers/isdn/capi/capiutil.c b/drivers/isdn/capi/capiutil.c index 03c469e4451..6e797e502cf 100644 --- a/drivers/isdn/capi/capiutil.c +++ b/drivers/isdn/capi/capiutil.c @@ -22,205 +22,6 @@  /* from CAPI2.0 DDK AVM Berlin GmbH */ -#ifndef CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON -char *capi_info2str(u16 reason) -{ -    return ".."; -} -#else -char *capi_info2str(u16 reason) -{ -    switch (reason) { - -/*-- informative values (corresponding message was processed) -----*/ -	case 0x0001: -	   return "NCPI not supported by current protocol, NCPI ignored"; -	case 0x0002: -	   return "Flags not supported by current protocol, flags ignored"; -	case 0x0003: -	   return "Alert already sent by another application"; - -/*-- error information concerning CAPI_REGISTER -----*/ -	case 0x1001: -	   return "Too many applications"; -	case 0x1002: -	   return "Logical block size too small, must be at least 128 Bytes"; -	case 0x1003: -	   return "Buffer exceeds 64 kByte"; -	case 0x1004: -	   return "Message buffer size too small, must be at least 1024 Bytes"; -	case 0x1005: -	   return "Max. number of logical connections not supported"; -	case 0x1006: -	   return "Reserved"; -	case 0x1007: -	   return "The message could not be accepted because of an internal busy condition"; -	case 0x1008: -	   return "OS resource error (no memory ?)"; -	case 0x1009: -	   return "CAPI not installed"; -	case 0x100A: -	   return "Controller does not support external equipment"; -	case 0x100B: -	   return "Controller does only support external equipment"; - -/*-- error information concerning message exchange functions -----*/ -	case 0x1101: -	   return "Illegal application number"; -	case 0x1102: -	   return "Illegal command or subcommand or message length less than 12 bytes"; -	case 0x1103: -	   return "The message could not be accepted because of a queue full condition !! The error code does not imply that CAPI cannot receive messages directed to another controller, PLCI or NCCI"; -	case 0x1104: -	   return "Queue is empty"; -	case 0x1105: -	   return "Queue overflow, a message was lost !! This indicates a configuration error. The only recovery from this error is to perform a CAPI_RELEASE"; -	case 0x1106: -	   return "Unknown notification parameter"; -	case 0x1107: -	   return "The Message could not be accepted because of an internal busy condition"; -	case 0x1108: -	   return "OS Resource error (no memory ?)"; -	case 0x1109: -	   return "CAPI not installed"; -	case 0x110A: -	   return "Controller does not support external equipment"; -	case 0x110B: -	   return "Controller does only support external equipment"; - -/*-- error information concerning resource / coding problems -----*/ -	case 0x2001: -	   return "Message not supported in current state"; -	case 0x2002: -	   return "Illegal Controller / PLCI / NCCI"; -	case 0x2003: -	   return "Out of PLCI"; -	case 0x2004: -	   return "Out of NCCI"; -	case 0x2005: -	   return "Out of LISTEN"; -	case 0x2006: -	   return "Out of FAX resources (protocol T.30)"; -	case 0x2007: -	   return "Illegal message parameter coding"; - -/*-- error information concerning requested services  -----*/ -	case 0x3001: -	   return "B1 protocol not supported"; -	case 0x3002:  -	   return "B2 protocol not supported"; -	case 0x3003:  -	   return "B3 protocol not supported"; -	case 0x3004:  -	   return "B1 protocol parameter not supported"; -	case 0x3005:  -	   return "B2 protocol parameter not supported"; -	case 0x3006:  -	   return "B3 protocol parameter not supported"; -	case 0x3007:  -	   return "B protocol combination not supported"; -	case 0x3008:  -	   return "NCPI not supported"; -	case 0x3009:  -	   return "CIP Value unknown"; -	case 0x300A:  -	   return "Flags not supported (reserved bits)"; -	case 0x300B:  -	   return "Facility not supported"; -	case 0x300C:  -	   return "Data length not supported by current protocol"; -	case 0x300D:  -	   return "Reset procedure not supported by current protocol"; - -/*-- informations about the clearing of a physical connection -----*/ -	case 0x3301:  -	   return "Protocol error layer 1 (broken line or B-channel removed by signalling protocol)"; -	case 0x3302:  -	   return "Protocol error layer 2"; -	case 0x3303:  -	   return "Protocol error layer 3"; -	case 0x3304:  -	   return "Another application got that call"; -/*-- T.30 specific reasons -----*/ -	case 0x3311:  -	   return "Connecting not successful (remote station is no FAX G3 machine)"; -	case 0x3312:  -	   return "Connecting not successful (training error)"; -	case 0x3313:  -	   return "Disconnected before transfer (remote station does not support transfer mode, e.g. resolution)"; -	case 0x3314:  -	   return "Disconnected during transfer (remote abort)"; -	case 0x3315:  -	   return "Disconnected during transfer (remote procedure error, e.g. unsuccessful repetition of T.30 commands)"; -	case 0x3316:  -	   return "Disconnected during transfer (local tx data underrun)"; -	case 0x3317:  -	   return "Disconnected during transfer (local rx data overflow)"; -	case 0x3318:  -	   return "Disconnected during transfer (local abort)"; -	case 0x3319:  -	   return "Illegal parameter coding (e.g. SFF coding error)"; - -/*-- disconnect causes from the network according to ETS 300 102-1/Q.931 -----*/ -	case 0x3481: return "Unallocated (unassigned) number"; -	case 0x3482: return "No route to specified transit network"; -	case 0x3483: return "No route to destination"; -	case 0x3486: return "Channel unacceptable"; -	case 0x3487:  -	   return "Call awarded and being delivered in an established channel"; -	case 0x3490: return "Normal call clearing"; -	case 0x3491: return "User busy"; -	case 0x3492: return "No user responding"; -	case 0x3493: return "No answer from user (user alerted)"; -	case 0x3495: return "Call rejected"; -	case 0x3496: return "Number changed"; -	case 0x349A: return "Non-selected user clearing"; -	case 0x349B: return "Destination out of order"; -	case 0x349C: return "Invalid number format"; -	case 0x349D: return "Facility rejected"; -	case 0x349E: return "Response to STATUS ENQUIRY"; -	case 0x349F: return "Normal, unspecified"; -	case 0x34A2: return "No circuit / channel available"; -	case 0x34A6: return "Network out of order"; -	case 0x34A9: return "Temporary failure"; -	case 0x34AA: return "Switching equipment congestion"; -	case 0x34AB: return "Access information discarded"; -	case 0x34AC: return "Requested circuit / channel not available"; -	case 0x34AF: return "Resources unavailable, unspecified"; -	case 0x34B1: return "Quality of service unavailable"; -	case 0x34B2: return "Requested facility not subscribed"; -	case 0x34B9: return "Bearer capability not authorized"; -	case 0x34BA: return "Bearer capability not presently available"; -	case 0x34BF: return "Service or option not available, unspecified"; -	case 0x34C1: return "Bearer capability not implemented"; -	case 0x34C2: return "Channel type not implemented"; -	case 0x34C5: return "Requested facility not implemented"; -	case 0x34C6: return "Only restricted digital information bearer capability is available"; -	case 0x34CF: return "Service or option not implemented, unspecified"; -	case 0x34D1: return "Invalid call reference value"; -	case 0x34D2: return "Identified channel does not exist"; -	case 0x34D3: return "A suspended call exists, but this call identity does not"; -	case 0x34D4: return "Call identity in use"; -	case 0x34D5: return "No call suspended"; -	case 0x34D6: return "Call having the requested call identity has been cleared"; -	case 0x34D8: return "Incompatible destination"; -	case 0x34DB: return "Invalid transit network selection"; -	case 0x34DF: return "Invalid message, unspecified"; -	case 0x34E0: return "Mandatory information element is missing"; -	case 0x34E1: return "Message type non-existent or not implemented"; -	case 0x34E2: return "Message not compatible with call state or message type non-existent or not implemented"; -	case 0x34E3: return "Information element non-existent or not implemented"; -	case 0x34E4: return "Invalid information element contents"; -	case 0x34E5: return "Message not compatible with call state"; -	case 0x34E6: return "Recovery on timer expiry"; -	case 0x34EF: return "Protocol error, unspecified"; -	case 0x34FF: return "Interworking, unspecified"; - -	default: return "No additional information"; -    } -} -#endif -  typedef struct {  	int typ;  	size_t off; @@ -235,169 +36,169 @@ typedef struct {  static _cdef cdef[] =  { -    /*00 */  - {_CEND}, -    /*01 */  - {_CEND}, -    /*02 */  - {_CEND}, -    /*03 */  - {_CDWORD, offsetof(_cmsg, adr.adrController)}, -    /*04 */  - {_CMSTRUCT, offsetof(_cmsg, AdditionalInfo)}, -    /*05 */  - {_CSTRUCT, offsetof(_cmsg, B1configuration)}, -    /*06 */  - {_CWORD, offsetof(_cmsg, B1protocol)}, -    /*07 */  - {_CSTRUCT, offsetof(_cmsg, B2configuration)}, -    /*08 */  - {_CWORD, offsetof(_cmsg, B2protocol)}, -    /*09 */  - {_CSTRUCT, offsetof(_cmsg, B3configuration)}, -    /*0a */  - {_CWORD, offsetof(_cmsg, B3protocol)}, -    /*0b */  - {_CSTRUCT, offsetof(_cmsg, BC)}, -    /*0c */  - {_CSTRUCT, offsetof(_cmsg, BChannelinformation)}, -    /*0d */  - {_CMSTRUCT, offsetof(_cmsg, BProtocol)}, -    /*0e */  - {_CSTRUCT, offsetof(_cmsg, CalledPartyNumber)}, -    /*0f */  - {_CSTRUCT, offsetof(_cmsg, CalledPartySubaddress)}, -    /*10 */  - {_CSTRUCT, offsetof(_cmsg, CallingPartyNumber)}, -    /*11 */  - {_CSTRUCT, offsetof(_cmsg, CallingPartySubaddress)}, -    /*12 */  - {_CDWORD, offsetof(_cmsg, CIPmask)}, -    /*13 */  - {_CDWORD, offsetof(_cmsg, CIPmask2)}, -    /*14 */  - {_CWORD, offsetof(_cmsg, CIPValue)}, -    /*15 */  - {_CDWORD, offsetof(_cmsg, Class)}, -    /*16 */  - {_CSTRUCT, offsetof(_cmsg, ConnectedNumber)}, -    /*17 */  - {_CSTRUCT, offsetof(_cmsg, ConnectedSubaddress)}, -    /*18 */  - {_CDWORD, offsetof(_cmsg, Data)}, -    /*19 */  - {_CWORD, offsetof(_cmsg, DataHandle)}, -    /*1a */  - {_CWORD, offsetof(_cmsg, DataLength)}, -    /*1b */  - {_CSTRUCT, offsetof(_cmsg, FacilityConfirmationParameter)}, -    /*1c */  - {_CSTRUCT, offsetof(_cmsg, Facilitydataarray)}, -    /*1d */  - {_CSTRUCT, offsetof(_cmsg, FacilityIndicationParameter)}, -    /*1e */  - {_CSTRUCT, offsetof(_cmsg, FacilityRequestParameter)}, -    /*1f */  - {_CWORD, offsetof(_cmsg, FacilitySelector)}, -    /*20 */  - {_CWORD, offsetof(_cmsg, Flags)}, -    /*21 */  - {_CDWORD, offsetof(_cmsg, Function)}, -    /*22 */  - {_CSTRUCT, offsetof(_cmsg, HLC)}, -    /*23 */  - {_CWORD, offsetof(_cmsg, Info)}, -    /*24 */  - {_CSTRUCT, offsetof(_cmsg, InfoElement)}, -    /*25 */  - {_CDWORD, offsetof(_cmsg, InfoMask)}, -    /*26 */  - {_CWORD, offsetof(_cmsg, InfoNumber)}, -    /*27 */  - {_CSTRUCT, offsetof(_cmsg, Keypadfacility)}, -    /*28 */  - {_CSTRUCT, offsetof(_cmsg, LLC)}, -    /*29 */  - {_CSTRUCT, offsetof(_cmsg, ManuData)}, -    /*2a */  - {_CDWORD, offsetof(_cmsg, ManuID)}, -    /*2b */  - {_CSTRUCT, offsetof(_cmsg, NCPI)}, -    /*2c */  - {_CWORD, offsetof(_cmsg, Reason)}, -    /*2d */  - {_CWORD, offsetof(_cmsg, Reason_B3)}, -    /*2e */  - {_CWORD, offsetof(_cmsg, Reject)}, -    /*2f */  - {_CSTRUCT, offsetof(_cmsg, Useruserdata)} +	/*00 */ +	{_CEND}, +	/*01 */ +	{_CEND}, +	/*02 */ +	{_CEND}, +	/*03 */ +	{_CDWORD, offsetof(_cmsg, adr.adrController)}, +	/*04 */ +	{_CMSTRUCT, offsetof(_cmsg, AdditionalInfo)}, +	/*05 */ +	{_CSTRUCT, offsetof(_cmsg, B1configuration)}, +	/*06 */ +	{_CWORD, offsetof(_cmsg, B1protocol)}, +	/*07 */ +	{_CSTRUCT, offsetof(_cmsg, B2configuration)}, +	/*08 */ +	{_CWORD, offsetof(_cmsg, B2protocol)}, +	/*09 */ +	{_CSTRUCT, offsetof(_cmsg, B3configuration)}, +	/*0a */ +	{_CWORD, offsetof(_cmsg, B3protocol)}, +	/*0b */ +	{_CSTRUCT, offsetof(_cmsg, BC)}, +	/*0c */ +	{_CSTRUCT, offsetof(_cmsg, BChannelinformation)}, +	/*0d */ +	{_CMSTRUCT, offsetof(_cmsg, BProtocol)}, +	/*0e */ +	{_CSTRUCT, offsetof(_cmsg, CalledPartyNumber)}, +	/*0f */ +	{_CSTRUCT, offsetof(_cmsg, CalledPartySubaddress)}, +	/*10 */ +	{_CSTRUCT, offsetof(_cmsg, CallingPartyNumber)}, +	/*11 */ +	{_CSTRUCT, offsetof(_cmsg, CallingPartySubaddress)}, +	/*12 */ +	{_CDWORD, offsetof(_cmsg, CIPmask)}, +	/*13 */ +	{_CDWORD, offsetof(_cmsg, CIPmask2)}, +	/*14 */ +	{_CWORD, offsetof(_cmsg, CIPValue)}, +	/*15 */ +	{_CDWORD, offsetof(_cmsg, Class)}, +	/*16 */ +	{_CSTRUCT, offsetof(_cmsg, ConnectedNumber)}, +	/*17 */ +	{_CSTRUCT, offsetof(_cmsg, ConnectedSubaddress)}, +	/*18 */ +	{_CDWORD, offsetof(_cmsg, Data)}, +	/*19 */ +	{_CWORD, offsetof(_cmsg, DataHandle)}, +	/*1a */ +	{_CWORD, offsetof(_cmsg, DataLength)}, +	/*1b */ +	{_CSTRUCT, offsetof(_cmsg, FacilityConfirmationParameter)}, +	/*1c */ +	{_CSTRUCT, offsetof(_cmsg, Facilitydataarray)}, +	/*1d */ +	{_CSTRUCT, offsetof(_cmsg, FacilityIndicationParameter)}, +	/*1e */ +	{_CSTRUCT, offsetof(_cmsg, FacilityRequestParameter)}, +	/*1f */ +	{_CWORD, offsetof(_cmsg, FacilitySelector)}, +	/*20 */ +	{_CWORD, offsetof(_cmsg, Flags)}, +	/*21 */ +	{_CDWORD, offsetof(_cmsg, Function)}, +	/*22 */ +	{_CSTRUCT, offsetof(_cmsg, HLC)}, +	/*23 */ +	{_CWORD, offsetof(_cmsg, Info)}, +	/*24 */ +	{_CSTRUCT, offsetof(_cmsg, InfoElement)}, +	/*25 */ +	{_CDWORD, offsetof(_cmsg, InfoMask)}, +	/*26 */ +	{_CWORD, offsetof(_cmsg, InfoNumber)}, +	/*27 */ +	{_CSTRUCT, offsetof(_cmsg, Keypadfacility)}, +	/*28 */ +	{_CSTRUCT, offsetof(_cmsg, LLC)}, +	/*29 */ +	{_CSTRUCT, offsetof(_cmsg, ManuData)}, +	/*2a */ +	{_CDWORD, offsetof(_cmsg, ManuID)}, +	/*2b */ +	{_CSTRUCT, offsetof(_cmsg, NCPI)}, +	/*2c */ +	{_CWORD, offsetof(_cmsg, Reason)}, +	/*2d */ +	{_CWORD, offsetof(_cmsg, Reason_B3)}, +	/*2e */ +	{_CWORD, offsetof(_cmsg, Reject)}, +	/*2f */ +	{_CSTRUCT, offsetof(_cmsg, Useruserdata)}  };  static unsigned char *cpars[] =  { -    /* ALERT_REQ */ [0x01] = "\x03\x04\x0c\x27\x2f\x1c\x01\x01", -    /* CONNECT_REQ */ [0x02] = "\x03\x14\x0e\x10\x0f\x11\x0d\x06\x08\x0a\x05\x07\x09\x01\x0b\x28\x22\x04\x0c\x27\x2f\x1c\x01\x01", -    /* DISCONNECT_REQ */ [0x04] = "\x03\x04\x0c\x27\x2f\x1c\x01\x01", -    /* LISTEN_REQ */ [0x05] = "\x03\x25\x12\x13\x10\x11\x01", -    /* INFO_REQ */ [0x08] = "\x03\x0e\x04\x0c\x27\x2f\x1c\x01\x01", -    /* FACILITY_REQ */ [0x09] = "\x03\x1f\x1e\x01", -    /* SELECT_B_PROTOCOL_REQ */ [0x0a] = "\x03\x0d\x06\x08\x0a\x05\x07\x09\x01\x01", -    /* CONNECT_B3_REQ */ [0x0b] = "\x03\x2b\x01", -    /* DISCONNECT_B3_REQ */ [0x0d] = "\x03\x2b\x01", -    /* DATA_B3_REQ */ [0x0f] = "\x03\x18\x1a\x19\x20\x01", -    /* RESET_B3_REQ */ [0x10] = "\x03\x2b\x01", -    /* ALERT_CONF */ [0x13] = "\x03\x23\x01", -    /* CONNECT_CONF */ [0x14] = "\x03\x23\x01", -    /* DISCONNECT_CONF */ [0x16] = "\x03\x23\x01", -    /* LISTEN_CONF */ [0x17] = "\x03\x23\x01", -    /* MANUFACTURER_REQ */ [0x18] = "\x03\x2a\x15\x21\x29\x01", -    /* INFO_CONF */ [0x1a] = "\x03\x23\x01", -    /* FACILITY_CONF */ [0x1b] = "\x03\x23\x1f\x1b\x01", -    /* SELECT_B_PROTOCOL_CONF */ [0x1c] = "\x03\x23\x01", -    /* CONNECT_B3_CONF */ [0x1d] = "\x03\x23\x01", -    /* DISCONNECT_B3_CONF */ [0x1f] = "\x03\x23\x01", -    /* DATA_B3_CONF */ [0x21] = "\x03\x19\x23\x01", -    /* RESET_B3_CONF */ [0x22] = "\x03\x23\x01", -    /* CONNECT_IND */ [0x26] = "\x03\x14\x0e\x10\x0f\x11\x0b\x28\x22\x04\x0c\x27\x2f\x1c\x01\x01", -    /* CONNECT_ACTIVE_IND */ [0x27] = "\x03\x16\x17\x28\x01", -    /* DISCONNECT_IND */ [0x28] = "\x03\x2c\x01", -    /* MANUFACTURER_CONF */ [0x2a] = "\x03\x2a\x15\x21\x29\x01", -    /* INFO_IND */ [0x2c] = "\x03\x26\x24\x01", -    /* FACILITY_IND */ [0x2d] = "\x03\x1f\x1d\x01", -    /* CONNECT_B3_IND */ [0x2f] = "\x03\x2b\x01", -    /* CONNECT_B3_ACTIVE_IND */ [0x30] = "\x03\x2b\x01", -    /* DISCONNECT_B3_IND */ [0x31] = "\x03\x2d\x2b\x01", -    /* DATA_B3_IND */ [0x33] = "\x03\x18\x1a\x19\x20\x01", -    /* RESET_B3_IND */ [0x34] = "\x03\x2b\x01", -    /* CONNECT_B3_T90_ACTIVE_IND */ [0x35] = "\x03\x2b\x01", -    /* CONNECT_RESP */ [0x38] = "\x03\x2e\x0d\x06\x08\x0a\x05\x07\x09\x01\x16\x17\x28\x04\x0c\x27\x2f\x1c\x01\x01", -    /* CONNECT_ACTIVE_RESP */ [0x39] = "\x03\x01", -    /* DISCONNECT_RESP */ [0x3a] = "\x03\x01", -    /* MANUFACTURER_IND */ [0x3c] = "\x03\x2a\x15\x21\x29\x01", -    /* INFO_RESP */ [0x3e] = "\x03\x01", -    /* FACILITY_RESP */ [0x3f] = "\x03\x1f\x01", -    /* CONNECT_B3_RESP */ [0x41] = "\x03\x2e\x2b\x01", -    /* CONNECT_B3_ACTIVE_RESP */ [0x42] = "\x03\x01", -    /* DISCONNECT_B3_RESP */ [0x43] = "\x03\x01", -    /* DATA_B3_RESP */ [0x45] = "\x03\x19\x01", -    /* RESET_B3_RESP */ [0x46] = "\x03\x01", -    /* CONNECT_B3_T90_ACTIVE_RESP */ [0x47] = "\x03\x01", -    /* MANUFACTURER_RESP */ [0x4e] = "\x03\x2a\x15\x21\x29\x01", +	/* ALERT_REQ */ [0x01] = "\x03\x04\x0c\x27\x2f\x1c\x01\x01", +	/* CONNECT_REQ */ [0x02] = "\x03\x14\x0e\x10\x0f\x11\x0d\x06\x08\x0a\x05\x07\x09\x01\x0b\x28\x22\x04\x0c\x27\x2f\x1c\x01\x01", +	/* DISCONNECT_REQ */ [0x04] = "\x03\x04\x0c\x27\x2f\x1c\x01\x01", +	/* LISTEN_REQ */ [0x05] = "\x03\x25\x12\x13\x10\x11\x01", +	/* INFO_REQ */ [0x08] = "\x03\x0e\x04\x0c\x27\x2f\x1c\x01\x01", +	/* FACILITY_REQ */ [0x09] = "\x03\x1f\x1e\x01", +	/* SELECT_B_PROTOCOL_REQ */ [0x0a] = "\x03\x0d\x06\x08\x0a\x05\x07\x09\x01\x01", +	/* CONNECT_B3_REQ */ [0x0b] = "\x03\x2b\x01", +	/* DISCONNECT_B3_REQ */ [0x0d] = "\x03\x2b\x01", +	/* DATA_B3_REQ */ [0x0f] = "\x03\x18\x1a\x19\x20\x01", +	/* RESET_B3_REQ */ [0x10] = "\x03\x2b\x01", +	/* ALERT_CONF */ [0x13] = "\x03\x23\x01", +	/* CONNECT_CONF */ [0x14] = "\x03\x23\x01", +	/* DISCONNECT_CONF */ [0x16] = "\x03\x23\x01", +	/* LISTEN_CONF */ [0x17] = "\x03\x23\x01", +	/* MANUFACTURER_REQ */ [0x18] = "\x03\x2a\x15\x21\x29\x01", +	/* INFO_CONF */ [0x1a] = "\x03\x23\x01", +	/* FACILITY_CONF */ [0x1b] = "\x03\x23\x1f\x1b\x01", +	/* SELECT_B_PROTOCOL_CONF */ [0x1c] = "\x03\x23\x01", +	/* CONNECT_B3_CONF */ [0x1d] = "\x03\x23\x01", +	/* DISCONNECT_B3_CONF */ [0x1f] = "\x03\x23\x01", +	/* DATA_B3_CONF */ [0x21] = "\x03\x19\x23\x01", +	/* RESET_B3_CONF */ [0x22] = "\x03\x23\x01", +	/* CONNECT_IND */ [0x26] = "\x03\x14\x0e\x10\x0f\x11\x0b\x28\x22\x04\x0c\x27\x2f\x1c\x01\x01", +	/* CONNECT_ACTIVE_IND */ [0x27] = "\x03\x16\x17\x28\x01", +	/* DISCONNECT_IND */ [0x28] = "\x03\x2c\x01", +	/* MANUFACTURER_CONF */ [0x2a] = "\x03\x2a\x15\x21\x29\x01", +	/* INFO_IND */ [0x2c] = "\x03\x26\x24\x01", +	/* FACILITY_IND */ [0x2d] = "\x03\x1f\x1d\x01", +	/* CONNECT_B3_IND */ [0x2f] = "\x03\x2b\x01", +	/* CONNECT_B3_ACTIVE_IND */ [0x30] = "\x03\x2b\x01", +	/* DISCONNECT_B3_IND */ [0x31] = "\x03\x2d\x2b\x01", +	/* DATA_B3_IND */ [0x33] = "\x03\x18\x1a\x19\x20\x01", +	/* RESET_B3_IND */ [0x34] = "\x03\x2b\x01", +	/* CONNECT_B3_T90_ACTIVE_IND */ [0x35] = "\x03\x2b\x01", +	/* CONNECT_RESP */ [0x38] = "\x03\x2e\x0d\x06\x08\x0a\x05\x07\x09\x01\x16\x17\x28\x04\x0c\x27\x2f\x1c\x01\x01", +	/* CONNECT_ACTIVE_RESP */ [0x39] = "\x03\x01", +	/* DISCONNECT_RESP */ [0x3a] = "\x03\x01", +	/* MANUFACTURER_IND */ [0x3c] = "\x03\x2a\x15\x21\x29\x01", +	/* INFO_RESP */ [0x3e] = "\x03\x01", +	/* FACILITY_RESP */ [0x3f] = "\x03\x1f\x01", +	/* CONNECT_B3_RESP */ [0x41] = "\x03\x2e\x2b\x01", +	/* CONNECT_B3_ACTIVE_RESP */ [0x42] = "\x03\x01", +	/* DISCONNECT_B3_RESP */ [0x43] = "\x03\x01", +	/* DATA_B3_RESP */ [0x45] = "\x03\x19\x01", +	/* RESET_B3_RESP */ [0x46] = "\x03\x01", +	/* CONNECT_B3_T90_ACTIVE_RESP */ [0x47] = "\x03\x01", +	/* MANUFACTURER_RESP */ [0x4e] = "\x03\x2a\x15\x21\x29\x01",  };  /*-------------------------------------------------------*/ -#define byteTLcpy(x,y)        *(u8 *)(x)=*(u8 *)(y); -#define wordTLcpy(x,y)        *(u16 *)(x)=*(u16 *)(y); -#define dwordTLcpy(x,y)       memcpy(x,y,4); -#define structTLcpy(x,y,l)    memcpy (x,y,l) -#define structTLcpyovl(x,y,l) memmove (x,y,l) +#define byteTLcpy(x, y)         *(u8 *)(x) = *(u8 *)(y); +#define wordTLcpy(x, y)         *(u16 *)(x) = *(u16 *)(y); +#define dwordTLcpy(x, y)        memcpy(x, y, 4); +#define structTLcpy(x, y, l)    memcpy(x, y, l) +#define structTLcpyovl(x, y, l) memmove(x, y, l) -#define byteTRcpy(x,y)        *(u8 *)(y)=*(u8 *)(x); -#define wordTRcpy(x,y)        *(u16 *)(y)=*(u16 *)(x); -#define dwordTRcpy(x,y)       memcpy(y,x,4); -#define structTRcpy(x,y,l)    memcpy (y,x,l) -#define structTRcpyovl(x,y,l) memmove (y,x,l) +#define byteTRcpy(x, y)         *(u8 *)(y) = *(u8 *)(x); +#define wordTRcpy(x, y)         *(u16 *)(y) = *(u16 *)(x); +#define dwordTRcpy(x, y)        memcpy(y, x, 4); +#define structTRcpy(x, y, l)    memcpy(y, x, l) +#define structTRcpyovl(x, y, l) memmove(y, x, l)  /*-------------------------------------------------------*/  static unsigned command_2_index(unsigned c, unsigned sc) @@ -414,9 +215,9 @@ static unsigned command_2_index(unsigned c, unsigned sc)  /*-------------------------------------------------------*/  #define TYP (cdef[cmsg->par[cmsg->p]].typ) -#define OFF (((u8 *)cmsg)+cdef[cmsg->par[cmsg->p]].off) +#define OFF (((u8 *)cmsg) + cdef[cmsg->par[cmsg->p]].off) -static void jumpcstruct(_cmsg * cmsg) +static void jumpcstruct(_cmsg *cmsg)  {  	unsigned layer;  	for (cmsg->p++, layer = 1; layer;) { @@ -433,7 +234,7 @@ static void jumpcstruct(_cmsg * cmsg)  	}  }  /*-------------------------------------------------------*/ -static void pars_2_message(_cmsg * cmsg) +static void pars_2_message(_cmsg *cmsg)  {  	for (; TYP != _CEND; cmsg->p++) { @@ -499,7 +300,7 @@ static void pars_2_message(_cmsg * cmsg)   * Return value: 0 for success   */ -unsigned capi_cmsg2message(_cmsg * cmsg, u8 * msg) +unsigned capi_cmsg2message(_cmsg *cmsg, u8 *msg)  {  	cmsg->m = msg;  	cmsg->l = 8; @@ -518,7 +319,7 @@ unsigned capi_cmsg2message(_cmsg * cmsg, u8 * msg)  }  /*-------------------------------------------------------*/ -static void message_2_pars(_cmsg * cmsg) +static void message_2_pars(_cmsg *cmsg)  {  	for (; TYP != _CEND; cmsg->p++) { @@ -569,7 +370,7 @@ static void message_2_pars(_cmsg * cmsg)   * Return value: 0 for success   */ -unsigned capi_message2cmsg(_cmsg * cmsg, u8 * msg) +unsigned capi_message2cmsg(_cmsg *cmsg, u8 *msg)  {  	memset(cmsg, 0, sizeof(_cmsg));  	cmsg->m = msg; @@ -600,7 +401,7 @@ unsigned capi_message2cmsg(_cmsg * cmsg, u8 * msg)   * Return value: 0 for success   */ -unsigned capi_cmsg_header(_cmsg * cmsg, u16 _ApplId, +unsigned capi_cmsg_header(_cmsg *cmsg, u16 _ApplId,  			  u8 _Command, u8 _Subcommand,  			  u16 _Messagenumber, u32 _Controller)  { @@ -689,54 +490,54 @@ char *capi_cmd2str(u8 cmd, u8 subcmd)  static char *pnames[] =  { -    /*00 */ NULL, -    /*01 */ NULL, -    /*02 */ NULL, -    /*03 */ "Controller/PLCI/NCCI", -    /*04 */ "AdditionalInfo", -    /*05 */ "B1configuration", -    /*06 */ "B1protocol", -    /*07 */ "B2configuration", -    /*08 */ "B2protocol", -    /*09 */ "B3configuration", -    /*0a */ "B3protocol", -    /*0b */ "BC", -    /*0c */ "BChannelinformation", -    /*0d */ "BProtocol", -    /*0e */ "CalledPartyNumber", -    /*0f */ "CalledPartySubaddress", -    /*10 */ "CallingPartyNumber", -    /*11 */ "CallingPartySubaddress", -    /*12 */ "CIPmask", -    /*13 */ "CIPmask2", -    /*14 */ "CIPValue", -    /*15 */ "Class", -    /*16 */ "ConnectedNumber", -    /*17 */ "ConnectedSubaddress", -    /*18 */ "Data32", -    /*19 */ "DataHandle", -    /*1a */ "DataLength", -    /*1b */ "FacilityConfirmationParameter", -    /*1c */ "Facilitydataarray", -    /*1d */ "FacilityIndicationParameter", -    /*1e */ "FacilityRequestParameter", -    /*1f */ "FacilitySelector", -    /*20 */ "Flags", -    /*21 */ "Function", -    /*22 */ "HLC", -    /*23 */ "Info", -    /*24 */ "InfoElement", -    /*25 */ "InfoMask", -    /*26 */ "InfoNumber", -    /*27 */ "Keypadfacility", -    /*28 */ "LLC", -    /*29 */ "ManuData", -    /*2a */ "ManuID", -    /*2b */ "NCPI", -    /*2c */ "Reason", -    /*2d */ "Reason_B3", -    /*2e */ "Reject", -    /*2f */ "Useruserdata" +	/*00 */ NULL, +	/*01 */ NULL, +	/*02 */ NULL, +	/*03 */ "Controller/PLCI/NCCI", +	/*04 */ "AdditionalInfo", +	/*05 */ "B1configuration", +	/*06 */ "B1protocol", +	/*07 */ "B2configuration", +	/*08 */ "B2protocol", +	/*09 */ "B3configuration", +	/*0a */ "B3protocol", +	/*0b */ "BC", +	/*0c */ "BChannelinformation", +	/*0d */ "BProtocol", +	/*0e */ "CalledPartyNumber", +	/*0f */ "CalledPartySubaddress", +	/*10 */ "CallingPartyNumber", +	/*11 */ "CallingPartySubaddress", +	/*12 */ "CIPmask", +	/*13 */ "CIPmask2", +	/*14 */ "CIPValue", +	/*15 */ "Class", +	/*16 */ "ConnectedNumber", +	/*17 */ "ConnectedSubaddress", +	/*18 */ "Data32", +	/*19 */ "DataHandle", +	/*1a */ "DataLength", +	/*1b */ "FacilityConfirmationParameter", +	/*1c */ "Facilitydataarray", +	/*1d */ "FacilityIndicationParameter", +	/*1e */ "FacilityRequestParameter", +	/*1f */ "FacilitySelector", +	/*20 */ "Flags", +	/*21 */ "Function", +	/*22 */ "HLC", +	/*23 */ "Info", +	/*24 */ "InfoElement", +	/*25 */ "InfoMask", +	/*26 */ "InfoNumber", +	/*27 */ "Keypadfacility", +	/*28 */ "LLC", +	/*29 */ "ManuData", +	/*2a */ "ManuID", +	/*2b */ "NCPI", +	/*2c */ "Reason", +	/*2d */ "Reason_B3", +	/*2e */ "Reject", +	/*2f */ "Useruserdata"  }; @@ -744,10 +545,10 @@ static char *pnames[] =  #include <stdarg.h>  /*-------------------------------------------------------*/ -static _cdebbuf *bufprint(_cdebbuf *cdb, char *fmt,...) +static _cdebbuf *bufprint(_cdebbuf *cdb, char *fmt, ...)  {  	va_list f; -	size_t n,r; +	size_t n, r;  	if (!cdb)  		return NULL; @@ -783,7 +584,7 @@ static _cdebbuf *bufprint(_cdebbuf *cdb, char *fmt,...)  	return cdb;  } -static _cdebbuf *printstructlen(_cdebbuf *cdb, u8 * m, unsigned len) +static _cdebbuf *printstructlen(_cdebbuf *cdb, u8 *m, unsigned len)  {  	unsigned hex = 0; @@ -807,7 +608,7 @@ static _cdebbuf *printstructlen(_cdebbuf *cdb, u8 * m, unsigned len)  	return cdb;  } -static _cdebbuf *printstruct(_cdebbuf *cdb, u8 * m) +static _cdebbuf *printstruct(_cdebbuf *cdb, u8 *m)  {  	unsigned len; @@ -940,7 +741,7 @@ void cdebbuf_free(_cdebbuf *cdb)   * The returned buffer should be freed by a call to cdebbuf_free() after use.   */ -_cdebbuf *capi_message2str(u8 * msg) +_cdebbuf *capi_message2str(u8 *msg)  {  	_cdebbuf *cdb;  	_cmsg	*cmsg; @@ -964,10 +765,10 @@ _cdebbuf *capi_message2str(u8 * msg)  	cmsg->par = cpars[command_2_index(cmsg->Command, cmsg->Subcommand)];  	cdb = bufprint(cdb, "%-26s ID=%03d #0x%04x LEN=%04d\n", -		 mnames[command_2_index(cmsg->Command, cmsg->Subcommand)], -		 ((unsigned short *) msg)[1], -		 ((unsigned short *) msg)[3], -		 ((unsigned short *) msg)[0]); +		       mnames[command_2_index(cmsg->Command, cmsg->Subcommand)], +		       ((unsigned short *) msg)[1], +		       ((unsigned short *) msg)[3], +		       ((unsigned short *) msg)[0]);  	cdb = protocol_message_2_pars(cdb, cmsg, 1);  	if (unlikely(cmsg != g_cmsg)) @@ -986,7 +787,7 @@ _cdebbuf *capi_message2str(u8 * msg)   * The returned buffer should be freed by a call to cdebbuf_free() after use.   */ -_cdebbuf *capi_cmsg2str(_cmsg * cmsg) +_cdebbuf *capi_cmsg2str(_cmsg *cmsg)  {  	_cdebbuf *cdb; @@ -998,17 +799,17 @@ _cdebbuf *capi_cmsg2str(_cmsg * cmsg)  	cmsg->l = 8;  	cmsg->p = 0;  	cdb = bufprint(cdb, "%s ID=%03d #0x%04x LEN=%04d\n", -		 mnames[command_2_index(cmsg->Command, cmsg->Subcommand)], -		 ((u16 *) cmsg->m)[1], -		 ((u16 *) cmsg->m)[3], -		 ((u16 *) cmsg->m)[0]); +		       mnames[command_2_index(cmsg->Command, cmsg->Subcommand)], +		       ((u16 *) cmsg->m)[1], +		       ((u16 *) cmsg->m)[3], +		       ((u16 *) cmsg->m)[0]);  	cdb = protocol_message_2_pars(cdb, cmsg, 1);  	return cdb;  }  int __init cdebug_init(void)  { -	g_cmsg= kmalloc(sizeof(_cmsg), GFP_KERNEL); +	g_cmsg = kmalloc(sizeof(_cmsg), GFP_KERNEL);  	if (!g_cmsg)  		return -ENOMEM;  	g_debbuf = kmalloc(sizeof(_cdebbuf), GFP_KERNEL); @@ -1041,12 +842,12 @@ void __exit cdebug_exit(void)  static _cdebbuf g_debbuf = {"CONFIG_CAPI_TRACE not enabled", NULL, 0, 0}; -_cdebbuf *capi_message2str(u8 * msg) +_cdebbuf *capi_message2str(u8 *msg)  {  	return &g_debbuf;  } -_cdebbuf *capi_cmsg2str(_cmsg * cmsg) +_cdebbuf *capi_cmsg2str(_cmsg *cmsg)  {  	return &g_debbuf;  } @@ -1073,4 +874,3 @@ EXPORT_SYMBOL(capi_cmsg_header);  EXPORT_SYMBOL(capi_cmd2str);  EXPORT_SYMBOL(capi_cmsg2str);  EXPORT_SYMBOL(capi_message2str); -EXPORT_SYMBOL(capi_info2str); diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index 3acf94cc5ac..c123709acf8 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c @@ -1,10 +1,10 @@  /* $Id: kcapi.c,v 1.1.2.8 2004/03/26 19:57:20 armin Exp $ - *  + *   * Kernel CAPI 2.0 Module - *  + *   * Copyright 1999 by Carsten Paeth <calle@calle.de>   * Copyright 2002 by Kai Germaschewski <kai@germaschewski.name> - *  + *   * This software may be used and distributed according to the terms   * of the GNU General Public License, incorporated herein by reference.   * @@ -38,6 +38,7 @@  #include <linux/rcupdate.h>  static int showcapimsgs = 0; +static struct workqueue_struct *kcapi_wq;  MODULE_DESCRIPTION("CAPI4Linux: kernel CAPI layer");  MODULE_AUTHOR("Carsten Paeth"); @@ -54,7 +55,7 @@ struct capictr_event {  /* ------------------------------------------------------------- */ -static struct capi_version driver_version = {2, 0, 1, 1<<4}; +static struct capi_version driver_version = {2, 0, 1, 1 << 4};  static char driver_serial[CAPI_SERIAL_LEN] = "0004711";  static char capi_manufakturer[64] = "AVM Berlin"; @@ -92,7 +93,7 @@ capi_ctr_put(struct capi_ctr *ctr)  static inline struct capi_ctr *get_capi_ctr_by_nr(u16 contr)  { -	if (contr - 1 >= CAPI_MAXCONTR) +	if (contr < 1 || contr - 1 >= CAPI_MAXCONTR)  		return NULL;  	return capi_controller[contr - 1]; @@ -102,7 +103,7 @@ static inline struct capi20_appl *__get_capi_appl_by_nr(u16 applid)  {  	lockdep_assert_held(&capi_controller_lock); -	if (applid - 1 >= CAPI_MAXAPPL) +	if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)  		return NULL;  	return capi_applications[applid - 1]; @@ -110,7 +111,7 @@ static inline struct capi20_appl *__get_capi_appl_by_nr(u16 applid)  static inline struct capi20_appl *get_capi_appl_by_nr(u16 applid)  { -	if (applid - 1 >= CAPI_MAXAPPL) +	if (applid < 1 || applid - 1 >= CAPI_MAXAPPL)  		return NULL;  	return rcu_dereference(capi_applications[applid - 1]); @@ -171,7 +172,7 @@ register_appl(struct capi_ctr *ctr, u16 applid, capi_register_params *rparam)  static void release_appl(struct capi_ctr *ctr, u16 applid)  {  	DBG("applid %#x", applid); -	 +  	ctr->release_appl(ctr, applid);  	capi_ctr_put(ctr);  } @@ -185,7 +186,7 @@ static void notify_up(u32 contr)  	mutex_lock(&capi_controller_lock);  	if (showcapimsgs & 1) -	        printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr); +		printk(KERN_DEBUG "kcapi: notify up contr %d\n", contr);  	ctr = get_capi_ctr_by_nr(contr);  	if (ctr) { @@ -291,7 +292,7 @@ static int notify_push(unsigned int event_type, u32 controller)  	event->type = event_type;  	event->controller = controller; -	schedule_work(&event->work); +	queue_work(kcapi_wq, &event->work);  	return 0;  } @@ -351,16 +352,16 @@ void capi_ctr_handle_message(struct capi_ctr *ctr, u16 appl,  		cdb = capi_message2str(skb->data);  		if (cdb) {  			printk(KERN_INFO "kcapi: controller [%03d] not active, got: %s", -				ctr->cnr, cdb->buf); +			       ctr->cnr, cdb->buf);  			cdebbuf_free(cdb);  		} else  			printk(KERN_INFO "kcapi: controller [%03d] not active, cannot trace\n", -				ctr->cnr); +			       ctr->cnr);  		goto error;  	}  	cmd = CAPIMSG_COMMAND(skb->data); -        subcmd = CAPIMSG_SUBCOMMAND(skb->data); +	subcmd = CAPIMSG_SUBCOMMAND(skb->data);  	if (cmd == CAPI_DATA_B3 && subcmd == CAPI_IND) {  		ctr->nrecvdatapkt++;  		if (ctr->traceflag > 2) @@ -381,13 +382,13 @@ void capi_ctr_handle_message(struct capi_ctr *ctr, u16 appl,  			cdb = capi_message2str(skb->data);  			if (cdb) {  				printk(KERN_DEBUG "kcapi: got [%03d] %s\n", -					ctr->cnr, cdb->buf); +				       ctr->cnr, cdb->buf);  				cdebbuf_free(cdb);  			} else  				printk(KERN_DEBUG "kcapi: got [%03d] id#%d %s len=%u, cannot trace\n", -					ctr->cnr, CAPIMSG_APPID(skb->data), -					capi_cmd2str(cmd, subcmd), -					CAPIMSG_LEN(skb->data)); +				       ctr->cnr, CAPIMSG_APPID(skb->data), +				       capi_cmd2str(cmd, subcmd), +				       CAPIMSG_LEN(skb->data));  		}  	} @@ -399,16 +400,16 @@ void capi_ctr_handle_message(struct capi_ctr *ctr, u16 appl,  		cdb = capi_message2str(skb->data);  		if (cdb) {  			printk(KERN_ERR "kcapi: handle_message: applid %d state released (%s)\n", -			CAPIMSG_APPID(skb->data), cdb->buf); +			       CAPIMSG_APPID(skb->data), cdb->buf);  			cdebbuf_free(cdb);  		} else  			printk(KERN_ERR "kcapi: handle_message: applid %d state released (%s) cannot trace\n", -				CAPIMSG_APPID(skb->data), -				capi_cmd2str(cmd, subcmd)); +			       CAPIMSG_APPID(skb->data), +			       capi_cmd2str(cmd, subcmd));  		goto error;  	}  	skb_queue_tail(&ap->recv_queue, skb); -	schedule_work(&ap->recv_work); +	queue_work(kcapi_wq, &ap->recv_work);  	rcu_read_unlock();  	return; @@ -518,7 +519,7 @@ int attach_capi_ctr(struct capi_ctr *ctr)  	if (i == CAPI_MAXCONTR) {  		mutex_unlock(&capi_controller_lock);  		printk(KERN_ERR "kcapi: out of controller slots\n"); -	   	return -EBUSY; +		return -EBUSY;  	}  	capi_controller[i] = ctr; @@ -540,7 +541,7 @@ int attach_capi_ctr(struct capi_ctr *ctr)  	mutex_unlock(&capi_controller_lock);  	printk(KERN_NOTICE "kcapi: controller [%03d]: %s attached\n", -			ctr->cnr, ctr->name); +	       ctr->cnr, ctr->name);  	return 0;  } @@ -743,7 +744,7 @@ u16 capi20_release(struct capi20_appl *ap)  	mutex_unlock(&capi_controller_lock); -	flush_scheduled_work(); +	flush_workqueue(kcapi_wq);  	skb_queue_purge(&ap->recv_queue);  	if (showcapimsgs & 1) { @@ -771,7 +772,7 @@ u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb)  	u8 cmd, subcmd;  	DBG("applid %#x", ap->applid); -  +  	if (ncontrollers == 0)  		return CAPI_REGNOTINSTALLED;  	if ((ap->applid == 0) || ap->release_in_progress) @@ -793,9 +794,9 @@ u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb)  		return CAPI_SENDQUEUEFULL;  	cmd = CAPIMSG_COMMAND(skb->data); -        subcmd = CAPIMSG_SUBCOMMAND(skb->data); +	subcmd = CAPIMSG_SUBCOMMAND(skb->data); -	if (cmd == CAPI_DATA_B3 && subcmd== CAPI_REQ) { +	if (cmd == CAPI_DATA_B3 && subcmd == CAPI_REQ) {  		ctr->nsentdatapkt++;  		ap->nsentdatapkt++;  		if (ctr->traceflag > 2) @@ -818,15 +819,15 @@ u16 capi20_put_message(struct capi20_appl *ap, struct sk_buff *skb)  			_cdebbuf *cdb = capi_message2str(skb->data);  			if (cdb) {  				printk(KERN_DEBUG "kcapi: put [%03d] %s\n", -					CAPIMSG_CONTROLLER(skb->data), -					cdb->buf); +				       CAPIMSG_CONTROLLER(skb->data), +				       cdb->buf);  				cdebbuf_free(cdb);  			} else  				printk(KERN_DEBUG "kcapi: put [%03d] id#%d %s len=%u cannot trace\n", -					CAPIMSG_CONTROLLER(skb->data), -					CAPIMSG_APPID(skb->data), -					capi_cmd2str(cmd, subcmd), -					CAPIMSG_LEN(skb->data)); +				       CAPIMSG_CONTROLLER(skb->data), +				       CAPIMSG_APPID(skb->data), +				       capi_cmd2str(cmd, subcmd), +				       CAPIMSG_LEN(skb->data));  		}  	}  	return ctr->send_message(ctr, skb); @@ -1027,14 +1028,14 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)  	case AVMB1_ADDCARD:  	case AVMB1_ADDCARD_WITH_TYPE:  		if (cmd == AVMB1_ADDCARD) { -		   if ((retval = copy_from_user(&cdef, data, -					    sizeof(avmb1_carddef)))) -			   return -EFAULT; -		   cdef.cardtype = AVM_CARDTYPE_B1; +			if ((retval = copy_from_user(&cdef, data, +						     sizeof(avmb1_carddef)))) +				return -EFAULT; +			cdef.cardtype = AVM_CARDTYPE_B1;  		} else { -		   if ((retval = copy_from_user(&cdef, data, -					    sizeof(avmb1_extcarddef)))) -			   return -EFAULT; +			if ((retval = copy_from_user(&cdef, data, +						     sizeof(avmb1_extcarddef)))) +				return -EFAULT;  		}  		cparams.port = cdef.port;  		cparams.irq = cdef.irq; @@ -1042,24 +1043,24 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)  		mutex_lock(&capi_drivers_lock); -                switch (cdef.cardtype) { -			case AVM_CARDTYPE_B1: -				list_for_each(l, &capi_drivers) { -					driver = list_entry(l, struct capi_driver, list); -					if (strcmp(driver->name, "b1isa") == 0) -						break; -				} -				break; -			case AVM_CARDTYPE_T1: -				list_for_each(l, &capi_drivers) { -					driver = list_entry(l, struct capi_driver, list); -					if (strcmp(driver->name, "t1isa") == 0) -						break; -				} -				break; -			default: -				driver = NULL; -				break; +		switch (cdef.cardtype) { +		case AVM_CARDTYPE_B1: +			list_for_each(l, &capi_drivers) { +				driver = list_entry(l, struct capi_driver, list); +				if (strcmp(driver->name, "b1isa") == 0) +					break; +			} +			break; +		case AVM_CARDTYPE_T1: +			list_for_each(l, &capi_drivers) { +				driver = list_entry(l, struct capi_driver, list); +				if (strcmp(driver->name, "t1isa") == 0) +					break; +			} +			break; +		default: +			driver = NULL; +			break;  		}  		if (!driver) {  			printk(KERN_ERR "kcapi: driver not loaded.\n"); @@ -1135,7 +1136,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)  		retval = wait_on_ctr_state(ctr, CAPI_CTR_RUNNING); -load_unlock_out: +	load_unlock_out:  		mutex_unlock(&capi_controller_lock);  		return retval; @@ -1166,7 +1167,7 @@ load_unlock_out:  		retval = wait_on_ctr_state(ctr, CAPI_CTR_DETECTED); -reset_unlock_out: +	reset_unlock_out:  		mutex_unlock(&capi_controller_lock);  		return retval;  	} @@ -1234,7 +1235,7 @@ int capi20_manufacturer(unsigned int cmd, void __user *data)  		cparams.membase = cdef.membase;  		cparams.cardnr = cdef.cardnr;  		cparams.cardtype = 0; -		cdef.driver[sizeof(cdef.driver)-1] = 0; +		cdef.driver[sizeof(cdef.driver) - 1] = 0;  		mutex_lock(&capi_drivers_lock); @@ -1245,7 +1246,7 @@ int capi20_manufacturer(unsigned int cmd, void __user *data)  		}  		if (driver == NULL) {  			printk(KERN_ERR "kcapi: driver \"%s\" not loaded.\n", -					cdef.driver); +			       cdef.driver);  			retval = -ESRCH;  		} else if (!driver->add_card) {  			printk(KERN_ERR "kcapi: driver \"%s\" has no add card function.\n", cdef.driver); @@ -1259,7 +1260,7 @@ int capi20_manufacturer(unsigned int cmd, void __user *data)  	default:  		printk(KERN_ERR "kcapi: manufacturer command %d unknown.\n", -					cmd); +		       cmd);  		break;  	} @@ -1285,21 +1286,30 @@ static int __init kcapi_init(void)  {  	int err; +	kcapi_wq = alloc_workqueue("kcapi", 0, 0); +	if (!kcapi_wq) +		return -ENOMEM; +  	register_capictr_notifier(&capictr_nb);  	err = cdebug_init(); -	if (!err) -		kcapi_proc_init(); -	return err; +	if (err) { +		unregister_capictr_notifier(&capictr_nb); +		destroy_workqueue(kcapi_wq); +		return err; +	} + +	kcapi_proc_init(); +	return 0;  }  static void __exit kcapi_exit(void)  { -        kcapi_proc_exit(); +	kcapi_proc_exit(); -	/* make sure all notifiers are finished */ -	flush_scheduled_work(); +	unregister_capictr_notifier(&capictr_nb);  	cdebug_exit(); +	destroy_workqueue(kcapi_wq);  }  module_init(kcapi_init); diff --git a/drivers/isdn/capi/kcapi.h b/drivers/isdn/capi/kcapi.h index f4620b38ec5..6d439f9a76b 100644 --- a/drivers/isdn/capi/kcapi.h +++ b/drivers/isdn/capi/kcapi.h @@ -1,9 +1,9 @@  /*   * Kernel CAPI 2.0 Module - *  + *   * Copyright 1999 by Carsten Paeth <calle@calle.de>   * Copyright 2002 by Kai Germaschewski <kai@germaschewski.name> - *  + *   * This software may be used and distributed according to the terms   * of the GNU General Public License, incorporated herein by reference.   * @@ -16,9 +16,9 @@  #include <linux/isdn/capilli.h>  #ifdef KCAPI_DEBUG -#define DBG(format, arg...) do { \ -printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ -} while (0) +#define DBG(format, arg...) do {					\ +		printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \ +	} while (0)  #else  #define DBG(format, arg...) /* */  #endif @@ -49,4 +49,3 @@ static inline void kcapi_proc_init(void) { };  static inline void kcapi_proc_exit(void) { };  #endif - diff --git a/drivers/isdn/capi/kcapi_proc.c b/drivers/isdn/capi/kcapi_proc.c index ea2dff602e4..68db3c5a106 100644 --- a/drivers/isdn/capi/kcapi_proc.c +++ b/drivers/isdn/capi/kcapi_proc.c @@ -1,9 +1,9 @@  /*   * Kernel CAPI 2.0 Module - /proc/capi handling - *  + *   * Copyright 1999 by Carsten Paeth <calle@calle.de>   * Copyright 2002 by Kai Germaschewski <kai@germaschewski.name> - *  + *   * This software may be used and distributed according to the terms   * of the GNU General Public License, incorporated herein by reference.   * @@ -14,6 +14,7 @@  #include <linux/proc_fs.h>  #include <linux/seq_file.h>  #include <linux/init.h> +#include <linux/export.h>  static char *state2str(unsigned short state)  { @@ -28,7 +29,7 @@ static char *state2str(unsigned short state)  // /proc/capi  // =========================================================================== -// /proc/capi/controller:  +// /proc/capi/controller:  //      cnr driver cardstate name driverinfo  // /proc/capi/contrstats:  //      cnr nrecvctlpkt nrecvdatapkt nsentctlpkt nsentdatapkt @@ -84,7 +85,7 @@ static int contrstats_show(struct seq_file *seq, void *v)  		return 0;  	seq_printf(seq, "%d %lu %lu %lu %lu\n", -		   ctr->cnr,  +		   ctr->cnr,  		   ctr->nrecvctlpkt,  		   ctr->nrecvdatapkt,  		   ctr->nsentctlpkt, @@ -133,9 +134,9 @@ static const struct file_operations proc_contrstats_ops = {  	.release	= seq_release,  }; -// /proc/capi/applications:  +// /proc/capi/applications:  //      applid l3cnt dblkcnt dblklen #ncci recvqueuelen -// /proc/capi/applstats:  +// /proc/capi/applstats:  //      applid nrecvctlpkt nrecvdatapkt nsentctlpkt nsentdatapkt  // --------------------------------------------------------------------------- @@ -296,7 +297,7 @@ static const struct file_operations proc_driver_ops = {  // --------------------------------------------------------------------------- -void __init  +void __init  kcapi_proc_init(void)  {  	proc_mkdir("capi",             NULL);  | 
