mwavedd.c (ff877ea80efa2015b6263766f78ee42c2a1b32f9) | mwavedd.c (909d145f0decbc4f17955e1fc4122a669a51fbc0) |
---|---|
1/* 2* 3* mwavedd.c -- mwave device driver 4* 5* 6* Written By: Mike Sullivan IBM Corporation 7* 8* Copyright (C) 1999 IBM Corporation --- 72 unchanged lines hidden (view full) --- 81module_param(mwave_debug, int, 0); 82module_param(mwave_3780i_irq, int, 0); 83module_param(mwave_3780i_io, int, 0); 84module_param(mwave_uart_irq, int, 0); 85module_param(mwave_uart_io, int, 0); 86 87static int mwave_open(struct inode *inode, struct file *file); 88static int mwave_close(struct inode *inode, struct file *file); | 1/* 2* 3* mwavedd.c -- mwave device driver 4* 5* 6* Written By: Mike Sullivan IBM Corporation 7* 8* Copyright (C) 1999 IBM Corporation --- 72 unchanged lines hidden (view full) --- 81module_param(mwave_debug, int, 0); 82module_param(mwave_3780i_irq, int, 0); 83module_param(mwave_3780i_io, int, 0); 84module_param(mwave_uart_irq, int, 0); 85module_param(mwave_uart_io, int, 0); 86 87static int mwave_open(struct inode *inode, struct file *file); 88static int mwave_close(struct inode *inode, struct file *file); |
89static int mwave_ioctl(struct inode *inode, struct file *filp, 90 unsigned int iocmd, unsigned long ioarg); | 89static long mwave_ioctl(struct file *filp, unsigned int iocmd, 90 unsigned long ioarg); |
91 92MWAVE_DEVICE_DATA mwave_s_mdd; 93 94static int mwave_open(struct inode *inode, struct file *file) 95{ 96 unsigned int retval = 0; 97 98 PRINTK_3(TRACE_MWAVE, --- 15 unchanged lines hidden (view full) --- 114 inode, file); 115 116 PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_close, exit retval %x\n", 117 retval); 118 119 return retval; 120} 121 | 91 92MWAVE_DEVICE_DATA mwave_s_mdd; 93 94static int mwave_open(struct inode *inode, struct file *file) 95{ 96 unsigned int retval = 0; 97 98 PRINTK_3(TRACE_MWAVE, --- 15 unchanged lines hidden (view full) --- 114 inode, file); 115 116 PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_close, exit retval %x\n", 117 retval); 118 119 return retval; 120} 121 |
122static int mwave_ioctl(struct inode *inode, struct file *file, 123 unsigned int iocmd, unsigned long ioarg) | 122static long mwave_ioctl(struct file *file, unsigned int iocmd, 123 unsigned long ioarg) |
124{ 125 unsigned int retval = 0; 126 pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; 127 void __user *arg = (void __user *)ioarg; 128 | 124{ 125 unsigned int retval = 0; 126 pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; 127 void __user *arg = (void __user *)ioarg; 128 |
129 PRINTK_5(TRACE_MWAVE, 130 "mwavedd::mwave_ioctl, entry inode %p file %p cmd %x arg %x\n", 131 inode, file, iocmd, (int) ioarg); | 129 PRINTK_4(TRACE_MWAVE, 130 "mwavedd::mwave_ioctl, entry file %p cmd %x arg %x\n", 131 file, iocmd, (int) ioarg); |
132 133 switch (iocmd) { 134 135 case IOCTL_MW_RESET: 136 PRINTK_1(TRACE_MWAVE, 137 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 138 " calling tp3780I_ResetDSP\n"); | 132 133 switch (iocmd) { 134 135 case IOCTL_MW_RESET: 136 PRINTK_1(TRACE_MWAVE, 137 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 138 " calling tp3780I_ResetDSP\n"); |
139 lock_kernel(); |
|
139 retval = tp3780I_ResetDSP(&pDrvData->rBDData); | 140 retval = tp3780I_ResetDSP(&pDrvData->rBDData); |
141 unlock_kernel(); |
|
140 PRINTK_2(TRACE_MWAVE, 141 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 142 " retval %x from tp3780I_ResetDSP\n", 143 retval); 144 break; 145 146 case IOCTL_MW_RUN: 147 PRINTK_1(TRACE_MWAVE, 148 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 149 " calling tp3780I_StartDSP\n"); | 142 PRINTK_2(TRACE_MWAVE, 143 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 144 " retval %x from tp3780I_ResetDSP\n", 145 retval); 146 break; 147 148 case IOCTL_MW_RUN: 149 PRINTK_1(TRACE_MWAVE, 150 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 151 " calling tp3780I_StartDSP\n"); |
152 lock_kernel(); |
|
150 retval = tp3780I_StartDSP(&pDrvData->rBDData); | 153 retval = tp3780I_StartDSP(&pDrvData->rBDData); |
154 unlock_kernel(); |
|
151 PRINTK_2(TRACE_MWAVE, 152 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 153 " retval %x from tp3780I_StartDSP\n", 154 retval); 155 break; 156 157 case IOCTL_MW_DSP_ABILITIES: { 158 MW_ABILITIES rAbilities; 159 160 PRINTK_1(TRACE_MWAVE, 161 "mwavedd::mwave_ioctl," 162 " IOCTL_MW_DSP_ABILITIES calling" 163 " tp3780I_QueryAbilities\n"); | 155 PRINTK_2(TRACE_MWAVE, 156 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 157 " retval %x from tp3780I_StartDSP\n", 158 retval); 159 break; 160 161 case IOCTL_MW_DSP_ABILITIES: { 162 MW_ABILITIES rAbilities; 163 164 PRINTK_1(TRACE_MWAVE, 165 "mwavedd::mwave_ioctl," 166 " IOCTL_MW_DSP_ABILITIES calling" 167 " tp3780I_QueryAbilities\n"); |
168 lock_kernel(); |
|
164 retval = tp3780I_QueryAbilities(&pDrvData->rBDData, 165 &rAbilities); | 169 retval = tp3780I_QueryAbilities(&pDrvData->rBDData, 170 &rAbilities); |
171 unlock_kernel(); |
|
166 PRINTK_2(TRACE_MWAVE, 167 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" 168 " retval %x from tp3780I_QueryAbilities\n", 169 retval); 170 if (retval == 0) { 171 if( copy_to_user(arg, &rAbilities, 172 sizeof(MW_ABILITIES)) ) 173 return -EFAULT; --- 14 unchanged lines hidden (view full) --- 188 sizeof(MW_READWRITE)) ) 189 return -EFAULT; 190 pusBuffer = (unsigned short __user *) (rReadData.pBuf); 191 192 PRINTK_4(TRACE_MWAVE, 193 "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," 194 " size %lx, ioarg %lx pusBuffer %p\n", 195 rReadData.ulDataLength, ioarg, pusBuffer); | 172 PRINTK_2(TRACE_MWAVE, 173 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" 174 " retval %x from tp3780I_QueryAbilities\n", 175 retval); 176 if (retval == 0) { 177 if( copy_to_user(arg, &rAbilities, 178 sizeof(MW_ABILITIES)) ) 179 return -EFAULT; --- 14 unchanged lines hidden (view full) --- 194 sizeof(MW_READWRITE)) ) 195 return -EFAULT; 196 pusBuffer = (unsigned short __user *) (rReadData.pBuf); 197 198 PRINTK_4(TRACE_MWAVE, 199 "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," 200 " size %lx, ioarg %lx pusBuffer %p\n", 201 rReadData.ulDataLength, ioarg, pusBuffer); |
202 lock_kernel(); |
|
196 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 197 iocmd, 198 pusBuffer, 199 rReadData.ulDataLength, 200 rReadData.usDspAddress); | 203 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 204 iocmd, 205 pusBuffer, 206 rReadData.ulDataLength, 207 rReadData.usDspAddress); |
208 unlock_kernel(); |
|
201 } 202 break; 203 204 case IOCTL_MW_READ_INST: { 205 MW_READWRITE rReadData; 206 unsigned short __user *pusBuffer = NULL; 207 208 if( copy_from_user(&rReadData, arg, 209 sizeof(MW_READWRITE)) ) 210 return -EFAULT; 211 pusBuffer = (unsigned short __user *) (rReadData.pBuf); 212 213 PRINTK_4(TRACE_MWAVE, 214 "mwavedd::mwave_ioctl IOCTL_MW_READ_INST," 215 " size %lx, ioarg %lx pusBuffer %p\n", 216 rReadData.ulDataLength / 2, ioarg, 217 pusBuffer); | 209 } 210 break; 211 212 case IOCTL_MW_READ_INST: { 213 MW_READWRITE rReadData; 214 unsigned short __user *pusBuffer = NULL; 215 216 if( copy_from_user(&rReadData, arg, 217 sizeof(MW_READWRITE)) ) 218 return -EFAULT; 219 pusBuffer = (unsigned short __user *) (rReadData.pBuf); 220 221 PRINTK_4(TRACE_MWAVE, 222 "mwavedd::mwave_ioctl IOCTL_MW_READ_INST," 223 " size %lx, ioarg %lx pusBuffer %p\n", 224 rReadData.ulDataLength / 2, ioarg, 225 pusBuffer); |
226 lock_kernel(); |
|
218 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 219 iocmd, pusBuffer, 220 rReadData.ulDataLength / 2, 221 rReadData.usDspAddress); | 227 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 228 iocmd, pusBuffer, 229 rReadData.ulDataLength / 2, 230 rReadData.usDspAddress); |
231 unlock_kernel(); |
|
222 } 223 break; 224 225 case IOCTL_MW_WRITE_DATA: { 226 MW_READWRITE rWriteData; 227 unsigned short __user *pusBuffer = NULL; 228 229 if( copy_from_user(&rWriteData, arg, 230 sizeof(MW_READWRITE)) ) 231 return -EFAULT; 232 pusBuffer = (unsigned short __user *) (rWriteData.pBuf); 233 234 PRINTK_4(TRACE_MWAVE, 235 "mwavedd::mwave_ioctl IOCTL_MW_WRITE_DATA," 236 " size %lx, ioarg %lx pusBuffer %p\n", 237 rWriteData.ulDataLength, ioarg, 238 pusBuffer); | 232 } 233 break; 234 235 case IOCTL_MW_WRITE_DATA: { 236 MW_READWRITE rWriteData; 237 unsigned short __user *pusBuffer = NULL; 238 239 if( copy_from_user(&rWriteData, arg, 240 sizeof(MW_READWRITE)) ) 241 return -EFAULT; 242 pusBuffer = (unsigned short __user *) (rWriteData.pBuf); 243 244 PRINTK_4(TRACE_MWAVE, 245 "mwavedd::mwave_ioctl IOCTL_MW_WRITE_DATA," 246 " size %lx, ioarg %lx pusBuffer %p\n", 247 rWriteData.ulDataLength, ioarg, 248 pusBuffer); |
249 lock_kernel(); |
|
239 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 240 iocmd, pusBuffer, 241 rWriteData.ulDataLength, 242 rWriteData.usDspAddress); | 250 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 251 iocmd, pusBuffer, 252 rWriteData.ulDataLength, 253 rWriteData.usDspAddress); |
254 unlock_kernel(); |
|
243 } 244 break; 245 246 case IOCTL_MW_WRITE_INST: { 247 MW_READWRITE rWriteData; 248 unsigned short __user *pusBuffer = NULL; 249 250 if( copy_from_user(&rWriteData, arg, 251 sizeof(MW_READWRITE)) ) 252 return -EFAULT; 253 pusBuffer = (unsigned short __user *)(rWriteData.pBuf); 254 255 PRINTK_4(TRACE_MWAVE, 256 "mwavedd::mwave_ioctl IOCTL_MW_WRITE_INST," 257 " size %lx, ioarg %lx pusBuffer %p\n", 258 rWriteData.ulDataLength, ioarg, 259 pusBuffer); | 255 } 256 break; 257 258 case IOCTL_MW_WRITE_INST: { 259 MW_READWRITE rWriteData; 260 unsigned short __user *pusBuffer = NULL; 261 262 if( copy_from_user(&rWriteData, arg, 263 sizeof(MW_READWRITE)) ) 264 return -EFAULT; 265 pusBuffer = (unsigned short __user *)(rWriteData.pBuf); 266 267 PRINTK_4(TRACE_MWAVE, 268 "mwavedd::mwave_ioctl IOCTL_MW_WRITE_INST," 269 " size %lx, ioarg %lx pusBuffer %p\n", 270 rWriteData.ulDataLength, ioarg, 271 pusBuffer); |
272 lock_kernel(); |
|
260 retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, 261 iocmd, pusBuffer, 262 rWriteData.ulDataLength, 263 rWriteData.usDspAddress); | 273 retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, 274 iocmd, pusBuffer, 275 rWriteData.ulDataLength, 276 rWriteData.usDspAddress); |
277 unlock_kernel(); |
|
264 } 265 break; 266 267 case IOCTL_MW_REGISTER_IPC: { 268 unsigned int ipcnum = (unsigned int) ioarg; 269 270 PRINTK_3(TRACE_MWAVE, 271 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" --- 4 unchanged lines hidden (view full) --- 276 if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) { 277 PRINTK_ERROR(KERN_ERR_MWAVE 278 "mwavedd::mwave_ioctl:" 279 " IOCTL_MW_REGISTER_IPC:" 280 " Error: Invalid ipcnum %x\n", 281 ipcnum); 282 return -EINVAL; 283 } | 278 } 279 break; 280 281 case IOCTL_MW_REGISTER_IPC: { 282 unsigned int ipcnum = (unsigned int) ioarg; 283 284 PRINTK_3(TRACE_MWAVE, 285 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" --- 4 unchanged lines hidden (view full) --- 290 if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) { 291 PRINTK_ERROR(KERN_ERR_MWAVE 292 "mwavedd::mwave_ioctl:" 293 " IOCTL_MW_REGISTER_IPC:" 294 " Error: Invalid ipcnum %x\n", 295 ipcnum); 296 return -EINVAL; 297 } |
298 lock_kernel(); |
|
284 pDrvData->IPCs[ipcnum].bIsHere = FALSE; 285 pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; | 299 pDrvData->IPCs[ipcnum].bIsHere = FALSE; 300 pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; |
301 unlock_kernel(); |
|
286 287 PRINTK_2(TRACE_MWAVE, 288 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" 289 " ipcnum %x exit\n", 290 ipcnum); 291 } 292 break; 293 --- 8 unchanged lines hidden (view full) --- 302 if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) { 303 PRINTK_ERROR(KERN_ERR_MWAVE 304 "mwavedd::mwave_ioctl:" 305 " IOCTL_MW_GET_IPC: Error:" 306 " Invalid ipcnum %x\n", ipcnum); 307 return -EINVAL; 308 } 309 | 302 303 PRINTK_2(TRACE_MWAVE, 304 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" 305 " ipcnum %x exit\n", 306 ipcnum); 307 } 308 break; 309 --- 8 unchanged lines hidden (view full) --- 318 if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) { 319 PRINTK_ERROR(KERN_ERR_MWAVE 320 "mwavedd::mwave_ioctl:" 321 " IOCTL_MW_GET_IPC: Error:" 322 " Invalid ipcnum %x\n", ipcnum); 323 return -EINVAL; 324 } 325 |
326 lock_kernel(); |
|
310 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 311 DECLARE_WAITQUEUE(wait, current); 312 313 PRINTK_2(TRACE_MWAVE, 314 "mwavedd::mwave_ioctl, thread for" 315 " ipc %x going to sleep\n", 316 ipcnum); 317 add_wait_queue(&pDrvData->IPCs[ipcnum].ipc_wait_queue, &wait); --- 24 unchanged lines hidden (view full) --- 342 remove_wait_queue(&pDrvData->IPCs[ipcnum].ipc_wait_queue, &wait); 343 set_current_state(TASK_RUNNING); 344 PRINTK_2(TRACE_MWAVE, 345 "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC," 346 " returning thread for ipc %x" 347 " processing\n", 348 ipcnum); 349 } | 327 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 328 DECLARE_WAITQUEUE(wait, current); 329 330 PRINTK_2(TRACE_MWAVE, 331 "mwavedd::mwave_ioctl, thread for" 332 " ipc %x going to sleep\n", 333 ipcnum); 334 add_wait_queue(&pDrvData->IPCs[ipcnum].ipc_wait_queue, &wait); --- 24 unchanged lines hidden (view full) --- 359 remove_wait_queue(&pDrvData->IPCs[ipcnum].ipc_wait_queue, &wait); 360 set_current_state(TASK_RUNNING); 361 PRINTK_2(TRACE_MWAVE, 362 "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC," 363 " returning thread for ipc %x" 364 " processing\n", 365 ipcnum); 366 } |
367 unlock_kernel(); |
|
350 } 351 break; 352 353 case IOCTL_MW_UNREGISTER_IPC: { 354 unsigned int ipcnum = (unsigned int) ioarg; 355 356 PRINTK_2(TRACE_MWAVE, 357 "mwavedd::mwave_ioctl IOCTL_MW_UNREGISTER_IPC" 358 " ipcnum %x\n", 359 ipcnum); 360 if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) { 361 PRINTK_ERROR(KERN_ERR_MWAVE 362 "mwavedd::mwave_ioctl:" 363 " IOCTL_MW_UNREGISTER_IPC:" 364 " Error: Invalid ipcnum %x\n", 365 ipcnum); 366 return -EINVAL; 367 } | 368 } 369 break; 370 371 case IOCTL_MW_UNREGISTER_IPC: { 372 unsigned int ipcnum = (unsigned int) ioarg; 373 374 PRINTK_2(TRACE_MWAVE, 375 "mwavedd::mwave_ioctl IOCTL_MW_UNREGISTER_IPC" 376 " ipcnum %x\n", 377 ipcnum); 378 if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) { 379 PRINTK_ERROR(KERN_ERR_MWAVE 380 "mwavedd::mwave_ioctl:" 381 " IOCTL_MW_UNREGISTER_IPC:" 382 " Error: Invalid ipcnum %x\n", 383 ipcnum); 384 return -EINVAL; 385 } |
386 lock_kernel(); |
|
368 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 369 pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; 370 if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { 371 wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); 372 } 373 } | 387 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 388 pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; 389 if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { 390 wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); 391 } 392 } |
393 unlock_kernel(); |
|
374 } 375 break; 376 377 default: | 394 } 395 break; 396 397 default: |
378 PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::mwave_ioctl:" 379 " Error: Unrecognized iocmd %x\n", 380 iocmd); | |
381 return -ENOTTY; 382 break; 383 } /* switch */ 384 385 PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_ioctl, exit retval %x\n", retval); 386 387 return retval; 388} --- 66 unchanged lines hidden (view full) --- 455 return serial8250_register_port(&uart); 456} 457 458 459static const struct file_operations mwave_fops = { 460 .owner = THIS_MODULE, 461 .read = mwave_read, 462 .write = mwave_write, | 398 return -ENOTTY; 399 break; 400 } /* switch */ 401 402 PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_ioctl, exit retval %x\n", retval); 403 404 return retval; 405} --- 66 unchanged lines hidden (view full) --- 472 return serial8250_register_port(&uart); 473} 474 475 476static const struct file_operations mwave_fops = { 477 .owner = THIS_MODULE, 478 .read = mwave_read, 479 .write = mwave_write, |
463 .ioctl = mwave_ioctl, | 480 .unlocked_ioctl = mwave_ioctl, |
464 .open = mwave_open, 465 .release = mwave_close 466}; 467 468 469static struct miscdevice mwave_misc_dev = { MWAVE_MINOR, "mwave", &mwave_fops }; 470 471#if 0 /* totally b0rked */ --- 208 unchanged lines hidden --- | 481 .open = mwave_open, 482 .release = mwave_close 483}; 484 485 486static struct miscdevice mwave_misc_dev = { MWAVE_MINOR, "mwave", &mwave_fops }; 487 488#if 0 /* totally b0rked */ --- 208 unchanged lines hidden --- |