1/* 2 * Device driver for the Apple Desktop Bus 3 * and the /dev/adb device on macintoshes. 4 * 5 * Copyright (C) 1996 Paul Mackerras. 6 * 7 * Modified to declare controllers as structures, added 8 * client notification of bus reset and handles PowerBook 9 * sleep, by Benjamin Herrenschmidt. 10 * 11 * To do: 12 * 13 * - /proc/adb to list the devices and infos 14 * - more /dev/adb to allow userland to receive the 15 * flow of auto-polling datas from a given device. 16 * - move bus probe to a kernel thread 17 */ 18 19#include <linux/config.h> 20#include <linux/types.h> 21#include <linux/errno.h> 22#include <linux/kernel.h> 23#include <linux/slab.h> 24#include <linux/module.h> 25#include <linux/fs.h> 26#include <linux/devfs_fs_kernel.h> 27#include <linux/mm.h> 28#include <linux/sched.h> 29#include <linux/smp_lock.h> 30#include <linux/adb.h> 31#include <linux/cuda.h> 32#include <linux/pmu.h> 33#include <linux/notifier.h> 34#include <linux/wait.h> 35#include <linux/init.h> 36#include <linux/delay.h> 37#include <linux/completion.h> 38#include <asm/uaccess.h> 39#ifdef CONFIG_PPC 40#include <asm/prom.h> 41#include <asm/hydra.h> 42#endif 43 44EXPORT_SYMBOL(adb_controller); 45EXPORT_SYMBOL(adb_client_list); 46 47extern struct adb_driver via_macii_driver; 48extern struct adb_driver via_maciisi_driver; 49extern struct adb_driver via_cuda_driver; 50extern struct adb_driver adb_iop_driver; 51extern struct adb_driver via_pmu_driver; 52extern struct adb_driver macio_adb_driver; 53 54static struct adb_driver *adb_driver_list[] = { 55#ifdef CONFIG_ADB_MACII 56 &via_macii_driver, 57#endif 58#ifdef CONFIG_ADB_MACIISI 59 &via_maciisi_driver, 60#endif 61#ifdef CONFIG_ADB_CUDA 62 &via_cuda_driver, 63#endif 64#ifdef CONFIG_ADB_IOP 65 &adb_iop_driver, 66#endif 67#if defined(CONFIG_ADB_PMU) || defined(CONFIG_ADB_PMU68K) 68 &via_pmu_driver, 69#endif 70#ifdef CONFIG_ADB_MACIO 71 &macio_adb_driver, 72#endif 73 NULL 74}; 75 76struct adb_driver *adb_controller; 77struct notifier_block *adb_client_list = NULL; 78static int adb_got_sleep = 0; 79static int adb_inited = 0; 80static pid_t adb_probe_task_pid; 81static DECLARE_MUTEX(adb_probe_mutex); 82static struct completion adb_probe_task_comp; 83static int sleepy_trackpad; 84int __adb_probe_sync; 85 86#ifdef CONFIG_PMAC_PBOOK 87static int adb_notify_sleep(struct pmu_sleep_notifier *self, int when); 88static struct pmu_sleep_notifier adb_sleep_notifier = { 89 adb_notify_sleep, 90 SLEEP_LEVEL_ADB, 91}; 92#endif 93 94static int adb_scan_bus(void); 95static int do_adb_reset_bus(void); 96static void adbdev_init(void); 97 98 99static struct adb_handler { 100 void (*handler)(unsigned char *, int, struct pt_regs *, int); 101 int original_address; 102 int handler_id; 103} adb_handler[16]; 104 105 106 107static __inline__ void adb_wait_ms(unsigned int ms) 108{ 109 if (current->pid && adb_probe_task_pid && 110 adb_probe_task_pid == current->pid) { 111 current->state = TASK_UNINTERRUPTIBLE; 112 schedule_timeout(1 + ms * HZ / 1000); 113 } else 114 mdelay(ms); 115} 116 117static int adb_scan_bus(void) 118{ 119 int i, highFree=0, noMovement; 120 int devmask = 0; 121 struct adb_request req; 122 123 /* assumes adb_handler[] is all zeroes at this point */ 124 for (i = 1; i < 16; i++) { 125 /* see if there is anything at address i */ 126 adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1, 127 (i << 4) | 0xf); 128 if (req.reply_len > 1) 129 /* one or more devices at this address */ 130 adb_handler[i].original_address = i; 131 else if (i > highFree) 132 highFree = i; 133 } 134 135 /* Note we reset noMovement to 0 each time we move a device */ 136 for (noMovement = 1; noMovement < 2 && highFree > 0; noMovement++) { 137 for (i = 1; i < 16; i++) { 138 if (adb_handler[i].original_address == 0) 139 continue; 140 /* 141 * Send a "talk register 3" command to address i 142 * to provoke a collision if there is more than 143 * one device at this address. 144 */ 145 adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1, 146 (i << 4) | 0xf); 147 /* 148 * Move the device(s) which didn't detect a 149 * collision to address `highFree'. Hopefully 150 * this only moves one device. 151 */ 152 adb_request(&req, NULL, ADBREQ_SYNC, 3, 153 (i<< 4) | 0xb, (highFree | 0x60), 0xfe); 154 /* 155 * See if anybody actually moved. This is suggested 156 * by HW TechNote 01: 157 * 158 * http://developer.apple.com/technotes/hw/hw_01.html 159 */ 160 adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1, 161 (highFree << 4) | 0xf); 162 if (req.reply_len <= 1) continue; 163 /* 164 * Test whether there are any device(s) left 165 * at address i. 166 */ 167 adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1, 168 (i << 4) | 0xf); 169 if (req.reply_len > 1) { 170 /* 171 * There are still one or more devices 172 * left at address i. Register the one(s) 173 * we moved to `highFree', and find a new 174 * value for highFree. 175 */ 176 adb_handler[highFree].original_address = 177 adb_handler[i].original_address; 178 while (highFree > 0 && 179 adb_handler[highFree].original_address) 180 highFree--; 181 if (highFree <= 0) 182 break; 183 184 noMovement = 0; 185 } 186 else { 187 /* 188 * No devices left at address i; move the 189 * one(s) we moved to `highFree' back to i. 190 */ 191 adb_request(&req, NULL, ADBREQ_SYNC, 3, 192 (highFree << 4) | 0xb, 193 (i | 0x60), 0xfe); 194 } 195 } 196 } 197 198 /* Now fill in the handler_id field of the adb_handler entries. */ 199 printk(KERN_DEBUG "adb devices:"); 200 for (i = 1; i < 16; i++) { 201 if (adb_handler[i].original_address == 0) 202 continue; 203 adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1, 204 (i << 4) | 0xf); 205 adb_handler[i].handler_id = req.reply[2]; 206 printk(" [%d]: %d %x", i, adb_handler[i].original_address, 207 adb_handler[i].handler_id); 208 devmask |= 1 << i; 209 } 210 printk("\n"); 211 return devmask; 212} 213 214/* 215 * This kernel task handles ADB probing. It dies once probing is 216 * completed. 217 */ 218static int 219adb_probe_task(void *x) 220{ 221 strcpy(current->comm, "kadbprobe"); 222 223 spin_lock_irq(¤t->sigmask_lock); 224 sigfillset(¤t->blocked); 225 flush_signals(current); 226 spin_unlock_irq(¤t->sigmask_lock); 227 228 printk(KERN_INFO "adb: starting probe task...\n"); 229 do_adb_reset_bus(); 230 printk(KERN_INFO "adb: finished probe task...\n"); 231 232 adb_probe_task_pid = 0; 233 up(&adb_probe_mutex); 234 235 return 0; 236} 237 238static void 239__adb_probe_task(void *data) 240{ 241 adb_probe_task_pid = kernel_thread(adb_probe_task, NULL, 242 SIGCHLD | CLONE_FS | CLONE_FILES | CLONE_SIGHAND); 243} 244 245int 246adb_reset_bus(void) 247{ 248 static struct tq_struct tqs = { 249 routine: __adb_probe_task, 250 }; 251 252 if (__adb_probe_sync) { 253 do_adb_reset_bus(); 254 return 0; 255 } 256 257 down(&adb_probe_mutex); 258 259 /* Create probe thread as a child of keventd */ 260 if (current_is_keventd()) 261 __adb_probe_task(NULL); 262 else 263 schedule_task(&tqs); 264 return 0; 265} 266 267int __init adb_init(void) 268{ 269 struct adb_driver *driver; 270 int i; 271 272#ifdef CONFIG_PPC 273 if ( (_machine != _MACH_chrp) && (_machine != _MACH_Pmac) ) 274 return 0; 275#endif 276#ifdef CONFIG_MAC 277 if (!MACH_IS_MAC) 278 return 0; 279#endif 280 281 /* xmon may do early-init */ 282 if (adb_inited) 283 return 0; 284 adb_inited = 1; 285 286 adb_controller = NULL; 287 288 i = 0; 289 while ((driver = adb_driver_list[i++]) != NULL) { 290 if (!driver->probe()) { 291 adb_controller = driver; 292 break; 293 } 294 } 295 if ((adb_controller == NULL) || adb_controller->init()) { 296 printk(KERN_WARNING "Warning: no ADB interface detected\n"); 297 adb_controller = NULL; 298 } else { 299#ifdef CONFIG_PMAC_PBOOK 300 pmu_register_sleep_notifier(&adb_sleep_notifier); 301#endif /* CONFIG_PMAC_PBOOK */ 302#ifdef CONFIG_PPC 303 if (machine_is_compatible("AAPL,PowerBook1998") || 304 machine_is_compatible("PowerBook1,1")) 305 sleepy_trackpad = 1; 306#endif /* CONFIG_PPC */ 307 init_completion(&adb_probe_task_comp); 308 adbdev_init(); 309 adb_reset_bus(); 310 } 311 return 0; 312} 313 314__initcall(adb_init); 315 316#ifdef CONFIG_PMAC_PBOOK 317/* 318 * notify clients before sleep and reset bus afterwards 319 */ 320int 321adb_notify_sleep(struct pmu_sleep_notifier *self, int when) 322{ 323 int ret; 324 325 switch (when) { 326 case PBOOK_SLEEP_REQUEST: 327 adb_got_sleep = 1; 328 /* We need to get a lock on the probe thread */ 329 down(&adb_probe_mutex); 330 /* Stop autopoll */ 331 if (adb_controller->autopoll) 332 adb_controller->autopoll(0); 333 ret = notifier_call_chain(&adb_client_list, ADB_MSG_POWERDOWN, NULL); 334 if (ret & NOTIFY_STOP_MASK) { 335 up(&adb_probe_mutex); 336 return PBOOK_SLEEP_REFUSE; 337 } 338 break; 339 case PBOOK_SLEEP_REJECT: 340 if (adb_got_sleep) { 341 adb_got_sleep = 0; 342 up(&adb_probe_mutex); 343 adb_reset_bus(); 344 } 345 break; 346 347 case PBOOK_SLEEP_NOW: 348 break; 349 case PBOOK_WAKE: 350 adb_got_sleep = 0; 351 up(&adb_probe_mutex); 352 adb_reset_bus(); 353 break; 354 } 355 return PBOOK_SLEEP_OK; 356} 357#endif /* CONFIG_PMAC_PBOOK */ 358 359static int 360do_adb_reset_bus(void) 361{ 362 int ret, nret, devs; 363 unsigned long flags; 364 365 if (adb_controller == NULL) 366 return -ENXIO; 367 368 if (adb_controller->autopoll) 369 adb_controller->autopoll(0); 370 371 nret = notifier_call_chain(&adb_client_list, ADB_MSG_PRE_RESET, NULL); 372 if (nret & NOTIFY_STOP_MASK) { 373 if (adb_controller->autopoll) 374 adb_controller->autopoll(devs); 375 return -EBUSY; 376 } 377 378 if (sleepy_trackpad) { 379 /* Let the trackpad settle down */ 380 adb_wait_ms(500); 381 } 382 383 save_flags(flags); 384 cli(); 385 memset(adb_handler, 0, sizeof(adb_handler)); 386 restore_flags(flags); 387 388 /* That one is still a bit synchronous, oh well... */ 389 if (adb_controller->reset_bus) 390 ret = adb_controller->reset_bus(); 391 else 392 ret = 0; 393 394 if (sleepy_trackpad) { 395 /* Let the trackpad settle down */ 396 adb_wait_ms(1500); 397 } 398 399 if (!ret) { 400 devs = adb_scan_bus(); 401 if (adb_controller->autopoll) 402 adb_controller->autopoll(devs); 403 } 404 405 nret = notifier_call_chain(&adb_client_list, ADB_MSG_POST_RESET, NULL); 406 if (nret & NOTIFY_STOP_MASK) 407 return -EBUSY; 408 409 return ret; 410} 411 412void 413adb_poll(void) 414{ 415 if ((adb_controller == NULL)||(adb_controller->poll == NULL)) 416 return; 417 adb_controller->poll(); 418} 419 420static void 421adb_probe_wakeup(struct adb_request *req) 422{ 423 complete(&adb_probe_task_comp); 424} 425 426static struct adb_request adb_sreq; 427static int adb_sreq_lock; // Use semaphore ! */ 428 429int 430adb_request(struct adb_request *req, void (*done)(struct adb_request *), 431 int flags, int nbytes, ...) 432{ 433 va_list list; 434 int i, use_sreq; 435 int rc; 436 437 if ((adb_controller == NULL) || (adb_controller->send_request == NULL)) 438 return -ENXIO; 439 if (nbytes < 1) 440 return -EINVAL; 441 if (req == NULL && (flags & ADBREQ_NOSEND)) 442 return -EINVAL; 443 444 if (req == NULL) { 445 if (test_and_set_bit(0,&adb_sreq_lock)) { 446 printk("adb.c: Warning: contention on static request !\n"); 447 return -EPERM; 448 } 449 req = &adb_sreq; 450 flags |= ADBREQ_SYNC; 451 use_sreq = 1; 452 } else 453 use_sreq = 0; 454 req->nbytes = nbytes+1; 455 req->done = done; 456 req->reply_expected = flags & ADBREQ_REPLY; 457 req->data[0] = ADB_PACKET; 458 va_start(list, nbytes); 459 for (i = 0; i < nbytes; ++i) 460 req->data[i+1] = va_arg(list, int); 461 va_end(list); 462 463 if (flags & ADBREQ_NOSEND) 464 return 0; 465 466 /* Synchronous requests send from the probe thread cause it to 467 * block. Beware that the "done" callback will be overriden ! 468 */ 469 if ((flags & ADBREQ_SYNC) && 470 (current->pid && adb_probe_task_pid && 471 adb_probe_task_pid == current->pid)) { 472 req->done = adb_probe_wakeup; 473 rc = adb_controller->send_request(req, 0); 474 if (rc || req->complete) 475 goto bail; 476 wait_for_completion(&adb_probe_task_comp); 477 rc = 0; 478 goto bail; 479 } 480 481 rc = adb_controller->send_request(req, flags & ADBREQ_SYNC); 482bail: 483 if (use_sreq) 484 clear_bit(0, &adb_sreq_lock); 485 486 return rc; 487} 488 489 /* Ultimately this should return the number of devices with 490 the given default id. 491 And it does it now ! Note: changed behaviour: This function 492 will now register if default_id _and_ handler_id both match 493 but handler_id can be left to 0 to match with default_id only. 494 When handler_id is set, this function will try to adjust 495 the handler_id id it doesn't match. */ 496int 497adb_register(int default_id, int handler_id, struct adb_ids *ids, 498 void (*handler)(unsigned char *, int, struct pt_regs *, int)) 499{ 500 int i; 501 502 ids->nids = 0; 503 for (i = 1; i < 16; i++) { 504 if ((adb_handler[i].original_address == default_id) && 505 (!handler_id || (handler_id == adb_handler[i].handler_id) || 506 adb_try_handler_change(i, handler_id))) { 507 if (adb_handler[i].handler != 0) { 508 printk(KERN_ERR 509 "Two handlers for ADB device %d\n", 510 default_id); 511 continue; 512 } 513 adb_handler[i].handler = handler; 514 ids->id[ids->nids++] = i; 515 } 516 } 517 return ids->nids; 518} 519 520int 521adb_unregister(int index) 522{ 523 if (!adb_handler[index].handler) 524 return -ENODEV; 525 adb_handler[index].handler = 0; 526 return 0; 527} 528 529void 530adb_input(unsigned char *buf, int nb, struct pt_regs *regs, int autopoll) 531{ 532 int i, id; 533 static int dump_adb_input = 0; 534 535 /* We skip keystrokes and mouse moves when the sleep process 536 * has been started. We stop autopoll, but this is another security 537 */ 538 if (adb_got_sleep) 539 return; 540 541 id = buf[0] >> 4; 542 if (dump_adb_input) { 543 printk(KERN_INFO "adb packet: "); 544 for (i = 0; i < nb; ++i) 545 printk(" %x", buf[i]); 546 printk(", id = %d\n", id); 547 } 548 if (adb_handler[id].handler != 0) { 549 (*adb_handler[id].handler)(buf, nb, regs, autopoll); 550 } 551} 552 553/* Try to change handler to new_id. Will return 1 if successful */ 554int 555adb_try_handler_change(int address, int new_id) 556{ 557 struct adb_request req; 558 559 if (adb_handler[address].handler_id == new_id) 560 return 1; 561 adb_request(&req, NULL, ADBREQ_SYNC, 3, 562 ADB_WRITEREG(address, 3), address | 0x20, new_id); 563 adb_request(&req, NULL, ADBREQ_SYNC | ADBREQ_REPLY, 1, 564 ADB_READREG(address, 3)); 565 if (req.reply_len < 2) 566 return 0; 567 if (req.reply[2] != new_id) 568 return 0; 569 adb_handler[address].handler_id = req.reply[2]; 570 571 return 1; 572} 573 574int 575adb_get_infos(int address, int *original_address, int *handler_id) 576{ 577 *original_address = adb_handler[address].original_address; 578 *handler_id = adb_handler[address].handler_id; 579 580 return (*original_address != 0); 581} 582 583 584/* 585 * /dev/adb device driver. 586 */ 587 588#define ADB_MAJOR 56 /* major number for /dev/adb */ 589 590struct adbdev_state { 591 spinlock_t lock; 592 atomic_t n_pending; 593 struct adb_request *completed; 594 wait_queue_head_t wait_queue; 595 int inuse; 596}; 597 598static void adb_write_done(struct adb_request *req) 599{ 600 struct adbdev_state *state = (struct adbdev_state *) req->arg; 601 unsigned long flags; 602 603 if (!req->complete) { 604 req->reply_len = 0; 605 req->complete = 1; 606 } 607 spin_lock_irqsave(&state->lock, flags); 608 atomic_dec(&state->n_pending); 609 if (!state->inuse) { 610 kfree(req); 611 if (atomic_read(&state->n_pending) == 0) { 612 spin_unlock_irqrestore(&state->lock, flags); 613 kfree(state); 614 return; 615 } 616 } else { 617 struct adb_request **ap = &state->completed; 618 while (*ap != NULL) 619 ap = &(*ap)->next; 620 req->next = NULL; 621 *ap = req; 622 wake_up_interruptible(&state->wait_queue); 623 } 624 spin_unlock_irqrestore(&state->lock, flags); 625} 626 627static int adb_open(struct inode *inode, struct file *file) 628{ 629 struct adbdev_state *state; 630 631 if (MINOR(inode->i_rdev) > 0 || adb_controller == NULL) 632 return -ENXIO; 633 state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL); 634 if (state == 0) 635 return -ENOMEM; 636 file->private_data = state; 637 spin_lock_init(&state->lock); 638 atomic_set(&state->n_pending, 0); 639 state->completed = NULL; 640 init_waitqueue_head(&state->wait_queue); 641 state->inuse = 1; 642 643 return 0; 644} 645 646static int adb_release(struct inode *inode, struct file *file) 647{ 648 struct adbdev_state *state = file->private_data; 649 unsigned long flags; 650 651 lock_kernel(); 652 if (state) { 653 file->private_data = NULL; 654 spin_lock_irqsave(&state->lock, flags); 655 if (atomic_read(&state->n_pending) == 0 656 && state->completed == NULL) { 657 spin_unlock_irqrestore(&state->lock, flags); 658 kfree(state); 659 } else { 660 state->inuse = 0; 661 spin_unlock_irqrestore(&state->lock, flags); 662 } 663 } 664 unlock_kernel(); 665 return 0; 666} 667 668static ssize_t adb_read(struct file *file, char *buf, 669 size_t count, loff_t *ppos) 670{ 671 int ret; 672 struct adbdev_state *state = file->private_data; 673 struct adb_request *req; 674 wait_queue_t wait = __WAITQUEUE_INITIALIZER(wait,current); 675 unsigned long flags; 676 677 if (count < 2) 678 return -EINVAL; 679 if (count > sizeof(req->reply)) 680 count = sizeof(req->reply); 681 ret = verify_area(VERIFY_WRITE, buf, count); 682 if (ret) 683 return ret; 684 685 req = NULL; 686 spin_lock_irqsave(&state->lock, flags); 687 add_wait_queue(&state->wait_queue, &wait); 688 current->state = TASK_INTERRUPTIBLE; 689 690 for (;;) { 691 req = state->completed; 692 if (req != NULL) 693 state->completed = req->next; 694 else if (atomic_read(&state->n_pending) == 0) 695 ret = -EIO; 696 if (req != NULL || ret != 0) 697 break; 698 699 if (file->f_flags & O_NONBLOCK) { 700 ret = -EAGAIN; 701 break; 702 } 703 if (signal_pending(current)) { 704 ret = -ERESTARTSYS; 705 break; 706 } 707 spin_unlock_irqrestore(&state->lock, flags); 708 schedule(); 709 spin_lock_irqsave(&state->lock, flags); 710 } 711 712 current->state = TASK_RUNNING; 713 remove_wait_queue(&state->wait_queue, &wait); 714 spin_unlock_irqrestore(&state->lock, flags); 715 716 if (ret) 717 return ret; 718 719 ret = req->reply_len; 720 if (ret > count) 721 ret = count; 722 if (ret > 0 && copy_to_user(buf, req->reply, ret)) 723 ret = -EFAULT; 724 725 kfree(req); 726 return ret; 727} 728 729static ssize_t adb_write(struct file *file, const char *buf, 730 size_t count, loff_t *ppos) 731{ 732 int ret/*, i*/; 733 struct adbdev_state *state = file->private_data; 734 struct adb_request *req; 735 736 if (count < 2 || count > sizeof(req->data)) 737 return -EINVAL; 738 if (adb_controller == NULL) 739 return -ENXIO; 740 ret = verify_area(VERIFY_READ, buf, count); 741 if (ret) 742 return ret; 743 744 req = (struct adb_request *) kmalloc(sizeof(struct adb_request), 745 GFP_KERNEL); 746 if (req == NULL) 747 return -ENOMEM; 748 749 req->nbytes = count; 750 req->done = adb_write_done; 751 req->arg = (void *) state; 752 req->complete = 0; 753 754 ret = -EFAULT; 755 if (copy_from_user(req->data, buf, count)) 756 goto out; 757 758 atomic_inc(&state->n_pending); 759 760 /* If a probe is in progress or we are sleeping, wait for it to complete */ 761 down(&adb_probe_mutex); 762 763 /* Special case for ADB_BUSRESET request, all others are sent to 764 the controller */ 765 if ((req->data[0] == ADB_PACKET)&&(count > 1) 766 &&(req->data[1] == ADB_BUSRESET)) { 767 ret = do_adb_reset_bus(); 768 up(&adb_probe_mutex); 769 atomic_dec(&state->n_pending); 770 if (ret == 0) 771 ret = count; 772 goto out; 773 } else { 774 req->reply_expected = ((req->data[1] & 0xc) == 0xc); 775 if (adb_controller && adb_controller->send_request) 776 ret = adb_controller->send_request(req, 0); 777 else 778 ret = -ENXIO; 779 up(&adb_probe_mutex); 780 } 781 782 if (ret != 0) { 783 atomic_dec(&state->n_pending); 784 goto out; 785 } 786 return count; 787 788out: 789 kfree(req); 790 return ret; 791} 792 793static struct file_operations adb_fops = { 794 llseek: no_llseek, 795 read: adb_read, 796 write: adb_write, 797 open: adb_open, 798 release: adb_release, 799}; 800 801static void 802adbdev_init(void) 803{ 804 if (devfs_register_chrdev(ADB_MAJOR, "adb", &adb_fops)) 805 printk(KERN_ERR "adb: unable to get major %d\n", ADB_MAJOR); 806 else 807 devfs_register (NULL, "adb", DEVFS_FL_DEFAULT, 808 ADB_MAJOR, 0, 809 S_IFCHR | S_IRUSR | S_IWUSR, 810 &adb_fops, NULL); 811} 812