Skip to contentSkip to conversation

linux-2.5.2-pre8/drivers/telephony kdev_t compilation fixes

PATCH Adam J. Richter 1 participant 1 message Jan 5, 2002

lore
Share & tools
lore
#0 lore raw

Here is a patch to make linux-2.5.2-pre8/drivers/telephony
compile. It changes some MINOR() calls to minor(). gcc-3.0.2 also identified two places that could produce undefined behavior under the C standard, so I fixed those too.

I only know that this code compiles. I don't know that it
works.

Signature · 4 lines
Adam J. Richter     __     ______________   4880 Stevens Creek Blvd, Suite 104
[email protected]     \ /                  San Jose, California 95129-1034
+1 408 261-6630         | g g d r a s i l   United States of America
fax +1 408 261-6631      "Free Software For The Rest Of Us."
drivers/telephony/ixj.c +14 -10
diff -u -r linux-2.5.2-pre8/drivers/telephony/ixj.c linux/drivers/telephony/ixj.c
@@ -274,8 +274,8 @@
 
 #include "ixj.h"
 
-#define TYPE(dev) (MINOR(dev) >> 4)
-#define NUM(dev) (MINOR(dev) & 0xf)
+#define TYPE(dev) (minor(dev) >> 4)
+#define NUM(dev) (minor(dev) & 0xf)
 
 static int ixjdebug;
 static int hertz = HZ;
@@ -2805,8 +2835,10 @@
 		0xD6, 0xD6, 0xD7, 0xD7, 0xD4, 0xD4, 0xD5, 0xD5
 	};
 
-	while (len--)
-		*buff++ = table_ulaw2alaw[*(unsigned char *)buff];
+	while (len--) {
+		*buff = table_ulaw2alaw[*(unsigned char *)buff];
+		buff++;
+	}
 }
 
 static void alaw2ulaw(unsigned char *buff, unsigned long len)
@@ -2847,8 +2879,10 @@
 		0xCF, 0xCF, 0xCE, 0xCE, 0xD2, 0xD3, 0xD0, 0xD1
 	};
 
-        while (len--)
-                *buff++ = table_alaw2ulaw[*(unsigned char *)buff];
+        while (len--) {
+                *buff = table_alaw2ulaw[*(unsigned char *)buff];
+		buff++;
+	}
 }
 
 static ssize_t ixj_read(struct file * file_p, char *buf, size_t length, loff_t * ppos)
@@ -6202,7 +6236,7 @@
 	IXJ_FILTER_RAW jfr;
 
 	unsigned int raise, mant;
-	unsigned int minor = MINOR(inode->i_rdev);
+	unsigned int index = minor(inode->i_rdev);
 	int board = NUM(inode->i_rdev);
 
 	IXJ *j = get_ixj(NUM(inode->i_rdev));
@@ -6218,8 +6252,8 @@
 		schedule_timeout(1);
 	}
 	if (ixjdebug & 0x0040)
-		printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
-	if (minor >= IXJMAX) {
+		printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", index, cmd, arg);
+	if (index >= IXJMAX) {
 		clear_bit(board, &j->busyflags);
 		return -ENODEV;
 	}
@@ -6746,7 +6780,7 @@
 		break;
 	}
 	if (ixjdebug & 0x0040)
-		printk("phone%d ioctl end, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
+		printk("phone%d ioctl end, cmd: 0x%x, arg: 0x%lx\n", index, cmd, arg);
 	clear_bit(board, &j->busyflags);
 	return retval;
 }
drivers/telephony/phonedev.c +5 -5
diff -u -r linux-2.5.2-pre8/drivers/telephony/phonedev.c linux/drivers/telephony/phonedev.c
@@ -46,26 +46,26 @@
 
 static int phone_open(struct inode *inode, struct file *file)
 {
-	unsigned int minor = MINOR(inode->i_rdev);
+	unsigned int index = minor(inode->i_rdev);
 	int err = 0;
 	struct phone_device *p;
 	struct file_operations *old_fops, *new_fops = NULL;
 
-	if (minor >= PHONE_NUM_DEVICES)
+	if (index >= PHONE_NUM_DEVICES)
 		return -ENODEV;
 
 	down(&phone_lock);
-	p = phone_device[minor];
+	p = phone_device[index];
 	if (p)
 		new_fops = fops_get(p->f_op);
 	if (!new_fops) {
 		char modname[32];
 
 		up(&phone_lock);
-		sprintf(modname, "char-major-%d-%d", PHONE_MAJOR, minor);
+		sprintf(modname, "char-major-%d-%d", PHONE_MAJOR, index);
 		request_module(modname);
 		down(&phone_lock);
-		p = phone_device[minor];
+		p = phone_device[index];
 		if (p == NULL || (new_fops = fops_get(p->f_op)) == NULL)
 		{
 			err=-ENODEV;