All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/telephony/phonedev.c (brings this code up to date with Quicknet CVS)
@ 2001-05-13  0:41 David Ford
  2001-05-13 16:25 ` Alan Cox
  0 siblings, 1 reply; 4+ messages in thread
From: David Ford @ 2001-05-13  0:41 UTC (permalink / raw)
  To: Alan Cox, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 326 bytes --]

phonedev.diff is against 2.4.4 and brings the file phonedev.c up to date 
with respect to the Quicknet CVS.  Changes are very minor, mostly #if 
LINUX_VERSION_CODE matching and structure updates.  Small off by one 
fixes and file operation semantics updates.

There is no impact to other files or functions functions.

David


[-- Attachment #2: phonedev.diff --]
[-- Type: text/plain, Size: 4753 bytes --]

--- drivers/telephony/phonedev.c	Tue Sep 19 08:31:53 2000
+++ /zip/code/VoIP/ixj/phonedev.c	Sat May 12 17:32:05 2001
@@ -12,8 +12,14 @@
  *
  * Fixes:       Mar 01 2000 Thomas Sparr, <thomas.l.sparr@telia.com>
  *              phone_register_device now works with unit!=PHONE_UNIT_ANY
+ *
+ *              May 12 2001 David Ford, <david@blue-labs.org>
+ *              brought kernel version up to date with CVS, minor changes
  */
 
+#if LINUX_VERSION_CODE < 0x020400
+#include <linux/config.h>
+#endif
 #include <linux/version.h>
 #include <linux/module.h>
 #include <linux/types.h>
@@ -23,13 +29,16 @@
 #include <linux/string.h>
 #include <linux/errno.h>
 #include <linux/phonedev.h>
+#if LINUX_VERSION_CODE >= 0x020400
 #include <linux/init.h>
+#endif
 #include <asm/uaccess.h>
 #include <asm/system.h>
 
 #include <linux/kmod.h>
+#if LINUX_VERSION_CODE >= 0x020400
 #include <linux/sem.h>
-
+#endif
 
 #define PHONE_NUM_DEVICES	256
 
@@ -38,8 +47,9 @@
  */
 
 static struct phone_device *phone_device[PHONE_NUM_DEVICES];
+#if LINUX_VERSION_CODE >= 0x020400
 static DECLARE_MUTEX(phone_lock);
-
+#endif
 /*
  *    Open a phone device.
  */
@@ -49,26 +59,48 @@
 	unsigned int minor = MINOR(inode->i_rdev);
 	int err = 0;
 	struct phone_device *p;
+#if LINUX_VERSION_CODE >= 0x020400
 	struct file_operations *old_fops, *new_fops = NULL;
-
+#endif
 	if (minor >= PHONE_NUM_DEVICES)
 		return -ENODEV;
 
+#if LINUX_VERSION_CODE >= 0x020400
 	down(&phone_lock);
+#endif
 	p = phone_device[minor];
+#if LINUX_VERSION_CODE < 0x020400
+	if (p == NULL) {
+#else
 	if (p)
 		new_fops = fops_get(p->f_op);
 	if (!new_fops) {
+#endif
 		char modname[32];
 
+#if LINUX_VERSION_CODE >= 0x020400
 		up(&phone_lock);
+#endif
 		sprintf(modname, "char-major-%d-%d", PHONE_MAJOR, minor);
 		request_module(modname);
+#if LINUX_VERSION_CODE >= 0x020400
 		down(&phone_lock);
+#endif
 		p = phone_device[minor];
-		if (p == NULL || (new_fops = fops_get(p->f_op)) == NULL)
-		{
-			err=-ENODEV;
+#if LINUX_VERSION_CODE < 0x020400
+		if (p == NULL)
+			return -ENODEV;
+	}
+	if (p->open) {
+		err = p->open(p, file);	/* Tell the device it is open */
+		if (err)
+			return err;
+	}
+	file->f_op = p->f_op;
+	return 0;
+#else
+		if (p == NULL || (new_fops = fops_get(p->f_op)) == NULL) {
+			err = -ENODEV;
 			goto end;
 		}
 	}
@@ -81,9 +113,10 @@
 		file->f_op = fops_get(old_fops);
 	}
 	fops_put(old_fops);
-end:
+      end:
 	up(&phone_lock);
 	return err;
+#endif
 }
 
 /*
@@ -101,20 +134,25 @@
 
 	if (unit != PHONE_UNIT_ANY) {
 		base = unit;
-		end = unit + 1;  /* enter the loop at least one time */
+		end = unit;
 	}
-	
+#if LINUX_VERSION_CODE >= 0x020400
 	down(&phone_lock);
+#endif
 	for (i = base; i < end; i++) {
 		if (phone_device[i] == NULL) {
 			phone_device[i] = p;
 			p->minor = i;
 			MOD_INC_USE_COUNT;
+#if LINUX_VERSION_CODE >= 0x020400
 			up(&phone_lock);
+#endif
 			return 0;
 		}
 	}
+#if LINUX_VERSION_CODE >= 0x020400
 	up(&phone_lock);
+#endif
 	return -ENFILE;
 }
 
@@ -124,48 +162,90 @@
 
 void phone_unregister_device(struct phone_device *pfd)
 {
+#if LINUX_VERSION_CODE >= 0x020400
 	down(&phone_lock);
+#endif
 	if (phone_device[pfd->minor] != pfd)
 		panic("phone: bad unregister");
 	phone_device[pfd->minor] = NULL;
+#if LINUX_VERSION_CODE >= 0x020400
 	up(&phone_lock);
+#endif
 	MOD_DEC_USE_COUNT;
 }
 
 
-static struct file_operations phone_fops =
-{
-	owner:		THIS_MODULE,
-	open:		phone_open,
+static struct file_operations phone_fops = {
+#if LINUX_VERSION_CODE >= 0x020400
+	owner:THIS_MODULE,
+	open:phone_open,
+#else
+	NULL,
+	NULL,
+	NULL,
+	NULL,			/* readdir */
+	NULL,
+	NULL,
+	NULL,
+	phone_open,
+	NULL,			/* flush */
+	NULL
+#endif
 };
 
 /*
- *	Board init functions
+ *    Board init functions
  */
- 
+
+#if LINUX_VERSION_CODE < 0x020400
+extern int ixj_init(void);
 
 /*
  *    Initialise Telephony for linux
  */
 
+int telephony_init(void)
+#else
 static int __init telephony_init(void)
+#endif
 {
 	printk(KERN_INFO "Linux telephony interface: v1.00\n");
 	if (register_chrdev(PHONE_MAJOR, "telephony", &phone_fops)) {
 		printk("phonedev: unable to get major %d\n", PHONE_MAJOR);
 		return -EIO;
 	}
-
+#if LINUX_VERSION_CODE < 0x020400
+	/*
+	 *    Init kernel installed drivers
+	 */
+#ifdef CONFIG_PHONE_IXJ
+	ixj_init();
+#endif
+#endif
 	return 0;
 }
 
+#ifdef MODULE
+#if LINUX_VERSION_CODE < 0x020400
+int init_module(void)
+{
+	return telephony_init();
+}
+
+void cleanup_module(void)
+#else
 static void __exit telephony_exit(void)
+#endif
 {
 	unregister_chrdev(PHONE_MAJOR, "telephony");
 }
 
+#endif
+
+#if LINUX_VERSION_CODE >= 0x020400
 module_init(telephony_init);
 module_exit(telephony_exit);
+#endif
 
 EXPORT_SYMBOL(phone_register_device);
 EXPORT_SYMBOL(phone_unregister_device);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-05-13 18:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-13  0:41 [PATCH] drivers/telephony/phonedev.c (brings this code up to date with Quicknet CVS) David Ford
2001-05-13 16:25 ` Alan Cox
2001-05-13 17:14   ` David Ford
2001-05-13 18:37     ` Alan Cox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.