瀏覽代碼

mISDN cleanup user interface

The channelmap should have the same size on 32 and 64 bit systems
and should not depend on endianess.
Thanks to David Woodhouse for spotting this.

Signed-off-by: Karsten Keil <kkeil@suse.de>
Karsten Keil 17 年之前
父節點
當前提交
ff4cc1de24

+ 3 - 3
drivers/isdn/hardware/mISDN/hfcmulti.c

@@ -3971,7 +3971,7 @@ open_bchannel(struct hfc_multi *hc, struct dchannel *dch,
 	struct bchannel	*bch;
 	struct bchannel	*bch;
 	int		ch;
 	int		ch;
 
 
-	if (!test_bit(rq->adr.channel, &dch->dev.channelmap[0]))
+	if (!test_channelmap(rq->adr.channel, dch->dev.channelmap))
 		return -EINVAL;
 		return -EINVAL;
 	if (rq->protocol == ISDN_P_NONE)
 	if (rq->protocol == ISDN_P_NONE)
 		return -EINVAL;
 		return -EINVAL;
@@ -4587,7 +4587,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
 		list_add(&bch->ch.list, &dch->dev.bchannels);
 		list_add(&bch->ch.list, &dch->dev.bchannels);
 		hc->chan[ch].bch = bch;
 		hc->chan[ch].bch = bch;
 		hc->chan[ch].port = 0;
 		hc->chan[ch].port = 0;
-		test_and_set_bit(bch->nr, &dch->dev.channelmap[0]);
+		set_channelmap(bch->nr, dch->dev.channelmap);
 	}
 	}
 	/* set optical line type */
 	/* set optical line type */
 	if (port[Port_cnt] & 0x001) {
 	if (port[Port_cnt] & 0x001) {
@@ -4755,7 +4755,7 @@ init_multi_port(struct hfc_multi *hc, int pt)
 		list_add(&bch->ch.list, &dch->dev.bchannels);
 		list_add(&bch->ch.list, &dch->dev.bchannels);
 		hc->chan[i + ch].bch = bch;
 		hc->chan[i + ch].bch = bch;
 		hc->chan[i + ch].port = pt;
 		hc->chan[i + ch].port = pt;
-		test_and_set_bit(bch->nr, &dch->dev.channelmap[0]);
+		set_channelmap(bch->nr, dch->dev.channelmap);
 	}
 	}
 	/* set master clock */
 	/* set master clock */
 	if (port[Port_cnt] & 0x001) {
 	if (port[Port_cnt] & 0x001) {

+ 1 - 1
drivers/isdn/hardware/mISDN/hfcpci.c

@@ -2056,7 +2056,7 @@ setup_card(struct hfc_pci *card)
 	card->dch.dev.nrbchan = 2;
 	card->dch.dev.nrbchan = 2;
 	for (i = 0; i < 2; i++) {
 	for (i = 0; i < 2; i++) {
 		card->bch[i].nr = i + 1;
 		card->bch[i].nr = i + 1;
-		test_and_set_bit(i + 1, &card->dch.dev.channelmap[0]);
+		set_channelmap(i + 1, card->dch.dev.channelmap);
 		card->bch[i].debug = debug;
 		card->bch[i].debug = debug;
 		mISDN_initbchannel(&card->bch[i], MAX_DATA_MEM);
 		mISDN_initbchannel(&card->bch[i], MAX_DATA_MEM);
 		card->bch[i].hw = card;
 		card->bch[i].hw = card;

+ 2 - 4
drivers/isdn/mISDN/l1oip_core.c

@@ -1006,8 +1006,7 @@ open_bchannel(struct l1oip *hc, struct dchannel *dch, struct channel_req *rq)
 	struct bchannel	*bch;
 	struct bchannel	*bch;
 	int		ch;
 	int		ch;
 
 
-	if (!test_bit(rq->adr.channel & 0x1f,
-		&dch->dev.channelmap[rq->adr.channel >> 5]))
+	if (!test_channelmap(rq->adr.channel, dch->dev.channelmap))
 		return -EINVAL;
 		return -EINVAL;
 	if (rq->protocol == ISDN_P_NONE)
 	if (rq->protocol == ISDN_P_NONE)
 		return -EINVAL;
 		return -EINVAL;
@@ -1412,8 +1411,7 @@ init_card(struct l1oip *hc, int pri, int bundle)
 		bch->ch.nr = i + ch;
 		bch->ch.nr = i + ch;
 		list_add(&bch->ch.list, &dch->dev.bchannels);
 		list_add(&bch->ch.list, &dch->dev.bchannels);
 		hc->chan[i + ch].bch = bch;
 		hc->chan[i + ch].bch = bch;
-		test_and_set_bit(bch->nr & 0x1f,
-			&dch->dev.channelmap[bch->nr >> 5]);
+		set_channelmap(bch->nr, dch->dev.channelmap);
 	}
 	}
 	ret = mISDN_register_device(&dch->dev, hc->name);
 	ret = mISDN_register_device(&dch->dev, hc->name);
 	if (ret)
 	if (ret)

+ 2 - 2
drivers/isdn/mISDN/socket.c

@@ -379,7 +379,7 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 			di.Bprotocols = dev->Bprotocols | get_all_Bprotocols();
 			di.Bprotocols = dev->Bprotocols | get_all_Bprotocols();
 			di.protocol = dev->D.protocol;
 			di.protocol = dev->D.protocol;
 			memcpy(di.channelmap, dev->channelmap,
 			memcpy(di.channelmap, dev->channelmap,
-				MISDN_CHMAP_SIZE * 4);
+				sizeof(di.channelmap));
 			di.nrbchan = dev->nrbchan;
 			di.nrbchan = dev->nrbchan;
 			strcpy(di.name, dev->name);
 			strcpy(di.name, dev->name);
 			if (copy_to_user((void __user *)arg, &di, sizeof(di)))
 			if (copy_to_user((void __user *)arg, &di, sizeof(di)))
@@ -637,7 +637,7 @@ base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 			di.Bprotocols = dev->Bprotocols | get_all_Bprotocols();
 			di.Bprotocols = dev->Bprotocols | get_all_Bprotocols();
 			di.protocol = dev->D.protocol;
 			di.protocol = dev->D.protocol;
 			memcpy(di.channelmap, dev->channelmap,
 			memcpy(di.channelmap, dev->channelmap,
-				MISDN_CHMAP_SIZE * 4);
+				sizeof(di.channelmap));
 			di.nrbchan = dev->nrbchan;
 			di.nrbchan = dev->nrbchan;
 			strcpy(di.name, dev->name);
 			strcpy(di.name, dev->name);
 			if (copy_to_user((void __user *)arg, &di, sizeof(di)))
 			if (copy_to_user((void __user *)arg, &di, sizeof(di)))

+ 27 - 5
include/linux/mISDNif.h

@@ -37,7 +37,7 @@
  */
  */
 #define	MISDN_MAJOR_VERSION	1
 #define	MISDN_MAJOR_VERSION	1
 #define	MISDN_MINOR_VERSION	0
 #define	MISDN_MINOR_VERSION	0
-#define MISDN_RELEASE		18
+#define MISDN_RELEASE		19
 
 
 /* primitives for information exchange
 /* primitives for information exchange
  * generell format
  * generell format
@@ -242,7 +242,8 @@ struct mISDNhead {
 #define TEI_SAPI		63
 #define TEI_SAPI		63
 #define CTRL_SAPI		0
 #define CTRL_SAPI		0
 
 
-#define MISDN_CHMAP_SIZE	4
+#define MISDN_MAX_CHANNEL	127
+#define MISDN_CHMAP_SIZE	((MISDN_MAX_CHANNEL + 1) >> 3)
 
 
 #define SOL_MISDN	0
 #define SOL_MISDN	0
 
 
@@ -275,11 +276,32 @@ struct mISDN_devinfo {
 	u_int			Dprotocols;
 	u_int			Dprotocols;
 	u_int			Bprotocols;
 	u_int			Bprotocols;
 	u_int			protocol;
 	u_int			protocol;
-	u_long			channelmap[MISDN_CHMAP_SIZE];
+	u_char			channelmap[MISDN_CHMAP_SIZE];
 	u_int			nrbchan;
 	u_int			nrbchan;
 	char			name[MISDN_MAX_IDLEN];
 	char			name[MISDN_MAX_IDLEN];
 };
 };
 
 
+static inline int
+test_channelmap(u_int nr, u_char *map)
+{
+	if (nr <= MISDN_MAX_CHANNEL)
+		return map[nr >> 3] & (1 << (nr & 7));
+	else
+		return 0;
+}
+
+static inline void
+set_channelmap(u_int nr, u_char *map)
+{
+	map[nr >> 3] |= (1 << (nr & 7));
+}
+
+static inline void
+clear_channelmap(u_int nr, u_char *map)
+{
+	map[nr >> 3] &= ~(1 << (nr & 7));
+}
+
 /* CONTROL_CHANNEL parameters */
 /* CONTROL_CHANNEL parameters */
 #define MISDN_CTRL_GETOP		0x0000
 #define MISDN_CTRL_GETOP		0x0000
 #define MISDN_CTRL_LOOP			0x0001
 #define MISDN_CTRL_LOOP			0x0001
@@ -405,7 +427,7 @@ struct mISDNdevice {
 	u_int			Dprotocols;
 	u_int			Dprotocols;
 	u_int			Bprotocols;
 	u_int			Bprotocols;
 	u_int			nrbchan;
 	u_int			nrbchan;
-	u_long			channelmap[MISDN_CHMAP_SIZE];
+	u_char			channelmap[MISDN_CHMAP_SIZE];
 	struct list_head	bchannels;
 	struct list_head	bchannels;
 	struct mISDNchannel	*teimgr;
 	struct mISDNchannel	*teimgr;
 	struct device		dev;
 	struct device		dev;
@@ -430,7 +452,7 @@ struct mISDNstack {
 #endif
 #endif
 };
 };
 
 
-/* global alloc/queue dunctions */
+/* global alloc/queue functions */
 
 
 static inline struct sk_buff *
 static inline struct sk_buff *
 mI_alloc_skb(unsigned int len, gfp_t gfp_mask)
 mI_alloc_skb(unsigned int len, gfp_t gfp_mask)