| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 1996  SpellCaster Telecommunications Inc. | 
 | 3 |  * | 
 | 4 |  * This software may be used and distributed according to the terms | 
 | 5 |  * of the GNU General Public License, incorporated herein by reference. | 
 | 6 |  * | 
 | 7 |  */ | 
 | 8 |  | 
 | 9 | #include "includes.h" | 
 | 10 | #include "hardware.h" | 
 | 11 | #include "message.h" | 
 | 12 | #include "card.h" | 
 | 13 | #include "scioc.h" | 
 | 14 |  | 
| Adrian Bunk | e3ca5e7 | 2005-06-25 14:58:34 -0700 | [diff] [blame] | 15 | static int GetStatus(int card, boardInfo *); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 |  | 
 | 17 | /* | 
 | 18 |  * Process private IOCTL messages (typically from scctrl) | 
 | 19 |  */ | 
 | 20 | int sc_ioctl(int card, scs_ioctl *data) | 
 | 21 | { | 
 | 22 | 	int		status; | 
 | 23 | 	RspMessage	*rcvmsg; | 
 | 24 | 	char		*spid; | 
 | 25 | 	char		*dn; | 
 | 26 | 	char		switchtype; | 
 | 27 | 	char		speed; | 
 | 28 |  | 
 | 29 | 	rcvmsg = kmalloc(sizeof(RspMessage), GFP_KERNEL); | 
 | 30 | 	if (!rcvmsg) | 
 | 31 | 		return -ENOMEM; | 
 | 32 |  | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 33 | 	switch (data->command) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | 	case SCIOCRESET:	/* Perform a hard reset of the adapter */ | 
 | 35 | 	{ | 
 | 36 | 		pr_debug("%s: SCIOCRESET: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 37 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | 		sc_adapter[card]->StartOnReset = 0; | 
| Jesper Juhl | d32af0f | 2006-03-31 02:30:57 -0800 | [diff] [blame] | 39 | 		kfree(rcvmsg); | 
 | 40 | 		return reset(card); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | 	} | 
 | 42 |  | 
 | 43 | 	case SCIOCLOAD: | 
 | 44 | 	{ | 
 | 45 | 		char *srec; | 
 | 46 |  | 
 | 47 | 		srec = kmalloc(SCIOC_SRECSIZE, GFP_KERNEL); | 
 | 48 | 		if (!srec) { | 
 | 49 | 			kfree(rcvmsg); | 
 | 50 | 			return -ENOMEM; | 
 | 51 | 		} | 
 | 52 | 		pr_debug("%s: SCIOLOAD: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 53 | 			 sc_adapter[card]->devicename); | 
 | 54 | 		if (sc_adapter[card]->EngineUp) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | 			pr_debug("%s: SCIOCLOAD: command failed, LoadProc while engine running.\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 56 | 				 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | 			kfree(rcvmsg); | 
 | 58 | 			kfree(srec); | 
 | 59 | 			return -1; | 
 | 60 | 		} | 
 | 61 |  | 
 | 62 | 		/* | 
 | 63 | 		 * Get the SRec from user space | 
 | 64 | 		 */ | 
| Domen Puncer | abffa7d | 2006-02-03 03:04:14 -0800 | [diff] [blame] | 65 | 		if (copy_from_user(srec, data->dataptr, SCIOC_SRECSIZE)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | 			kfree(rcvmsg); | 
 | 67 | 			kfree(srec); | 
 | 68 | 			return -EFAULT; | 
 | 69 | 		} | 
 | 70 |  | 
 | 71 | 		status = send_and_receive(card, CMPID, cmReqType2, cmReqClass0, cmReqLoadProc, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 72 | 					  0, SCIOC_SRECSIZE, srec, rcvmsg, SAR_TIMEOUT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | 		kfree(rcvmsg); | 
 | 74 | 		kfree(srec); | 
 | 75 |  | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 76 | 		if (status) { | 
 | 77 | 			pr_debug("%s: SCIOCLOAD: command failed, status = %d\n", | 
 | 78 | 				 sc_adapter[card]->devicename, status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | 			return -1; | 
 | 80 | 		} | 
 | 81 | 		else { | 
 | 82 | 			pr_debug("%s: SCIOCLOAD: command successful\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 83 | 				 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | 			return 0; | 
 | 85 | 		} | 
 | 86 | 	} | 
 | 87 |  | 
 | 88 | 	case SCIOCSTART: | 
 | 89 | 	{ | 
| Jesper Juhl | 94a6735 | 2006-06-23 02:05:27 -0700 | [diff] [blame] | 90 | 		kfree(rcvmsg); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | 		pr_debug("%s: SCIOSTART: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 92 | 			 sc_adapter[card]->devicename); | 
 | 93 | 		if (sc_adapter[card]->EngineUp) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | 			pr_debug("%s: SCIOCSTART: command failed, engine already running.\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 95 | 				 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | 			return -1; | 
 | 97 | 		} | 
 | 98 |  | 
 | 99 | 		sc_adapter[card]->StartOnReset = 1; | 
 | 100 | 		startproc(card); | 
 | 101 | 		return 0; | 
 | 102 | 	} | 
 | 103 |  | 
 | 104 | 	case SCIOCSETSWITCH: | 
 | 105 | 	{ | 
 | 106 | 		pr_debug("%s: SCIOSETSWITCH: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 107 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 |  | 
 | 109 | 		/* | 
 | 110 | 		 * Get the switch type from user space | 
 | 111 | 		 */ | 
 | 112 | 		if (copy_from_user(&switchtype, data->dataptr, sizeof(char))) { | 
 | 113 | 			kfree(rcvmsg); | 
 | 114 | 			return -EFAULT; | 
 | 115 | 		} | 
 | 116 |  | 
 | 117 | 		pr_debug("%s: SCIOCSETSWITCH: setting switch type to %d\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 118 | 			 sc_adapter[card]->devicename, | 
 | 119 | 			 switchtype); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | 		status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallSetSwitchType, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 121 | 					  0, sizeof(char), &switchtype, rcvmsg, SAR_TIMEOUT); | 
 | 122 | 		if (!status && !(rcvmsg->rsp_status)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | 			pr_debug("%s: SCIOCSETSWITCH: command successful\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 124 | 				 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | 			kfree(rcvmsg); | 
 | 126 | 			return 0; | 
 | 127 | 		} | 
 | 128 | 		else { | 
 | 129 | 			pr_debug("%s: SCIOCSETSWITCH: command failed (status = %d)\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 130 | 				 sc_adapter[card]->devicename, status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | 			kfree(rcvmsg); | 
 | 132 | 			return status; | 
 | 133 | 		} | 
 | 134 | 	} | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 135 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | 	case SCIOCGETSWITCH: | 
 | 137 | 	{ | 
 | 138 | 		pr_debug("%s: SCIOGETSWITCH: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 139 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 |  | 
 | 141 | 		/* | 
 | 142 | 		 * Get the switch type from the board | 
 | 143 | 		 */ | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 144 | 		status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, | 
 | 145 | 					  ceReqCallGetSwitchType, 0, 0, NULL, rcvmsg, SAR_TIMEOUT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | 		if (!status && !(rcvmsg->rsp_status)) { | 
 | 147 | 			pr_debug("%s: SCIOCGETSWITCH: command successful\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 148 | 				 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | 		} | 
 | 150 | 		else { | 
 | 151 | 			pr_debug("%s: SCIOCGETSWITCH: command failed (status = %d)\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 152 | 				 sc_adapter[card]->devicename, status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | 			kfree(rcvmsg); | 
 | 154 | 			return status; | 
 | 155 | 		} | 
 | 156 |  | 
 | 157 | 		switchtype = rcvmsg->msg_data.byte_array[0]; | 
 | 158 |  | 
 | 159 | 		/* | 
 | 160 | 		 * Package the switch type and send to user space | 
 | 161 | 		 */ | 
 | 162 | 		if (copy_to_user(data->dataptr, &switchtype, | 
 | 163 | 				 sizeof(char))) { | 
 | 164 | 			kfree(rcvmsg); | 
 | 165 | 			return -EFAULT; | 
 | 166 | 		} | 
 | 167 |  | 
 | 168 | 		kfree(rcvmsg); | 
 | 169 | 		return 0; | 
 | 170 | 	} | 
 | 171 |  | 
 | 172 | 	case SCIOCGETSPID: | 
 | 173 | 	{ | 
 | 174 | 		pr_debug("%s: SCIOGETSPID: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 175 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 |  | 
| Dan Carpenter | 4b030d4 | 2010-08-04 23:38:06 +0000 | [diff] [blame] | 177 | 		spid = kzalloc(SCIOC_SPIDSIZE, GFP_KERNEL); | 
| Jesper Juhl | d32af0f | 2006-03-31 02:30:57 -0800 | [diff] [blame] | 178 | 		if (!spid) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | 			kfree(rcvmsg); | 
 | 180 | 			return -ENOMEM; | 
 | 181 | 		} | 
 | 182 | 		/* | 
 | 183 | 		 * Get the spid from the board | 
 | 184 | 		 */ | 
 | 185 | 		status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetSPID, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 186 | 					  data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | 		if (!status) { | 
 | 188 | 			pr_debug("%s: SCIOCGETSPID: command successful\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 189 | 				 sc_adapter[card]->devicename); | 
| Jesper Juhl | d32af0f | 2006-03-31 02:30:57 -0800 | [diff] [blame] | 190 | 		} else { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | 			pr_debug("%s: SCIOCGETSPID: command failed (status = %d)\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 192 | 				 sc_adapter[card]->devicename, status); | 
| Jesper Juhl | d32af0f | 2006-03-31 02:30:57 -0800 | [diff] [blame] | 193 | 			kfree(spid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | 			kfree(rcvmsg); | 
 | 195 | 			return status; | 
 | 196 | 		} | 
| Dan Carpenter | 4b030d4 | 2010-08-04 23:38:06 +0000 | [diff] [blame] | 197 | 		strlcpy(spid, rcvmsg->msg_data.byte_array, SCIOC_SPIDSIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 |  | 
 | 199 | 		/* | 
 | 200 | 		 * Package the switch type and send to user space | 
 | 201 | 		 */ | 
 | 202 | 		if (copy_to_user(data->dataptr, spid, SCIOC_SPIDSIZE)) { | 
 | 203 | 			kfree(spid); | 
 | 204 | 			kfree(rcvmsg); | 
 | 205 | 			return -EFAULT; | 
 | 206 | 		} | 
 | 207 |  | 
 | 208 | 		kfree(spid); | 
 | 209 | 		kfree(rcvmsg); | 
 | 210 | 		return 0; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 211 | 	} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 |  | 
 | 213 | 	case SCIOCSETSPID: | 
 | 214 | 	{ | 
 | 215 | 		pr_debug("%s: DCBIOSETSPID: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 216 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | 		/* | 
 | 219 | 		 * Get the spid from user space | 
 | 220 | 		 */ | 
| Julia Lawall | 024cb8a | 2010-05-21 22:26:42 +0000 | [diff] [blame] | 221 | 		spid = memdup_user(data->dataptr, SCIOC_SPIDSIZE); | 
 | 222 | 		if (IS_ERR(spid)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | 			kfree(rcvmsg); | 
| Julia Lawall | 024cb8a | 2010-05-21 22:26:42 +0000 | [diff] [blame] | 224 | 			return PTR_ERR(spid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | 		} | 
 | 226 |  | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 227 | 		pr_debug("%s: SCIOCSETSPID: setting channel %d spid to %s\n", | 
 | 228 | 			 sc_adapter[card]->devicename, data->channel, spid); | 
 | 229 | 		status = send_and_receive(card, CEPID, ceReqTypeCall, | 
 | 230 | 					  ceReqClass0, ceReqCallSetSPID, data->channel, | 
 | 231 | 					  strlen(spid), spid, rcvmsg, SAR_TIMEOUT); | 
 | 232 | 		if (!status && !(rcvmsg->rsp_status)) { | 
 | 233 | 			pr_debug("%s: SCIOCSETSPID: command successful\n", | 
 | 234 | 				 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | 			kfree(rcvmsg); | 
 | 236 | 			kfree(spid); | 
 | 237 | 			return 0; | 
 | 238 | 		} | 
 | 239 | 		else { | 
 | 240 | 			pr_debug("%s: SCIOCSETSPID: command failed (status = %d)\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 241 | 				 sc_adapter[card]->devicename, status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | 			kfree(rcvmsg); | 
 | 243 | 			kfree(spid); | 
 | 244 | 			return status; | 
 | 245 | 		} | 
 | 246 | 	} | 
 | 247 |  | 
 | 248 | 	case SCIOCGETDN: | 
 | 249 | 	{ | 
 | 250 | 		pr_debug("%s: SCIOGETDN: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 251 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 |  | 
 | 253 | 		/* | 
 | 254 | 		 * Get the dn from the board | 
 | 255 | 		 */ | 
 | 256 | 		status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 257 | 					  data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | 		if (!status) { | 
 | 259 | 			pr_debug("%s: SCIOCGETDN: command successful\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 260 | 				 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | 		} | 
 | 262 | 		else { | 
 | 263 | 			pr_debug("%s: SCIOCGETDN: command failed (status = %d)\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 264 | 				 sc_adapter[card]->devicename, status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | 			kfree(rcvmsg); | 
 | 266 | 			return status; | 
 | 267 | 		} | 
 | 268 |  | 
| Dan Carpenter | 4b030d4 | 2010-08-04 23:38:06 +0000 | [diff] [blame] | 269 | 		dn = kzalloc(SCIOC_DNSIZE, GFP_KERNEL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | 		if (!dn) { | 
 | 271 | 			kfree(rcvmsg); | 
 | 272 | 			return -ENOMEM; | 
 | 273 | 		} | 
| Dan Carpenter | 4b030d4 | 2010-08-04 23:38:06 +0000 | [diff] [blame] | 274 | 		strlcpy(dn, rcvmsg->msg_data.byte_array, SCIOC_DNSIZE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | 		kfree(rcvmsg); | 
 | 276 |  | 
 | 277 | 		/* | 
 | 278 | 		 * Package the dn and send to user space | 
 | 279 | 		 */ | 
 | 280 | 		if (copy_to_user(data->dataptr, dn, SCIOC_DNSIZE)) { | 
 | 281 | 			kfree(dn); | 
 | 282 | 			return -EFAULT; | 
 | 283 | 		} | 
 | 284 | 		kfree(dn); | 
 | 285 | 		return 0; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 286 | 	} | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 |  | 
 | 288 | 	case SCIOCSETDN: | 
 | 289 | 	{ | 
 | 290 | 		pr_debug("%s: SCIOSETDN: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 291 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | 		/* | 
 | 294 | 		 * Get the spid from user space | 
 | 295 | 		 */ | 
| Julia Lawall | 024cb8a | 2010-05-21 22:26:42 +0000 | [diff] [blame] | 296 | 		dn = memdup_user(data->dataptr, SCIOC_DNSIZE); | 
 | 297 | 		if (IS_ERR(dn)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | 			kfree(rcvmsg); | 
| Julia Lawall | 024cb8a | 2010-05-21 22:26:42 +0000 | [diff] [blame] | 299 | 			return PTR_ERR(dn); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | 		} | 
 | 301 |  | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 302 | 		pr_debug("%s: SCIOCSETDN: setting channel %d dn to %s\n", | 
 | 303 | 			 sc_adapter[card]->devicename, data->channel, dn); | 
 | 304 | 		status = send_and_receive(card, CEPID, ceReqTypeCall, | 
 | 305 | 					  ceReqClass0, ceReqCallSetMyNumber, data->channel, | 
 | 306 | 					  strlen(dn), dn, rcvmsg, SAR_TIMEOUT); | 
 | 307 | 		if (!status && !(rcvmsg->rsp_status)) { | 
 | 308 | 			pr_debug("%s: SCIOCSETDN: command successful\n", | 
 | 309 | 				 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | 			kfree(rcvmsg); | 
 | 311 | 			kfree(dn); | 
 | 312 | 			return 0; | 
 | 313 | 		} | 
 | 314 | 		else { | 
 | 315 | 			pr_debug("%s: SCIOCSETDN: command failed (status = %d)\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 316 | 				 sc_adapter[card]->devicename, status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | 			kfree(rcvmsg); | 
 | 318 | 			kfree(dn); | 
 | 319 | 			return status; | 
 | 320 | 		} | 
 | 321 | 	} | 
 | 322 |  | 
 | 323 | 	case SCIOCTRACE: | 
 | 324 |  | 
 | 325 | 		pr_debug("%s: SCIOTRACE: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 326 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | /*		sc_adapter[card]->trace = !sc_adapter[card]->trace; | 
 | 328 | 		pr_debug("%s: SCIOCTRACE: tracing turned %s\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 329 | 		sc_adapter[card]->devicename, | 
 | 330 | 		sc_adapter[card]->trace ? "ON" : "OFF"); */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | 		break; | 
 | 332 |  | 
 | 333 | 	case SCIOCSTAT: | 
 | 334 | 	{ | 
 | 335 | 		boardInfo *bi; | 
 | 336 |  | 
 | 337 | 		pr_debug("%s: SCIOSTAT: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 338 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 |  | 
| Dan Carpenter | 4b030d4 | 2010-08-04 23:38:06 +0000 | [diff] [blame] | 340 | 		bi = kzalloc(sizeof(boardInfo), GFP_KERNEL); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | 		if (!bi) { | 
 | 342 | 			kfree(rcvmsg); | 
 | 343 | 			return -ENOMEM; | 
 | 344 | 		} | 
 | 345 |  | 
 | 346 | 		kfree(rcvmsg); | 
 | 347 | 		GetStatus(card, bi); | 
 | 348 |  | 
 | 349 | 		if (copy_to_user(data->dataptr, bi, sizeof(boardInfo))) { | 
 | 350 | 			kfree(bi); | 
 | 351 | 			return -EFAULT; | 
 | 352 | 		} | 
 | 353 |  | 
 | 354 | 		kfree(bi); | 
 | 355 | 		return 0; | 
 | 356 | 	} | 
 | 357 |  | 
 | 358 | 	case SCIOCGETSPEED: | 
 | 359 | 	{ | 
 | 360 | 		pr_debug("%s: SCIOGETSPEED: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 361 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 |  | 
 | 363 | 		/* | 
 | 364 | 		 * Get the speed from the board | 
 | 365 | 		 */ | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 366 | 		status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, | 
 | 367 | 					  ceReqCallGetCallType, data->channel, 0, NULL, rcvmsg, SAR_TIMEOUT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | 		if (!status && !(rcvmsg->rsp_status)) { | 
 | 369 | 			pr_debug("%s: SCIOCGETSPEED: command successful\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 370 | 				 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | 		} | 
 | 372 | 		else { | 
 | 373 | 			pr_debug("%s: SCIOCGETSPEED: command failed (status = %d)\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 374 | 				 sc_adapter[card]->devicename, status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | 			kfree(rcvmsg); | 
 | 376 | 			return status; | 
 | 377 | 		} | 
 | 378 |  | 
 | 379 | 		speed = rcvmsg->msg_data.byte_array[0]; | 
 | 380 |  | 
 | 381 | 		kfree(rcvmsg); | 
 | 382 |  | 
 | 383 | 		/* | 
 | 384 | 		 * Package the switch type and send to user space | 
 | 385 | 		 */ | 
 | 386 |  | 
 | 387 | 		if (copy_to_user(data->dataptr, &speed, sizeof(char))) | 
 | 388 | 			return -EFAULT; | 
 | 389 |  | 
 | 390 | 		return 0; | 
 | 391 | 	} | 
 | 392 |  | 
 | 393 | 	case SCIOCSETSPEED: | 
 | 394 | 		pr_debug("%s: SCIOCSETSPEED: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 395 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | 		break; | 
 | 397 |  | 
 | 398 | 	case SCIOCLOOPTST: | 
 | 399 | 		pr_debug("%s: SCIOCLOOPTST: ioctl received\n", | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 400 | 			 sc_adapter[card]->devicename); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | 		break; | 
 | 402 |  | 
 | 403 | 	default: | 
 | 404 | 		kfree(rcvmsg); | 
 | 405 | 		return -1; | 
 | 406 | 	} | 
 | 407 |  | 
 | 408 | 	kfree(rcvmsg); | 
 | 409 | 	return 0; | 
 | 410 | } | 
 | 411 |  | 
| Adrian Bunk | e3ca5e7 | 2005-06-25 14:58:34 -0700 | [diff] [blame] | 412 | static int GetStatus(int card, boardInfo *bi) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | { | 
 | 414 | 	RspMessage rcvmsg; | 
 | 415 | 	int i, status; | 
 | 416 |  | 
 | 417 | 	/* | 
 | 418 | 	 * Fill in some of the basic info about the board | 
 | 419 | 	 */ | 
 | 420 | 	bi->modelid = sc_adapter[card]->model; | 
 | 421 | 	strcpy(bi->serial_no, sc_adapter[card]->hwconfig.serial_no); | 
 | 422 | 	strcpy(bi->part_no, sc_adapter[card]->hwconfig.part_no); | 
 | 423 | 	bi->iobase = sc_adapter[card]->iobase; | 
 | 424 | 	bi->rambase = sc_adapter[card]->rambase; | 
 | 425 | 	bi->irq = sc_adapter[card]->interrupt; | 
 | 426 | 	bi->ramsize = sc_adapter[card]->hwconfig.ram_size; | 
 | 427 | 	bi->interface = sc_adapter[card]->hwconfig.st_u_sense; | 
 | 428 | 	strcpy(bi->load_ver, sc_adapter[card]->load_ver); | 
 | 429 | 	strcpy(bi->proc_ver, sc_adapter[card]->proc_ver); | 
 | 430 |  | 
 | 431 | 	/* | 
 | 432 | 	 * Get the current PhyStats and LnkStats | 
 | 433 | 	 */ | 
 | 434 | 	status = send_and_receive(card, CEPID, ceReqTypePhy, ceReqClass2, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 435 | 				  ceReqPhyStatus, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); | 
 | 436 | 	if (!status) { | 
 | 437 | 		if (sc_adapter[card]->model < PRI_BOARD) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | 			bi->l1_status = rcvmsg.msg_data.byte_array[2]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 439 | 			for (i = 0; i < BRI_CHANNELS; i++) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | 				bi->status.bristats[i].phy_stat = | 
 | 441 | 					rcvmsg.msg_data.byte_array[i]; | 
 | 442 | 		} | 
 | 443 | 		else { | 
 | 444 | 			bi->l1_status = rcvmsg.msg_data.byte_array[0]; | 
 | 445 | 			bi->l2_status = rcvmsg.msg_data.byte_array[1]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 446 | 			for (i = 0; i < PRI_CHANNELS; i++) | 
 | 447 | 				bi->status.pristats[i].phy_stat = | 
 | 448 | 					rcvmsg.msg_data.byte_array[i + 2]; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | 		} | 
 | 450 | 	} | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 451 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | 	/* | 
 | 453 | 	 * Get the call types for each channel | 
 | 454 | 	 */ | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 455 | 	for (i = 0; i < sc_adapter[card]->nChannels; i++) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 456 | 		status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 457 | 					  ceReqCallGetCallType, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); | 
 | 458 | 		if (!status) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | 			if (sc_adapter[card]->model == PRI_BOARD) { | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 460 | 				bi->status.pristats[i].call_type = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | 					rcvmsg.msg_data.byte_array[0]; | 
 | 462 | 			} | 
 | 463 | 			else { | 
 | 464 | 				bi->status.bristats[i].call_type = | 
 | 465 | 					rcvmsg.msg_data.byte_array[0]; | 
 | 466 | 			} | 
 | 467 | 		} | 
 | 468 | 	} | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 469 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | 	/* | 
 | 471 | 	 * If PRI, get the call states and service states for each channel | 
 | 472 | 	 */ | 
 | 473 | 	if (sc_adapter[card]->model == PRI_BOARD) { | 
 | 474 | 		/* | 
 | 475 | 		 * Get the call states | 
 | 476 | 		 */ | 
 | 477 | 		status = send_and_receive(card, CEPID, ceReqTypeStat, ceReqClass2, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 478 | 					  ceReqPhyChCallState, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); | 
 | 479 | 		if (!status) { | 
 | 480 | 			for (i = 0; i < PRI_CHANNELS; i++) | 
 | 481 | 				bi->status.pristats[i].call_state = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | 					rcvmsg.msg_data.byte_array[i]; | 
 | 483 | 		} | 
 | 484 |  | 
 | 485 | 		/* | 
 | 486 | 		 * Get the service states | 
 | 487 | 		 */ | 
 | 488 | 		status = send_and_receive(card, CEPID, ceReqTypeStat, ceReqClass2, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 489 | 					  ceReqPhyChServState, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); | 
 | 490 | 		if (!status) { | 
 | 491 | 			for (i = 0; i < PRI_CHANNELS; i++) | 
 | 492 | 				bi->status.pristats[i].serv_state = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | 					rcvmsg.msg_data.byte_array[i]; | 
 | 494 | 		} | 
 | 495 |  | 
 | 496 | 		/* | 
 | 497 | 		 * Get the link stats for the channels | 
 | 498 | 		 */ | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 499 | 		for (i = 1; i <= PRI_CHANNELS; i++) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | 			status = send_and_receive(card, CEPID, ceReqTypeLnk, ceReqClass0, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 501 | 						  ceReqLnkGetStats, i, 0, NULL, &rcvmsg, SAR_TIMEOUT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | 			if (!status) { | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 503 | 				bi->status.pristats[i - 1].link_stats.tx_good = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | 					(unsigned long)rcvmsg.msg_data.byte_array[0]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 505 | 				bi->status.pristats[i - 1].link_stats.tx_bad = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | 					(unsigned long)rcvmsg.msg_data.byte_array[4]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 507 | 				bi->status.pristats[i - 1].link_stats.rx_good = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | 					(unsigned long)rcvmsg.msg_data.byte_array[8]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 509 | 				bi->status.pristats[i - 1].link_stats.rx_bad = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | 					(unsigned long)rcvmsg.msg_data.byte_array[12]; | 
 | 511 | 			} | 
 | 512 | 		} | 
 | 513 |  | 
 | 514 | 		/* | 
 | 515 | 		 * Link stats for the D channel | 
 | 516 | 		 */ | 
 | 517 | 		status = send_and_receive(card, CEPID, ceReqTypeLnk, ceReqClass0, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 518 | 					  ceReqLnkGetStats, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | 		if (!status) { | 
 | 520 | 			bi->dch_stats.tx_good = (unsigned long)rcvmsg.msg_data.byte_array[0]; | 
 | 521 | 			bi->dch_stats.tx_bad = (unsigned long)rcvmsg.msg_data.byte_array[4]; | 
 | 522 | 			bi->dch_stats.rx_good = (unsigned long)rcvmsg.msg_data.byte_array[8]; | 
 | 523 | 			bi->dch_stats.rx_bad = (unsigned long)rcvmsg.msg_data.byte_array[12]; | 
 | 524 | 		} | 
 | 525 |  | 
 | 526 | 		return 0; | 
 | 527 | 	} | 
 | 528 |  | 
 | 529 | 	/* | 
 | 530 | 	 * If BRI or POTS, Get SPID, DN and call types for each channel | 
 | 531 | 	 */ | 
 | 532 |  | 
 | 533 | 	/* | 
 | 534 | 	 * Get the link stats for the channels | 
 | 535 | 	 */ | 
 | 536 | 	status = send_and_receive(card, CEPID, ceReqTypeLnk, ceReqClass0, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 537 | 				  ceReqLnkGetStats, 0, 0, NULL, &rcvmsg, SAR_TIMEOUT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | 	if (!status) { | 
 | 539 | 		bi->dch_stats.tx_good = (unsigned long)rcvmsg.msg_data.byte_array[0]; | 
 | 540 | 		bi->dch_stats.tx_bad = (unsigned long)rcvmsg.msg_data.byte_array[4]; | 
 | 541 | 		bi->dch_stats.rx_good = (unsigned long)rcvmsg.msg_data.byte_array[8]; | 
 | 542 | 		bi->dch_stats.rx_bad = (unsigned long)rcvmsg.msg_data.byte_array[12]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 543 | 		bi->status.bristats[0].link_stats.tx_good = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | 			(unsigned long)rcvmsg.msg_data.byte_array[16]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 545 | 		bi->status.bristats[0].link_stats.tx_bad = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | 			(unsigned long)rcvmsg.msg_data.byte_array[20]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 547 | 		bi->status.bristats[0].link_stats.rx_good = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | 			(unsigned long)rcvmsg.msg_data.byte_array[24]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 549 | 		bi->status.bristats[0].link_stats.rx_bad = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | 			(unsigned long)rcvmsg.msg_data.byte_array[28]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 551 | 		bi->status.bristats[1].link_stats.tx_good = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | 			(unsigned long)rcvmsg.msg_data.byte_array[32]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 553 | 		bi->status.bristats[1].link_stats.tx_bad = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 554 | 			(unsigned long)rcvmsg.msg_data.byte_array[36]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 555 | 		bi->status.bristats[1].link_stats.rx_good = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 556 | 			(unsigned long)rcvmsg.msg_data.byte_array[40]; | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 557 | 		bi->status.bristats[1].link_stats.rx_bad = | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | 			(unsigned long)rcvmsg.msg_data.byte_array[44]; | 
 | 559 | 	} | 
 | 560 |  | 
 | 561 | 	/* | 
 | 562 | 	 * Get the SPIDs | 
 | 563 | 	 */ | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 564 | 	for (i = 0; i < BRI_CHANNELS; i++) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | 		status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 566 | 					  ceReqCallGetSPID, i + 1, 0, NULL, &rcvmsg, SAR_TIMEOUT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | 		if (!status) | 
 | 568 | 			strcpy(bi->status.bristats[i].spid, rcvmsg.msg_data.byte_array); | 
 | 569 | 	} | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 570 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | 	/* | 
 | 572 | 	 * Get the DNs | 
 | 573 | 	 */ | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 574 | 	for (i = 0; i < BRI_CHANNELS; i++) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | 		status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 576 | 					  ceReqCallGetMyNumber, i + 1, 0, NULL, &rcvmsg, SAR_TIMEOUT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | 		if (!status) | 
 | 578 | 			strcpy(bi->status.bristats[i].dn, rcvmsg.msg_data.byte_array); | 
 | 579 | 	} | 
| Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 580 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | 	return 0; | 
 | 582 | } |