115 } serial_device_t; |
116 } serial_device_t; |
116 |
117 |
117 static serial_device_t *ser = NULL; |
118 static serial_device_t *ser = NULL; |
118 static char tx_data[] = "ATZ\r\n"; |
119 static char tx_data[] = "ATZ\r\n"; |
119 static off_t tx_off = 0; |
120 static off_t tx_off = 0; |
|
121 static ec_tty_t *tty = NULL; |
120 |
122 |
121 /*****************************************************************************/ |
123 /*****************************************************************************/ |
122 |
124 |
123 /* Slave 1, "EL6002" |
125 /* Slave 1, "EL6002" |
124 * Vendor ID: 0x00000002 |
126 * Vendor ID: 0x00000002 |
442 ec_slave_config_t *sc; |
444 ec_slave_config_t *sc; |
443 |
445 |
444 printk(KERN_INFO PFX "Starting...\n"); |
446 printk(KERN_INFO PFX "Starting...\n"); |
445 |
447 |
446 ser = kmalloc(sizeof(*ser), GFP_KERNEL); |
448 ser = kmalloc(sizeof(*ser), GFP_KERNEL); |
447 if (ser == NULL) { |
449 if (!ser) { |
448 printk(KERN_ERR PFX "Failed to allocate serial device object.\n"); |
450 printk(KERN_ERR PFX "Failed to allocate serial device object.\n"); |
449 return -ENOMEM; |
451 ret = -ENOMEM; |
450 } |
452 goto out_return; |
|
453 } |
|
454 |
451 ret = serial_init(ser, 22, 22); |
455 ret = serial_init(ser, 22, 22); |
452 if (ret) { |
456 if (ret) { |
453 printk(KERN_ERR PFX "Failed to init serial device object.\n"); |
457 printk(KERN_ERR PFX "Failed to init serial device object.\n"); |
454 return ret; |
458 goto out_free_serial; |
|
459 } |
|
460 |
|
461 tty = ectty_create(); |
|
462 if (IS_ERR(tty)) { |
|
463 printk(KERN_ERR PFX "Failed to create tty.\n"); |
|
464 ret = PTR_ERR(tty); |
|
465 goto out_serial; |
455 } |
466 } |
456 |
467 |
457 master = ecrt_request_master(0); |
468 master = ecrt_request_master(0); |
458 if (!master) { |
469 if (!master) { |
459 ret = -EBUSY; |
470 ret = -EBUSY; |
460 printk(KERN_ERR PFX "Requesting master 0 failed.\n"); |
471 printk(KERN_ERR PFX "Requesting master 0 failed.\n"); |
461 goto out_return; |
472 goto out_tty; |
462 } |
473 } |
463 |
474 |
464 init_MUTEX(&master_sem); |
475 init_MUTEX(&master_sem); |
465 ecrt_master_callbacks(master, send_callback, receive_callback, master); |
476 ecrt_master_callbacks(master, send_callback, receive_callback, master); |
466 |
477 |
527 del_timer_sync(&timer); |
544 del_timer_sync(&timer); |
528 |
545 |
529 printk(KERN_INFO PFX "Releasing master...\n"); |
546 printk(KERN_INFO PFX "Releasing master...\n"); |
530 ecrt_release_master(master); |
547 ecrt_release_master(master); |
531 |
548 |
|
549 ectty_free(tty); |
|
550 serial_clear(ser); |
|
551 kfree(ser); |
|
552 |
532 printk(KERN_INFO PFX "Unloading.\n"); |
553 printk(KERN_INFO PFX "Unloading.\n"); |
533 } |
554 } |
534 |
555 |
535 /*****************************************************************************/ |
556 /*****************************************************************************/ |
536 |
557 |