diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-09-09 21:14:47 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-09-09 21:14:47 -0400 |
commit | d344c5e0856ad03278d8700b503762dbc8b86e12 (patch) | |
tree | a6d893a643470a3c2580a58f3228a55fa1fd1d82 /drivers/char | |
parent | 010988e888a0abbe7118635c1b33d049caae6b29 (diff) | |
parent | 87fc767b832ef5a681a0ff9d203c3289bc3be2bf (diff) |
Manual merge with Linus
Diffstat (limited to 'drivers/char')
51 files changed, 1964 insertions, 2050 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 7333b41d4224..c29365d5b524 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -80,7 +80,7 @@ config SERIAL_NONSTANDARD | |||
80 | 80 | ||
81 | config COMPUTONE | 81 | config COMPUTONE |
82 | tristate "Computone IntelliPort Plus serial support" | 82 | tristate "Computone IntelliPort Plus serial support" |
83 | depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP && (BROKEN || !SPARC32) | 83 | depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP |
84 | ---help--- | 84 | ---help--- |
85 | This driver supports the entire family of Intelliport II/Plus | 85 | This driver supports the entire family of Intelliport II/Plus |
86 | controllers with the exception of the MicroChannel controllers and | 86 | controllers with the exception of the MicroChannel controllers and |
@@ -138,7 +138,7 @@ config CYZ_INTR | |||
138 | 138 | ||
139 | config DIGIEPCA | 139 | config DIGIEPCA |
140 | tristate "Digiboard Intelligent Async Support" | 140 | tristate "Digiboard Intelligent Async Support" |
141 | depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP && (!64BIT || BROKEN) | 141 | depends on SERIAL_NONSTANDARD |
142 | ---help--- | 142 | ---help--- |
143 | This is a driver for Digi International's Xx, Xeve, and Xem series | 143 | This is a driver for Digi International's Xx, Xeve, and Xem series |
144 | of cards which provide multiple serial ports. You would need | 144 | of cards which provide multiple serial ports. You would need |
@@ -208,7 +208,7 @@ config SYNCLINK | |||
208 | 208 | ||
209 | config SYNCLINKMP | 209 | config SYNCLINKMP |
210 | tristate "SyncLink Multiport support" | 210 | tristate "SyncLink Multiport support" |
211 | depends on SERIAL_NONSTANDARD && (BROKEN || !SPARC32) | 211 | depends on SERIAL_NONSTANDARD |
212 | help | 212 | help |
213 | Enable support for the SyncLink Multiport (2 or 4 ports) | 213 | Enable support for the SyncLink Multiport (2 or 4 ports) |
214 | serial adapter, running asynchronous and HDLC communications up | 214 | serial adapter, running asynchronous and HDLC communications up |
@@ -735,7 +735,7 @@ config SGI_IP27_RTC | |||
735 | 735 | ||
736 | config GEN_RTC | 736 | config GEN_RTC |
737 | tristate "Generic /dev/rtc emulation" | 737 | tristate "Generic /dev/rtc emulation" |
738 | depends on RTC!=y && !IA64 && !ARM && !PPC64 && !M32R && !SPARC32 | 738 | depends on RTC!=y && !IA64 && !ARM && !PPC64 && !M32R && !SPARC32 && !SPARC64 |
739 | ---help--- | 739 | ---help--- |
740 | If you say Y here and create a character special file /dev/rtc with | 740 | If you say Y here and create a character special file /dev/rtc with |
741 | major number 10 and minor number 135 using mknod ("man mknod"), you | 741 | major number 10 and minor number 135 using mknod ("man mknod"), you |
@@ -842,8 +842,7 @@ config SONYPI | |||
842 | 842 | ||
843 | config TANBAC_TB0219 | 843 | config TANBAC_TB0219 |
844 | tristate "TANBAC TB0219 base board support" | 844 | tristate "TANBAC TB0219 base board support" |
845 | depends TANBAC_TB0229 | 845 | depends TANBAC_TB022X |
846 | |||
847 | 846 | ||
848 | menu "Ftape, the floppy tape device driver" | 847 | menu "Ftape, the floppy tape device driver" |
849 | 848 | ||
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index 59f589d733f9..0a7624a9b1c1 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c | |||
@@ -429,7 +429,7 @@ static int __devinit uli_agp_init(struct pci_dev *pdev) | |||
429 | struct pci_dev *dev1; | 429 | struct pci_dev *dev1; |
430 | int i; | 430 | int i; |
431 | unsigned size = amd64_fetch_size(); | 431 | unsigned size = amd64_fetch_size(); |
432 | printk(KERN_INFO "Setting up ULi AGP. \n"); | 432 | printk(KERN_INFO "Setting up ULi AGP.\n"); |
433 | dev1 = pci_find_slot ((unsigned int)pdev->bus->number,PCI_DEVFN(0,0)); | 433 | dev1 = pci_find_slot ((unsigned int)pdev->bus->number,PCI_DEVFN(0,0)); |
434 | if (dev1 == NULL) { | 434 | if (dev1 == NULL) { |
435 | printk(KERN_INFO PFX "Detected a ULi chipset, " | 435 | printk(KERN_INFO PFX "Detected a ULi chipset, " |
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index f0079e991bdc..ac9da0ca36b7 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c | |||
@@ -319,7 +319,6 @@ int agp_copy_info(struct agp_bridge_data *bridge, struct agp_kern_info *info) | |||
319 | info->mode = bridge->mode & ~AGP3_RESERVED_MASK; | 319 | info->mode = bridge->mode & ~AGP3_RESERVED_MASK; |
320 | else | 320 | else |
321 | info->mode = bridge->mode & ~AGP2_RESERVED_MASK; | 321 | info->mode = bridge->mode & ~AGP2_RESERVED_MASK; |
322 | info->mode = bridge->mode; | ||
323 | info->aper_base = bridge->gart_bus_addr; | 322 | info->aper_base = bridge->gart_bus_addr; |
324 | info->aper_size = agp_return_size(); | 323 | info->aper_size = agp_return_size(); |
325 | info->max_memory = bridge->max_memory_agp; | 324 | info->max_memory = bridge->max_memory_agp; |
@@ -356,7 +355,7 @@ int agp_bind_memory(struct agp_memory *curr, off_t pg_start) | |||
356 | return -EINVAL; | 355 | return -EINVAL; |
357 | 356 | ||
358 | if (curr->is_bound == TRUE) { | 357 | if (curr->is_bound == TRUE) { |
359 | printk (KERN_INFO PFX "memory %p is already bound!\n", curr); | 358 | printk(KERN_INFO PFX "memory %p is already bound!\n", curr); |
360 | return -EINVAL; | 359 | return -EINVAL; |
361 | } | 360 | } |
362 | if (curr->is_flushed == FALSE) { | 361 | if (curr->is_flushed == FALSE) { |
@@ -391,7 +390,7 @@ int agp_unbind_memory(struct agp_memory *curr) | |||
391 | return -EINVAL; | 390 | return -EINVAL; |
392 | 391 | ||
393 | if (curr->is_bound != TRUE) { | 392 | if (curr->is_bound != TRUE) { |
394 | printk (KERN_INFO PFX "memory %p was not bound!\n", curr); | 393 | printk(KERN_INFO PFX "memory %p was not bound!\n", curr); |
395 | return -EINVAL; | 394 | return -EINVAL; |
396 | } | 395 | } |
397 | 396 | ||
@@ -415,7 +414,7 @@ static void agp_v2_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ | |||
415 | u32 tmp; | 414 | u32 tmp; |
416 | 415 | ||
417 | if (*requested_mode & AGP2_RESERVED_MASK) { | 416 | if (*requested_mode & AGP2_RESERVED_MASK) { |
418 | printk (KERN_INFO PFX "reserved bits set in mode 0x%x. Fixed.\n", *requested_mode); | 417 | printk(KERN_INFO PFX "reserved bits set in mode 0x%x. Fixed.\n", *requested_mode); |
419 | *requested_mode &= ~AGP2_RESERVED_MASK; | 418 | *requested_mode &= ~AGP2_RESERVED_MASK; |
420 | } | 419 | } |
421 | 420 | ||
@@ -423,7 +422,7 @@ static void agp_v2_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ | |||
423 | tmp = *requested_mode & 7; | 422 | tmp = *requested_mode & 7; |
424 | switch (tmp) { | 423 | switch (tmp) { |
425 | case 0: | 424 | case 0: |
426 | printk (KERN_INFO PFX "%s tried to set rate=x0. Setting to x1 mode.\n", current->comm); | 425 | printk(KERN_INFO PFX "%s tried to set rate=x0. Setting to x1 mode.\n", current->comm); |
427 | *requested_mode |= AGPSTAT2_1X; | 426 | *requested_mode |= AGPSTAT2_1X; |
428 | break; | 427 | break; |
429 | case 1: | 428 | case 1: |
@@ -493,18 +492,18 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ | |||
493 | u32 tmp; | 492 | u32 tmp; |
494 | 493 | ||
495 | if (*requested_mode & AGP3_RESERVED_MASK) { | 494 | if (*requested_mode & AGP3_RESERVED_MASK) { |
496 | printk (KERN_INFO PFX "reserved bits set in mode 0x%x. Fixed.\n", *requested_mode); | 495 | printk(KERN_INFO PFX "reserved bits set in mode 0x%x. Fixed.\n", *requested_mode); |
497 | *requested_mode &= ~AGP3_RESERVED_MASK; | 496 | *requested_mode &= ~AGP3_RESERVED_MASK; |
498 | } | 497 | } |
499 | 498 | ||
500 | /* Check the speed bits make sense. */ | 499 | /* Check the speed bits make sense. */ |
501 | tmp = *requested_mode & 7; | 500 | tmp = *requested_mode & 7; |
502 | if (tmp == 0) { | 501 | if (tmp == 0) { |
503 | printk (KERN_INFO PFX "%s tried to set rate=x0. Setting to AGP3 x4 mode.\n", current->comm); | 502 | printk(KERN_INFO PFX "%s tried to set rate=x0. Setting to AGP3 x4 mode.\n", current->comm); |
504 | *requested_mode |= AGPSTAT3_4X; | 503 | *requested_mode |= AGPSTAT3_4X; |
505 | } | 504 | } |
506 | if (tmp >= 3) { | 505 | if (tmp >= 3) { |
507 | printk (KERN_INFO PFX "%s tried to set rate=x%d. Setting to AGP3 x8 mode.\n", current->comm, tmp * 4); | 506 | printk(KERN_INFO PFX "%s tried to set rate=x%d. Setting to AGP3 x8 mode.\n", current->comm, tmp * 4); |
508 | *requested_mode = (*requested_mode & ~7) | AGPSTAT3_8X; | 507 | *requested_mode = (*requested_mode & ~7) | AGPSTAT3_8X; |
509 | } | 508 | } |
510 | 509 | ||
@@ -533,7 +532,7 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ | |||
533 | * AGP2.x 4x -> AGP3.0 4x. | 532 | * AGP2.x 4x -> AGP3.0 4x. |
534 | */ | 533 | */ |
535 | if (*requested_mode & AGPSTAT2_4X) { | 534 | if (*requested_mode & AGPSTAT2_4X) { |
536 | printk (KERN_INFO PFX "%s passes broken AGP3 flags (%x). Fixed.\n", | 535 | printk(KERN_INFO PFX "%s passes broken AGP3 flags (%x). Fixed.\n", |
537 | current->comm, *requested_mode); | 536 | current->comm, *requested_mode); |
538 | *requested_mode &= ~AGPSTAT2_4X; | 537 | *requested_mode &= ~AGPSTAT2_4X; |
539 | *requested_mode |= AGPSTAT3_4X; | 538 | *requested_mode |= AGPSTAT3_4X; |
@@ -544,7 +543,7 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ | |||
544 | * but have been passed an AGP 2.x mode. | 543 | * but have been passed an AGP 2.x mode. |
545 | * Convert AGP 1x,2x,4x -> AGP 3.0 4x. | 544 | * Convert AGP 1x,2x,4x -> AGP 3.0 4x. |
546 | */ | 545 | */ |
547 | printk (KERN_INFO PFX "%s passes broken AGP2 flags (%x) in AGP3 mode. Fixed.\n", | 546 | printk(KERN_INFO PFX "%s passes broken AGP2 flags (%x) in AGP3 mode. Fixed.\n", |
548 | current->comm, *requested_mode); | 547 | current->comm, *requested_mode); |
549 | *requested_mode &= ~(AGPSTAT2_4X | AGPSTAT2_2X | AGPSTAT2_1X); | 548 | *requested_mode &= ~(AGPSTAT2_4X | AGPSTAT2_2X | AGPSTAT2_1X); |
550 | *requested_mode |= AGPSTAT3_4X; | 549 | *requested_mode |= AGPSTAT3_4X; |
@@ -554,13 +553,13 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ | |||
554 | if (!(*bridge_agpstat & AGPSTAT3_8X)) { | 553 | if (!(*bridge_agpstat & AGPSTAT3_8X)) { |
555 | *bridge_agpstat &= ~(AGPSTAT3_8X | AGPSTAT3_RSVD); | 554 | *bridge_agpstat &= ~(AGPSTAT3_8X | AGPSTAT3_RSVD); |
556 | *bridge_agpstat |= AGPSTAT3_4X; | 555 | *bridge_agpstat |= AGPSTAT3_4X; |
557 | printk ("%s requested AGPx8 but bridge not capable.\n", current->comm); | 556 | printk(KERN_INFO PFX "%s requested AGPx8 but bridge not capable.\n", current->comm); |
558 | return; | 557 | return; |
559 | } | 558 | } |
560 | if (!(*vga_agpstat & AGPSTAT3_8X)) { | 559 | if (!(*vga_agpstat & AGPSTAT3_8X)) { |
561 | *bridge_agpstat &= ~(AGPSTAT3_8X | AGPSTAT3_RSVD); | 560 | *bridge_agpstat &= ~(AGPSTAT3_8X | AGPSTAT3_RSVD); |
562 | *bridge_agpstat |= AGPSTAT3_4X; | 561 | *bridge_agpstat |= AGPSTAT3_4X; |
563 | printk ("%s requested AGPx8 but graphic card not capable.\n", current->comm); | 562 | printk(KERN_INFO PFX "%s requested AGPx8 but graphic card not capable.\n", current->comm); |
564 | return; | 563 | return; |
565 | } | 564 | } |
566 | /* All set, bridge & device can do AGP x8*/ | 565 | /* All set, bridge & device can do AGP x8*/ |
@@ -578,13 +577,13 @@ static void agp_v3_parse_one(u32 *requested_mode, u32 *bridge_agpstat, u32 *vga_ | |||
578 | if ((*bridge_agpstat & AGPSTAT3_4X) && (*vga_agpstat & AGPSTAT3_4X)) | 577 | if ((*bridge_agpstat & AGPSTAT3_4X) && (*vga_agpstat & AGPSTAT3_4X)) |
579 | *bridge_agpstat |= AGPSTAT3_4X; | 578 | *bridge_agpstat |= AGPSTAT3_4X; |
580 | else { | 579 | else { |
581 | printk (KERN_INFO PFX "Badness. Don't know which AGP mode to set. " | 580 | printk(KERN_INFO PFX "Badness. Don't know which AGP mode to set. " |
582 | "[bridge_agpstat:%x vga_agpstat:%x fell back to:- bridge_agpstat:%x vga_agpstat:%x]\n", | 581 | "[bridge_agpstat:%x vga_agpstat:%x fell back to:- bridge_agpstat:%x vga_agpstat:%x]\n", |
583 | origbridge, origvga, *bridge_agpstat, *vga_agpstat); | 582 | origbridge, origvga, *bridge_agpstat, *vga_agpstat); |
584 | if (!(*bridge_agpstat & AGPSTAT3_4X)) | 583 | if (!(*bridge_agpstat & AGPSTAT3_4X)) |
585 | printk (KERN_INFO PFX "Bridge couldn't do AGP x4.\n"); | 584 | printk(KERN_INFO PFX "Bridge couldn't do AGP x4.\n"); |
586 | if (!(*vga_agpstat & AGPSTAT3_4X)) | 585 | if (!(*vga_agpstat & AGPSTAT3_4X)) |
587 | printk (KERN_INFO PFX "Graphic card couldn't do AGP x4.\n"); | 586 | printk(KERN_INFO PFX "Graphic card couldn't do AGP x4.\n"); |
588 | return; | 587 | return; |
589 | } | 588 | } |
590 | } | 589 | } |
@@ -622,7 +621,7 @@ u32 agp_collect_device_status(struct agp_bridge_data *bridge, u32 requested_mode | |||
622 | for (;;) { | 621 | for (;;) { |
623 | device = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, device); | 622 | device = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, device); |
624 | if (!device) { | 623 | if (!device) { |
625 | printk (KERN_INFO PFX "Couldn't find an AGP VGA controller.\n"); | 624 | printk(KERN_INFO PFX "Couldn't find an AGP VGA controller.\n"); |
626 | return 0; | 625 | return 0; |
627 | } | 626 | } |
628 | cap_ptr = pci_find_capability(device, PCI_CAP_ID_AGP); | 627 | cap_ptr = pci_find_capability(device, PCI_CAP_ID_AGP); |
@@ -734,7 +733,7 @@ void agp_generic_enable(struct agp_bridge_data *bridge, u32 requested_mode) | |||
734 | pci_write_config_dword(bridge->dev, | 733 | pci_write_config_dword(bridge->dev, |
735 | bridge->capndx+AGPCTRL, temp); | 734 | bridge->capndx+AGPCTRL, temp); |
736 | 735 | ||
737 | printk (KERN_INFO PFX "Device is in legacy mode," | 736 | printk(KERN_INFO PFX "Device is in legacy mode," |
738 | " falling back to 2.x\n"); | 737 | " falling back to 2.x\n"); |
739 | } | 738 | } |
740 | } | 739 | } |
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 6a5337bf0936..cf4c3648463d 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c | |||
@@ -865,7 +865,7 @@ static void cyz_poll(unsigned long); | |||
865 | static long cyz_polling_cycle = CZ_DEF_POLL; | 865 | static long cyz_polling_cycle = CZ_DEF_POLL; |
866 | 866 | ||
867 | static int cyz_timeron = 0; | 867 | static int cyz_timeron = 0; |
868 | static struct timer_list cyz_timerlist = TIMER_INITIALIZER(cyz_poll, 0, 0); | 868 | static DEFINE_TIMER(cyz_timerlist, cyz_poll, 0, 0); |
869 | 869 | ||
870 | #else /* CONFIG_CYZ_INTR */ | 870 | #else /* CONFIG_CYZ_INTR */ |
871 | static void cyz_rx_restart(unsigned long); | 871 | static void cyz_rx_restart(unsigned long); |
diff --git a/drivers/char/digi1.h b/drivers/char/digi1.h index 184378d23f8c..94d4eab5d3ca 100644 --- a/drivers/char/digi1.h +++ b/drivers/char/digi1.h | |||
@@ -1,46 +1,46 @@ | |||
1 | /* Definitions for DigiBoard ditty(1) command. */ | 1 | /* Definitions for DigiBoard ditty(1) command. */ |
2 | 2 | ||
3 | #if !defined(TIOCMODG) | 3 | #if !defined(TIOCMODG) |
4 | #define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */ | 4 | #define TIOCMODG (('d'<<8) | 250) /* get modem ctrl state */ |
5 | #define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */ | 5 | #define TIOCMODS (('d'<<8) | 251) /* set modem ctrl state */ |
6 | #endif | 6 | #endif |
7 | 7 | ||
8 | #if !defined(TIOCMSET) | 8 | #if !defined(TIOCMSET) |
9 | #define TIOCMSET ('d'<<8) | 252 /* set modem ctrl state */ | 9 | #define TIOCMSET (('d'<<8) | 252) /* set modem ctrl state */ |
10 | #define TIOCMGET ('d'<<8) | 253 /* set modem ctrl state */ | 10 | #define TIOCMGET (('d'<<8) | 253) /* set modem ctrl state */ |
11 | #endif | 11 | #endif |
12 | 12 | ||
13 | #if !defined(TIOCMBIC) | 13 | #if !defined(TIOCMBIC) |
14 | #define TIOCMBIC ('d'<<8) | 254 /* set modem ctrl state */ | 14 | #define TIOCMBIC (('d'<<8) | 254) /* set modem ctrl state */ |
15 | #define TIOCMBIS ('d'<<8) | 255 /* set modem ctrl state */ | 15 | #define TIOCMBIS (('d'<<8) | 255) /* set modem ctrl state */ |
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | #if !defined(TIOCSDTR) | 18 | #if !defined(TIOCSDTR) |
19 | #define TIOCSDTR ('e'<<8) | 0 /* set DTR */ | 19 | #define TIOCSDTR (('e'<<8) | 0) /* set DTR */ |
20 | #define TIOCCDTR ('e'<<8) | 1 /* clear DTR */ | 20 | #define TIOCCDTR (('e'<<8) | 1) /* clear DTR */ |
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | /************************************************************************ | 23 | /************************************************************************ |
24 | * Ioctl command arguments for DIGI parameters. | 24 | * Ioctl command arguments for DIGI parameters. |
25 | ************************************************************************/ | 25 | ************************************************************************/ |
26 | #define DIGI_GETA ('e'<<8) | 94 /* Read params */ | 26 | #define DIGI_GETA (('e'<<8) | 94) /* Read params */ |
27 | 27 | ||
28 | #define DIGI_SETA ('e'<<8) | 95 /* Set params */ | 28 | #define DIGI_SETA (('e'<<8) | 95) /* Set params */ |
29 | #define DIGI_SETAW ('e'<<8) | 96 /* Drain & set params */ | 29 | #define DIGI_SETAW (('e'<<8) | 96) /* Drain & set params */ |
30 | #define DIGI_SETAF ('e'<<8) | 97 /* Drain, flush & set params */ | 30 | #define DIGI_SETAF (('e'<<8) | 97) /* Drain, flush & set params */ |
31 | 31 | ||
32 | #define DIGI_GETFLOW ('e'<<8) | 99 /* Get startc/stopc flow */ | 32 | #define DIGI_GETFLOW (('e'<<8) | 99) /* Get startc/stopc flow */ |
33 | /* control characters */ | 33 | /* control characters */ |
34 | #define DIGI_SETFLOW ('e'<<8) | 100 /* Set startc/stopc flow */ | 34 | #define DIGI_SETFLOW (('e'<<8) | 100) /* Set startc/stopc flow */ |
35 | /* control characters */ | 35 | /* control characters */ |
36 | #define DIGI_GETAFLOW ('e'<<8) | 101 /* Get Aux. startc/stopc */ | 36 | #define DIGI_GETAFLOW (('e'<<8) | 101) /* Get Aux. startc/stopc */ |
37 | /* flow control chars */ | 37 | /* flow control chars */ |
38 | #define DIGI_SETAFLOW ('e'<<8) | 102 /* Set Aux. startc/stopc */ | 38 | #define DIGI_SETAFLOW (('e'<<8) | 102) /* Set Aux. startc/stopc */ |
39 | /* flow control chars */ | 39 | /* flow control chars */ |
40 | 40 | ||
41 | #define DIGI_GETINFO ('e'<<8) | 103 /* Fill in digi_info */ | 41 | #define DIGI_GETINFO (('e'<<8) | 103) /* Fill in digi_info */ |
42 | #define DIGI_POLLER ('e'<<8) | 104 /* Turn on/off poller */ | 42 | #define DIGI_POLLER (('e'<<8) | 104) /* Turn on/off poller */ |
43 | #define DIGI_INIT ('e'<<8) | 105 /* Allow things to run. */ | 43 | #define DIGI_INIT (('e'<<8) | 105) /* Allow things to run. */ |
44 | 44 | ||
45 | struct digiflow_struct | 45 | struct digiflow_struct |
46 | { | 46 | { |
diff --git a/drivers/char/digiFep1.h b/drivers/char/digiFep1.h index c47d7fcb8400..3c1f1922c798 100644 --- a/drivers/char/digiFep1.h +++ b/drivers/char/digiFep1.h | |||
@@ -13,88 +13,88 @@ | |||
13 | 13 | ||
14 | struct global_data | 14 | struct global_data |
15 | { | 15 | { |
16 | volatile ushort cin; | 16 | u16 cin; |
17 | volatile ushort cout; | 17 | u16 cout; |
18 | volatile ushort cstart; | 18 | u16 cstart; |
19 | volatile ushort cmax; | 19 | u16 cmax; |
20 | volatile ushort ein; | 20 | u16 ein; |
21 | volatile ushort eout; | 21 | u16 eout; |
22 | volatile ushort istart; | 22 | u16 istart; |
23 | volatile ushort imax; | 23 | u16 imax; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | 26 | ||
27 | struct board_chan | 27 | struct board_chan |
28 | { | 28 | { |
29 | int filler1; | 29 | u32 filler1; |
30 | int filler2; | 30 | u32 filler2; |
31 | volatile ushort tseg; | 31 | u16 tseg; |
32 | volatile ushort tin; | 32 | u16 tin; |
33 | volatile ushort tout; | 33 | u16 tout; |
34 | volatile ushort tmax; | 34 | u16 tmax; |
35 | 35 | ||
36 | volatile ushort rseg; | 36 | u16 rseg; |
37 | volatile ushort rin; | 37 | u16 rin; |
38 | volatile ushort rout; | 38 | u16 rout; |
39 | volatile ushort rmax; | 39 | u16 rmax; |
40 | 40 | ||
41 | volatile ushort tlow; | 41 | u16 tlow; |
42 | volatile ushort rlow; | 42 | u16 rlow; |
43 | volatile ushort rhigh; | 43 | u16 rhigh; |
44 | volatile ushort incr; | 44 | u16 incr; |
45 | 45 | ||
46 | volatile ushort etime; | 46 | u16 etime; |
47 | volatile ushort edelay; | 47 | u16 edelay; |
48 | volatile unchar *dev; | 48 | unchar *dev; |
49 | 49 | ||
50 | volatile ushort iflag; | 50 | u16 iflag; |
51 | volatile ushort oflag; | 51 | u16 oflag; |
52 | volatile ushort cflag; | 52 | u16 cflag; |
53 | volatile ushort gmask; | 53 | u16 gmask; |
54 | 54 | ||
55 | volatile ushort col; | 55 | u16 col; |
56 | volatile ushort delay; | 56 | u16 delay; |
57 | volatile ushort imask; | 57 | u16 imask; |
58 | volatile ushort tflush; | 58 | u16 tflush; |
59 | 59 | ||
60 | int filler3; | 60 | u32 filler3; |
61 | int filler4; | 61 | u32 filler4; |
62 | int filler5; | 62 | u32 filler5; |
63 | int filler6; | 63 | u32 filler6; |
64 | 64 | ||
65 | volatile unchar num; | 65 | u8 num; |
66 | volatile unchar ract; | 66 | u8 ract; |
67 | volatile unchar bstat; | 67 | u8 bstat; |
68 | volatile unchar tbusy; | 68 | u8 tbusy; |
69 | volatile unchar iempty; | 69 | u8 iempty; |
70 | volatile unchar ilow; | 70 | u8 ilow; |
71 | volatile unchar idata; | 71 | u8 idata; |
72 | volatile unchar eflag; | 72 | u8 eflag; |
73 | 73 | ||
74 | volatile unchar tflag; | 74 | u8 tflag; |
75 | volatile unchar rflag; | 75 | u8 rflag; |
76 | volatile unchar xmask; | 76 | u8 xmask; |
77 | volatile unchar xval; | 77 | u8 xval; |
78 | volatile unchar mstat; | 78 | u8 mstat; |
79 | volatile unchar mchange; | 79 | u8 mchange; |
80 | volatile unchar mint; | 80 | u8 mint; |
81 | volatile unchar lstat; | 81 | u8 lstat; |
82 | 82 | ||
83 | volatile unchar mtran; | 83 | u8 mtran; |
84 | volatile unchar orun; | 84 | u8 orun; |
85 | volatile unchar startca; | 85 | u8 startca; |
86 | volatile unchar stopca; | 86 | u8 stopca; |
87 | volatile unchar startc; | 87 | u8 startc; |
88 | volatile unchar stopc; | 88 | u8 stopc; |
89 | volatile unchar vnext; | 89 | u8 vnext; |
90 | volatile unchar hflow; | 90 | u8 hflow; |
91 | 91 | ||
92 | volatile unchar fillc; | 92 | u8 fillc; |
93 | volatile unchar ochar; | 93 | u8 ochar; |
94 | volatile unchar omask; | 94 | u8 omask; |
95 | 95 | ||
96 | unchar filler7; | 96 | u8 filler7; |
97 | unchar filler8[28]; | 97 | u8 filler8[28]; |
98 | }; | 98 | }; |
99 | 99 | ||
100 | 100 | ||
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h index 6f98701dfe15..121cc85f347e 100644 --- a/drivers/char/drm/drmP.h +++ b/drivers/char/drm/drmP.h | |||
@@ -1071,5 +1071,9 @@ extern void *drm_calloc(size_t nmemb, size_t size, int area); | |||
1071 | extern unsigned long drm_core_get_map_ofs(drm_map_t *map); | 1071 | extern unsigned long drm_core_get_map_ofs(drm_map_t *map); |
1072 | extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); | 1072 | extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); |
1073 | 1073 | ||
1074 | #ifndef pci_pretty_name | ||
1075 | #define pci_pretty_name(dev) "" | ||
1076 | #endif | ||
1077 | |||
1074 | #endif /* __KERNEL__ */ | 1078 | #endif /* __KERNEL__ */ |
1075 | #endif | 1079 | #endif |
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c index e0743ebbe4bd..f28e70ae6606 100644 --- a/drivers/char/drm/drm_bufs.c +++ b/drivers/char/drm/drm_bufs.c | |||
@@ -48,8 +48,8 @@ unsigned long drm_get_resource_len(drm_device_t *dev, unsigned int resource) | |||
48 | } | 48 | } |
49 | EXPORT_SYMBOL(drm_get_resource_len); | 49 | EXPORT_SYMBOL(drm_get_resource_len); |
50 | 50 | ||
51 | static drm_local_map_t *drm_find_matching_map(drm_device_t *dev, | 51 | static drm_map_list_t *drm_find_matching_map(drm_device_t *dev, |
52 | drm_local_map_t *map) | 52 | drm_local_map_t *map) |
53 | { | 53 | { |
54 | struct list_head *list; | 54 | struct list_head *list; |
55 | 55 | ||
@@ -57,7 +57,7 @@ static drm_local_map_t *drm_find_matching_map(drm_device_t *dev, | |||
57 | drm_map_list_t *entry = list_entry(list, drm_map_list_t, head); | 57 | drm_map_list_t *entry = list_entry(list, drm_map_list_t, head); |
58 | if (entry->map && map->type == entry->map->type && | 58 | if (entry->map && map->type == entry->map->type && |
59 | entry->map->offset == map->offset) { | 59 | entry->map->offset == map->offset) { |
60 | return entry->map; | 60 | return entry; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
@@ -114,14 +114,13 @@ static __inline__ unsigned int HandleID(unsigned long lhandle, drm_device_t *dev | |||
114 | * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where | 114 | * type. Adds the map to the map list drm_device::maplist. Adds MTRR's where |
115 | * applicable and if supported by the kernel. | 115 | * applicable and if supported by the kernel. |
116 | */ | 116 | */ |
117 | int drm_addmap(drm_device_t * dev, unsigned int offset, | 117 | int drm_addmap_core(drm_device_t * dev, unsigned int offset, |
118 | unsigned int size, drm_map_type_t type, | 118 | unsigned int size, drm_map_type_t type, |
119 | drm_map_flags_t flags, drm_local_map_t ** map_ptr) | 119 | drm_map_flags_t flags, drm_map_list_t **maplist) |
120 | { | 120 | { |
121 | drm_map_t *map; | 121 | drm_map_t *map; |
122 | drm_map_list_t *list; | 122 | drm_map_list_t *list; |
123 | drm_dma_handle_t *dmah; | 123 | drm_dma_handle_t *dmah; |
124 | drm_local_map_t *found_map; | ||
125 | 124 | ||
126 | map = drm_alloc( sizeof(*map), DRM_MEM_MAPS ); | 125 | map = drm_alloc( sizeof(*map), DRM_MEM_MAPS ); |
127 | if ( !map ) | 126 | if ( !map ) |
@@ -166,17 +165,17 @@ int drm_addmap(drm_device_t * dev, unsigned int offset, | |||
166 | * needing to be aware of it. Therefore, we just return success | 165 | * needing to be aware of it. Therefore, we just return success |
167 | * when the server tries to create a duplicate map. | 166 | * when the server tries to create a duplicate map. |
168 | */ | 167 | */ |
169 | found_map = drm_find_matching_map(dev, map); | 168 | list = drm_find_matching_map(dev, map); |
170 | if (found_map != NULL) { | 169 | if (list != NULL) { |
171 | if (found_map->size != map->size) { | 170 | if (list->map->size != map->size) { |
172 | DRM_DEBUG("Matching maps of type %d with " | 171 | DRM_DEBUG("Matching maps of type %d with " |
173 | "mismatched sizes, (%ld vs %ld)\n", | 172 | "mismatched sizes, (%ld vs %ld)\n", |
174 | map->type, map->size, found_map->size); | 173 | map->type, map->size, list->map->size); |
175 | found_map->size = map->size; | 174 | list->map->size = map->size; |
176 | } | 175 | } |
177 | 176 | ||
178 | drm_free(map, sizeof(*map), DRM_MEM_MAPS); | 177 | drm_free(map, sizeof(*map), DRM_MEM_MAPS); |
179 | *map_ptr = found_map; | 178 | *maplist = list; |
180 | return 0; | 179 | return 0; |
181 | } | 180 | } |
182 | 181 | ||
@@ -264,9 +263,22 @@ int drm_addmap(drm_device_t * dev, unsigned int offset, | |||
264 | : map->offset, dev); | 263 | : map->offset, dev); |
265 | up(&dev->struct_sem); | 264 | up(&dev->struct_sem); |
266 | 265 | ||
267 | *map_ptr = map; | 266 | *maplist = list; |
268 | return 0; | 267 | return 0; |
269 | } | 268 | } |
269 | |||
270 | int drm_addmap(drm_device_t *dev, unsigned int offset, | ||
271 | unsigned int size, drm_map_type_t type, | ||
272 | drm_map_flags_t flags, drm_local_map_t **map_ptr) | ||
273 | { | ||
274 | drm_map_list_t *list; | ||
275 | int rc; | ||
276 | |||
277 | rc = drm_addmap_core(dev, offset, size, type, flags, &list); | ||
278 | if (!rc) | ||
279 | *map_ptr = list->map; | ||
280 | return rc; | ||
281 | } | ||
270 | EXPORT_SYMBOL(drm_addmap); | 282 | EXPORT_SYMBOL(drm_addmap); |
271 | 283 | ||
272 | int drm_addmap_ioctl(struct inode *inode, struct file *filp, | 284 | int drm_addmap_ioctl(struct inode *inode, struct file *filp, |
@@ -275,10 +287,9 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp, | |||
275 | drm_file_t *priv = filp->private_data; | 287 | drm_file_t *priv = filp->private_data; |
276 | drm_device_t *dev = priv->head->dev; | 288 | drm_device_t *dev = priv->head->dev; |
277 | drm_map_t map; | 289 | drm_map_t map; |
278 | drm_map_t *map_ptr; | 290 | drm_map_list_t *maplist; |
279 | drm_map_t __user *argp = (void __user *)arg; | 291 | drm_map_t __user *argp = (void __user *)arg; |
280 | int err; | 292 | int err; |
281 | unsigned long handle = 0; | ||
282 | 293 | ||
283 | if (!(filp->f_mode & 3)) | 294 | if (!(filp->f_mode & 3)) |
284 | return -EACCES; /* Require read/write */ | 295 | return -EACCES; /* Require read/write */ |
@@ -287,26 +298,15 @@ int drm_addmap_ioctl(struct inode *inode, struct file *filp, | |||
287 | return -EFAULT; | 298 | return -EFAULT; |
288 | } | 299 | } |
289 | 300 | ||
290 | err = drm_addmap(dev, map.offset, map.size, map.type, map.flags, | 301 | err = drm_addmap_core(dev, map.offset, map.size, map.type, map.flags, |
291 | &map_ptr); | 302 | &maplist); |
292 | 303 | ||
293 | if (err) { | 304 | if (err) |
294 | return err; | 305 | return err; |
295 | } | ||
296 | |||
297 | { | ||
298 | drm_map_list_t *_entry; | ||
299 | list_for_each_entry(_entry, &dev->maplist->head, head) { | ||
300 | if (_entry->map == map_ptr) | ||
301 | handle = _entry->user_token; | ||
302 | } | ||
303 | if (!handle) | ||
304 | return -EFAULT; | ||
305 | } | ||
306 | 306 | ||
307 | if (copy_to_user(argp, map_ptr, sizeof(*map_ptr))) | 307 | if (copy_to_user(argp, maplist->map, sizeof(drm_map_t))) |
308 | return -EFAULT; | 308 | return -EFAULT; |
309 | if (put_user(handle, &argp->handle)) | 309 | if (put_user(maplist->user_token, &argp->handle)) |
310 | return -EFAULT; | 310 | return -EFAULT; |
311 | return 0; | 311 | return 0; |
312 | } | 312 | } |
@@ -1041,7 +1041,7 @@ static int drm_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request) | |||
1041 | return 0; | 1041 | return 0; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | int drm_addbufs_fb(drm_device_t *dev, drm_buf_desc_t *request) | 1044 | static int drm_addbufs_fb(drm_device_t *dev, drm_buf_desc_t *request) |
1045 | { | 1045 | { |
1046 | drm_device_dma_t *dma = dev->dma; | 1046 | drm_device_dma_t *dma = dev->dma; |
1047 | drm_buf_entry_t *entry; | 1047 | drm_buf_entry_t *entry; |
diff --git a/drivers/char/drm/drm_context.c b/drivers/char/drm/drm_context.c index f515567e5b6f..502892794c16 100644 --- a/drivers/char/drm/drm_context.c +++ b/drivers/char/drm/drm_context.c | |||
@@ -308,7 +308,7 @@ found: | |||
308 | * | 308 | * |
309 | * Attempt to set drm_device::context_flag. | 309 | * Attempt to set drm_device::context_flag. |
310 | */ | 310 | */ |
311 | int drm_context_switch( drm_device_t *dev, int old, int new ) | 311 | static int drm_context_switch( drm_device_t *dev, int old, int new ) |
312 | { | 312 | { |
313 | if ( test_and_set_bit( 0, &dev->context_flag ) ) { | 313 | if ( test_and_set_bit( 0, &dev->context_flag ) ) { |
314 | DRM_ERROR( "Reentering -- FIXME\n" ); | 314 | DRM_ERROR( "Reentering -- FIXME\n" ); |
diff --git a/drivers/char/drm/drm_sysfs.c b/drivers/char/drm/drm_sysfs.c index 2fc10c4bbcdf..475cc5e555e1 100644 --- a/drivers/char/drm/drm_sysfs.c +++ b/drivers/char/drm/drm_sysfs.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/err.h> | 17 | #include <linux/err.h> |
18 | 18 | ||
19 | #include "drm_core.h" | 19 | #include "drm_core.h" |
20 | #include "drmP.h" | ||
20 | 21 | ||
21 | struct drm_sysfs_class { | 22 | struct drm_sysfs_class { |
22 | struct class_device_attribute attr; | 23 | struct class_device_attribute attr; |
diff --git a/drivers/char/drm/mga_dma.c b/drivers/char/drm/mga_dma.c index 567b425b784f..fc7d4a594bca 100644 --- a/drivers/char/drm/mga_dma.c +++ b/drivers/char/drm/mga_dma.c | |||
@@ -417,6 +417,7 @@ int mga_driver_preinit(drm_device_t *dev, unsigned long flags) | |||
417 | return 0; | 417 | return 0; |
418 | } | 418 | } |
419 | 419 | ||
420 | #if __OS_HAS_AGP | ||
420 | /** | 421 | /** |
421 | * Bootstrap the driver for AGP DMA. | 422 | * Bootstrap the driver for AGP DMA. |
422 | * | 423 | * |
@@ -560,6 +561,13 @@ static int mga_do_agp_dma_bootstrap(drm_device_t * dev, | |||
560 | DRM_INFO("Initialized card for AGP DMA.\n"); | 561 | DRM_INFO("Initialized card for AGP DMA.\n"); |
561 | return 0; | 562 | return 0; |
562 | } | 563 | } |
564 | #else | ||
565 | static int mga_do_agp_dma_bootstrap(drm_device_t * dev, | ||
566 | drm_mga_dma_bootstrap_t * dma_bs) | ||
567 | { | ||
568 | return -EINVAL; | ||
569 | } | ||
570 | #endif | ||
563 | 571 | ||
564 | /** | 572 | /** |
565 | * Bootstrap the driver for PCI DMA. | 573 | * Bootstrap the driver for PCI DMA. |
@@ -697,7 +705,6 @@ static int mga_do_dma_bootstrap(drm_device_t * dev, | |||
697 | * carve off portions of it for internal uses. The remaining memory | 705 | * carve off portions of it for internal uses. The remaining memory |
698 | * is returned to user-mode to be used for AGP textures. | 706 | * is returned to user-mode to be used for AGP textures. |
699 | */ | 707 | */ |
700 | |||
701 | if (is_agp) { | 708 | if (is_agp) { |
702 | err = mga_do_agp_dma_bootstrap(dev, dma_bs); | 709 | err = mga_do_agp_dma_bootstrap(dev, dma_bs); |
703 | } | 710 | } |
@@ -932,6 +939,7 @@ static int mga_do_cleanup_dma( drm_device_t *dev ) | |||
932 | drm_core_ioremapfree(dev->agp_buffer_map, dev); | 939 | drm_core_ioremapfree(dev->agp_buffer_map, dev); |
933 | 940 | ||
934 | if (dev_priv->used_new_dma_init) { | 941 | if (dev_priv->used_new_dma_init) { |
942 | #if __OS_HAS_AGP | ||
935 | if (dev_priv->agp_mem != NULL) { | 943 | if (dev_priv->agp_mem != NULL) { |
936 | dev_priv->agp_textures = NULL; | 944 | dev_priv->agp_textures = NULL; |
937 | drm_unbind_agp(dev_priv->agp_mem); | 945 | drm_unbind_agp(dev_priv->agp_mem); |
@@ -944,7 +952,7 @@ static int mga_do_cleanup_dma( drm_device_t *dev ) | |||
944 | if ((dev->agp != NULL) && dev->agp->acquired) { | 952 | if ((dev->agp != NULL) && dev->agp->acquired) { |
945 | err = drm_agp_release(dev); | 953 | err = drm_agp_release(dev); |
946 | } | 954 | } |
947 | 955 | #endif | |
948 | dev_priv->used_new_dma_init = 0; | 956 | dev_priv->used_new_dma_init = 0; |
949 | } | 957 | } |
950 | 958 | ||
@@ -965,7 +973,7 @@ static int mga_do_cleanup_dma( drm_device_t *dev ) | |||
965 | } | 973 | } |
966 | } | 974 | } |
967 | 975 | ||
968 | return 0; | 976 | return err; |
969 | } | 977 | } |
970 | 978 | ||
971 | int mga_dma_init( DRM_IOCTL_ARGS ) | 979 | int mga_dma_init( DRM_IOCTL_ARGS ) |
diff --git a/drivers/char/epca.c b/drivers/char/epca.c index 6025e1866c7e..58d3738a2b7f 100644 --- a/drivers/char/epca.c +++ b/drivers/char/epca.c | |||
@@ -6,6 +6,8 @@ | |||
6 | For technical support please email digiLinux@dgii.com or | 6 | For technical support please email digiLinux@dgii.com or |
7 | call Digi tech support at (612) 912-3456 | 7 | call Digi tech support at (612) 912-3456 |
8 | 8 | ||
9 | ** This driver is no longer supported by Digi ** | ||
10 | |||
9 | Much of this design and code came from epca.c which was | 11 | Much of this design and code came from epca.c which was |
10 | copyright (C) 1994, 1995 Troy De Jongh, and subsquently | 12 | copyright (C) 1994, 1995 Troy De Jongh, and subsquently |
11 | modified by David Nugent, Christoph Lameter, Mike McLagan. | 13 | modified by David Nugent, Christoph Lameter, Mike McLagan. |
@@ -43,31 +45,19 @@ | |||
43 | #include <linux/interrupt.h> | 45 | #include <linux/interrupt.h> |
44 | #include <asm/uaccess.h> | 46 | #include <asm/uaccess.h> |
45 | #include <asm/io.h> | 47 | #include <asm/io.h> |
46 | 48 | #include <linux/spinlock.h> | |
47 | #ifdef CONFIG_PCI | ||
48 | #define ENABLE_PCI | ||
49 | #endif /* CONFIG_PCI */ | ||
50 | |||
51 | #define putUser(arg1, arg2) put_user(arg1, (unsigned long __user *)arg2) | ||
52 | #define getUser(arg1, arg2) get_user(arg1, (unsigned __user *)arg2) | ||
53 | |||
54 | #ifdef ENABLE_PCI | ||
55 | #include <linux/pci.h> | 49 | #include <linux/pci.h> |
56 | #include "digiPCI.h" | 50 | #include "digiPCI.h" |
57 | #endif /* ENABLE_PCI */ | 51 | |
58 | 52 | ||
59 | #include "digi1.h" | 53 | #include "digi1.h" |
60 | #include "digiFep1.h" | 54 | #include "digiFep1.h" |
61 | #include "epca.h" | 55 | #include "epca.h" |
62 | #include "epcaconfig.h" | 56 | #include "epcaconfig.h" |
63 | 57 | ||
64 | #if BITS_PER_LONG != 32 | ||
65 | # error FIXME: this driver only works on 32-bit platforms | ||
66 | #endif | ||
67 | |||
68 | /* ---------------------- Begin defines ------------------------ */ | 58 | /* ---------------------- Begin defines ------------------------ */ |
69 | 59 | ||
70 | #define VERSION "1.3.0.1-LK" | 60 | #define VERSION "1.3.0.1-LK2.6" |
71 | 61 | ||
72 | /* This major needs to be submitted to Linux to join the majors list */ | 62 | /* This major needs to be submitted to Linux to join the majors list */ |
73 | 63 | ||
@@ -81,13 +71,17 @@ | |||
81 | 71 | ||
82 | /* ----------------- Begin global definitions ------------------- */ | 72 | /* ----------------- Begin global definitions ------------------- */ |
83 | 73 | ||
84 | static char mesg[100]; | ||
85 | static int nbdevs, num_cards, liloconfig; | 74 | static int nbdevs, num_cards, liloconfig; |
86 | static int digi_poller_inhibited = 1 ; | 75 | static int digi_poller_inhibited = 1 ; |
87 | 76 | ||
88 | static int setup_error_code; | 77 | static int setup_error_code; |
89 | static int invalid_lilo_config; | 78 | static int invalid_lilo_config; |
90 | 79 | ||
80 | /* The ISA boards do window flipping into the same spaces so its only sane | ||
81 | with a single lock. It's still pretty efficient */ | ||
82 | |||
83 | static spinlock_t epca_lock = SPIN_LOCK_UNLOCKED; | ||
84 | |||
91 | /* ----------------------------------------------------------------------- | 85 | /* ----------------------------------------------------------------------- |
92 | MAXBOARDS is typically 12, but ISA and EISA cards are restricted to | 86 | MAXBOARDS is typically 12, but ISA and EISA cards are restricted to |
93 | 7 below. | 87 | 7 below. |
@@ -129,58 +123,58 @@ static struct timer_list epca_timer; | |||
129 | configured. | 123 | configured. |
130 | ----------------------------------------------------------------------- */ | 124 | ----------------------------------------------------------------------- */ |
131 | 125 | ||
132 | static inline void memwinon(struct board_info *b, unsigned int win); | 126 | static void memwinon(struct board_info *b, unsigned int win); |
133 | static inline void memwinoff(struct board_info *b, unsigned int win); | 127 | static void memwinoff(struct board_info *b, unsigned int win); |
134 | static inline void globalwinon(struct channel *ch); | 128 | static void globalwinon(struct channel *ch); |
135 | static inline void rxwinon(struct channel *ch); | 129 | static void rxwinon(struct channel *ch); |
136 | static inline void txwinon(struct channel *ch); | 130 | static void txwinon(struct channel *ch); |
137 | static inline void memoff(struct channel *ch); | 131 | static void memoff(struct channel *ch); |
138 | static inline void assertgwinon(struct channel *ch); | 132 | static void assertgwinon(struct channel *ch); |
139 | static inline void assertmemoff(struct channel *ch); | 133 | static void assertmemoff(struct channel *ch); |
140 | 134 | ||
141 | /* ---- Begin more 'specific' memory functions for cx_like products --- */ | 135 | /* ---- Begin more 'specific' memory functions for cx_like products --- */ |
142 | 136 | ||
143 | static inline void pcxem_memwinon(struct board_info *b, unsigned int win); | 137 | static void pcxem_memwinon(struct board_info *b, unsigned int win); |
144 | static inline void pcxem_memwinoff(struct board_info *b, unsigned int win); | 138 | static void pcxem_memwinoff(struct board_info *b, unsigned int win); |
145 | static inline void pcxem_globalwinon(struct channel *ch); | 139 | static void pcxem_globalwinon(struct channel *ch); |
146 | static inline void pcxem_rxwinon(struct channel *ch); | 140 | static void pcxem_rxwinon(struct channel *ch); |
147 | static inline void pcxem_txwinon(struct channel *ch); | 141 | static void pcxem_txwinon(struct channel *ch); |
148 | static inline void pcxem_memoff(struct channel *ch); | 142 | static void pcxem_memoff(struct channel *ch); |
149 | 143 | ||
150 | /* ------ Begin more 'specific' memory functions for the pcxe ------- */ | 144 | /* ------ Begin more 'specific' memory functions for the pcxe ------- */ |
151 | 145 | ||
152 | static inline void pcxe_memwinon(struct board_info *b, unsigned int win); | 146 | static void pcxe_memwinon(struct board_info *b, unsigned int win); |
153 | static inline void pcxe_memwinoff(struct board_info *b, unsigned int win); | 147 | static void pcxe_memwinoff(struct board_info *b, unsigned int win); |
154 | static inline void pcxe_globalwinon(struct channel *ch); | 148 | static void pcxe_globalwinon(struct channel *ch); |
155 | static inline void pcxe_rxwinon(struct channel *ch); | 149 | static void pcxe_rxwinon(struct channel *ch); |
156 | static inline void pcxe_txwinon(struct channel *ch); | 150 | static void pcxe_txwinon(struct channel *ch); |
157 | static inline void pcxe_memoff(struct channel *ch); | 151 | static void pcxe_memoff(struct channel *ch); |
158 | 152 | ||
159 | /* ---- Begin more 'specific' memory functions for the pc64xe and pcxi ---- */ | 153 | /* ---- Begin more 'specific' memory functions for the pc64xe and pcxi ---- */ |
160 | /* Note : pc64xe and pcxi share the same windowing routines */ | 154 | /* Note : pc64xe and pcxi share the same windowing routines */ |
161 | 155 | ||
162 | static inline void pcxi_memwinon(struct board_info *b, unsigned int win); | 156 | static void pcxi_memwinon(struct board_info *b, unsigned int win); |
163 | static inline void pcxi_memwinoff(struct board_info *b, unsigned int win); | 157 | static void pcxi_memwinoff(struct board_info *b, unsigned int win); |
164 | static inline void pcxi_globalwinon(struct channel *ch); | 158 | static void pcxi_globalwinon(struct channel *ch); |
165 | static inline void pcxi_rxwinon(struct channel *ch); | 159 | static void pcxi_rxwinon(struct channel *ch); |
166 | static inline void pcxi_txwinon(struct channel *ch); | 160 | static void pcxi_txwinon(struct channel *ch); |
167 | static inline void pcxi_memoff(struct channel *ch); | 161 | static void pcxi_memoff(struct channel *ch); |
168 | 162 | ||
169 | /* - Begin 'specific' do nothing memory functions needed for some cards - */ | 163 | /* - Begin 'specific' do nothing memory functions needed for some cards - */ |
170 | 164 | ||
171 | static inline void dummy_memwinon(struct board_info *b, unsigned int win); | 165 | static void dummy_memwinon(struct board_info *b, unsigned int win); |
172 | static inline void dummy_memwinoff(struct board_info *b, unsigned int win); | 166 | static void dummy_memwinoff(struct board_info *b, unsigned int win); |
173 | static inline void dummy_globalwinon(struct channel *ch); | 167 | static void dummy_globalwinon(struct channel *ch); |
174 | static inline void dummy_rxwinon(struct channel *ch); | 168 | static void dummy_rxwinon(struct channel *ch); |
175 | static inline void dummy_txwinon(struct channel *ch); | 169 | static void dummy_txwinon(struct channel *ch); |
176 | static inline void dummy_memoff(struct channel *ch); | 170 | static void dummy_memoff(struct channel *ch); |
177 | static inline void dummy_assertgwinon(struct channel *ch); | 171 | static void dummy_assertgwinon(struct channel *ch); |
178 | static inline void dummy_assertmemoff(struct channel *ch); | 172 | static void dummy_assertmemoff(struct channel *ch); |
179 | 173 | ||
180 | /* ------------------- Begin declare functions ----------------------- */ | 174 | /* ------------------- Begin declare functions ----------------------- */ |
181 | 175 | ||
182 | static inline struct channel *verifyChannel(register struct tty_struct *); | 176 | static struct channel *verifyChannel(struct tty_struct *); |
183 | static inline void pc_sched_event(struct channel *, int); | 177 | static void pc_sched_event(struct channel *, int); |
184 | static void epca_error(int, char *); | 178 | static void epca_error(int, char *); |
185 | static void pc_close(struct tty_struct *, struct file *); | 179 | static void pc_close(struct tty_struct *, struct file *); |
186 | static void shutdown(struct channel *); | 180 | static void shutdown(struct channel *); |
@@ -215,15 +209,11 @@ static void pc_unthrottle(struct tty_struct *tty); | |||
215 | static void digi_send_break(struct channel *ch, int msec); | 209 | static void digi_send_break(struct channel *ch, int msec); |
216 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch); | 210 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch); |
217 | void epca_setup(char *, int *); | 211 | void epca_setup(char *, int *); |
218 | void console_print(const char *); | ||
219 | 212 | ||
220 | static int get_termio(struct tty_struct *, struct termio __user *); | 213 | static int get_termio(struct tty_struct *, struct termio __user *); |
221 | static int pc_write(struct tty_struct *, const unsigned char *, int); | 214 | static int pc_write(struct tty_struct *, const unsigned char *, int); |
222 | int pc_init(void); | 215 | static int pc_init(void); |
223 | |||
224 | #ifdef ENABLE_PCI | ||
225 | static int init_PCI(void); | 216 | static int init_PCI(void); |
226 | #endif /* ENABLE_PCI */ | ||
227 | 217 | ||
228 | 218 | ||
229 | /* ------------------------------------------------------------------ | 219 | /* ------------------------------------------------------------------ |
@@ -237,41 +227,41 @@ static int init_PCI(void); | |||
237 | making direct calls deserves what they get. | 227 | making direct calls deserves what they get. |
238 | -------------------------------------------------------------------- */ | 228 | -------------------------------------------------------------------- */ |
239 | 229 | ||
240 | static inline void memwinon(struct board_info *b, unsigned int win) | 230 | static void memwinon(struct board_info *b, unsigned int win) |
241 | { | 231 | { |
242 | (b->memwinon)(b, win); | 232 | (b->memwinon)(b, win); |
243 | } | 233 | } |
244 | 234 | ||
245 | static inline void memwinoff(struct board_info *b, unsigned int win) | 235 | static void memwinoff(struct board_info *b, unsigned int win) |
246 | { | 236 | { |
247 | (b->memwinoff)(b, win); | 237 | (b->memwinoff)(b, win); |
248 | } | 238 | } |
249 | 239 | ||
250 | static inline void globalwinon(struct channel *ch) | 240 | static void globalwinon(struct channel *ch) |
251 | { | 241 | { |
252 | (ch->board->globalwinon)(ch); | 242 | (ch->board->globalwinon)(ch); |
253 | } | 243 | } |
254 | 244 | ||
255 | static inline void rxwinon(struct channel *ch) | 245 | static void rxwinon(struct channel *ch) |
256 | { | 246 | { |
257 | (ch->board->rxwinon)(ch); | 247 | (ch->board->rxwinon)(ch); |
258 | } | 248 | } |
259 | 249 | ||
260 | static inline void txwinon(struct channel *ch) | 250 | static void txwinon(struct channel *ch) |
261 | { | 251 | { |
262 | (ch->board->txwinon)(ch); | 252 | (ch->board->txwinon)(ch); |
263 | } | 253 | } |
264 | 254 | ||
265 | static inline void memoff(struct channel *ch) | 255 | static void memoff(struct channel *ch) |
266 | { | 256 | { |
267 | (ch->board->memoff)(ch); | 257 | (ch->board->memoff)(ch); |
268 | } | 258 | } |
269 | static inline void assertgwinon(struct channel *ch) | 259 | static void assertgwinon(struct channel *ch) |
270 | { | 260 | { |
271 | (ch->board->assertgwinon)(ch); | 261 | (ch->board->assertgwinon)(ch); |
272 | } | 262 | } |
273 | 263 | ||
274 | static inline void assertmemoff(struct channel *ch) | 264 | static void assertmemoff(struct channel *ch) |
275 | { | 265 | { |
276 | (ch->board->assertmemoff)(ch); | 266 | (ch->board->assertmemoff)(ch); |
277 | } | 267 | } |
@@ -281,66 +271,66 @@ static inline void assertmemoff(struct channel *ch) | |||
281 | and CX series cards. | 271 | and CX series cards. |
282 | ------------------------------------------------------------ */ | 272 | ------------------------------------------------------------ */ |
283 | 273 | ||
284 | static inline void pcxem_memwinon(struct board_info *b, unsigned int win) | 274 | static void pcxem_memwinon(struct board_info *b, unsigned int win) |
285 | { | 275 | { |
286 | outb_p(FEPWIN|win, (int)b->port + 1); | 276 | outb_p(FEPWIN|win, b->port + 1); |
287 | } | 277 | } |
288 | 278 | ||
289 | static inline void pcxem_memwinoff(struct board_info *b, unsigned int win) | 279 | static void pcxem_memwinoff(struct board_info *b, unsigned int win) |
290 | { | 280 | { |
291 | outb_p(0, (int)b->port + 1); | 281 | outb_p(0, b->port + 1); |
292 | } | 282 | } |
293 | 283 | ||
294 | static inline void pcxem_globalwinon(struct channel *ch) | 284 | static void pcxem_globalwinon(struct channel *ch) |
295 | { | 285 | { |
296 | outb_p( FEPWIN, (int)ch->board->port + 1); | 286 | outb_p( FEPWIN, (int)ch->board->port + 1); |
297 | } | 287 | } |
298 | 288 | ||
299 | static inline void pcxem_rxwinon(struct channel *ch) | 289 | static void pcxem_rxwinon(struct channel *ch) |
300 | { | 290 | { |
301 | outb_p(ch->rxwin, (int)ch->board->port + 1); | 291 | outb_p(ch->rxwin, (int)ch->board->port + 1); |
302 | } | 292 | } |
303 | 293 | ||
304 | static inline void pcxem_txwinon(struct channel *ch) | 294 | static void pcxem_txwinon(struct channel *ch) |
305 | { | 295 | { |
306 | outb_p(ch->txwin, (int)ch->board->port + 1); | 296 | outb_p(ch->txwin, (int)ch->board->port + 1); |
307 | } | 297 | } |
308 | 298 | ||
309 | static inline void pcxem_memoff(struct channel *ch) | 299 | static void pcxem_memoff(struct channel *ch) |
310 | { | 300 | { |
311 | outb_p(0, (int)ch->board->port + 1); | 301 | outb_p(0, (int)ch->board->port + 1); |
312 | } | 302 | } |
313 | 303 | ||
314 | /* ----------------- Begin pcxe memory window stuff ------------------ */ | 304 | /* ----------------- Begin pcxe memory window stuff ------------------ */ |
315 | 305 | ||
316 | static inline void pcxe_memwinon(struct board_info *b, unsigned int win) | 306 | static void pcxe_memwinon(struct board_info *b, unsigned int win) |
317 | { | 307 | { |
318 | outb_p(FEPWIN | win, (int)b->port + 1); | 308 | outb_p(FEPWIN | win, b->port + 1); |
319 | } | 309 | } |
320 | 310 | ||
321 | static inline void pcxe_memwinoff(struct board_info *b, unsigned int win) | 311 | static void pcxe_memwinoff(struct board_info *b, unsigned int win) |
322 | { | 312 | { |
323 | outb_p(inb((int)b->port) & ~FEPMEM, | 313 | outb_p(inb(b->port) & ~FEPMEM, |
324 | (int)b->port + 1); | 314 | b->port + 1); |
325 | outb_p(0, (int)b->port + 1); | 315 | outb_p(0, b->port + 1); |
326 | } | 316 | } |
327 | 317 | ||
328 | static inline void pcxe_globalwinon(struct channel *ch) | 318 | static void pcxe_globalwinon(struct channel *ch) |
329 | { | 319 | { |
330 | outb_p( FEPWIN, (int)ch->board->port + 1); | 320 | outb_p( FEPWIN, (int)ch->board->port + 1); |
331 | } | 321 | } |
332 | 322 | ||
333 | static inline void pcxe_rxwinon(struct channel *ch) | 323 | static void pcxe_rxwinon(struct channel *ch) |
334 | { | 324 | { |
335 | outb_p(ch->rxwin, (int)ch->board->port + 1); | 325 | outb_p(ch->rxwin, (int)ch->board->port + 1); |
336 | } | 326 | } |
337 | 327 | ||
338 | static inline void pcxe_txwinon(struct channel *ch) | 328 | static void pcxe_txwinon(struct channel *ch) |
339 | { | 329 | { |
340 | outb_p(ch->txwin, (int)ch->board->port + 1); | 330 | outb_p(ch->txwin, (int)ch->board->port + 1); |
341 | } | 331 | } |
342 | 332 | ||
343 | static inline void pcxe_memoff(struct channel *ch) | 333 | static void pcxe_memoff(struct channel *ch) |
344 | { | 334 | { |
345 | outb_p(0, (int)ch->board->port); | 335 | outb_p(0, (int)ch->board->port); |
346 | outb_p(0, (int)ch->board->port + 1); | 336 | outb_p(0, (int)ch->board->port + 1); |
@@ -348,44 +338,44 @@ static inline void pcxe_memoff(struct channel *ch) | |||
348 | 338 | ||
349 | /* ------------- Begin pc64xe and pcxi memory window stuff -------------- */ | 339 | /* ------------- Begin pc64xe and pcxi memory window stuff -------------- */ |
350 | 340 | ||
351 | static inline void pcxi_memwinon(struct board_info *b, unsigned int win) | 341 | static void pcxi_memwinon(struct board_info *b, unsigned int win) |
352 | { | 342 | { |
353 | outb_p(inb((int)b->port) | FEPMEM, (int)b->port); | 343 | outb_p(inb(b->port) | FEPMEM, b->port); |
354 | } | 344 | } |
355 | 345 | ||
356 | static inline void pcxi_memwinoff(struct board_info *b, unsigned int win) | 346 | static void pcxi_memwinoff(struct board_info *b, unsigned int win) |
357 | { | 347 | { |
358 | outb_p(inb((int)b->port) & ~FEPMEM, (int)b->port); | 348 | outb_p(inb(b->port) & ~FEPMEM, b->port); |
359 | } | 349 | } |
360 | 350 | ||
361 | static inline void pcxi_globalwinon(struct channel *ch) | 351 | static void pcxi_globalwinon(struct channel *ch) |
362 | { | 352 | { |
363 | outb_p(FEPMEM, (int)ch->board->port); | 353 | outb_p(FEPMEM, ch->board->port); |
364 | } | 354 | } |
365 | 355 | ||
366 | static inline void pcxi_rxwinon(struct channel *ch) | 356 | static void pcxi_rxwinon(struct channel *ch) |
367 | { | 357 | { |
368 | outb_p(FEPMEM, (int)ch->board->port); | 358 | outb_p(FEPMEM, ch->board->port); |
369 | } | 359 | } |
370 | 360 | ||
371 | static inline void pcxi_txwinon(struct channel *ch) | 361 | static void pcxi_txwinon(struct channel *ch) |
372 | { | 362 | { |
373 | outb_p(FEPMEM, (int)ch->board->port); | 363 | outb_p(FEPMEM, ch->board->port); |
374 | } | 364 | } |
375 | 365 | ||
376 | static inline void pcxi_memoff(struct channel *ch) | 366 | static void pcxi_memoff(struct channel *ch) |
377 | { | 367 | { |
378 | outb_p(0, (int)ch->board->port); | 368 | outb_p(0, ch->board->port); |
379 | } | 369 | } |
380 | 370 | ||
381 | static inline void pcxi_assertgwinon(struct channel *ch) | 371 | static void pcxi_assertgwinon(struct channel *ch) |
382 | { | 372 | { |
383 | epcaassert(inb((int)ch->board->port) & FEPMEM, "Global memory off"); | 373 | epcaassert(inb(ch->board->port) & FEPMEM, "Global memory off"); |
384 | } | 374 | } |
385 | 375 | ||
386 | static inline void pcxi_assertmemoff(struct channel *ch) | 376 | static void pcxi_assertmemoff(struct channel *ch) |
387 | { | 377 | { |
388 | epcaassert(!(inb((int)ch->board->port) & FEPMEM), "Memory on"); | 378 | epcaassert(!(inb(ch->board->port) & FEPMEM), "Memory on"); |
389 | } | 379 | } |
390 | 380 | ||
391 | 381 | ||
@@ -398,185 +388,143 @@ static inline void pcxi_assertmemoff(struct channel *ch) | |||
398 | may or may not do anything. | 388 | may or may not do anything. |
399 | ---------------------------------------------------------------------------*/ | 389 | ---------------------------------------------------------------------------*/ |
400 | 390 | ||
401 | static inline void dummy_memwinon(struct board_info *b, unsigned int win) | 391 | static void dummy_memwinon(struct board_info *b, unsigned int win) |
402 | { | 392 | { |
403 | } | 393 | } |
404 | 394 | ||
405 | static inline void dummy_memwinoff(struct board_info *b, unsigned int win) | 395 | static void dummy_memwinoff(struct board_info *b, unsigned int win) |
406 | { | 396 | { |
407 | } | 397 | } |
408 | 398 | ||
409 | static inline void dummy_globalwinon(struct channel *ch) | 399 | static void dummy_globalwinon(struct channel *ch) |
410 | { | 400 | { |
411 | } | 401 | } |
412 | 402 | ||
413 | static inline void dummy_rxwinon(struct channel *ch) | 403 | static void dummy_rxwinon(struct channel *ch) |
414 | { | 404 | { |
415 | } | 405 | } |
416 | 406 | ||
417 | static inline void dummy_txwinon(struct channel *ch) | 407 | static void dummy_txwinon(struct channel *ch) |
418 | { | 408 | { |
419 | } | 409 | } |
420 | 410 | ||
421 | static inline void dummy_memoff(struct channel *ch) | 411 | static void dummy_memoff(struct channel *ch) |
422 | { | 412 | { |
423 | } | 413 | } |
424 | 414 | ||
425 | static inline void dummy_assertgwinon(struct channel *ch) | 415 | static void dummy_assertgwinon(struct channel *ch) |
426 | { | 416 | { |
427 | } | 417 | } |
428 | 418 | ||
429 | static inline void dummy_assertmemoff(struct channel *ch) | 419 | static void dummy_assertmemoff(struct channel *ch) |
430 | { | 420 | { |
431 | } | 421 | } |
432 | 422 | ||
433 | /* ----------------- Begin verifyChannel function ----------------------- */ | 423 | /* ----------------- Begin verifyChannel function ----------------------- */ |
434 | static inline struct channel *verifyChannel(register struct tty_struct *tty) | 424 | static struct channel *verifyChannel(struct tty_struct *tty) |
435 | { /* Begin verifyChannel */ | 425 | { /* Begin verifyChannel */ |
436 | |||
437 | /* -------------------------------------------------------------------- | 426 | /* -------------------------------------------------------------------- |
438 | This routine basically provides a sanity check. It insures that | 427 | This routine basically provides a sanity check. It insures that |
439 | the channel returned is within the proper range of addresses as | 428 | the channel returned is within the proper range of addresses as |
440 | well as properly initialized. If some bogus info gets passed in | 429 | well as properly initialized. If some bogus info gets passed in |
441 | through tty->driver_data this should catch it. | 430 | through tty->driver_data this should catch it. |
442 | --------------------------------------------------------------------- */ | 431 | --------------------------------------------------------------------- */ |
443 | 432 | if (tty) { | |
444 | if (tty) | 433 | struct channel *ch = (struct channel *)tty->driver_data; |
445 | { /* Begin if tty */ | 434 | if ((ch >= &digi_channels[0]) && (ch < &digi_channels[nbdevs])) { |
446 | |||
447 | register struct channel *ch = (struct channel *)tty->driver_data; | ||
448 | |||
449 | if ((ch >= &digi_channels[0]) && (ch < &digi_channels[nbdevs])) | ||
450 | { | ||
451 | if (ch->magic == EPCA_MAGIC) | 435 | if (ch->magic == EPCA_MAGIC) |
452 | return ch; | 436 | return ch; |
453 | } | 437 | } |
454 | 438 | } | |
455 | } /* End if tty */ | ||
456 | |||
457 | /* Else return a NULL for invalid */ | ||
458 | return NULL; | 439 | return NULL; |
459 | 440 | ||
460 | } /* End verifyChannel */ | 441 | } /* End verifyChannel */ |
461 | 442 | ||
462 | /* ------------------ Begin pc_sched_event ------------------------- */ | 443 | /* ------------------ Begin pc_sched_event ------------------------- */ |
463 | 444 | ||
464 | static inline void pc_sched_event(struct channel *ch, int event) | 445 | static void pc_sched_event(struct channel *ch, int event) |
465 | { /* Begin pc_sched_event */ | 446 | { |
466 | |||
467 | |||
468 | /* ---------------------------------------------------------------------- | 447 | /* ---------------------------------------------------------------------- |
469 | We call this to schedule interrupt processing on some event. The | 448 | We call this to schedule interrupt processing on some event. The |
470 | kernel sees our request and calls the related routine in OUR driver. | 449 | kernel sees our request and calls the related routine in OUR driver. |
471 | -------------------------------------------------------------------------*/ | 450 | -------------------------------------------------------------------------*/ |
472 | |||
473 | ch->event |= 1 << event; | 451 | ch->event |= 1 << event; |
474 | schedule_work(&ch->tqueue); | 452 | schedule_work(&ch->tqueue); |
475 | |||
476 | |||
477 | } /* End pc_sched_event */ | 453 | } /* End pc_sched_event */ |
478 | 454 | ||
479 | /* ------------------ Begin epca_error ------------------------- */ | 455 | /* ------------------ Begin epca_error ------------------------- */ |
480 | 456 | ||
481 | static void epca_error(int line, char *msg) | 457 | static void epca_error(int line, char *msg) |
482 | { /* Begin epca_error */ | 458 | { |
483 | |||
484 | printk(KERN_ERR "epca_error (Digi): line = %d %s\n",line,msg); | 459 | printk(KERN_ERR "epca_error (Digi): line = %d %s\n",line,msg); |
485 | return; | 460 | } |
486 | |||
487 | } /* End epca_error */ | ||
488 | 461 | ||
489 | /* ------------------ Begin pc_close ------------------------- */ | 462 | /* ------------------ Begin pc_close ------------------------- */ |
490 | static void pc_close(struct tty_struct * tty, struct file * filp) | 463 | static void pc_close(struct tty_struct * tty, struct file * filp) |
491 | { /* Begin pc_close */ | 464 | { |
492 | |||
493 | struct channel *ch; | 465 | struct channel *ch; |
494 | unsigned long flags; | 466 | unsigned long flags; |
495 | |||
496 | /* --------------------------------------------------------- | 467 | /* --------------------------------------------------------- |
497 | verifyChannel returns the channel from the tty struct | 468 | verifyChannel returns the channel from the tty struct |
498 | if it is valid. This serves as a sanity check. | 469 | if it is valid. This serves as a sanity check. |
499 | ------------------------------------------------------------- */ | 470 | ------------------------------------------------------------- */ |
500 | 471 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if ch != NULL */ | |
501 | if ((ch = verifyChannel(tty)) != NULL) | 472 | spin_lock_irqsave(&epca_lock, flags); |
502 | { /* Begin if ch != NULL */ | 473 | if (tty_hung_up_p(filp)) { |
503 | 474 | spin_unlock_irqrestore(&epca_lock, flags); | |
504 | save_flags(flags); | ||
505 | cli(); | ||
506 | |||
507 | if (tty_hung_up_p(filp)) | ||
508 | { | ||
509 | restore_flags(flags); | ||
510 | return; | 475 | return; |
511 | } | 476 | } |
512 | |||
513 | /* Check to see if the channel is open more than once */ | 477 | /* Check to see if the channel is open more than once */ |
514 | if (ch->count-- > 1) | 478 | if (ch->count-- > 1) { |
515 | { /* Begin channel is open more than once */ | 479 | /* Begin channel is open more than once */ |
516 | |||
517 | /* ------------------------------------------------------------- | 480 | /* ------------------------------------------------------------- |
518 | Return without doing anything. Someone might still be using | 481 | Return without doing anything. Someone might still be using |
519 | the channel. | 482 | the channel. |
520 | ---------------------------------------------------------------- */ | 483 | ---------------------------------------------------------------- */ |
521 | 484 | spin_unlock_irqrestore(&epca_lock, flags); | |
522 | restore_flags(flags); | ||
523 | return; | 485 | return; |
524 | } /* End channel is open more than once */ | 486 | } /* End channel is open more than once */ |
525 | 487 | ||
526 | /* Port open only once go ahead with shutdown & reset */ | 488 | /* Port open only once go ahead with shutdown & reset */ |
527 | 489 | if (ch->count < 0) | |
528 | if (ch->count < 0) | 490 | BUG(); |
529 | { | ||
530 | ch->count = 0; | ||
531 | } | ||
532 | 491 | ||
533 | /* --------------------------------------------------------------- | 492 | /* --------------------------------------------------------------- |
534 | Let the rest of the driver know the channel is being closed. | 493 | Let the rest of the driver know the channel is being closed. |
535 | This becomes important if an open is attempted before close | 494 | This becomes important if an open is attempted before close |
536 | is finished. | 495 | is finished. |
537 | ------------------------------------------------------------------ */ | 496 | ------------------------------------------------------------------ */ |
538 | |||
539 | ch->asyncflags |= ASYNC_CLOSING; | 497 | ch->asyncflags |= ASYNC_CLOSING; |
540 | |||
541 | tty->closing = 1; | 498 | tty->closing = 1; |
542 | 499 | ||
543 | if (ch->asyncflags & ASYNC_INITIALIZED) | 500 | spin_unlock_irqrestore(&epca_lock, flags); |
544 | { | 501 | |
502 | if (ch->asyncflags & ASYNC_INITIALIZED) { | ||
545 | /* Setup an event to indicate when the transmit buffer empties */ | 503 | /* Setup an event to indicate when the transmit buffer empties */ |
546 | setup_empty_event(tty, ch); | 504 | setup_empty_event(tty, ch); |
547 | tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ | 505 | tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ |
548 | } | 506 | } |
549 | |||
550 | if (tty->driver->flush_buffer) | 507 | if (tty->driver->flush_buffer) |
551 | tty->driver->flush_buffer(tty); | 508 | tty->driver->flush_buffer(tty); |
552 | 509 | ||
553 | tty_ldisc_flush(tty); | 510 | tty_ldisc_flush(tty); |
554 | shutdown(ch); | 511 | shutdown(ch); |
512 | |||
513 | spin_lock_irqsave(&epca_lock, flags); | ||
555 | tty->closing = 0; | 514 | tty->closing = 0; |
556 | ch->event = 0; | 515 | ch->event = 0; |
557 | ch->tty = NULL; | 516 | ch->tty = NULL; |
517 | spin_unlock_irqrestore(&epca_lock, flags); | ||
558 | 518 | ||
559 | if (ch->blocked_open) | 519 | if (ch->blocked_open) { /* Begin if blocked_open */ |
560 | { /* Begin if blocked_open */ | ||
561 | |||
562 | if (ch->close_delay) | 520 | if (ch->close_delay) |
563 | { | ||
564 | msleep_interruptible(jiffies_to_msecs(ch->close_delay)); | 521 | msleep_interruptible(jiffies_to_msecs(ch->close_delay)); |
565 | } | ||
566 | |||
567 | wake_up_interruptible(&ch->open_wait); | 522 | wake_up_interruptible(&ch->open_wait); |
568 | |||
569 | } /* End if blocked_open */ | 523 | } /* End if blocked_open */ |
570 | |||
571 | ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED | | 524 | ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED | |
572 | ASYNC_CLOSING); | 525 | ASYNC_CLOSING); |
573 | wake_up_interruptible(&ch->close_wait); | 526 | wake_up_interruptible(&ch->close_wait); |
574 | |||
575 | |||
576 | restore_flags(flags); | ||
577 | |||
578 | } /* End if ch != NULL */ | 527 | } /* End if ch != NULL */ |
579 | |||
580 | } /* End pc_close */ | 528 | } /* End pc_close */ |
581 | 529 | ||
582 | /* ------------------ Begin shutdown ------------------------- */ | 530 | /* ------------------ Begin shutdown ------------------------- */ |
@@ -586,15 +534,14 @@ static void shutdown(struct channel *ch) | |||
586 | 534 | ||
587 | unsigned long flags; | 535 | unsigned long flags; |
588 | struct tty_struct *tty; | 536 | struct tty_struct *tty; |
589 | volatile struct board_chan *bc; | 537 | struct board_chan *bc; |
590 | 538 | ||
591 | if (!(ch->asyncflags & ASYNC_INITIALIZED)) | 539 | if (!(ch->asyncflags & ASYNC_INITIALIZED)) |
592 | return; | 540 | return; |
593 | 541 | ||
594 | save_flags(flags); | 542 | spin_lock_irqsave(&epca_lock, flags); |
595 | cli(); | ||
596 | globalwinon(ch); | ||
597 | 543 | ||
544 | globalwinon(ch); | ||
598 | bc = ch->brdchan; | 545 | bc = ch->brdchan; |
599 | 546 | ||
600 | /* ------------------------------------------------------------------ | 547 | /* ------------------------------------------------------------------ |
@@ -604,20 +551,17 @@ static void shutdown(struct channel *ch) | |||
604 | --------------------------------------------------------------------- */ | 551 | --------------------------------------------------------------------- */ |
605 | 552 | ||
606 | if (bc) | 553 | if (bc) |
607 | bc->idata = 0; | 554 | writeb(0, &bc->idata); |
608 | |||
609 | tty = ch->tty; | 555 | tty = ch->tty; |
610 | 556 | ||
611 | /* ---------------------------------------------------------------- | 557 | /* ---------------------------------------------------------------- |
612 | If we're a modem control device and HUPCL is on, drop RTS & DTR. | 558 | If we're a modem control device and HUPCL is on, drop RTS & DTR. |
613 | ------------------------------------------------------------------ */ | 559 | ------------------------------------------------------------------ */ |
614 | 560 | ||
615 | if (tty->termios->c_cflag & HUPCL) | 561 | if (tty->termios->c_cflag & HUPCL) { |
616 | { | ||
617 | ch->omodem &= ~(ch->m_rts | ch->m_dtr); | 562 | ch->omodem &= ~(ch->m_rts | ch->m_dtr); |
618 | fepcmd(ch, SETMODEM, 0, ch->m_dtr | ch->m_rts, 10, 1); | 563 | fepcmd(ch, SETMODEM, 0, ch->m_dtr | ch->m_rts, 10, 1); |
619 | } | 564 | } |
620 | |||
621 | memoff(ch); | 565 | memoff(ch); |
622 | 566 | ||
623 | /* ------------------------------------------------------------------ | 567 | /* ------------------------------------------------------------------ |
@@ -628,7 +572,7 @@ static void shutdown(struct channel *ch) | |||
628 | /* Prevent future Digi programmed interrupts from coming active */ | 572 | /* Prevent future Digi programmed interrupts from coming active */ |
629 | 573 | ||
630 | ch->asyncflags &= ~ASYNC_INITIALIZED; | 574 | ch->asyncflags &= ~ASYNC_INITIALIZED; |
631 | restore_flags(flags); | 575 | spin_unlock_irqrestore(&epca_lock, flags); |
632 | 576 | ||
633 | } /* End shutdown */ | 577 | } /* End shutdown */ |
634 | 578 | ||
@@ -636,7 +580,6 @@ static void shutdown(struct channel *ch) | |||
636 | 580 | ||
637 | static void pc_hangup(struct tty_struct *tty) | 581 | static void pc_hangup(struct tty_struct *tty) |
638 | { /* Begin pc_hangup */ | 582 | { /* Begin pc_hangup */ |
639 | |||
640 | struct channel *ch; | 583 | struct channel *ch; |
641 | 584 | ||
642 | /* --------------------------------------------------------- | 585 | /* --------------------------------------------------------- |
@@ -644,25 +587,21 @@ static void pc_hangup(struct tty_struct *tty) | |||
644 | if it is valid. This serves as a sanity check. | 587 | if it is valid. This serves as a sanity check. |
645 | ------------------------------------------------------------- */ | 588 | ------------------------------------------------------------- */ |
646 | 589 | ||
647 | if ((ch = verifyChannel(tty)) != NULL) | 590 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if ch != NULL */ |
648 | { /* Begin if ch != NULL */ | ||
649 | |||
650 | unsigned long flags; | 591 | unsigned long flags; |
651 | 592 | ||
652 | save_flags(flags); | ||
653 | cli(); | ||
654 | if (tty->driver->flush_buffer) | 593 | if (tty->driver->flush_buffer) |
655 | tty->driver->flush_buffer(tty); | 594 | tty->driver->flush_buffer(tty); |
656 | tty_ldisc_flush(tty); | 595 | tty_ldisc_flush(tty); |
657 | shutdown(ch); | 596 | shutdown(ch); |
658 | 597 | ||
598 | spin_lock_irqsave(&epca_lock, flags); | ||
659 | ch->tty = NULL; | 599 | ch->tty = NULL; |
660 | ch->event = 0; | 600 | ch->event = 0; |
661 | ch->count = 0; | 601 | ch->count = 0; |
662 | restore_flags(flags); | ||
663 | ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED); | 602 | ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED); |
603 | spin_unlock_irqrestore(&epca_lock, flags); | ||
664 | wake_up_interruptible(&ch->open_wait); | 604 | wake_up_interruptible(&ch->open_wait); |
665 | |||
666 | } /* End if ch != NULL */ | 605 | } /* End if ch != NULL */ |
667 | 606 | ||
668 | } /* End pc_hangup */ | 607 | } /* End pc_hangup */ |
@@ -672,18 +611,14 @@ static void pc_hangup(struct tty_struct *tty) | |||
672 | static int pc_write(struct tty_struct * tty, | 611 | static int pc_write(struct tty_struct * tty, |
673 | const unsigned char *buf, int bytesAvailable) | 612 | const unsigned char *buf, int bytesAvailable) |
674 | { /* Begin pc_write */ | 613 | { /* Begin pc_write */ |
675 | 614 | unsigned int head, tail; | |
676 | register unsigned int head, tail; | 615 | int dataLen; |
677 | register int dataLen; | 616 | int size; |
678 | register int size; | 617 | int amountCopied; |
679 | register int amountCopied; | ||
680 | |||
681 | |||
682 | struct channel *ch; | 618 | struct channel *ch; |
683 | unsigned long flags; | 619 | unsigned long flags; |
684 | int remain; | 620 | int remain; |
685 | volatile struct board_chan *bc; | 621 | struct board_chan *bc; |
686 | |||
687 | 622 | ||
688 | /* ---------------------------------------------------------------- | 623 | /* ---------------------------------------------------------------- |
689 | pc_write is primarily called directly by the kernel routine | 624 | pc_write is primarily called directly by the kernel routine |
@@ -706,24 +641,20 @@ static int pc_write(struct tty_struct * tty, | |||
706 | 641 | ||
707 | bc = ch->brdchan; | 642 | bc = ch->brdchan; |
708 | size = ch->txbufsize; | 643 | size = ch->txbufsize; |
709 | |||
710 | amountCopied = 0; | 644 | amountCopied = 0; |
711 | save_flags(flags); | ||
712 | cli(); | ||
713 | 645 | ||
646 | spin_lock_irqsave(&epca_lock, flags); | ||
714 | globalwinon(ch); | 647 | globalwinon(ch); |
715 | 648 | ||
716 | head = bc->tin & (size - 1); | 649 | head = readw(&bc->tin) & (size - 1); |
717 | tail = bc->tout; | 650 | tail = readw(&bc->tout); |
718 | 651 | ||
719 | if (tail != bc->tout) | 652 | if (tail != readw(&bc->tout)) |
720 | tail = bc->tout; | 653 | tail = readw(&bc->tout); |
721 | tail &= (size - 1); | 654 | tail &= (size - 1); |
722 | 655 | ||
723 | /* If head >= tail, head has not wrapped around. */ | 656 | /* If head >= tail, head has not wrapped around. */ |
724 | if (head >= tail) | 657 | if (head >= tail) { /* Begin head has not wrapped */ |
725 | { /* Begin head has not wrapped */ | ||
726 | |||
727 | /* --------------------------------------------------------------- | 658 | /* --------------------------------------------------------------- |
728 | remain (much like dataLen above) represents the total amount of | 659 | remain (much like dataLen above) represents the total amount of |
729 | space available on the card for data. Here dataLen represents | 660 | space available on the card for data. Here dataLen represents |
@@ -731,26 +662,19 @@ static int pc_write(struct tty_struct * tty, | |||
731 | buffer. This is important because a memcpy cannot be told to | 662 | buffer. This is important because a memcpy cannot be told to |
732 | automatically wrap around when it hits the buffer end. | 663 | automatically wrap around when it hits the buffer end. |
733 | ------------------------------------------------------------------ */ | 664 | ------------------------------------------------------------------ */ |
734 | |||
735 | dataLen = size - head; | 665 | dataLen = size - head; |
736 | remain = size - (head - tail) - 1; | 666 | remain = size - (head - tail) - 1; |
737 | 667 | } else { /* Begin head has wrapped around */ | |
738 | } /* End head has not wrapped */ | ||
739 | else | ||
740 | { /* Begin head has wrapped around */ | ||
741 | 668 | ||
742 | remain = tail - head - 1; | 669 | remain = tail - head - 1; |
743 | dataLen = remain; | 670 | dataLen = remain; |
744 | 671 | ||
745 | } /* End head has wrapped around */ | 672 | } /* End head has wrapped around */ |
746 | |||
747 | /* ------------------------------------------------------------------- | 673 | /* ------------------------------------------------------------------- |
748 | Check the space on the card. If we have more data than | 674 | Check the space on the card. If we have more data than |
749 | space; reduce the amount of data to fit the space. | 675 | space; reduce the amount of data to fit the space. |
750 | ---------------------------------------------------------------------- */ | 676 | ---------------------------------------------------------------------- */ |
751 | |||
752 | bytesAvailable = min(remain, bytesAvailable); | 677 | bytesAvailable = min(remain, bytesAvailable); |
753 | |||
754 | txwinon(ch); | 678 | txwinon(ch); |
755 | while (bytesAvailable > 0) | 679 | while (bytesAvailable > 0) |
756 | { /* Begin while there is data to copy onto card */ | 680 | { /* Begin while there is data to copy onto card */ |
@@ -767,26 +691,21 @@ static int pc_write(struct tty_struct * tty, | |||
767 | amountCopied += dataLen; | 691 | amountCopied += dataLen; |
768 | bytesAvailable -= dataLen; | 692 | bytesAvailable -= dataLen; |
769 | 693 | ||
770 | if (head >= size) | 694 | if (head >= size) { |
771 | { | ||
772 | head = 0; | 695 | head = 0; |
773 | dataLen = tail; | 696 | dataLen = tail; |
774 | } | 697 | } |
775 | |||
776 | } /* End while there is data to copy onto card */ | 698 | } /* End while there is data to copy onto card */ |
777 | |||
778 | ch->statusflags |= TXBUSY; | 699 | ch->statusflags |= TXBUSY; |
779 | globalwinon(ch); | 700 | globalwinon(ch); |
780 | bc->tin = head; | 701 | writew(head, &bc->tin); |
781 | 702 | ||
782 | if ((ch->statusflags & LOWWAIT) == 0) | 703 | if ((ch->statusflags & LOWWAIT) == 0) { |
783 | { | ||
784 | ch->statusflags |= LOWWAIT; | 704 | ch->statusflags |= LOWWAIT; |
785 | bc->ilow = 1; | 705 | writeb(1, &bc->ilow); |
786 | } | 706 | } |
787 | memoff(ch); | 707 | memoff(ch); |
788 | restore_flags(flags); | 708 | spin_unlock_irqrestore(&epca_lock, flags); |
789 | |||
790 | return(amountCopied); | 709 | return(amountCopied); |
791 | 710 | ||
792 | } /* End pc_write */ | 711 | } /* End pc_write */ |
@@ -795,11 +714,7 @@ static int pc_write(struct tty_struct * tty, | |||
795 | 714 | ||
796 | static void pc_put_char(struct tty_struct *tty, unsigned char c) | 715 | static void pc_put_char(struct tty_struct *tty, unsigned char c) |
797 | { /* Begin pc_put_char */ | 716 | { /* Begin pc_put_char */ |
798 | |||
799 | |||
800 | pc_write(tty, &c, 1); | 717 | pc_write(tty, &c, 1); |
801 | return; | ||
802 | |||
803 | } /* End pc_put_char */ | 718 | } /* End pc_put_char */ |
804 | 719 | ||
805 | /* ------------------ Begin pc_write_room ------------------------- */ | 720 | /* ------------------ Begin pc_write_room ------------------------- */ |
@@ -811,7 +726,7 @@ static int pc_write_room(struct tty_struct *tty) | |||
811 | struct channel *ch; | 726 | struct channel *ch; |
812 | unsigned long flags; | 727 | unsigned long flags; |
813 | unsigned int head, tail; | 728 | unsigned int head, tail; |
814 | volatile struct board_chan *bc; | 729 | struct board_chan *bc; |
815 | 730 | ||
816 | remain = 0; | 731 | remain = 0; |
817 | 732 | ||
@@ -820,33 +735,29 @@ static int pc_write_room(struct tty_struct *tty) | |||
820 | if it is valid. This serves as a sanity check. | 735 | if it is valid. This serves as a sanity check. |
821 | ------------------------------------------------------------- */ | 736 | ------------------------------------------------------------- */ |
822 | 737 | ||
823 | if ((ch = verifyChannel(tty)) != NULL) | 738 | if ((ch = verifyChannel(tty)) != NULL) { |
824 | { | 739 | spin_lock_irqsave(&epca_lock, flags); |
825 | save_flags(flags); | ||
826 | cli(); | ||
827 | globalwinon(ch); | 740 | globalwinon(ch); |
828 | 741 | ||
829 | bc = ch->brdchan; | 742 | bc = ch->brdchan; |
830 | head = bc->tin & (ch->txbufsize - 1); | 743 | head = readw(&bc->tin) & (ch->txbufsize - 1); |
831 | tail = bc->tout; | 744 | tail = readw(&bc->tout); |
832 | 745 | ||
833 | if (tail != bc->tout) | 746 | if (tail != readw(&bc->tout)) |
834 | tail = bc->tout; | 747 | tail = readw(&bc->tout); |
835 | /* Wrap tail if necessary */ | 748 | /* Wrap tail if necessary */ |
836 | tail &= (ch->txbufsize - 1); | 749 | tail &= (ch->txbufsize - 1); |
837 | 750 | ||
838 | if ((remain = tail - head - 1) < 0 ) | 751 | if ((remain = tail - head - 1) < 0 ) |
839 | remain += ch->txbufsize; | 752 | remain += ch->txbufsize; |
840 | 753 | ||
841 | if (remain && (ch->statusflags & LOWWAIT) == 0) | 754 | if (remain && (ch->statusflags & LOWWAIT) == 0) { |
842 | { | ||
843 | ch->statusflags |= LOWWAIT; | 755 | ch->statusflags |= LOWWAIT; |
844 | bc->ilow = 1; | 756 | writeb(1, &bc->ilow); |
845 | } | 757 | } |
846 | memoff(ch); | 758 | memoff(ch); |
847 | restore_flags(flags); | 759 | spin_unlock_irqrestore(&epca_lock, flags); |
848 | } | 760 | } |
849 | |||
850 | /* Return how much room is left on card */ | 761 | /* Return how much room is left on card */ |
851 | return remain; | 762 | return remain; |
852 | 763 | ||
@@ -862,8 +773,7 @@ static int pc_chars_in_buffer(struct tty_struct *tty) | |||
862 | int remain; | 773 | int remain; |
863 | unsigned long flags; | 774 | unsigned long flags; |
864 | struct channel *ch; | 775 | struct channel *ch; |
865 | volatile struct board_chan *bc; | 776 | struct board_chan *bc; |
866 | |||
867 | 777 | ||
868 | /* --------------------------------------------------------- | 778 | /* --------------------------------------------------------- |
869 | verifyChannel returns the channel from the tty struct | 779 | verifyChannel returns the channel from the tty struct |
@@ -873,34 +783,27 @@ static int pc_chars_in_buffer(struct tty_struct *tty) | |||
873 | if ((ch = verifyChannel(tty)) == NULL) | 783 | if ((ch = verifyChannel(tty)) == NULL) |
874 | return(0); | 784 | return(0); |
875 | 785 | ||
876 | save_flags(flags); | 786 | spin_lock_irqsave(&epca_lock, flags); |
877 | cli(); | ||
878 | globalwinon(ch); | 787 | globalwinon(ch); |
879 | 788 | ||
880 | bc = ch->brdchan; | 789 | bc = ch->brdchan; |
881 | tail = bc->tout; | 790 | tail = readw(&bc->tout); |
882 | head = bc->tin; | 791 | head = readw(&bc->tin); |
883 | ctail = ch->mailbox->cout; | 792 | ctail = readw(&ch->mailbox->cout); |
884 | 793 | ||
885 | if (tail == head && ch->mailbox->cin == ctail && bc->tbusy == 0) | 794 | if (tail == head && readw(&ch->mailbox->cin) == ctail && readb(&bc->tbusy) == 0) |
886 | chars = 0; | 795 | chars = 0; |
887 | else | 796 | else { /* Begin if some space on the card has been used */ |
888 | { /* Begin if some space on the card has been used */ | 797 | head = readw(&bc->tin) & (ch->txbufsize - 1); |
889 | |||
890 | head = bc->tin & (ch->txbufsize - 1); | ||
891 | tail &= (ch->txbufsize - 1); | 798 | tail &= (ch->txbufsize - 1); |
892 | |||
893 | /* -------------------------------------------------------------- | 799 | /* -------------------------------------------------------------- |
894 | The logic here is basically opposite of the above pc_write_room | 800 | The logic here is basically opposite of the above pc_write_room |
895 | here we are finding the amount of bytes in the buffer filled. | 801 | here we are finding the amount of bytes in the buffer filled. |
896 | Not the amount of bytes empty. | 802 | Not the amount of bytes empty. |
897 | ------------------------------------------------------------------- */ | 803 | ------------------------------------------------------------------- */ |
898 | |||
899 | if ((remain = tail - head - 1) < 0 ) | 804 | if ((remain = tail - head - 1) < 0 ) |
900 | remain += ch->txbufsize; | 805 | remain += ch->txbufsize; |
901 | |||
902 | chars = (int)(ch->txbufsize - remain); | 806 | chars = (int)(ch->txbufsize - remain); |
903 | |||
904 | /* ------------------------------------------------------------- | 807 | /* ------------------------------------------------------------- |
905 | Make it possible to wakeup anything waiting for output | 808 | Make it possible to wakeup anything waiting for output |
906 | in tty_ioctl.c, etc. | 809 | in tty_ioctl.c, etc. |
@@ -908,15 +811,12 @@ static int pc_chars_in_buffer(struct tty_struct *tty) | |||
908 | If not already set. Setup an event to indicate when the | 811 | If not already set. Setup an event to indicate when the |
909 | transmit buffer empties | 812 | transmit buffer empties |
910 | ----------------------------------------------------------------- */ | 813 | ----------------------------------------------------------------- */ |
911 | |||
912 | if (!(ch->statusflags & EMPTYWAIT)) | 814 | if (!(ch->statusflags & EMPTYWAIT)) |
913 | setup_empty_event(tty,ch); | 815 | setup_empty_event(tty,ch); |
914 | 816 | ||
915 | } /* End if some space on the card has been used */ | 817 | } /* End if some space on the card has been used */ |
916 | |||
917 | memoff(ch); | 818 | memoff(ch); |
918 | restore_flags(flags); | 819 | spin_unlock_irqrestore(&epca_lock, flags); |
919 | |||
920 | /* Return number of characters residing on card. */ | 820 | /* Return number of characters residing on card. */ |
921 | return(chars); | 821 | return(chars); |
922 | 822 | ||
@@ -930,67 +830,46 @@ static void pc_flush_buffer(struct tty_struct *tty) | |||
930 | unsigned int tail; | 830 | unsigned int tail; |
931 | unsigned long flags; | 831 | unsigned long flags; |
932 | struct channel *ch; | 832 | struct channel *ch; |
933 | volatile struct board_chan *bc; | 833 | struct board_chan *bc; |
934 | |||
935 | |||
936 | /* --------------------------------------------------------- | 834 | /* --------------------------------------------------------- |
937 | verifyChannel returns the channel from the tty struct | 835 | verifyChannel returns the channel from the tty struct |
938 | if it is valid. This serves as a sanity check. | 836 | if it is valid. This serves as a sanity check. |
939 | ------------------------------------------------------------- */ | 837 | ------------------------------------------------------------- */ |
940 | |||
941 | if ((ch = verifyChannel(tty)) == NULL) | 838 | if ((ch = verifyChannel(tty)) == NULL) |
942 | return; | 839 | return; |
943 | 840 | ||
944 | save_flags(flags); | 841 | spin_lock_irqsave(&epca_lock, flags); |
945 | cli(); | ||
946 | |||
947 | globalwinon(ch); | 842 | globalwinon(ch); |
948 | |||
949 | bc = ch->brdchan; | 843 | bc = ch->brdchan; |
950 | tail = bc->tout; | 844 | tail = readw(&bc->tout); |
951 | |||
952 | /* Have FEP move tout pointer; effectively flushing transmit buffer */ | 845 | /* Have FEP move tout pointer; effectively flushing transmit buffer */ |
953 | |||
954 | fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0); | 846 | fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0); |
955 | |||
956 | memoff(ch); | 847 | memoff(ch); |
957 | restore_flags(flags); | 848 | spin_unlock_irqrestore(&epca_lock, flags); |
958 | |||
959 | wake_up_interruptible(&tty->write_wait); | 849 | wake_up_interruptible(&tty->write_wait); |
960 | tty_wakeup(tty); | 850 | tty_wakeup(tty); |
961 | |||
962 | } /* End pc_flush_buffer */ | 851 | } /* End pc_flush_buffer */ |
963 | 852 | ||
964 | /* ------------------ Begin pc_flush_chars ---------------------- */ | 853 | /* ------------------ Begin pc_flush_chars ---------------------- */ |
965 | 854 | ||
966 | static void pc_flush_chars(struct tty_struct *tty) | 855 | static void pc_flush_chars(struct tty_struct *tty) |
967 | { /* Begin pc_flush_chars */ | 856 | { /* Begin pc_flush_chars */ |
968 | |||
969 | struct channel * ch; | 857 | struct channel * ch; |
970 | |||
971 | /* --------------------------------------------------------- | 858 | /* --------------------------------------------------------- |
972 | verifyChannel returns the channel from the tty struct | 859 | verifyChannel returns the channel from the tty struct |
973 | if it is valid. This serves as a sanity check. | 860 | if it is valid. This serves as a sanity check. |
974 | ------------------------------------------------------------- */ | 861 | ------------------------------------------------------------- */ |
975 | 862 | if ((ch = verifyChannel(tty)) != NULL) { | |
976 | if ((ch = verifyChannel(tty)) != NULL) | ||
977 | { | ||
978 | unsigned long flags; | 863 | unsigned long flags; |
979 | 864 | spin_lock_irqsave(&epca_lock, flags); | |
980 | save_flags(flags); | ||
981 | cli(); | ||
982 | |||
983 | /* ---------------------------------------------------------------- | 865 | /* ---------------------------------------------------------------- |
984 | If not already set and the transmitter is busy setup an event | 866 | If not already set and the transmitter is busy setup an event |
985 | to indicate when the transmit empties. | 867 | to indicate when the transmit empties. |
986 | ------------------------------------------------------------------- */ | 868 | ------------------------------------------------------------------- */ |
987 | |||
988 | if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT)) | 869 | if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT)) |
989 | setup_empty_event(tty,ch); | 870 | setup_empty_event(tty,ch); |
990 | 871 | spin_unlock_irqrestore(&epca_lock, flags); | |
991 | restore_flags(flags); | ||
992 | } | 872 | } |
993 | |||
994 | } /* End pc_flush_chars */ | 873 | } /* End pc_flush_chars */ |
995 | 874 | ||
996 | /* ------------------ Begin block_til_ready ---------------------- */ | 875 | /* ------------------ Begin block_til_ready ---------------------- */ |
@@ -998,14 +877,11 @@ static void pc_flush_chars(struct tty_struct *tty) | |||
998 | static int block_til_ready(struct tty_struct *tty, | 877 | static int block_til_ready(struct tty_struct *tty, |
999 | struct file *filp, struct channel *ch) | 878 | struct file *filp, struct channel *ch) |
1000 | { /* Begin block_til_ready */ | 879 | { /* Begin block_til_ready */ |
1001 | |||
1002 | DECLARE_WAITQUEUE(wait,current); | 880 | DECLARE_WAITQUEUE(wait,current); |
1003 | int retval, do_clocal = 0; | 881 | int retval, do_clocal = 0; |
1004 | unsigned long flags; | 882 | unsigned long flags; |
1005 | 883 | ||
1006 | 884 | if (tty_hung_up_p(filp)) { | |
1007 | if (tty_hung_up_p(filp)) | ||
1008 | { | ||
1009 | if (ch->asyncflags & ASYNC_HUP_NOTIFY) | 885 | if (ch->asyncflags & ASYNC_HUP_NOTIFY) |
1010 | retval = -EAGAIN; | 886 | retval = -EAGAIN; |
1011 | else | 887 | else |
@@ -1017,8 +893,7 @@ static int block_til_ready(struct tty_struct *tty, | |||
1017 | If the device is in the middle of being closed, then block | 893 | If the device is in the middle of being closed, then block |
1018 | until it's done, and then try again. | 894 | until it's done, and then try again. |
1019 | -------------------------------------------------------------------- */ | 895 | -------------------------------------------------------------------- */ |
1020 | if (ch->asyncflags & ASYNC_CLOSING) | 896 | if (ch->asyncflags & ASYNC_CLOSING) { |
1021 | { | ||
1022 | interruptible_sleep_on(&ch->close_wait); | 897 | interruptible_sleep_on(&ch->close_wait); |
1023 | 898 | ||
1024 | if (ch->asyncflags & ASYNC_HUP_NOTIFY) | 899 | if (ch->asyncflags & ASYNC_HUP_NOTIFY) |
@@ -1027,43 +902,29 @@ static int block_til_ready(struct tty_struct *tty, | |||
1027 | return -ERESTARTSYS; | 902 | return -ERESTARTSYS; |
1028 | } | 903 | } |
1029 | 904 | ||
1030 | if (filp->f_flags & O_NONBLOCK) | 905 | if (filp->f_flags & O_NONBLOCK) { |
1031 | { | ||
1032 | /* ----------------------------------------------------------------- | 906 | /* ----------------------------------------------------------------- |
1033 | If non-blocking mode is set, then make the check up front | 907 | If non-blocking mode is set, then make the check up front |
1034 | and then exit. | 908 | and then exit. |
1035 | -------------------------------------------------------------------- */ | 909 | -------------------------------------------------------------------- */ |
1036 | |||
1037 | ch->asyncflags |= ASYNC_NORMAL_ACTIVE; | 910 | ch->asyncflags |= ASYNC_NORMAL_ACTIVE; |
1038 | |||
1039 | return 0; | 911 | return 0; |
1040 | } | 912 | } |
1041 | |||
1042 | |||
1043 | if (tty->termios->c_cflag & CLOCAL) | 913 | if (tty->termios->c_cflag & CLOCAL) |
1044 | do_clocal = 1; | 914 | do_clocal = 1; |
1045 | 915 | /* Block waiting for the carrier detect and the line to become free */ | |
1046 | /* Block waiting for the carrier detect and the line to become free */ | ||
1047 | 916 | ||
1048 | retval = 0; | 917 | retval = 0; |
1049 | add_wait_queue(&ch->open_wait, &wait); | 918 | add_wait_queue(&ch->open_wait, &wait); |
1050 | save_flags(flags); | ||
1051 | cli(); | ||
1052 | |||
1053 | 919 | ||
920 | spin_lock_irqsave(&epca_lock, flags); | ||
1054 | /* We dec count so that pc_close will know when to free things */ | 921 | /* We dec count so that pc_close will know when to free things */ |
1055 | if (!tty_hung_up_p(filp)) | 922 | if (!tty_hung_up_p(filp)) |
1056 | ch->count--; | 923 | ch->count--; |
1057 | |||
1058 | restore_flags(flags); | ||
1059 | |||
1060 | ch->blocked_open++; | 924 | ch->blocked_open++; |
1061 | |||
1062 | while(1) | 925 | while(1) |
1063 | { /* Begin forever while */ | 926 | { /* Begin forever while */ |
1064 | |||
1065 | set_current_state(TASK_INTERRUPTIBLE); | 927 | set_current_state(TASK_INTERRUPTIBLE); |
1066 | |||
1067 | if (tty_hung_up_p(filp) || | 928 | if (tty_hung_up_p(filp) || |
1068 | !(ch->asyncflags & ASYNC_INITIALIZED)) | 929 | !(ch->asyncflags & ASYNC_INITIALIZED)) |
1069 | { | 930 | { |
@@ -1073,17 +934,14 @@ static int block_til_ready(struct tty_struct *tty, | |||
1073 | retval = -ERESTARTSYS; | 934 | retval = -ERESTARTSYS; |
1074 | break; | 935 | break; |
1075 | } | 936 | } |
1076 | |||
1077 | if (!(ch->asyncflags & ASYNC_CLOSING) && | 937 | if (!(ch->asyncflags & ASYNC_CLOSING) && |
1078 | (do_clocal || (ch->imodem & ch->dcd))) | 938 | (do_clocal || (ch->imodem & ch->dcd))) |
1079 | break; | 939 | break; |
1080 | 940 | if (signal_pending(current)) { | |
1081 | if (signal_pending(current)) | ||
1082 | { | ||
1083 | retval = -ERESTARTSYS; | 941 | retval = -ERESTARTSYS; |
1084 | break; | 942 | break; |
1085 | } | 943 | } |
1086 | 944 | spin_unlock_irqrestore(&epca_lock, flags); | |
1087 | /* --------------------------------------------------------------- | 945 | /* --------------------------------------------------------------- |
1088 | Allow someone else to be scheduled. We will occasionally go | 946 | Allow someone else to be scheduled. We will occasionally go |
1089 | through this loop until one of the above conditions change. | 947 | through this loop until one of the above conditions change. |
@@ -1091,25 +949,23 @@ static int block_til_ready(struct tty_struct *tty, | |||
1091 | prevent this loop from hogging the cpu. | 949 | prevent this loop from hogging the cpu. |
1092 | ------------------------------------------------------------------ */ | 950 | ------------------------------------------------------------------ */ |
1093 | schedule(); | 951 | schedule(); |
952 | spin_lock_irqsave(&epca_lock, flags); | ||
1094 | 953 | ||
1095 | } /* End forever while */ | 954 | } /* End forever while */ |
1096 | 955 | ||
1097 | current->state = TASK_RUNNING; | 956 | current->state = TASK_RUNNING; |
1098 | remove_wait_queue(&ch->open_wait, &wait); | 957 | remove_wait_queue(&ch->open_wait, &wait); |
1099 | cli(); | ||
1100 | if (!tty_hung_up_p(filp)) | 958 | if (!tty_hung_up_p(filp)) |
1101 | ch->count++; | 959 | ch->count++; |
1102 | restore_flags(flags); | ||
1103 | |||
1104 | ch->blocked_open--; | 960 | ch->blocked_open--; |
1105 | 961 | ||
962 | spin_unlock_irqrestore(&epca_lock, flags); | ||
963 | |||
1106 | if (retval) | 964 | if (retval) |
1107 | return retval; | 965 | return retval; |
1108 | 966 | ||
1109 | ch->asyncflags |= ASYNC_NORMAL_ACTIVE; | 967 | ch->asyncflags |= ASYNC_NORMAL_ACTIVE; |
1110 | |||
1111 | return 0; | 968 | return 0; |
1112 | |||
1113 | } /* End block_til_ready */ | 969 | } /* End block_til_ready */ |
1114 | 970 | ||
1115 | /* ------------------ Begin pc_open ---------------------- */ | 971 | /* ------------------ Begin pc_open ---------------------- */ |
@@ -1120,17 +976,12 @@ static int pc_open(struct tty_struct *tty, struct file * filp) | |||
1120 | struct channel *ch; | 976 | struct channel *ch; |
1121 | unsigned long flags; | 977 | unsigned long flags; |
1122 | int line, retval, boardnum; | 978 | int line, retval, boardnum; |
1123 | volatile struct board_chan *bc; | 979 | struct board_chan *bc; |
1124 | volatile unsigned int head; | 980 | unsigned int head; |
1125 | 981 | ||
1126 | line = tty->index; | 982 | line = tty->index; |
1127 | if (line < 0 || line >= nbdevs) | 983 | if (line < 0 || line >= nbdevs) |
1128 | { | 984 | return -ENODEV; |
1129 | printk(KERN_ERR "<Error> - pc_open : line out of range in pc_open\n"); | ||
1130 | tty->driver_data = NULL; | ||
1131 | return(-ENODEV); | ||
1132 | } | ||
1133 | |||
1134 | 985 | ||
1135 | ch = &digi_channels[line]; | 986 | ch = &digi_channels[line]; |
1136 | boardnum = ch->boardnum; | 987 | boardnum = ch->boardnum; |
@@ -1143,66 +994,49 @@ static int pc_open(struct tty_struct *tty, struct file * filp) | |||
1143 | goes here. | 994 | goes here. |
1144 | ---------------------------------------------------------------------- */ | 995 | ---------------------------------------------------------------------- */ |
1145 | 996 | ||
1146 | if (invalid_lilo_config) | 997 | if (invalid_lilo_config) { |
1147 | { | ||
1148 | if (setup_error_code & INVALID_BOARD_TYPE) | 998 | if (setup_error_code & INVALID_BOARD_TYPE) |
1149 | printk(KERN_ERR "<Error> - pc_open: Invalid board type specified in LILO command\n"); | 999 | printk(KERN_ERR "epca: pc_open: Invalid board type specified in kernel options.\n"); |
1150 | |||
1151 | if (setup_error_code & INVALID_NUM_PORTS) | 1000 | if (setup_error_code & INVALID_NUM_PORTS) |
1152 | printk(KERN_ERR "<Error> - pc_open: Invalid number of ports specified in LILO command\n"); | 1001 | printk(KERN_ERR "epca: pc_open: Invalid number of ports specified in kernel options.\n"); |
1153 | |||
1154 | if (setup_error_code & INVALID_MEM_BASE) | 1002 | if (setup_error_code & INVALID_MEM_BASE) |
1155 | printk(KERN_ERR "<Error> - pc_open: Invalid board memory address specified in LILO command\n"); | 1003 | printk(KERN_ERR "epca: pc_open: Invalid board memory address specified in kernel options.\n"); |
1156 | |||
1157 | if (setup_error_code & INVALID_PORT_BASE) | 1004 | if (setup_error_code & INVALID_PORT_BASE) |
1158 | printk(KERN_ERR "<Error> - pc_open: Invalid board port address specified in LILO command\n"); | 1005 | printk(KERN_ERR "epca; pc_open: Invalid board port address specified in kernel options.\n"); |
1159 | |||
1160 | if (setup_error_code & INVALID_BOARD_STATUS) | 1006 | if (setup_error_code & INVALID_BOARD_STATUS) |
1161 | printk(KERN_ERR "<Error> - pc_open: Invalid board status specified in LILO command\n"); | 1007 | printk(KERN_ERR "epca: pc_open: Invalid board status specified in kernel options.\n"); |
1162 | |||
1163 | if (setup_error_code & INVALID_ALTPIN) | 1008 | if (setup_error_code & INVALID_ALTPIN) |
1164 | printk(KERN_ERR "<Error> - pc_open: Invalid board altpin specified in LILO command\n"); | 1009 | printk(KERN_ERR "epca: pc_open: Invalid board altpin specified in kernel options;\n"); |
1165 | |||
1166 | tty->driver_data = NULL; /* Mark this device as 'down' */ | 1010 | tty->driver_data = NULL; /* Mark this device as 'down' */ |
1167 | return(-ENODEV); | 1011 | return -ENODEV; |
1168 | } | 1012 | } |
1169 | 1013 | if (boardnum >= num_cards || boards[boardnum].status == DISABLED) { | |
1170 | if ((boardnum >= num_cards) || (boards[boardnum].status == DISABLED)) | ||
1171 | { | ||
1172 | tty->driver_data = NULL; /* Mark this device as 'down' */ | 1014 | tty->driver_data = NULL; /* Mark this device as 'down' */ |
1173 | return(-ENODEV); | 1015 | return(-ENODEV); |
1174 | } | 1016 | } |
1175 | 1017 | ||
1176 | if (( bc = ch->brdchan) == 0) | 1018 | if ((bc = ch->brdchan) == 0) { |
1177 | { | ||
1178 | tty->driver_data = NULL; | 1019 | tty->driver_data = NULL; |
1179 | return(-ENODEV); | 1020 | return -ENODEV; |
1180 | } | 1021 | } |
1181 | 1022 | ||
1023 | spin_lock_irqsave(&epca_lock, flags); | ||
1182 | /* ------------------------------------------------------------------ | 1024 | /* ------------------------------------------------------------------ |
1183 | Every time a channel is opened, increment a counter. This is | 1025 | Every time a channel is opened, increment a counter. This is |
1184 | necessary because we do not wish to flush and shutdown the channel | 1026 | necessary because we do not wish to flush and shutdown the channel |
1185 | until the last app holding the channel open, closes it. | 1027 | until the last app holding the channel open, closes it. |
1186 | --------------------------------------------------------------------- */ | 1028 | --------------------------------------------------------------------- */ |
1187 | |||
1188 | ch->count++; | 1029 | ch->count++; |
1189 | |||
1190 | /* ---------------------------------------------------------------- | 1030 | /* ---------------------------------------------------------------- |
1191 | Set a kernel structures pointer to our local channel | 1031 | Set a kernel structures pointer to our local channel |
1192 | structure. This way we can get to it when passed only | 1032 | structure. This way we can get to it when passed only |
1193 | a tty struct. | 1033 | a tty struct. |
1194 | ------------------------------------------------------------------ */ | 1034 | ------------------------------------------------------------------ */ |
1195 | |||
1196 | tty->driver_data = ch; | 1035 | tty->driver_data = ch; |
1197 | |||
1198 | /* ---------------------------------------------------------------- | 1036 | /* ---------------------------------------------------------------- |
1199 | If this is the first time the channel has been opened, initialize | 1037 | If this is the first time the channel has been opened, initialize |
1200 | the tty->termios struct otherwise let pc_close handle it. | 1038 | the tty->termios struct otherwise let pc_close handle it. |
1201 | -------------------------------------------------------------------- */ | 1039 | -------------------------------------------------------------------- */ |
1202 | |||
1203 | save_flags(flags); | ||
1204 | cli(); | ||
1205 | |||
1206 | globalwinon(ch); | 1040 | globalwinon(ch); |
1207 | ch->statusflags = 0; | 1041 | ch->statusflags = 0; |
1208 | 1042 | ||
@@ -1213,8 +1047,8 @@ static int pc_open(struct tty_struct *tty, struct file * filp) | |||
1213 | Set receive head and tail ptrs to each other. This indicates | 1047 | Set receive head and tail ptrs to each other. This indicates |
1214 | no data available to read. | 1048 | no data available to read. |
1215 | ----------------------------------------------------------------- */ | 1049 | ----------------------------------------------------------------- */ |
1216 | head = bc->rin; | 1050 | head = readw(&bc->rin); |
1217 | bc->rout = head; | 1051 | writew(head, &bc->rout); |
1218 | 1052 | ||
1219 | /* Set the channels associated tty structure */ | 1053 | /* Set the channels associated tty structure */ |
1220 | ch->tty = tty; | 1054 | ch->tty = tty; |
@@ -1224,122 +1058,74 @@ static int pc_open(struct tty_struct *tty, struct file * filp) | |||
1224 | issues, etc.... It effect both control flags and input flags. | 1058 | issues, etc.... It effect both control flags and input flags. |
1225 | -------------------------------------------------------------------- */ | 1059 | -------------------------------------------------------------------- */ |
1226 | epcaparam(tty,ch); | 1060 | epcaparam(tty,ch); |
1227 | |||
1228 | ch->asyncflags |= ASYNC_INITIALIZED; | 1061 | ch->asyncflags |= ASYNC_INITIALIZED; |
1229 | memoff(ch); | 1062 | memoff(ch); |
1230 | 1063 | spin_unlock_irqrestore(&epca_lock, flags); | |
1231 | restore_flags(flags); | ||
1232 | 1064 | ||
1233 | retval = block_til_ready(tty, filp, ch); | 1065 | retval = block_til_ready(tty, filp, ch); |
1234 | if (retval) | 1066 | if (retval) |
1235 | { | ||
1236 | return retval; | 1067 | return retval; |
1237 | } | ||
1238 | |||
1239 | /* ------------------------------------------------------------- | 1068 | /* ------------------------------------------------------------- |
1240 | Set this again in case a hangup set it to zero while this | 1069 | Set this again in case a hangup set it to zero while this |
1241 | open() was waiting for the line... | 1070 | open() was waiting for the line... |
1242 | --------------------------------------------------------------- */ | 1071 | --------------------------------------------------------------- */ |
1072 | spin_lock_irqsave(&epca_lock, flags); | ||
1243 | ch->tty = tty; | 1073 | ch->tty = tty; |
1244 | |||
1245 | save_flags(flags); | ||
1246 | cli(); | ||
1247 | globalwinon(ch); | 1074 | globalwinon(ch); |
1248 | |||
1249 | /* Enable Digi Data events */ | 1075 | /* Enable Digi Data events */ |
1250 | bc->idata = 1; | 1076 | writeb(1, &bc->idata); |
1251 | |||
1252 | memoff(ch); | 1077 | memoff(ch); |
1253 | restore_flags(flags); | 1078 | spin_unlock_irqrestore(&epca_lock, flags); |
1254 | |||
1255 | return 0; | 1079 | return 0; |
1256 | |||
1257 | } /* End pc_open */ | 1080 | } /* End pc_open */ |
1258 | 1081 | ||
1259 | #ifdef MODULE | ||
1260 | static int __init epca_module_init(void) | 1082 | static int __init epca_module_init(void) |
1261 | { /* Begin init_module */ | 1083 | { /* Begin init_module */ |
1262 | 1084 | return pc_init(); | |
1263 | unsigned long flags; | ||
1264 | |||
1265 | save_flags(flags); | ||
1266 | cli(); | ||
1267 | |||
1268 | pc_init(); | ||
1269 | |||
1270 | restore_flags(flags); | ||
1271 | |||
1272 | return(0); | ||
1273 | } | 1085 | } |
1274 | 1086 | ||
1275 | module_init(epca_module_init); | 1087 | module_init(epca_module_init); |
1276 | #endif | ||
1277 | 1088 | ||
1278 | #ifdef ENABLE_PCI | ||
1279 | static struct pci_driver epca_driver; | 1089 | static struct pci_driver epca_driver; |
1280 | #endif | ||
1281 | |||
1282 | #ifdef MODULE | ||
1283 | /* -------------------- Begin cleanup_module ---------------------- */ | ||
1284 | 1090 | ||
1285 | static void __exit epca_module_exit(void) | 1091 | static void __exit epca_module_exit(void) |
1286 | { | 1092 | { |
1287 | |||
1288 | int count, crd; | 1093 | int count, crd; |
1289 | struct board_info *bd; | 1094 | struct board_info *bd; |
1290 | struct channel *ch; | 1095 | struct channel *ch; |
1291 | unsigned long flags; | ||
1292 | 1096 | ||
1293 | del_timer_sync(&epca_timer); | 1097 | del_timer_sync(&epca_timer); |
1294 | 1098 | ||
1295 | save_flags(flags); | ||
1296 | cli(); | ||
1297 | |||
1298 | if ((tty_unregister_driver(pc_driver)) || | 1099 | if ((tty_unregister_driver(pc_driver)) || |
1299 | (tty_unregister_driver(pc_info))) | 1100 | (tty_unregister_driver(pc_info))) |
1300 | { | 1101 | { |
1301 | printk(KERN_WARNING "<Error> - DIGI : cleanup_module failed to un-register tty driver\n"); | 1102 | printk(KERN_WARNING "epca: cleanup_module failed to un-register tty driver\n"); |
1302 | restore_flags(flags); | ||
1303 | return; | 1103 | return; |
1304 | } | 1104 | } |
1305 | put_tty_driver(pc_driver); | 1105 | put_tty_driver(pc_driver); |
1306 | put_tty_driver(pc_info); | 1106 | put_tty_driver(pc_info); |
1307 | 1107 | ||
1308 | for (crd = 0; crd < num_cards; crd++) | 1108 | for (crd = 0; crd < num_cards; crd++) { /* Begin for each card */ |
1309 | { /* Begin for each card */ | ||
1310 | |||
1311 | bd = &boards[crd]; | 1109 | bd = &boards[crd]; |
1312 | |||
1313 | if (!bd) | 1110 | if (!bd) |
1314 | { /* Begin sanity check */ | 1111 | { /* Begin sanity check */ |
1315 | printk(KERN_ERR "<Error> - Digi : cleanup_module failed\n"); | 1112 | printk(KERN_ERR "<Error> - Digi : cleanup_module failed\n"); |
1316 | return; | 1113 | return; |
1317 | } /* End sanity check */ | 1114 | } /* End sanity check */ |
1318 | 1115 | ch = card_ptr[crd]; | |
1319 | ch = card_ptr[crd]; | ||
1320 | |||
1321 | for (count = 0; count < bd->numports; count++, ch++) | 1116 | for (count = 0; count < bd->numports; count++, ch++) |
1322 | { /* Begin for each port */ | 1117 | { /* Begin for each port */ |
1323 | 1118 | if (ch) { | |
1324 | if (ch) | ||
1325 | { | ||
1326 | if (ch->tty) | 1119 | if (ch->tty) |
1327 | tty_hangup(ch->tty); | 1120 | tty_hangup(ch->tty); |
1328 | kfree(ch->tmp_buf); | 1121 | kfree(ch->tmp_buf); |
1329 | } | 1122 | } |
1330 | |||
1331 | } /* End for each port */ | 1123 | } /* End for each port */ |
1332 | } /* End for each card */ | 1124 | } /* End for each card */ |
1333 | |||
1334 | #ifdef ENABLE_PCI | ||
1335 | pci_unregister_driver (&epca_driver); | 1125 | pci_unregister_driver (&epca_driver); |
1336 | #endif | ||
1337 | |||
1338 | restore_flags(flags); | ||
1339 | |||
1340 | } | 1126 | } |
1127 | |||
1341 | module_exit(epca_module_exit); | 1128 | module_exit(epca_module_exit); |
1342 | #endif /* MODULE */ | ||
1343 | 1129 | ||
1344 | static struct tty_operations pc_ops = { | 1130 | static struct tty_operations pc_ops = { |
1345 | .open = pc_open, | 1131 | .open = pc_open, |
@@ -1371,34 +1157,15 @@ static struct tty_operations info_ops = { | |||
1371 | 1157 | ||
1372 | /* ------------------ Begin pc_init ---------------------- */ | 1158 | /* ------------------ Begin pc_init ---------------------- */ |
1373 | 1159 | ||
1374 | int __init pc_init(void) | 1160 | static int __init pc_init(void) |
1375 | { /* Begin pc_init */ | 1161 | { /* Begin pc_init */ |
1376 | |||
1377 | /* ---------------------------------------------------------------- | ||
1378 | pc_init is called by the operating system during boot up prior to | ||
1379 | any open calls being made. In the older versions of Linux (Prior | ||
1380 | to 2.0.0) an entry is made into tty_io.c. A pointer to the last | ||
1381 | memory location (from kernel space) used (kmem_start) is passed | ||
1382 | to pc_init. It is pc_inits responsibility to modify this value | ||
1383 | for any memory that the Digi driver might need and then return | ||
1384 | this value to the operating system. For example if the driver | ||
1385 | wishes to allocate 1K of kernel memory, pc_init would return | ||
1386 | (kmem_start + 1024). This memory (Between kmem_start and kmem_start | ||
1387 | + 1024) would then be available for use exclusively by the driver. | ||
1388 | In this case our driver does not allocate any of this kernel | ||
1389 | memory. | ||
1390 | ------------------------------------------------------------------*/ | ||
1391 | |||
1392 | ulong flags; | ||
1393 | int crd; | 1162 | int crd; |
1394 | struct board_info *bd; | 1163 | struct board_info *bd; |
1395 | unsigned char board_id = 0; | 1164 | unsigned char board_id = 0; |
1396 | 1165 | ||
1397 | #ifdef ENABLE_PCI | ||
1398 | int pci_boards_found, pci_count; | 1166 | int pci_boards_found, pci_count; |
1399 | 1167 | ||
1400 | pci_count = 0; | 1168 | pci_count = 0; |
1401 | #endif /* ENABLE_PCI */ | ||
1402 | 1169 | ||
1403 | pc_driver = alloc_tty_driver(MAX_ALLOC); | 1170 | pc_driver = alloc_tty_driver(MAX_ALLOC); |
1404 | if (!pc_driver) | 1171 | if (!pc_driver) |
@@ -1416,8 +1183,7 @@ int __init pc_init(void) | |||
1416 | Note : If LILO has ran epca_setup then epca_setup will handle defining | 1183 | Note : If LILO has ran epca_setup then epca_setup will handle defining |
1417 | num_cards as well as copying the data into the board structure. | 1184 | num_cards as well as copying the data into the board structure. |
1418 | -------------------------------------------------------------------------- */ | 1185 | -------------------------------------------------------------------------- */ |
1419 | if (!liloconfig) | 1186 | if (!liloconfig) { /* Begin driver has been configured via. epcaconfig */ |
1420 | { /* Begin driver has been configured via. epcaconfig */ | ||
1421 | 1187 | ||
1422 | nbdevs = NBDEVS; | 1188 | nbdevs = NBDEVS; |
1423 | num_cards = NUMCARDS; | 1189 | num_cards = NUMCARDS; |
@@ -1440,8 +1206,6 @@ int __init pc_init(void) | |||
1440 | 1206 | ||
1441 | printk(KERN_INFO "DIGI epca driver version %s loaded.\n",VERSION); | 1207 | printk(KERN_INFO "DIGI epca driver version %s loaded.\n",VERSION); |
1442 | 1208 | ||
1443 | #ifdef ENABLE_PCI | ||
1444 | |||
1445 | /* ------------------------------------------------------------------ | 1209 | /* ------------------------------------------------------------------ |
1446 | NOTE : This code assumes that the number of ports found in | 1210 | NOTE : This code assumes that the number of ports found in |
1447 | the boards array is correct. This could be wrong if | 1211 | the boards array is correct. This could be wrong if |
@@ -1467,8 +1231,6 @@ int __init pc_init(void) | |||
1467 | pci_boards_found += init_PCI(); | 1231 | pci_boards_found += init_PCI(); |
1468 | num_cards += pci_boards_found; | 1232 | num_cards += pci_boards_found; |
1469 | 1233 | ||
1470 | #endif /* ENABLE_PCI */ | ||
1471 | |||
1472 | pc_driver->owner = THIS_MODULE; | 1234 | pc_driver->owner = THIS_MODULE; |
1473 | pc_driver->name = "ttyD"; | 1235 | pc_driver->name = "ttyD"; |
1474 | pc_driver->devfs_name = "tts/D"; | 1236 | pc_driver->devfs_name = "tts/D"; |
@@ -1499,9 +1261,6 @@ int __init pc_init(void) | |||
1499 | tty_set_operations(pc_info, &info_ops); | 1261 | tty_set_operations(pc_info, &info_ops); |
1500 | 1262 | ||
1501 | 1263 | ||
1502 | save_flags(flags); | ||
1503 | cli(); | ||
1504 | |||
1505 | for (crd = 0; crd < num_cards; crd++) | 1264 | for (crd = 0; crd < num_cards; crd++) |
1506 | { /* Begin for each card */ | 1265 | { /* Begin for each card */ |
1507 | 1266 | ||
@@ -1610,11 +1369,7 @@ int __init pc_init(void) | |||
1610 | if ((board_id & 0x30) == 0x30) | 1369 | if ((board_id & 0x30) == 0x30) |
1611 | bd->memory_seg = 0x8000; | 1370 | bd->memory_seg = 0x8000; |
1612 | 1371 | ||
1613 | } /* End it is an XI card */ | 1372 | } else printk(KERN_ERR "epca: Board at 0x%x doesn't appear to be an XI\n",(int)bd->port); |
1614 | else | ||
1615 | { | ||
1616 | printk(KERN_ERR "<Error> - Board at 0x%x doesn't appear to be an XI\n",(int)bd->port); | ||
1617 | } | ||
1618 | break; | 1373 | break; |
1619 | 1374 | ||
1620 | } /* End switch on bd->type */ | 1375 | } /* End switch on bd->type */ |
@@ -1634,9 +1389,6 @@ int __init pc_init(void) | |||
1634 | init_timer(&epca_timer); | 1389 | init_timer(&epca_timer); |
1635 | epca_timer.function = epcapoll; | 1390 | epca_timer.function = epcapoll; |
1636 | mod_timer(&epca_timer, jiffies + HZ/25); | 1391 | mod_timer(&epca_timer, jiffies + HZ/25); |
1637 | |||
1638 | restore_flags(flags); | ||
1639 | |||
1640 | return 0; | 1392 | return 0; |
1641 | 1393 | ||
1642 | } /* End pc_init */ | 1394 | } /* End pc_init */ |
@@ -1647,10 +1399,10 @@ static void post_fep_init(unsigned int crd) | |||
1647 | { /* Begin post_fep_init */ | 1399 | { /* Begin post_fep_init */ |
1648 | 1400 | ||
1649 | int i; | 1401 | int i; |
1650 | unchar *memaddr; | 1402 | unsigned char *memaddr; |
1651 | volatile struct global_data *gd; | 1403 | struct global_data *gd; |
1652 | struct board_info *bd; | 1404 | struct board_info *bd; |
1653 | volatile struct board_chan *bc; | 1405 | struct board_chan *bc; |
1654 | struct channel *ch; | 1406 | struct channel *ch; |
1655 | int shrinkmem = 0, lowwater ; | 1407 | int shrinkmem = 0, lowwater ; |
1656 | 1408 | ||
@@ -1669,9 +1421,7 @@ static void post_fep_init(unsigned int crd) | |||
1669 | after DIGI_INIT has been called will return the proper values. | 1421 | after DIGI_INIT has been called will return the proper values. |
1670 | ------------------------------------------------------------------- */ | 1422 | ------------------------------------------------------------------- */ |
1671 | 1423 | ||
1672 | if (bd->type >= PCIXEM) /* If the board in question is PCI */ | 1424 | if (bd->type >= PCIXEM) { /* Begin get PCI number of ports */ |
1673 | { /* Begin get PCI number of ports */ | ||
1674 | |||
1675 | /* -------------------------------------------------------------------- | 1425 | /* -------------------------------------------------------------------- |
1676 | Below we use XEMPORTS as a memory offset regardless of which PCI | 1426 | Below we use XEMPORTS as a memory offset regardless of which PCI |
1677 | card it is. This is because all of the supported PCI cards have | 1427 | card it is. This is because all of the supported PCI cards have |
@@ -1685,15 +1435,15 @@ static void post_fep_init(unsigned int crd) | |||
1685 | (FYI - The id should be located at 0x1ac (And may use up to 4 bytes | 1435 | (FYI - The id should be located at 0x1ac (And may use up to 4 bytes |
1686 | if the box in question is a XEM or CX)). | 1436 | if the box in question is a XEM or CX)). |
1687 | ------------------------------------------------------------------------ */ | 1437 | ------------------------------------------------------------------------ */ |
1688 | 1438 | /* PCI cards are already remapped at this point ISA are not */ | |
1689 | bd->numports = (unsigned short)*(unsigned char *)bus_to_virt((unsigned long) | 1439 | bd->numports = readw(bd->re_map_membase + XEMPORTS); |
1690 | (bd->re_map_membase + XEMPORTS)); | ||
1691 | |||
1692 | |||
1693 | epcaassert(bd->numports <= 64,"PCI returned a invalid number of ports"); | 1440 | epcaassert(bd->numports <= 64,"PCI returned a invalid number of ports"); |
1694 | nbdevs += (bd->numports); | 1441 | nbdevs += (bd->numports); |
1695 | 1442 | } else { | |
1696 | } /* End get PCI number of ports */ | 1443 | /* Fix up the mappings for ISA/EISA etc */ |
1444 | /* FIXME: 64K - can we be smarter ? */ | ||
1445 | bd->re_map_membase = ioremap(bd->membase, 0x10000); | ||
1446 | } | ||
1697 | 1447 | ||
1698 | if (crd != 0) | 1448 | if (crd != 0) |
1699 | card_ptr[crd] = card_ptr[crd-1] + boards[crd-1].numports; | 1449 | card_ptr[crd] = card_ptr[crd-1] + boards[crd-1].numports; |
@@ -1701,19 +1451,9 @@ static void post_fep_init(unsigned int crd) | |||
1701 | card_ptr[crd] = &digi_channels[crd]; /* <- For card 0 only */ | 1451 | card_ptr[crd] = &digi_channels[crd]; /* <- For card 0 only */ |
1702 | 1452 | ||
1703 | ch = card_ptr[crd]; | 1453 | ch = card_ptr[crd]; |
1704 | |||
1705 | |||
1706 | epcaassert(ch <= &digi_channels[nbdevs - 1], "ch out of range"); | 1454 | epcaassert(ch <= &digi_channels[nbdevs - 1], "ch out of range"); |
1707 | 1455 | ||
1708 | memaddr = (unchar *)bd->re_map_membase; | 1456 | memaddr = bd->re_map_membase; |
1709 | |||
1710 | /* | ||
1711 | The below command is necessary because newer kernels (2.1.x and | ||
1712 | up) do not have a 1:1 virtual to physical mapping. The below | ||
1713 | call adjust for that. | ||
1714 | */ | ||
1715 | |||
1716 | memaddr = (unsigned char *)bus_to_virt((unsigned long)memaddr); | ||
1717 | 1457 | ||
1718 | /* ----------------------------------------------------------------- | 1458 | /* ----------------------------------------------------------------- |
1719 | The below assignment will set bc to point at the BEGINING of | 1459 | The below assignment will set bc to point at the BEGINING of |
@@ -1721,7 +1461,7 @@ static void post_fep_init(unsigned int crd) | |||
1721 | 8 and 64 of these structures. | 1461 | 8 and 64 of these structures. |
1722 | -------------------------------------------------------------------- */ | 1462 | -------------------------------------------------------------------- */ |
1723 | 1463 | ||
1724 | bc = (volatile struct board_chan *)((ulong)memaddr + CHANSTRUCT); | 1464 | bc = (struct board_chan *)(memaddr + CHANSTRUCT); |
1725 | 1465 | ||
1726 | /* ------------------------------------------------------------------- | 1466 | /* ------------------------------------------------------------------- |
1727 | The below assignment will set gd to point at the BEGINING of | 1467 | The below assignment will set gd to point at the BEGINING of |
@@ -1730,20 +1470,18 @@ static void post_fep_init(unsigned int crd) | |||
1730 | pointer begins at 0xd10. | 1470 | pointer begins at 0xd10. |
1731 | ---------------------------------------------------------------------- */ | 1471 | ---------------------------------------------------------------------- */ |
1732 | 1472 | ||
1733 | gd = (volatile struct global_data *)((ulong)memaddr + GLOBAL); | 1473 | gd = (struct global_data *)(memaddr + GLOBAL); |
1734 | 1474 | ||
1735 | /* -------------------------------------------------------------------- | 1475 | /* -------------------------------------------------------------------- |
1736 | XEPORTS (address 0xc22) points at the number of channels the | 1476 | XEPORTS (address 0xc22) points at the number of channels the |
1737 | card supports. (For 64XE, XI, XEM, and XR use 0xc02) | 1477 | card supports. (For 64XE, XI, XEM, and XR use 0xc02) |
1738 | ----------------------------------------------------------------------- */ | 1478 | ----------------------------------------------------------------------- */ |
1739 | 1479 | ||
1740 | if (((bd->type == PCXEVE) | (bd->type == PCXE)) && | 1480 | if ((bd->type == PCXEVE || bd->type == PCXE) && (readw(memaddr + XEPORTS) < 3)) |
1741 | (*(ushort *)((ulong)memaddr + XEPORTS) < 3)) | ||
1742 | shrinkmem = 1; | 1481 | shrinkmem = 1; |
1743 | if (bd->type < PCIXEM) | 1482 | if (bd->type < PCIXEM) |
1744 | if (!request_region((int)bd->port, 4, board_desc[bd->type])) | 1483 | if (!request_region((int)bd->port, 4, board_desc[bd->type])) |
1745 | return; | 1484 | return; |
1746 | |||
1747 | memwinon(bd, 0); | 1485 | memwinon(bd, 0); |
1748 | 1486 | ||
1749 | /* -------------------------------------------------------------------- | 1487 | /* -------------------------------------------------------------------- |
@@ -1753,17 +1491,16 @@ static void post_fep_init(unsigned int crd) | |||
1753 | 1491 | ||
1754 | /* For every port on the card do ..... */ | 1492 | /* For every port on the card do ..... */ |
1755 | 1493 | ||
1756 | for (i = 0; i < bd->numports; i++, ch++, bc++) | 1494 | for (i = 0; i < bd->numports; i++, ch++, bc++) { /* Begin for each port */ |
1757 | { /* Begin for each port */ | 1495 | unsigned long flags; |
1758 | 1496 | ||
1759 | ch->brdchan = bc; | 1497 | ch->brdchan = bc; |
1760 | ch->mailbox = gd; | 1498 | ch->mailbox = gd; |
1761 | INIT_WORK(&ch->tqueue, do_softint, ch); | 1499 | INIT_WORK(&ch->tqueue, do_softint, ch); |
1762 | ch->board = &boards[crd]; | 1500 | ch->board = &boards[crd]; |
1763 | 1501 | ||
1764 | switch (bd->type) | 1502 | spin_lock_irqsave(&epca_lock, flags); |
1765 | { /* Begin switch bd->type */ | 1503 | switch (bd->type) { |
1766 | |||
1767 | /* ---------------------------------------------------------------- | 1504 | /* ---------------------------------------------------------------- |
1768 | Since some of the boards use different bitmaps for their | 1505 | Since some of the boards use different bitmaps for their |
1769 | control signals we cannot hard code these values and retain | 1506 | control signals we cannot hard code these values and retain |
@@ -1796,14 +1533,12 @@ static void post_fep_init(unsigned int crd) | |||
1796 | 1533 | ||
1797 | } /* End switch bd->type */ | 1534 | } /* End switch bd->type */ |
1798 | 1535 | ||
1799 | if (boards[crd].altpin) | 1536 | if (boards[crd].altpin) { |
1800 | { | ||
1801 | ch->dsr = ch->m_dcd; | 1537 | ch->dsr = ch->m_dcd; |
1802 | ch->dcd = ch->m_dsr; | 1538 | ch->dcd = ch->m_dsr; |
1803 | ch->digiext.digi_flags |= DIGI_ALTPIN; | 1539 | ch->digiext.digi_flags |= DIGI_ALTPIN; |
1804 | } | 1540 | } |
1805 | else | 1541 | else { |
1806 | { | ||
1807 | ch->dcd = ch->m_dcd; | 1542 | ch->dcd = ch->m_dcd; |
1808 | ch->dsr = ch->m_dsr; | 1543 | ch->dsr = ch->m_dsr; |
1809 | } | 1544 | } |
@@ -1813,14 +1548,12 @@ static void post_fep_init(unsigned int crd) | |||
1813 | ch->magic = EPCA_MAGIC; | 1548 | ch->magic = EPCA_MAGIC; |
1814 | ch->tty = NULL; | 1549 | ch->tty = NULL; |
1815 | 1550 | ||
1816 | if (shrinkmem) | 1551 | if (shrinkmem) { |
1817 | { | ||
1818 | fepcmd(ch, SETBUFFER, 32, 0, 0, 0); | 1552 | fepcmd(ch, SETBUFFER, 32, 0, 0, 0); |
1819 | shrinkmem = 0; | 1553 | shrinkmem = 0; |
1820 | } | 1554 | } |
1821 | 1555 | ||
1822 | switch (bd->type) | 1556 | switch (bd->type) { |
1823 | { /* Begin switch bd->type */ | ||
1824 | 1557 | ||
1825 | case PCIXEM: | 1558 | case PCIXEM: |
1826 | case PCIXRJ: | 1559 | case PCIXRJ: |
@@ -1878,13 +1611,13 @@ static void post_fep_init(unsigned int crd) | |||
1878 | 1611 | ||
1879 | fepcmd(ch, SRXHWATER, (3 * ch->rxbufsize / 4), 0, 10, 0); | 1612 | fepcmd(ch, SRXHWATER, (3 * ch->rxbufsize / 4), 0, 10, 0); |
1880 | 1613 | ||
1881 | bc->edelay = 100; | 1614 | writew(100, &bc->edelay); |
1882 | bc->idata = 1; | 1615 | writeb(1, &bc->idata); |
1883 | 1616 | ||
1884 | ch->startc = bc->startc; | 1617 | ch->startc = readb(&bc->startc); |
1885 | ch->stopc = bc->stopc; | 1618 | ch->stopc = readb(&bc->stopc); |
1886 | ch->startca = bc->startca; | 1619 | ch->startca = readb(&bc->startca); |
1887 | ch->stopca = bc->stopca; | 1620 | ch->stopca = readb(&bc->stopca); |
1888 | 1621 | ||
1889 | ch->fepcflag = 0; | 1622 | ch->fepcflag = 0; |
1890 | ch->fepiflag = 0; | 1623 | ch->fepiflag = 0; |
@@ -1899,27 +1632,23 @@ static void post_fep_init(unsigned int crd) | |||
1899 | ch->blocked_open = 0; | 1632 | ch->blocked_open = 0; |
1900 | init_waitqueue_head(&ch->open_wait); | 1633 | init_waitqueue_head(&ch->open_wait); |
1901 | init_waitqueue_head(&ch->close_wait); | 1634 | init_waitqueue_head(&ch->close_wait); |
1635 | |||
1636 | spin_unlock_irqrestore(&epca_lock, flags); | ||
1637 | |||
1902 | ch->tmp_buf = kmalloc(ch->txbufsize,GFP_KERNEL); | 1638 | ch->tmp_buf = kmalloc(ch->txbufsize,GFP_KERNEL); |
1903 | if (!(ch->tmp_buf)) | 1639 | if (!ch->tmp_buf) { |
1904 | { | ||
1905 | printk(KERN_ERR "POST FEP INIT : kmalloc failed for port 0x%x\n",i); | 1640 | printk(KERN_ERR "POST FEP INIT : kmalloc failed for port 0x%x\n",i); |
1906 | release_region((int)bd->port, 4); | 1641 | release_region((int)bd->port, 4); |
1907 | while(i-- > 0) | 1642 | while(i-- > 0) |
1908 | kfree((ch--)->tmp_buf); | 1643 | kfree((ch--)->tmp_buf); |
1909 | return; | 1644 | return; |
1910 | } | 1645 | } else |
1911 | else | ||
1912 | memset((void *)ch->tmp_buf,0,ch->txbufsize); | 1646 | memset((void *)ch->tmp_buf,0,ch->txbufsize); |
1913 | } /* End for each port */ | 1647 | } /* End for each port */ |
1914 | 1648 | ||
1915 | printk(KERN_INFO | 1649 | printk(KERN_INFO |
1916 | "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n", | 1650 | "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n", |
1917 | VERSION, board_desc[bd->type], (long)bd->port, (long)bd->membase, bd->numports); | 1651 | VERSION, board_desc[bd->type], (long)bd->port, (long)bd->membase, bd->numports); |
1918 | sprintf(mesg, | ||
1919 | "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n", | ||
1920 | VERSION, board_desc[bd->type], (long)bd->port, (long)bd->membase, bd->numports); | ||
1921 | console_print(mesg); | ||
1922 | |||
1923 | memwinoff(bd, 0); | 1652 | memwinoff(bd, 0); |
1924 | 1653 | ||
1925 | } /* End post_fep_init */ | 1654 | } /* End post_fep_init */ |
@@ -1943,9 +1672,6 @@ static void epcapoll(unsigned long ignored) | |||
1943 | buffer empty) and acts on those events. | 1672 | buffer empty) and acts on those events. |
1944 | ----------------------------------------------------------------------- */ | 1673 | ----------------------------------------------------------------------- */ |
1945 | 1674 | ||
1946 | save_flags(flags); | ||
1947 | cli(); | ||
1948 | |||
1949 | for (crd = 0; crd < num_cards; crd++) | 1675 | for (crd = 0; crd < num_cards; crd++) |
1950 | { /* Begin for each card */ | 1676 | { /* Begin for each card */ |
1951 | 1677 | ||
@@ -1961,6 +1687,8 @@ static void epcapoll(unsigned long ignored) | |||
1961 | some legacy boards. | 1687 | some legacy boards. |
1962 | ---------------------------------------------------------------- */ | 1688 | ---------------------------------------------------------------- */ |
1963 | 1689 | ||
1690 | spin_lock_irqsave(&epca_lock, flags); | ||
1691 | |||
1964 | assertmemoff(ch); | 1692 | assertmemoff(ch); |
1965 | 1693 | ||
1966 | globalwinon(ch); | 1694 | globalwinon(ch); |
@@ -1970,21 +1698,19 @@ static void epcapoll(unsigned long ignored) | |||
1970 | the transmit or receive queue. | 1698 | the transmit or receive queue. |
1971 | ------------------------------------------------------------------- */ | 1699 | ------------------------------------------------------------------- */ |
1972 | 1700 | ||
1973 | head = ch->mailbox->ein; | 1701 | head = readw(&ch->mailbox->ein); |
1974 | tail = ch->mailbox->eout; | 1702 | tail = readw(&ch->mailbox->eout); |
1975 | 1703 | ||
1976 | /* If head isn't equal to tail we have an event */ | 1704 | /* If head isn't equal to tail we have an event */ |
1977 | 1705 | ||
1978 | if (head != tail) | 1706 | if (head != tail) |
1979 | doevent(crd); | 1707 | doevent(crd); |
1980 | |||
1981 | memoff(ch); | 1708 | memoff(ch); |
1982 | 1709 | ||
1983 | } /* End for each card */ | 1710 | spin_unlock_irqrestore(&epca_lock, flags); |
1984 | 1711 | ||
1712 | } /* End for each card */ | ||
1985 | mod_timer(&epca_timer, jiffies + (HZ / 25)); | 1713 | mod_timer(&epca_timer, jiffies + (HZ / 25)); |
1986 | |||
1987 | restore_flags(flags); | ||
1988 | } /* End epcapoll */ | 1714 | } /* End epcapoll */ |
1989 | 1715 | ||
1990 | /* --------------------- Begin doevent ------------------------ */ | 1716 | /* --------------------- Begin doevent ------------------------ */ |
@@ -1992,53 +1718,42 @@ static void epcapoll(unsigned long ignored) | |||
1992 | static void doevent(int crd) | 1718 | static void doevent(int crd) |
1993 | { /* Begin doevent */ | 1719 | { /* Begin doevent */ |
1994 | 1720 | ||
1995 | volatile unchar *eventbuf; | 1721 | void *eventbuf; |
1996 | struct channel *ch, *chan0; | 1722 | struct channel *ch, *chan0; |
1997 | static struct tty_struct *tty; | 1723 | static struct tty_struct *tty; |
1998 | volatile struct board_info *bd; | 1724 | struct board_info *bd; |
1999 | volatile struct board_chan *bc; | 1725 | struct board_chan *bc; |
2000 | register volatile unsigned int tail, head; | 1726 | unsigned int tail, head; |
2001 | register int event, channel; | 1727 | int event, channel; |
2002 | register int mstat, lstat; | 1728 | int mstat, lstat; |
2003 | 1729 | ||
2004 | /* ------------------------------------------------------------------- | 1730 | /* ------------------------------------------------------------------- |
2005 | This subroutine is called by epcapoll when an event is detected | 1731 | This subroutine is called by epcapoll when an event is detected |
2006 | in the event queue. This routine responds to those events. | 1732 | in the event queue. This routine responds to those events. |
2007 | --------------------------------------------------------------------- */ | 1733 | --------------------------------------------------------------------- */ |
2008 | |||
2009 | bd = &boards[crd]; | 1734 | bd = &boards[crd]; |
2010 | 1735 | ||
2011 | chan0 = card_ptr[crd]; | 1736 | chan0 = card_ptr[crd]; |
2012 | epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range"); | 1737 | epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range"); |
2013 | |||
2014 | assertgwinon(chan0); | 1738 | assertgwinon(chan0); |
2015 | 1739 | while ((tail = readw(&chan0->mailbox->eout)) != (head = readw(&chan0->mailbox->ein))) | |
2016 | while ((tail = chan0->mailbox->eout) != (head = chan0->mailbox->ein)) | ||
2017 | { /* Begin while something in event queue */ | 1740 | { /* Begin while something in event queue */ |
2018 | |||
2019 | assertgwinon(chan0); | 1741 | assertgwinon(chan0); |
2020 | 1742 | eventbuf = bd->re_map_membase + tail + ISTART; | |
2021 | eventbuf = (volatile unchar *)bus_to_virt((ulong)(bd->re_map_membase + tail + ISTART)); | ||
2022 | |||
2023 | /* Get the channel the event occurred on */ | 1743 | /* Get the channel the event occurred on */ |
2024 | channel = eventbuf[0]; | 1744 | channel = readb(eventbuf); |
2025 | |||
2026 | /* Get the actual event code that occurred */ | 1745 | /* Get the actual event code that occurred */ |
2027 | event = eventbuf[1]; | 1746 | event = readb(eventbuf + 1); |
2028 | |||
2029 | /* ---------------------------------------------------------------- | 1747 | /* ---------------------------------------------------------------- |
2030 | The two assignments below get the current modem status (mstat) | 1748 | The two assignments below get the current modem status (mstat) |
2031 | and the previous modem status (lstat). These are useful becuase | 1749 | and the previous modem status (lstat). These are useful becuase |
2032 | an event could signal a change in modem signals itself. | 1750 | an event could signal a change in modem signals itself. |
2033 | ------------------------------------------------------------------- */ | 1751 | ------------------------------------------------------------------- */ |
2034 | 1752 | mstat = readb(eventbuf + 2); | |
2035 | mstat = eventbuf[2]; | 1753 | lstat = readb(eventbuf + 3); |
2036 | lstat = eventbuf[3]; | ||
2037 | 1754 | ||
2038 | ch = chan0 + channel; | 1755 | ch = chan0 + channel; |
2039 | 1756 | if ((unsigned)channel >= bd->numports || !ch) { | |
2040 | if ((unsigned)channel >= bd->numports || !ch) | ||
2041 | { | ||
2042 | if (channel >= bd->numports) | 1757 | if (channel >= bd->numports) |
2043 | ch = chan0; | 1758 | ch = chan0; |
2044 | bc = ch->brdchan; | 1759 | bc = ch->brdchan; |
@@ -2048,97 +1763,53 @@ static void doevent(int crd) | |||
2048 | if ((bc = ch->brdchan) == NULL) | 1763 | if ((bc = ch->brdchan) == NULL) |
2049 | goto next; | 1764 | goto next; |
2050 | 1765 | ||
2051 | if (event & DATA_IND) | 1766 | if (event & DATA_IND) { /* Begin DATA_IND */ |
2052 | { /* Begin DATA_IND */ | ||
2053 | |||
2054 | receive_data(ch); | 1767 | receive_data(ch); |
2055 | assertgwinon(ch); | 1768 | assertgwinon(ch); |
2056 | |||
2057 | } /* End DATA_IND */ | 1769 | } /* End DATA_IND */ |
2058 | /* else *//* Fix for DCD transition missed bug */ | 1770 | /* else *//* Fix for DCD transition missed bug */ |
2059 | if (event & MODEMCHG_IND) | 1771 | if (event & MODEMCHG_IND) { /* Begin MODEMCHG_IND */ |
2060 | { /* Begin MODEMCHG_IND */ | ||
2061 | |||
2062 | /* A modem signal change has been indicated */ | 1772 | /* A modem signal change has been indicated */ |
2063 | |||
2064 | ch->imodem = mstat; | 1773 | ch->imodem = mstat; |
2065 | 1774 | if (ch->asyncflags & ASYNC_CHECK_CD) { | |
2066 | if (ch->asyncflags & ASYNC_CHECK_CD) | ||
2067 | { | ||
2068 | if (mstat & ch->dcd) /* We are now receiving dcd */ | 1775 | if (mstat & ch->dcd) /* We are now receiving dcd */ |
2069 | wake_up_interruptible(&ch->open_wait); | 1776 | wake_up_interruptible(&ch->open_wait); |
2070 | else | 1777 | else |
2071 | pc_sched_event(ch, EPCA_EVENT_HANGUP); /* No dcd; hangup */ | 1778 | pc_sched_event(ch, EPCA_EVENT_HANGUP); /* No dcd; hangup */ |
2072 | } | 1779 | } |
2073 | |||
2074 | } /* End MODEMCHG_IND */ | 1780 | } /* End MODEMCHG_IND */ |
2075 | |||
2076 | tty = ch->tty; | 1781 | tty = ch->tty; |
2077 | if (tty) | 1782 | if (tty) { /* Begin if valid tty */ |
2078 | { /* Begin if valid tty */ | 1783 | if (event & BREAK_IND) { /* Begin if BREAK_IND */ |
2079 | |||
2080 | if (event & BREAK_IND) | ||
2081 | { /* Begin if BREAK_IND */ | ||
2082 | |||
2083 | /* A break has been indicated */ | 1784 | /* A break has been indicated */ |
2084 | |||
2085 | tty->flip.count++; | 1785 | tty->flip.count++; |
2086 | *tty->flip.flag_buf_ptr++ = TTY_BREAK; | 1786 | *tty->flip.flag_buf_ptr++ = TTY_BREAK; |
2087 | |||
2088 | *tty->flip.char_buf_ptr++ = 0; | 1787 | *tty->flip.char_buf_ptr++ = 0; |
2089 | |||
2090 | tty_schedule_flip(tty); | 1788 | tty_schedule_flip(tty); |
2091 | 1789 | } else if (event & LOWTX_IND) { /* Begin LOWTX_IND */ | |
2092 | } /* End if BREAK_IND */ | ||
2093 | else | ||
2094 | if (event & LOWTX_IND) | ||
2095 | { /* Begin LOWTX_IND */ | ||
2096 | |||
2097 | if (ch->statusflags & LOWWAIT) | 1790 | if (ch->statusflags & LOWWAIT) |
2098 | { /* Begin if LOWWAIT */ | 1791 | { /* Begin if LOWWAIT */ |
2099 | |||
2100 | ch->statusflags &= ~LOWWAIT; | 1792 | ch->statusflags &= ~LOWWAIT; |
2101 | tty_wakeup(tty); | 1793 | tty_wakeup(tty); |
2102 | wake_up_interruptible(&tty->write_wait); | 1794 | wake_up_interruptible(&tty->write_wait); |
2103 | |||
2104 | } /* End if LOWWAIT */ | 1795 | } /* End if LOWWAIT */ |
2105 | 1796 | } else if (event & EMPTYTX_IND) { /* Begin EMPTYTX_IND */ | |
2106 | } /* End LOWTX_IND */ | ||
2107 | else | ||
2108 | if (event & EMPTYTX_IND) | ||
2109 | { /* Begin EMPTYTX_IND */ | ||
2110 | |||
2111 | /* This event is generated by setup_empty_event */ | 1797 | /* This event is generated by setup_empty_event */ |
2112 | |||
2113 | ch->statusflags &= ~TXBUSY; | 1798 | ch->statusflags &= ~TXBUSY; |
2114 | if (ch->statusflags & EMPTYWAIT) | 1799 | if (ch->statusflags & EMPTYWAIT) { /* Begin if EMPTYWAIT */ |
2115 | { /* Begin if EMPTYWAIT */ | ||
2116 | |||
2117 | ch->statusflags &= ~EMPTYWAIT; | 1800 | ch->statusflags &= ~EMPTYWAIT; |
2118 | tty_wakeup(tty); | 1801 | tty_wakeup(tty); |
2119 | |||
2120 | wake_up_interruptible(&tty->write_wait); | 1802 | wake_up_interruptible(&tty->write_wait); |
2121 | |||
2122 | } /* End if EMPTYWAIT */ | 1803 | } /* End if EMPTYWAIT */ |
2123 | |||
2124 | } /* End EMPTYTX_IND */ | 1804 | } /* End EMPTYTX_IND */ |
2125 | |||
2126 | } /* End if valid tty */ | 1805 | } /* End if valid tty */ |
2127 | |||
2128 | |||
2129 | next: | 1806 | next: |
2130 | globalwinon(ch); | 1807 | globalwinon(ch); |
2131 | 1808 | BUG_ON(!bc); | |
2132 | if (!bc) | 1809 | writew(1, &bc->idata); |
2133 | printk(KERN_ERR "<Error> - bc == NULL in doevent!\n"); | 1810 | writew((tail + 4) & (IMAX - ISTART - 4), &chan0->mailbox->eout); |
2134 | else | ||
2135 | bc->idata = 1; | ||
2136 | |||
2137 | chan0->mailbox->eout = (tail + 4) & (IMAX - ISTART - 4); | ||
2138 | globalwinon(chan0); | 1811 | globalwinon(chan0); |
2139 | |||
2140 | } /* End while something in event queue */ | 1812 | } /* End while something in event queue */ |
2141 | |||
2142 | } /* End doevent */ | 1813 | } /* End doevent */ |
2143 | 1814 | ||
2144 | /* --------------------- Begin fepcmd ------------------------ */ | 1815 | /* --------------------- Begin fepcmd ------------------------ */ |
@@ -2146,7 +1817,6 @@ static void doevent(int crd) | |||
2146 | static void fepcmd(struct channel *ch, int cmd, int word_or_byte, | 1817 | static void fepcmd(struct channel *ch, int cmd, int word_or_byte, |
2147 | int byte2, int ncmds, int bytecmd) | 1818 | int byte2, int ncmds, int bytecmd) |
2148 | { /* Begin fepcmd */ | 1819 | { /* Begin fepcmd */ |
2149 | |||
2150 | unchar *memaddr; | 1820 | unchar *memaddr; |
2151 | unsigned int head, cmdTail, cmdStart, cmdMax; | 1821 | unsigned int head, cmdTail, cmdStart, cmdMax; |
2152 | long count; | 1822 | long count; |
@@ -2155,93 +1825,57 @@ static void fepcmd(struct channel *ch, int cmd, int word_or_byte, | |||
2155 | /* This is the routine in which commands may be passed to the card. */ | 1825 | /* This is the routine in which commands may be passed to the card. */ |
2156 | 1826 | ||
2157 | if (ch->board->status == DISABLED) | 1827 | if (ch->board->status == DISABLED) |
2158 | { | ||
2159 | return; | 1828 | return; |
2160 | } | ||
2161 | |||
2162 | assertgwinon(ch); | 1829 | assertgwinon(ch); |
2163 | |||
2164 | /* Remember head (As well as max) is just an offset not a base addr */ | 1830 | /* Remember head (As well as max) is just an offset not a base addr */ |
2165 | head = ch->mailbox->cin; | 1831 | head = readw(&ch->mailbox->cin); |
2166 | |||
2167 | /* cmdStart is a base address */ | 1832 | /* cmdStart is a base address */ |
2168 | cmdStart = ch->mailbox->cstart; | 1833 | cmdStart = readw(&ch->mailbox->cstart); |
2169 | |||
2170 | /* ------------------------------------------------------------------ | 1834 | /* ------------------------------------------------------------------ |
2171 | We do the addition below because we do not want a max pointer | 1835 | We do the addition below because we do not want a max pointer |
2172 | relative to cmdStart. We want a max pointer that points at the | 1836 | relative to cmdStart. We want a max pointer that points at the |
2173 | physical end of the command queue. | 1837 | physical end of the command queue. |
2174 | -------------------------------------------------------------------- */ | 1838 | -------------------------------------------------------------------- */ |
2175 | 1839 | cmdMax = (cmdStart + 4 + readw(&ch->mailbox->cmax)); | |
2176 | cmdMax = (cmdStart + 4 + (ch->mailbox->cmax)); | ||
2177 | |||
2178 | memaddr = ch->board->re_map_membase; | 1840 | memaddr = ch->board->re_map_membase; |
2179 | 1841 | ||
2180 | /* | 1842 | if (head >= (cmdMax - cmdStart) || (head & 03)) { |
2181 | The below command is necessary because newer kernels (2.1.x and | 1843 | printk(KERN_ERR "line %d: Out of range, cmd = %x, head = %x\n", __LINE__, cmd, head); |
2182 | up) do not have a 1:1 virtual to physical mapping. The below | 1844 | printk(KERN_ERR "line %d: Out of range, cmdMax = %x, cmdStart = %x\n", __LINE__, cmdMax, cmdStart); |
2183 | call adjust for that. | ||
2184 | */ | ||
2185 | |||
2186 | memaddr = (unsigned char *)bus_to_virt((unsigned long)memaddr); | ||
2187 | |||
2188 | if (head >= (cmdMax - cmdStart) || (head & 03)) | ||
2189 | { | ||
2190 | printk(KERN_ERR "line %d: Out of range, cmd = %x, head = %x\n", __LINE__, | ||
2191 | cmd, head); | ||
2192 | printk(KERN_ERR "line %d: Out of range, cmdMax = %x, cmdStart = %x\n", __LINE__, | ||
2193 | cmdMax, cmdStart); | ||
2194 | return; | 1845 | return; |
2195 | } | 1846 | } |
2196 | 1847 | if (bytecmd) { | |
2197 | if (bytecmd) | 1848 | writeb(cmd, memaddr + head + cmdStart + 0); |
2198 | { | 1849 | writeb(ch->channelnum, memaddr + head + cmdStart + 1); |
2199 | *(volatile unchar *)(memaddr + head + cmdStart + 0) = (unchar)cmd; | ||
2200 | |||
2201 | *(volatile unchar *)(memaddr + head + cmdStart + 1) = (unchar)ch->channelnum; | ||
2202 | /* Below word_or_byte is bits to set */ | 1850 | /* Below word_or_byte is bits to set */ |
2203 | *(volatile unchar *)(memaddr + head + cmdStart + 2) = (unchar)word_or_byte; | 1851 | writeb(word_or_byte, memaddr + head + cmdStart + 2); |
2204 | /* Below byte2 is bits to reset */ | 1852 | /* Below byte2 is bits to reset */ |
2205 | *(volatile unchar *)(memaddr + head + cmdStart + 3) = (unchar)byte2; | 1853 | writeb(byte2, memaddr + head + cmdStart + 3); |
2206 | 1854 | } else { | |
2207 | } | 1855 | writeb(cmd, memaddr + head + cmdStart + 0); |
2208 | else | 1856 | writeb(ch->channelnum, memaddr + head + cmdStart + 1); |
2209 | { | 1857 | writeb(word_or_byte, memaddr + head + cmdStart + 2); |
2210 | *(volatile unchar *)(memaddr + head + cmdStart + 0) = (unchar)cmd; | ||
2211 | *(volatile unchar *)(memaddr + head + cmdStart + 1) = (unchar)ch->channelnum; | ||
2212 | *(volatile ushort*)(memaddr + head + cmdStart + 2) = (ushort)word_or_byte; | ||
2213 | } | 1858 | } |
2214 | |||
2215 | head = (head + 4) & (cmdMax - cmdStart - 4); | 1859 | head = (head + 4) & (cmdMax - cmdStart - 4); |
2216 | ch->mailbox->cin = head; | 1860 | writew(head, &ch->mailbox->cin); |
2217 | |||
2218 | count = FEPTIMEOUT; | 1861 | count = FEPTIMEOUT; |
2219 | 1862 | ||
2220 | for (;;) | 1863 | for (;;) { /* Begin forever loop */ |
2221 | { /* Begin forever loop */ | ||
2222 | |||
2223 | count--; | 1864 | count--; |
2224 | if (count == 0) | 1865 | if (count == 0) { |
2225 | { | ||
2226 | printk(KERN_ERR "<Error> - Fep not responding in fepcmd()\n"); | 1866 | printk(KERN_ERR "<Error> - Fep not responding in fepcmd()\n"); |
2227 | return; | 1867 | return; |
2228 | } | 1868 | } |
2229 | 1869 | head = readw(&ch->mailbox->cin); | |
2230 | head = ch->mailbox->cin; | 1870 | cmdTail = readw(&ch->mailbox->cout); |
2231 | cmdTail = ch->mailbox->cout; | ||
2232 | |||
2233 | n = (head - cmdTail) & (cmdMax - cmdStart - 4); | 1871 | n = (head - cmdTail) & (cmdMax - cmdStart - 4); |
2234 | |||
2235 | /* ---------------------------------------------------------- | 1872 | /* ---------------------------------------------------------- |
2236 | Basically this will break when the FEP acknowledges the | 1873 | Basically this will break when the FEP acknowledges the |
2237 | command by incrementing cmdTail (Making it equal to head). | 1874 | command by incrementing cmdTail (Making it equal to head). |
2238 | ------------------------------------------------------------- */ | 1875 | ------------------------------------------------------------- */ |
2239 | |||
2240 | if (n <= ncmds * (sizeof(short) * 4)) | 1876 | if (n <= ncmds * (sizeof(short) * 4)) |
2241 | break; /* Well nearly forever :-) */ | 1877 | break; /* Well nearly forever :-) */ |
2242 | |||
2243 | } /* End forever loop */ | 1878 | } /* End forever loop */ |
2244 | |||
2245 | } /* End fepcmd */ | 1879 | } /* End fepcmd */ |
2246 | 1880 | ||
2247 | /* --------------------------------------------------------------------- | 1881 | /* --------------------------------------------------------------------- |
@@ -2255,11 +1889,9 @@ static void fepcmd(struct channel *ch, int cmd, int word_or_byte, | |||
2255 | 1889 | ||
2256 | static unsigned termios2digi_h(struct channel *ch, unsigned cflag) | 1890 | static unsigned termios2digi_h(struct channel *ch, unsigned cflag) |
2257 | { /* Begin termios2digi_h */ | 1891 | { /* Begin termios2digi_h */ |
2258 | |||
2259 | unsigned res = 0; | 1892 | unsigned res = 0; |
2260 | 1893 | ||
2261 | if (cflag & CRTSCTS) | 1894 | if (cflag & CRTSCTS) { |
2262 | { | ||
2263 | ch->digiext.digi_flags |= (RTSPACE | CTSPACE); | 1895 | ch->digiext.digi_flags |= (RTSPACE | CTSPACE); |
2264 | res |= ((ch->m_cts) | (ch->m_rts)); | 1896 | res |= ((ch->m_cts) | (ch->m_rts)); |
2265 | } | 1897 | } |
@@ -2295,7 +1927,6 @@ static unsigned termios2digi_i(struct channel *ch, unsigned iflag) | |||
2295 | 1927 | ||
2296 | unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | | 1928 | unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | |
2297 | INPCK | ISTRIP|IXON|IXANY|IXOFF); | 1929 | INPCK | ISTRIP|IXON|IXANY|IXOFF); |
2298 | |||
2299 | if (ch->digiext.digi_flags & DIGI_AIXON) | 1930 | if (ch->digiext.digi_flags & DIGI_AIXON) |
2300 | res |= IAIXON; | 1931 | res |= IAIXON; |
2301 | return res; | 1932 | return res; |
@@ -2308,28 +1939,15 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2308 | { /* Begin termios2digi_c */ | 1939 | { /* Begin termios2digi_c */ |
2309 | 1940 | ||
2310 | unsigned res = 0; | 1941 | unsigned res = 0; |
2311 | 1942 | if (cflag & CBAUDEX) { /* Begin detected CBAUDEX */ | |
2312 | #ifdef SPEED_HACK | ||
2313 | /* CL: HACK to force 115200 at 38400 and 57600 at 19200 Baud */ | ||
2314 | if ((cflag & CBAUD)== B38400) cflag=cflag - B38400 + B115200; | ||
2315 | if ((cflag & CBAUD)== B19200) cflag=cflag - B19200 + B57600; | ||
2316 | #endif /* SPEED_HACK */ | ||
2317 | |||
2318 | if (cflag & CBAUDEX) | ||
2319 | { /* Begin detected CBAUDEX */ | ||
2320 | |||
2321 | ch->digiext.digi_flags |= DIGI_FAST; | 1943 | ch->digiext.digi_flags |= DIGI_FAST; |
2322 | |||
2323 | /* ------------------------------------------------------------- | 1944 | /* ------------------------------------------------------------- |
2324 | HUPCL bit is used by FEP to indicate fast baud | 1945 | HUPCL bit is used by FEP to indicate fast baud |
2325 | table is to be used. | 1946 | table is to be used. |
2326 | ----------------------------------------------------------------- */ | 1947 | ----------------------------------------------------------------- */ |
2327 | |||
2328 | res |= FEP_HUPCL; | 1948 | res |= FEP_HUPCL; |
2329 | |||
2330 | } /* End detected CBAUDEX */ | 1949 | } /* End detected CBAUDEX */ |
2331 | else ch->digiext.digi_flags &= ~DIGI_FAST; | 1950 | else ch->digiext.digi_flags &= ~DIGI_FAST; |
2332 | |||
2333 | /* ------------------------------------------------------------------- | 1951 | /* ------------------------------------------------------------------- |
2334 | CBAUD has bit position 0x1000 set these days to indicate Linux | 1952 | CBAUD has bit position 0x1000 set these days to indicate Linux |
2335 | baud rate remap. Digi hardware can't handle the bit assignment. | 1953 | baud rate remap. Digi hardware can't handle the bit assignment. |
@@ -2337,7 +1955,6 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2337 | bit out. | 1955 | bit out. |
2338 | ---------------------------------------------------------------------- */ | 1956 | ---------------------------------------------------------------------- */ |
2339 | res |= cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE); | 1957 | res |= cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE); |
2340 | |||
2341 | /* ------------------------------------------------------------- | 1958 | /* ------------------------------------------------------------- |
2342 | This gets a little confusing. The Digi cards have their own | 1959 | This gets a little confusing. The Digi cards have their own |
2343 | representation of c_cflags controling baud rate. For the most | 1960 | representation of c_cflags controling baud rate. For the most |
@@ -2357,10 +1974,8 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2357 | should be checked for a screened out prior to termios2digi_c | 1974 | should be checked for a screened out prior to termios2digi_c |
2358 | returning. Since CLOCAL isn't used by the board this can be | 1975 | returning. Since CLOCAL isn't used by the board this can be |
2359 | ignored as long as the returned value is used only by Digi hardware. | 1976 | ignored as long as the returned value is used only by Digi hardware. |
2360 | ----------------------------------------------------------------- */ | 1977 | ----------------------------------------------------------------- */ |
2361 | 1978 | if (cflag & CBAUDEX) { | |
2362 | if (cflag & CBAUDEX) | ||
2363 | { | ||
2364 | /* ------------------------------------------------------------- | 1979 | /* ------------------------------------------------------------- |
2365 | The below code is trying to guarantee that only baud rates | 1980 | The below code is trying to guarantee that only baud rates |
2366 | 115200 and 230400 are remapped. We use exclusive or because | 1981 | 115200 and 230400 are remapped. We use exclusive or because |
@@ -2371,138 +1986,96 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2371 | 1986 | ||
2372 | if ((!((cflag & 0x7) ^ (B115200 & ~CBAUDEX))) || | 1987 | if ((!((cflag & 0x7) ^ (B115200 & ~CBAUDEX))) || |
2373 | (!((cflag & 0x7) ^ (B230400 & ~CBAUDEX)))) | 1988 | (!((cflag & 0x7) ^ (B230400 & ~CBAUDEX)))) |
2374 | { | ||
2375 | res += 1; | 1989 | res += 1; |
2376 | } | ||
2377 | } | 1990 | } |
2378 | |||
2379 | return res; | 1991 | return res; |
2380 | 1992 | ||
2381 | } /* End termios2digi_c */ | 1993 | } /* End termios2digi_c */ |
2382 | 1994 | ||
2383 | /* --------------------- Begin epcaparam ----------------------- */ | 1995 | /* --------------------- Begin epcaparam ----------------------- */ |
2384 | 1996 | ||
1997 | /* Caller must hold the locks */ | ||
2385 | static void epcaparam(struct tty_struct *tty, struct channel *ch) | 1998 | static void epcaparam(struct tty_struct *tty, struct channel *ch) |
2386 | { /* Begin epcaparam */ | 1999 | { /* Begin epcaparam */ |
2387 | 2000 | ||
2388 | unsigned int cmdHead; | 2001 | unsigned int cmdHead; |
2389 | struct termios *ts; | 2002 | struct termios *ts; |
2390 | volatile struct board_chan *bc; | 2003 | struct board_chan *bc; |
2391 | unsigned mval, hflow, cflag, iflag; | 2004 | unsigned mval, hflow, cflag, iflag; |
2392 | 2005 | ||
2393 | bc = ch->brdchan; | 2006 | bc = ch->brdchan; |
2394 | epcaassert(bc !=0, "bc out of range"); | 2007 | epcaassert(bc !=0, "bc out of range"); |
2395 | 2008 | ||
2396 | assertgwinon(ch); | 2009 | assertgwinon(ch); |
2397 | |||
2398 | ts = tty->termios; | 2010 | ts = tty->termios; |
2399 | 2011 | if ((ts->c_cflag & CBAUD) == 0) { /* Begin CBAUD detected */ | |
2400 | if ((ts->c_cflag & CBAUD) == 0) | 2012 | cmdHead = readw(&bc->rin); |
2401 | { /* Begin CBAUD detected */ | ||
2402 | |||
2403 | cmdHead = bc->rin; | ||
2404 | bc->rout = cmdHead; | 2013 | bc->rout = cmdHead; |
2405 | cmdHead = bc->tin; | 2014 | cmdHead = readw(&bc->tin); |
2406 | |||
2407 | /* Changing baud in mid-stream transmission can be wonderful */ | 2015 | /* Changing baud in mid-stream transmission can be wonderful */ |
2408 | /* --------------------------------------------------------------- | 2016 | /* --------------------------------------------------------------- |
2409 | Flush current transmit buffer by setting cmdTail pointer (tout) | 2017 | Flush current transmit buffer by setting cmdTail pointer (tout) |
2410 | to cmdHead pointer (tin). Hopefully the transmit buffer is empty. | 2018 | to cmdHead pointer (tin). Hopefully the transmit buffer is empty. |
2411 | ----------------------------------------------------------------- */ | 2019 | ----------------------------------------------------------------- */ |
2412 | |||
2413 | fepcmd(ch, STOUT, (unsigned) cmdHead, 0, 0, 0); | 2020 | fepcmd(ch, STOUT, (unsigned) cmdHead, 0, 0, 0); |
2414 | mval = 0; | 2021 | mval = 0; |
2415 | 2022 | } else { /* Begin CBAUD not detected */ | |
2416 | } /* End CBAUD detected */ | ||
2417 | else | ||
2418 | { /* Begin CBAUD not detected */ | ||
2419 | |||
2420 | /* ------------------------------------------------------------------- | 2023 | /* ------------------------------------------------------------------- |
2421 | c_cflags have changed but that change had nothing to do with BAUD. | 2024 | c_cflags have changed but that change had nothing to do with BAUD. |
2422 | Propagate the change to the card. | 2025 | Propagate the change to the card. |
2423 | ---------------------------------------------------------------------- */ | 2026 | ---------------------------------------------------------------------- */ |
2424 | |||
2425 | cflag = termios2digi_c(ch, ts->c_cflag); | 2027 | cflag = termios2digi_c(ch, ts->c_cflag); |
2426 | 2028 | if (cflag != ch->fepcflag) { | |
2427 | if (cflag != ch->fepcflag) | ||
2428 | { | ||
2429 | ch->fepcflag = cflag; | 2029 | ch->fepcflag = cflag; |
2430 | /* Set baud rate, char size, stop bits, parity */ | 2030 | /* Set baud rate, char size, stop bits, parity */ |
2431 | fepcmd(ch, SETCTRLFLAGS, (unsigned) cflag, 0, 0, 0); | 2031 | fepcmd(ch, SETCTRLFLAGS, (unsigned) cflag, 0, 0, 0); |
2432 | } | 2032 | } |
2433 | |||
2434 | |||
2435 | /* ---------------------------------------------------------------- | 2033 | /* ---------------------------------------------------------------- |
2436 | If the user has not forced CLOCAL and if the device is not a | 2034 | If the user has not forced CLOCAL and if the device is not a |
2437 | CALLOUT device (Which is always CLOCAL) we set flags such that | 2035 | CALLOUT device (Which is always CLOCAL) we set flags such that |
2438 | the driver will wait on carrier detect. | 2036 | the driver will wait on carrier detect. |
2439 | ------------------------------------------------------------------- */ | 2037 | ------------------------------------------------------------------- */ |
2440 | |||
2441 | if (ts->c_cflag & CLOCAL) | 2038 | if (ts->c_cflag & CLOCAL) |
2442 | { /* Begin it is a cud device or a ttyD device with CLOCAL on */ | ||
2443 | ch->asyncflags &= ~ASYNC_CHECK_CD; | 2039 | ch->asyncflags &= ~ASYNC_CHECK_CD; |
2444 | } /* End it is a cud device or a ttyD device with CLOCAL on */ | ||
2445 | else | 2040 | else |
2446 | { /* Begin it is a ttyD device */ | ||
2447 | ch->asyncflags |= ASYNC_CHECK_CD; | 2041 | ch->asyncflags |= ASYNC_CHECK_CD; |
2448 | } /* End it is a ttyD device */ | ||
2449 | |||
2450 | mval = ch->m_dtr | ch->m_rts; | 2042 | mval = ch->m_dtr | ch->m_rts; |
2451 | |||
2452 | } /* End CBAUD not detected */ | 2043 | } /* End CBAUD not detected */ |
2453 | |||
2454 | iflag = termios2digi_i(ch, ts->c_iflag); | 2044 | iflag = termios2digi_i(ch, ts->c_iflag); |
2455 | |||
2456 | /* Check input mode flags */ | 2045 | /* Check input mode flags */ |
2457 | 2046 | if (iflag != ch->fepiflag) { | |
2458 | if (iflag != ch->fepiflag) | ||
2459 | { | ||
2460 | ch->fepiflag = iflag; | 2047 | ch->fepiflag = iflag; |
2461 | |||
2462 | /* --------------------------------------------------------------- | 2048 | /* --------------------------------------------------------------- |
2463 | Command sets channels iflag structure on the board. Such things | 2049 | Command sets channels iflag structure on the board. Such things |
2464 | as input soft flow control, handling of parity errors, and | 2050 | as input soft flow control, handling of parity errors, and |
2465 | break handling are all set here. | 2051 | break handling are all set here. |
2466 | ------------------------------------------------------------------- */ | 2052 | ------------------------------------------------------------------- */ |
2467 | |||
2468 | /* break handling, parity handling, input stripping, flow control chars */ | 2053 | /* break handling, parity handling, input stripping, flow control chars */ |
2469 | fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0); | 2054 | fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0); |
2470 | } | 2055 | } |
2471 | |||
2472 | /* --------------------------------------------------------------- | 2056 | /* --------------------------------------------------------------- |
2473 | Set the board mint value for this channel. This will cause hardware | 2057 | Set the board mint value for this channel. This will cause hardware |
2474 | events to be generated each time the DCD signal (Described in mint) | 2058 | events to be generated each time the DCD signal (Described in mint) |
2475 | changes. | 2059 | changes. |
2476 | ------------------------------------------------------------------- */ | 2060 | ------------------------------------------------------------------- */ |
2477 | bc->mint = ch->dcd; | 2061 | writeb(ch->dcd, &bc->mint); |
2478 | |||
2479 | if ((ts->c_cflag & CLOCAL) || (ch->digiext.digi_flags & DIGI_FORCEDCD)) | 2062 | if ((ts->c_cflag & CLOCAL) || (ch->digiext.digi_flags & DIGI_FORCEDCD)) |
2480 | if (ch->digiext.digi_flags & DIGI_FORCEDCD) | 2063 | if (ch->digiext.digi_flags & DIGI_FORCEDCD) |
2481 | bc->mint = 0; | 2064 | writeb(0, &bc->mint); |
2482 | 2065 | ch->imodem = readb(&bc->mstat); | |
2483 | ch->imodem = bc->mstat; | ||
2484 | |||
2485 | hflow = termios2digi_h(ch, ts->c_cflag); | 2066 | hflow = termios2digi_h(ch, ts->c_cflag); |
2486 | 2067 | if (hflow != ch->hflow) { | |
2487 | if (hflow != ch->hflow) | ||
2488 | { | ||
2489 | ch->hflow = hflow; | 2068 | ch->hflow = hflow; |
2490 | |||
2491 | /* -------------------------------------------------------------- | 2069 | /* -------------------------------------------------------------- |
2492 | Hard flow control has been selected but the board is not | 2070 | Hard flow control has been selected but the board is not |
2493 | using it. Activate hard flow control now. | 2071 | using it. Activate hard flow control now. |
2494 | ----------------------------------------------------------------- */ | 2072 | ----------------------------------------------------------------- */ |
2495 | |||
2496 | fepcmd(ch, SETHFLOW, hflow, 0xff, 0, 1); | 2073 | fepcmd(ch, SETHFLOW, hflow, 0xff, 0, 1); |
2497 | } | 2074 | } |
2498 | |||
2499 | |||
2500 | mval ^= ch->modemfake & (mval ^ ch->modem); | 2075 | mval ^= ch->modemfake & (mval ^ ch->modem); |
2501 | 2076 | ||
2502 | if (ch->omodem ^ mval) | 2077 | if (ch->omodem ^ mval) { |
2503 | { | ||
2504 | ch->omodem = mval; | 2078 | ch->omodem = mval; |
2505 | |||
2506 | /* -------------------------------------------------------------- | 2079 | /* -------------------------------------------------------------- |
2507 | The below command sets the DTR and RTS mstat structure. If | 2080 | The below command sets the DTR and RTS mstat structure. If |
2508 | hard flow control is NOT active these changes will drive the | 2081 | hard flow control is NOT active these changes will drive the |
@@ -2514,87 +2087,65 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch) | |||
2514 | /* First reset DTR & RTS; then set them */ | 2087 | /* First reset DTR & RTS; then set them */ |
2515 | fepcmd(ch, SETMODEM, 0, ((ch->m_dtr)|(ch->m_rts)), 0, 1); | 2088 | fepcmd(ch, SETMODEM, 0, ((ch->m_dtr)|(ch->m_rts)), 0, 1); |
2516 | fepcmd(ch, SETMODEM, mval, 0, 0, 1); | 2089 | fepcmd(ch, SETMODEM, mval, 0, 0, 1); |
2517 | |||
2518 | } | 2090 | } |
2519 | 2091 | if (ch->startc != ch->fepstartc || ch->stopc != ch->fepstopc) { | |
2520 | if (ch->startc != ch->fepstartc || ch->stopc != ch->fepstopc) | ||
2521 | { | ||
2522 | ch->fepstartc = ch->startc; | 2092 | ch->fepstartc = ch->startc; |
2523 | ch->fepstopc = ch->stopc; | 2093 | ch->fepstopc = ch->stopc; |
2524 | |||
2525 | /* ------------------------------------------------------------ | 2094 | /* ------------------------------------------------------------ |
2526 | The XON / XOFF characters have changed; propagate these | 2095 | The XON / XOFF characters have changed; propagate these |
2527 | changes to the card. | 2096 | changes to the card. |
2528 | --------------------------------------------------------------- */ | 2097 | --------------------------------------------------------------- */ |
2529 | |||
2530 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); | 2098 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); |
2531 | } | 2099 | } |
2532 | 2100 | if (ch->startca != ch->fepstartca || ch->stopca != ch->fepstopca) { | |
2533 | if (ch->startca != ch->fepstartca || ch->stopca != ch->fepstopca) | ||
2534 | { | ||
2535 | ch->fepstartca = ch->startca; | 2101 | ch->fepstartca = ch->startca; |
2536 | ch->fepstopca = ch->stopca; | 2102 | ch->fepstopca = ch->stopca; |
2537 | |||
2538 | /* --------------------------------------------------------------- | 2103 | /* --------------------------------------------------------------- |
2539 | Similar to the above, this time the auxilarly XON / XOFF | 2104 | Similar to the above, this time the auxilarly XON / XOFF |
2540 | characters have changed; propagate these changes to the card. | 2105 | characters have changed; propagate these changes to the card. |
2541 | ------------------------------------------------------------------ */ | 2106 | ------------------------------------------------------------------ */ |
2542 | |||
2543 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); | 2107 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); |
2544 | } | 2108 | } |
2545 | |||
2546 | } /* End epcaparam */ | 2109 | } /* End epcaparam */ |
2547 | 2110 | ||
2548 | /* --------------------- Begin receive_data ----------------------- */ | 2111 | /* --------------------- Begin receive_data ----------------------- */ |
2549 | 2112 | /* Caller holds lock */ | |
2550 | static void receive_data(struct channel *ch) | 2113 | static void receive_data(struct channel *ch) |
2551 | { /* Begin receive_data */ | 2114 | { /* Begin receive_data */ |
2552 | 2115 | ||
2553 | unchar *rptr; | 2116 | unchar *rptr; |
2554 | struct termios *ts = NULL; | 2117 | struct termios *ts = NULL; |
2555 | struct tty_struct *tty; | 2118 | struct tty_struct *tty; |
2556 | volatile struct board_chan *bc; | 2119 | struct board_chan *bc; |
2557 | register int dataToRead, wrapgap, bytesAvailable; | 2120 | int dataToRead, wrapgap, bytesAvailable; |
2558 | register unsigned int tail, head; | 2121 | unsigned int tail, head; |
2559 | unsigned int wrapmask; | 2122 | unsigned int wrapmask; |
2560 | int rc; | 2123 | int rc; |
2561 | 2124 | ||
2562 | |||
2563 | /* --------------------------------------------------------------- | 2125 | /* --------------------------------------------------------------- |
2564 | This routine is called by doint when a receive data event | 2126 | This routine is called by doint when a receive data event |
2565 | has taken place. | 2127 | has taken place. |
2566 | ------------------------------------------------------------------- */ | 2128 | ------------------------------------------------------------------- */ |
2567 | 2129 | ||
2568 | globalwinon(ch); | 2130 | globalwinon(ch); |
2569 | |||
2570 | if (ch->statusflags & RXSTOPPED) | 2131 | if (ch->statusflags & RXSTOPPED) |
2571 | return; | 2132 | return; |
2572 | |||
2573 | tty = ch->tty; | 2133 | tty = ch->tty; |
2574 | if (tty) | 2134 | if (tty) |
2575 | ts = tty->termios; | 2135 | ts = tty->termios; |
2576 | |||
2577 | bc = ch->brdchan; | 2136 | bc = ch->brdchan; |
2578 | 2137 | BUG_ON(!bc); | |
2579 | if (!bc) | ||
2580 | { | ||
2581 | printk(KERN_ERR "<Error> - bc is NULL in receive_data!\n"); | ||
2582 | return; | ||
2583 | } | ||
2584 | |||
2585 | wrapmask = ch->rxbufsize - 1; | 2138 | wrapmask = ch->rxbufsize - 1; |
2586 | 2139 | ||
2587 | /* --------------------------------------------------------------------- | 2140 | /* --------------------------------------------------------------------- |
2588 | Get the head and tail pointers to the receiver queue. Wrap the | 2141 | Get the head and tail pointers to the receiver queue. Wrap the |
2589 | head pointer if it has reached the end of the buffer. | 2142 | head pointer if it has reached the end of the buffer. |
2590 | ------------------------------------------------------------------------ */ | 2143 | ------------------------------------------------------------------------ */ |
2591 | 2144 | head = readw(&bc->rin); | |
2592 | head = bc->rin; | ||
2593 | head &= wrapmask; | 2145 | head &= wrapmask; |
2594 | tail = bc->rout & wrapmask; | 2146 | tail = readw(&bc->rout) & wrapmask; |
2595 | 2147 | ||
2596 | bytesAvailable = (head - tail) & wrapmask; | 2148 | bytesAvailable = (head - tail) & wrapmask; |
2597 | |||
2598 | if (bytesAvailable == 0) | 2149 | if (bytesAvailable == 0) |
2599 | return; | 2150 | return; |
2600 | 2151 | ||
@@ -2602,8 +2153,7 @@ static void receive_data(struct channel *ch) | |||
2602 | If CREAD bit is off or device not open, set TX tail to head | 2153 | If CREAD bit is off or device not open, set TX tail to head |
2603 | --------------------------------------------------------------------- */ | 2154 | --------------------------------------------------------------------- */ |
2604 | 2155 | ||
2605 | if (!tty || !ts || !(ts->c_cflag & CREAD)) | 2156 | if (!tty || !ts || !(ts->c_cflag & CREAD)) { |
2606 | { | ||
2607 | bc->rout = head; | 2157 | bc->rout = head; |
2608 | return; | 2158 | return; |
2609 | } | 2159 | } |
@@ -2611,64 +2161,45 @@ static void receive_data(struct channel *ch) | |||
2611 | if (tty->flip.count == TTY_FLIPBUF_SIZE) | 2161 | if (tty->flip.count == TTY_FLIPBUF_SIZE) |
2612 | return; | 2162 | return; |
2613 | 2163 | ||
2614 | if (bc->orun) | 2164 | if (readb(&bc->orun)) { |
2615 | { | 2165 | writeb(0, &bc->orun); |
2616 | bc->orun = 0; | 2166 | printk(KERN_WARNING "epca; overrun! DigiBoard device %s\n",tty->name); |
2617 | printk(KERN_WARNING "overrun! DigiBoard device %s\n",tty->name); | ||
2618 | } | 2167 | } |
2619 | |||
2620 | rxwinon(ch); | 2168 | rxwinon(ch); |
2621 | rptr = tty->flip.char_buf_ptr; | 2169 | rptr = tty->flip.char_buf_ptr; |
2622 | rc = tty->flip.count; | 2170 | rc = tty->flip.count; |
2623 | 2171 | while (bytesAvailable > 0) { /* Begin while there is data on the card */ | |
2624 | while (bytesAvailable > 0) | ||
2625 | { /* Begin while there is data on the card */ | ||
2626 | |||
2627 | wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail; | 2172 | wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail; |
2628 | |||
2629 | /* --------------------------------------------------------------- | 2173 | /* --------------------------------------------------------------- |
2630 | Even if head has wrapped around only report the amount of | 2174 | Even if head has wrapped around only report the amount of |
2631 | data to be equal to the size - tail. Remember memcpy can't | 2175 | data to be equal to the size - tail. Remember memcpy can't |
2632 | automaticly wrap around the receive buffer. | 2176 | automaticly wrap around the receive buffer. |
2633 | ----------------------------------------------------------------- */ | 2177 | ----------------------------------------------------------------- */ |
2634 | |||
2635 | dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable; | 2178 | dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable; |
2636 | |||
2637 | /* -------------------------------------------------------------- | 2179 | /* -------------------------------------------------------------- |
2638 | Make sure we don't overflow the buffer | 2180 | Make sure we don't overflow the buffer |
2639 | ----------------------------------------------------------------- */ | 2181 | ----------------------------------------------------------------- */ |
2640 | |||
2641 | if ((rc + dataToRead) > TTY_FLIPBUF_SIZE) | 2182 | if ((rc + dataToRead) > TTY_FLIPBUF_SIZE) |
2642 | dataToRead = TTY_FLIPBUF_SIZE - rc; | 2183 | dataToRead = TTY_FLIPBUF_SIZE - rc; |
2643 | |||
2644 | if (dataToRead == 0) | 2184 | if (dataToRead == 0) |
2645 | break; | 2185 | break; |
2646 | |||
2647 | /* --------------------------------------------------------------- | 2186 | /* --------------------------------------------------------------- |
2648 | Move data read from our card into the line disciplines buffer | 2187 | Move data read from our card into the line disciplines buffer |
2649 | for translation if necessary. | 2188 | for translation if necessary. |
2650 | ------------------------------------------------------------------ */ | 2189 | ------------------------------------------------------------------ */ |
2651 | 2190 | memcpy_fromio(rptr, ch->rxptr + tail, dataToRead); | |
2652 | if ((memcpy(rptr, ch->rxptr + tail, dataToRead)) != rptr) | ||
2653 | printk(KERN_ERR "<Error> - receive_data : memcpy failed\n"); | ||
2654 | |||
2655 | rc += dataToRead; | 2191 | rc += dataToRead; |
2656 | rptr += dataToRead; | 2192 | rptr += dataToRead; |
2657 | tail = (tail + dataToRead) & wrapmask; | 2193 | tail = (tail + dataToRead) & wrapmask; |
2658 | bytesAvailable -= dataToRead; | 2194 | bytesAvailable -= dataToRead; |
2659 | |||
2660 | } /* End while there is data on the card */ | 2195 | } /* End while there is data on the card */ |
2661 | |||
2662 | |||
2663 | tty->flip.count = rc; | 2196 | tty->flip.count = rc; |
2664 | tty->flip.char_buf_ptr = rptr; | 2197 | tty->flip.char_buf_ptr = rptr; |
2665 | globalwinon(ch); | 2198 | globalwinon(ch); |
2666 | bc->rout = tail; | 2199 | writew(tail, &bc->rout); |
2667 | |||
2668 | /* Must be called with global data */ | 2200 | /* Must be called with global data */ |
2669 | tty_schedule_flip(ch->tty); | 2201 | tty_schedule_flip(ch->tty); |
2670 | return; | 2202 | return; |
2671 | |||
2672 | } /* End receive_data */ | 2203 | } /* End receive_data */ |
2673 | 2204 | ||
2674 | static int info_ioctl(struct tty_struct *tty, struct file * file, | 2205 | static int info_ioctl(struct tty_struct *tty, struct file * file, |
@@ -2676,17 +2207,15 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2676 | { | 2207 | { |
2677 | switch (cmd) | 2208 | switch (cmd) |
2678 | { /* Begin switch cmd */ | 2209 | { /* Begin switch cmd */ |
2679 | |||
2680 | case DIGI_GETINFO: | 2210 | case DIGI_GETINFO: |
2681 | { /* Begin case DIGI_GETINFO */ | 2211 | { /* Begin case DIGI_GETINFO */ |
2682 | |||
2683 | struct digi_info di ; | 2212 | struct digi_info di ; |
2684 | int brd; | 2213 | int brd; |
2685 | 2214 | ||
2686 | getUser(brd, (unsigned int __user *)arg); | 2215 | if(get_user(brd, (unsigned int __user *)arg)) |
2687 | 2216 | return -EFAULT; | |
2688 | if ((brd < 0) || (brd >= num_cards) || (num_cards == 0)) | 2217 | if (brd < 0 || brd >= num_cards || num_cards == 0) |
2689 | return (-ENODEV); | 2218 | return -ENODEV; |
2690 | 2219 | ||
2691 | memset(&di, 0, sizeof(di)); | 2220 | memset(&di, 0, sizeof(di)); |
2692 | 2221 | ||
@@ -2694,8 +2223,9 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2694 | di.status = boards[brd].status; | 2223 | di.status = boards[brd].status; |
2695 | di.type = boards[brd].type ; | 2224 | di.type = boards[brd].type ; |
2696 | di.numports = boards[brd].numports ; | 2225 | di.numports = boards[brd].numports ; |
2697 | di.port = boards[brd].port ; | 2226 | /* Legacy fixups - just move along nothing to see */ |
2698 | di.membase = boards[brd].membase ; | 2227 | di.port = (unsigned char *)boards[brd].port ; |
2228 | di.membase = (unsigned char *)boards[brd].membase ; | ||
2699 | 2229 | ||
2700 | if (copy_to_user((void __user *)arg, &di, sizeof (di))) | 2230 | if (copy_to_user((void __user *)arg, &di, sizeof (di))) |
2701 | return -EFAULT; | 2231 | return -EFAULT; |
@@ -2709,39 +2239,29 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2709 | int brd = arg & 0xff000000 >> 16 ; | 2239 | int brd = arg & 0xff000000 >> 16 ; |
2710 | unsigned char state = arg & 0xff ; | 2240 | unsigned char state = arg & 0xff ; |
2711 | 2241 | ||
2712 | if ((brd < 0) || (brd >= num_cards)) | 2242 | if (brd < 0 || brd >= num_cards) { |
2713 | { | 2243 | printk(KERN_ERR "epca: DIGI POLLER : brd not valid!\n"); |
2714 | printk(KERN_ERR "<Error> - DIGI POLLER : brd not valid!\n"); | ||
2715 | return (-ENODEV); | 2244 | return (-ENODEV); |
2716 | } | 2245 | } |
2717 | |||
2718 | digi_poller_inhibited = state ; | 2246 | digi_poller_inhibited = state ; |
2719 | break ; | 2247 | break ; |
2720 | |||
2721 | } /* End case DIGI_POLLER */ | 2248 | } /* End case DIGI_POLLER */ |
2722 | 2249 | ||
2723 | case DIGI_INIT: | 2250 | case DIGI_INIT: |
2724 | { /* Begin case DIGI_INIT */ | 2251 | { /* Begin case DIGI_INIT */ |
2725 | |||
2726 | /* ------------------------------------------------------------ | 2252 | /* ------------------------------------------------------------ |
2727 | This call is made by the apps to complete the initilization | 2253 | This call is made by the apps to complete the initilization |
2728 | of the board(s). This routine is responsible for setting | 2254 | of the board(s). This routine is responsible for setting |
2729 | the card to its initial state and setting the drivers control | 2255 | the card to its initial state and setting the drivers control |
2730 | fields to the sutianle settings for the card in question. | 2256 | fields to the sutianle settings for the card in question. |
2731 | ---------------------------------------------------------------- */ | 2257 | ---------------------------------------------------------------- */ |
2732 | |||
2733 | int crd ; | 2258 | int crd ; |
2734 | for (crd = 0; crd < num_cards; crd++) | 2259 | for (crd = 0; crd < num_cards; crd++) |
2735 | post_fep_init (crd); | 2260 | post_fep_init (crd); |
2736 | |||
2737 | break ; | 2261 | break ; |
2738 | |||
2739 | } /* End case DIGI_INIT */ | 2262 | } /* End case DIGI_INIT */ |
2740 | |||
2741 | |||
2742 | default: | 2263 | default: |
2743 | return -ENOIOCTLCMD; | 2264 | return -ENOTTY; |
2744 | |||
2745 | } /* End switch cmd */ | 2265 | } /* End switch cmd */ |
2746 | return (0) ; | 2266 | return (0) ; |
2747 | } | 2267 | } |
@@ -2750,43 +2270,33 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2750 | static int pc_tiocmget(struct tty_struct *tty, struct file *file) | 2270 | static int pc_tiocmget(struct tty_struct *tty, struct file *file) |
2751 | { | 2271 | { |
2752 | struct channel *ch = (struct channel *) tty->driver_data; | 2272 | struct channel *ch = (struct channel *) tty->driver_data; |
2753 | volatile struct board_chan *bc; | 2273 | struct board_chan *bc; |
2754 | unsigned int mstat, mflag = 0; | 2274 | unsigned int mstat, mflag = 0; |
2755 | unsigned long flags; | 2275 | unsigned long flags; |
2756 | 2276 | ||
2757 | if (ch) | 2277 | if (ch) |
2758 | bc = ch->brdchan; | 2278 | bc = ch->brdchan; |
2759 | else | 2279 | else |
2760 | { | 2280 | return -EINVAL; |
2761 | printk(KERN_ERR "<Error> - ch is NULL in pc_tiocmget!\n"); | ||
2762 | return(-EINVAL); | ||
2763 | } | ||
2764 | 2281 | ||
2765 | save_flags(flags); | 2282 | spin_lock_irqsave(&epca_lock, flags); |
2766 | cli(); | ||
2767 | globalwinon(ch); | 2283 | globalwinon(ch); |
2768 | mstat = bc->mstat; | 2284 | mstat = readb(&bc->mstat); |
2769 | memoff(ch); | 2285 | memoff(ch); |
2770 | restore_flags(flags); | 2286 | spin_unlock_irqrestore(&epca_lock, flags); |
2771 | 2287 | ||
2772 | if (mstat & ch->m_dtr) | 2288 | if (mstat & ch->m_dtr) |
2773 | mflag |= TIOCM_DTR; | 2289 | mflag |= TIOCM_DTR; |
2774 | |||
2775 | if (mstat & ch->m_rts) | 2290 | if (mstat & ch->m_rts) |
2776 | mflag |= TIOCM_RTS; | 2291 | mflag |= TIOCM_RTS; |
2777 | |||
2778 | if (mstat & ch->m_cts) | 2292 | if (mstat & ch->m_cts) |
2779 | mflag |= TIOCM_CTS; | 2293 | mflag |= TIOCM_CTS; |
2780 | |||
2781 | if (mstat & ch->dsr) | 2294 | if (mstat & ch->dsr) |
2782 | mflag |= TIOCM_DSR; | 2295 | mflag |= TIOCM_DSR; |
2783 | |||
2784 | if (mstat & ch->m_ri) | 2296 | if (mstat & ch->m_ri) |
2785 | mflag |= TIOCM_RI; | 2297 | mflag |= TIOCM_RI; |
2786 | |||
2787 | if (mstat & ch->dcd) | 2298 | if (mstat & ch->dcd) |
2788 | mflag |= TIOCM_CD; | 2299 | mflag |= TIOCM_CD; |
2789 | |||
2790 | return mflag; | 2300 | return mflag; |
2791 | } | 2301 | } |
2792 | 2302 | ||
@@ -2796,13 +2306,10 @@ static int pc_tiocmset(struct tty_struct *tty, struct file *file, | |||
2796 | struct channel *ch = (struct channel *) tty->driver_data; | 2306 | struct channel *ch = (struct channel *) tty->driver_data; |
2797 | unsigned long flags; | 2307 | unsigned long flags; |
2798 | 2308 | ||
2799 | if (!ch) { | 2309 | if (!ch) |
2800 | printk(KERN_ERR "<Error> - ch is NULL in pc_tiocmset!\n"); | 2310 | return -EINVAL; |
2801 | return(-EINVAL); | ||
2802 | } | ||
2803 | 2311 | ||
2804 | save_flags(flags); | 2312 | spin_lock_irqsave(&epca_lock, flags); |
2805 | cli(); | ||
2806 | /* | 2313 | /* |
2807 | * I think this modemfake stuff is broken. It doesn't | 2314 | * I think this modemfake stuff is broken. It doesn't |
2808 | * correctly reflect the behaviour desired by the TIOCM* | 2315 | * correctly reflect the behaviour desired by the TIOCM* |
@@ -2824,17 +2331,14 @@ static int pc_tiocmset(struct tty_struct *tty, struct file *file, | |||
2824 | ch->modemfake |= ch->m_dtr; | 2331 | ch->modemfake |= ch->m_dtr; |
2825 | ch->modem &= ~ch->m_dtr; | 2332 | ch->modem &= ~ch->m_dtr; |
2826 | } | 2333 | } |
2827 | |||
2828 | globalwinon(ch); | 2334 | globalwinon(ch); |
2829 | |||
2830 | /* -------------------------------------------------------------- | 2335 | /* -------------------------------------------------------------- |
2831 | The below routine generally sets up parity, baud, flow control | 2336 | The below routine generally sets up parity, baud, flow control |
2832 | issues, etc.... It effect both control flags and input flags. | 2337 | issues, etc.... It effect both control flags and input flags. |
2833 | ------------------------------------------------------------------ */ | 2338 | ------------------------------------------------------------------ */ |
2834 | |||
2835 | epcaparam(tty,ch); | 2339 | epcaparam(tty,ch); |
2836 | memoff(ch); | 2340 | memoff(ch); |
2837 | restore_flags(flags); | 2341 | spin_unlock_irqrestore(&epca_lock, flags); |
2838 | return 0; | 2342 | return 0; |
2839 | } | 2343 | } |
2840 | 2344 | ||
@@ -2847,19 +2351,14 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
2847 | unsigned long flags; | 2351 | unsigned long flags; |
2848 | unsigned int mflag, mstat; | 2352 | unsigned int mflag, mstat; |
2849 | unsigned char startc, stopc; | 2353 | unsigned char startc, stopc; |
2850 | volatile struct board_chan *bc; | 2354 | struct board_chan *bc; |
2851 | struct channel *ch = (struct channel *) tty->driver_data; | 2355 | struct channel *ch = (struct channel *) tty->driver_data; |
2852 | void __user *argp = (void __user *)arg; | 2356 | void __user *argp = (void __user *)arg; |
2853 | 2357 | ||
2854 | if (ch) | 2358 | if (ch) |
2855 | bc = ch->brdchan; | 2359 | bc = ch->brdchan; |
2856 | else | 2360 | else |
2857 | { | 2361 | return -EINVAL; |
2858 | printk(KERN_ERR "<Error> - ch is NULL in pc_ioctl!\n"); | ||
2859 | return(-EINVAL); | ||
2860 | } | ||
2861 | |||
2862 | save_flags(flags); | ||
2863 | 2362 | ||
2864 | /* ------------------------------------------------------------------- | 2363 | /* ------------------------------------------------------------------- |
2865 | For POSIX compliance we need to add more ioctls. See tty_ioctl.c | 2364 | For POSIX compliance we need to add more ioctls. See tty_ioctl.c |
@@ -2871,46 +2370,39 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
2871 | { /* Begin switch cmd */ | 2370 | { /* Begin switch cmd */ |
2872 | 2371 | ||
2873 | case TCGETS: | 2372 | case TCGETS: |
2874 | if (copy_to_user(argp, | 2373 | if (copy_to_user(argp, tty->termios, sizeof(struct termios))) |
2875 | tty->termios, sizeof(struct termios))) | ||
2876 | return -EFAULT; | 2374 | return -EFAULT; |
2877 | return(0); | 2375 | return 0; |
2878 | |||
2879 | case TCGETA: | 2376 | case TCGETA: |
2880 | return get_termio(tty, argp); | 2377 | return get_termio(tty, argp); |
2881 | |||
2882 | case TCSBRK: /* SVID version: non-zero arg --> no break */ | 2378 | case TCSBRK: /* SVID version: non-zero arg --> no break */ |
2883 | |||
2884 | retval = tty_check_change(tty); | 2379 | retval = tty_check_change(tty); |
2885 | if (retval) | 2380 | if (retval) |
2886 | return retval; | 2381 | return retval; |
2887 | |||
2888 | /* Setup an event to indicate when the transmit buffer empties */ | 2382 | /* Setup an event to indicate when the transmit buffer empties */ |
2889 | 2383 | spin_lock_irqsave(&epca_lock, flags); | |
2890 | setup_empty_event(tty,ch); | 2384 | setup_empty_event(tty,ch); |
2385 | spin_unlock_irqrestore(&epca_lock, flags); | ||
2891 | tty_wait_until_sent(tty, 0); | 2386 | tty_wait_until_sent(tty, 0); |
2892 | if (!arg) | 2387 | if (!arg) |
2893 | digi_send_break(ch, HZ/4); /* 1/4 second */ | 2388 | digi_send_break(ch, HZ/4); /* 1/4 second */ |
2894 | return 0; | 2389 | return 0; |
2895 | |||
2896 | case TCSBRKP: /* support for POSIX tcsendbreak() */ | 2390 | case TCSBRKP: /* support for POSIX tcsendbreak() */ |
2897 | |||
2898 | retval = tty_check_change(tty); | 2391 | retval = tty_check_change(tty); |
2899 | if (retval) | 2392 | if (retval) |
2900 | return retval; | 2393 | return retval; |
2901 | 2394 | ||
2902 | /* Setup an event to indicate when the transmit buffer empties */ | 2395 | /* Setup an event to indicate when the transmit buffer empties */ |
2903 | 2396 | spin_lock_irqsave(&epca_lock, flags); | |
2904 | setup_empty_event(tty,ch); | 2397 | setup_empty_event(tty,ch); |
2398 | spin_unlock_irqrestore(&epca_lock, flags); | ||
2905 | tty_wait_until_sent(tty, 0); | 2399 | tty_wait_until_sent(tty, 0); |
2906 | digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4); | 2400 | digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4); |
2907 | return 0; | 2401 | return 0; |
2908 | |||
2909 | case TIOCGSOFTCAR: | 2402 | case TIOCGSOFTCAR: |
2910 | if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)arg)) | 2403 | if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)arg)) |
2911 | return -EFAULT; | 2404 | return -EFAULT; |
2912 | return 0; | 2405 | return 0; |
2913 | |||
2914 | case TIOCSSOFTCAR: | 2406 | case TIOCSSOFTCAR: |
2915 | { | 2407 | { |
2916 | unsigned int value; | 2408 | unsigned int value; |
@@ -2922,75 +2414,63 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
2922 | (value ? CLOCAL : 0)); | 2414 | (value ? CLOCAL : 0)); |
2923 | return 0; | 2415 | return 0; |
2924 | } | 2416 | } |
2925 | |||
2926 | case TIOCMODG: | 2417 | case TIOCMODG: |
2927 | mflag = pc_tiocmget(tty, file); | 2418 | mflag = pc_tiocmget(tty, file); |
2928 | if (put_user(mflag, (unsigned long __user *)argp)) | 2419 | if (put_user(mflag, (unsigned long __user *)argp)) |
2929 | return -EFAULT; | 2420 | return -EFAULT; |
2930 | break; | 2421 | break; |
2931 | |||
2932 | case TIOCMODS: | 2422 | case TIOCMODS: |
2933 | if (get_user(mstat, (unsigned __user *)argp)) | 2423 | if (get_user(mstat, (unsigned __user *)argp)) |
2934 | return -EFAULT; | 2424 | return -EFAULT; |
2935 | return pc_tiocmset(tty, file, mstat, ~mstat); | 2425 | return pc_tiocmset(tty, file, mstat, ~mstat); |
2936 | |||
2937 | case TIOCSDTR: | 2426 | case TIOCSDTR: |
2427 | spin_lock_irqsave(&epca_lock, flags); | ||
2938 | ch->omodem |= ch->m_dtr; | 2428 | ch->omodem |= ch->m_dtr; |
2939 | cli(); | ||
2940 | globalwinon(ch); | 2429 | globalwinon(ch); |
2941 | fepcmd(ch, SETMODEM, ch->m_dtr, 0, 10, 1); | 2430 | fepcmd(ch, SETMODEM, ch->m_dtr, 0, 10, 1); |
2942 | memoff(ch); | 2431 | memoff(ch); |
2943 | restore_flags(flags); | 2432 | spin_unlock_irqrestore(&epca_lock, flags); |
2944 | break; | 2433 | break; |
2945 | 2434 | ||
2946 | case TIOCCDTR: | 2435 | case TIOCCDTR: |
2436 | spin_lock_irqsave(&epca_lock, flags); | ||
2947 | ch->omodem &= ~ch->m_dtr; | 2437 | ch->omodem &= ~ch->m_dtr; |
2948 | cli(); | ||
2949 | globalwinon(ch); | 2438 | globalwinon(ch); |
2950 | fepcmd(ch, SETMODEM, 0, ch->m_dtr, 10, 1); | 2439 | fepcmd(ch, SETMODEM, 0, ch->m_dtr, 10, 1); |
2951 | memoff(ch); | 2440 | memoff(ch); |
2952 | restore_flags(flags); | 2441 | spin_unlock_irqrestore(&epca_lock, flags); |
2953 | break; | 2442 | break; |
2954 | |||
2955 | case DIGI_GETA: | 2443 | case DIGI_GETA: |
2956 | if (copy_to_user(argp, &ch->digiext, sizeof(digi_t))) | 2444 | if (copy_to_user(argp, &ch->digiext, sizeof(digi_t))) |
2957 | return -EFAULT; | 2445 | return -EFAULT; |
2958 | break; | 2446 | break; |
2959 | |||
2960 | case DIGI_SETAW: | 2447 | case DIGI_SETAW: |
2961 | case DIGI_SETAF: | 2448 | case DIGI_SETAF: |
2962 | if ((cmd) == (DIGI_SETAW)) | 2449 | if (cmd == DIGI_SETAW) { |
2963 | { | ||
2964 | /* Setup an event to indicate when the transmit buffer empties */ | 2450 | /* Setup an event to indicate when the transmit buffer empties */ |
2965 | 2451 | spin_lock_irqsave(&epca_lock, flags); | |
2966 | setup_empty_event(tty,ch); | 2452 | setup_empty_event(tty,ch); |
2453 | spin_unlock_irqrestore(&epca_lock, flags); | ||
2967 | tty_wait_until_sent(tty, 0); | 2454 | tty_wait_until_sent(tty, 0); |
2968 | } | 2455 | } else { |
2969 | else | ||
2970 | { | ||
2971 | /* ldisc lock already held in ioctl */ | 2456 | /* ldisc lock already held in ioctl */ |
2972 | if (tty->ldisc.flush_buffer) | 2457 | if (tty->ldisc.flush_buffer) |
2973 | tty->ldisc.flush_buffer(tty); | 2458 | tty->ldisc.flush_buffer(tty); |
2974 | } | 2459 | } |
2975 | |||
2976 | /* Fall Thru */ | 2460 | /* Fall Thru */ |
2977 | |||
2978 | case DIGI_SETA: | 2461 | case DIGI_SETA: |
2979 | if (copy_from_user(&ch->digiext, argp, sizeof(digi_t))) | 2462 | if (copy_from_user(&ch->digiext, argp, sizeof(digi_t))) |
2980 | return -EFAULT; | 2463 | return -EFAULT; |
2981 | 2464 | ||
2982 | if (ch->digiext.digi_flags & DIGI_ALTPIN) | 2465 | if (ch->digiext.digi_flags & DIGI_ALTPIN) { |
2983 | { | ||
2984 | ch->dcd = ch->m_dsr; | 2466 | ch->dcd = ch->m_dsr; |
2985 | ch->dsr = ch->m_dcd; | 2467 | ch->dsr = ch->m_dcd; |
2986 | } | 2468 | } else { |
2987 | else | ||
2988 | { | ||
2989 | ch->dcd = ch->m_dcd; | 2469 | ch->dcd = ch->m_dcd; |
2990 | ch->dsr = ch->m_dsr; | 2470 | ch->dsr = ch->m_dsr; |
2991 | } | 2471 | } |
2992 | 2472 | ||
2993 | cli(); | 2473 | spin_lock_irqsave(&epca_lock, flags); |
2994 | globalwinon(ch); | 2474 | globalwinon(ch); |
2995 | 2475 | ||
2996 | /* ----------------------------------------------------------------- | 2476 | /* ----------------------------------------------------------------- |
@@ -3000,25 +2480,22 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
3000 | 2480 | ||
3001 | epcaparam(tty,ch); | 2481 | epcaparam(tty,ch); |
3002 | memoff(ch); | 2482 | memoff(ch); |
3003 | restore_flags(flags); | 2483 | spin_unlock_irqrestore(&epca_lock, flags); |
3004 | break; | 2484 | break; |
3005 | 2485 | ||
3006 | case DIGI_GETFLOW: | 2486 | case DIGI_GETFLOW: |
3007 | case DIGI_GETAFLOW: | 2487 | case DIGI_GETAFLOW: |
3008 | cli(); | 2488 | spin_lock_irqsave(&epca_lock, flags); |
3009 | globalwinon(ch); | 2489 | globalwinon(ch); |
3010 | if ((cmd) == (DIGI_GETFLOW)) | 2490 | if (cmd == DIGI_GETFLOW) { |
3011 | { | 2491 | dflow.startc = readb(&bc->startc); |
3012 | dflow.startc = bc->startc; | 2492 | dflow.stopc = readb(&bc->stopc); |
3013 | dflow.stopc = bc->stopc; | 2493 | } else { |
3014 | } | 2494 | dflow.startc = readb(&bc->startca); |
3015 | else | 2495 | dflow.stopc = readb(&bc->stopca); |
3016 | { | ||
3017 | dflow.startc = bc->startca; | ||
3018 | dflow.stopc = bc->stopca; | ||
3019 | } | 2496 | } |
3020 | memoff(ch); | 2497 | memoff(ch); |
3021 | restore_flags(flags); | 2498 | spin_unlock_irqrestore(&epca_lock, flags); |
3022 | 2499 | ||
3023 | if (copy_to_user(argp, &dflow, sizeof(dflow))) | 2500 | if (copy_to_user(argp, &dflow, sizeof(dflow))) |
3024 | return -EFAULT; | 2501 | return -EFAULT; |
@@ -3026,13 +2503,10 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
3026 | 2503 | ||
3027 | case DIGI_SETAFLOW: | 2504 | case DIGI_SETAFLOW: |
3028 | case DIGI_SETFLOW: | 2505 | case DIGI_SETFLOW: |
3029 | if ((cmd) == (DIGI_SETFLOW)) | 2506 | if (cmd == DIGI_SETFLOW) { |
3030 | { | ||
3031 | startc = ch->startc; | 2507 | startc = ch->startc; |
3032 | stopc = ch->stopc; | 2508 | stopc = ch->stopc; |
3033 | } | 2509 | } else { |
3034 | else | ||
3035 | { | ||
3036 | startc = ch->startca; | 2510 | startc = ch->startca; |
3037 | stopc = ch->stopca; | 2511 | stopc = ch->stopca; |
3038 | } | 2512 | } |
@@ -3040,40 +2514,31 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
3040 | if (copy_from_user(&dflow, argp, sizeof(dflow))) | 2514 | if (copy_from_user(&dflow, argp, sizeof(dflow))) |
3041 | return -EFAULT; | 2515 | return -EFAULT; |
3042 | 2516 | ||
3043 | if (dflow.startc != startc || dflow.stopc != stopc) | 2517 | if (dflow.startc != startc || dflow.stopc != stopc) { /* Begin if setflow toggled */ |
3044 | { /* Begin if setflow toggled */ | 2518 | spin_lock_irqsave(&epca_lock, flags); |
3045 | cli(); | ||
3046 | globalwinon(ch); | 2519 | globalwinon(ch); |
3047 | 2520 | ||
3048 | if ((cmd) == (DIGI_SETFLOW)) | 2521 | if (cmd == DIGI_SETFLOW) { |
3049 | { | ||
3050 | ch->fepstartc = ch->startc = dflow.startc; | 2522 | ch->fepstartc = ch->startc = dflow.startc; |
3051 | ch->fepstopc = ch->stopc = dflow.stopc; | 2523 | ch->fepstopc = ch->stopc = dflow.stopc; |
3052 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); | 2524 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); |
3053 | } | 2525 | } else { |
3054 | else | ||
3055 | { | ||
3056 | ch->fepstartca = ch->startca = dflow.startc; | 2526 | ch->fepstartca = ch->startca = dflow.startc; |
3057 | ch->fepstopca = ch->stopca = dflow.stopc; | 2527 | ch->fepstopca = ch->stopca = dflow.stopc; |
3058 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); | 2528 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); |
3059 | } | 2529 | } |
3060 | 2530 | ||
3061 | if (ch->statusflags & TXSTOPPED) | 2531 | if (ch->statusflags & TXSTOPPED) |
3062 | pc_start(tty); | 2532 | pc_start(tty); |
3063 | 2533 | ||
3064 | memoff(ch); | 2534 | memoff(ch); |
3065 | restore_flags(flags); | 2535 | spin_unlock_irqrestore(&epca_lock, flags); |
3066 | |||
3067 | } /* End if setflow toggled */ | 2536 | } /* End if setflow toggled */ |
3068 | break; | 2537 | break; |
3069 | |||
3070 | default: | 2538 | default: |
3071 | return -ENOIOCTLCMD; | 2539 | return -ENOIOCTLCMD; |
3072 | |||
3073 | } /* End switch cmd */ | 2540 | } /* End switch cmd */ |
3074 | |||
3075 | return 0; | 2541 | return 0; |
3076 | |||
3077 | } /* End pc_ioctl */ | 2542 | } /* End pc_ioctl */ |
3078 | 2543 | ||
3079 | /* --------------------- Begin pc_set_termios ----------------------- */ | 2544 | /* --------------------- Begin pc_set_termios ----------------------- */ |
@@ -3083,20 +2548,16 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios) | |||
3083 | 2548 | ||
3084 | struct channel *ch; | 2549 | struct channel *ch; |
3085 | unsigned long flags; | 2550 | unsigned long flags; |
3086 | |||
3087 | /* --------------------------------------------------------- | 2551 | /* --------------------------------------------------------- |
3088 | verifyChannel returns the channel from the tty struct | 2552 | verifyChannel returns the channel from the tty struct |
3089 | if it is valid. This serves as a sanity check. | 2553 | if it is valid. This serves as a sanity check. |
3090 | ------------------------------------------------------------- */ | 2554 | ------------------------------------------------------------- */ |
3091 | 2555 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ | |
3092 | if ((ch = verifyChannel(tty)) != NULL) | 2556 | spin_lock_irqsave(&epca_lock, flags); |
3093 | { /* Begin if channel valid */ | ||
3094 | |||
3095 | save_flags(flags); | ||
3096 | cli(); | ||
3097 | globalwinon(ch); | 2557 | globalwinon(ch); |
3098 | epcaparam(tty, ch); | 2558 | epcaparam(tty, ch); |
3099 | memoff(ch); | 2559 | memoff(ch); |
2560 | spin_unlock_irqrestore(&epca_lock, flags); | ||
3100 | 2561 | ||
3101 | if ((old_termios->c_cflag & CRTSCTS) && | 2562 | if ((old_termios->c_cflag & CRTSCTS) && |
3102 | ((tty->termios->c_cflag & CRTSCTS) == 0)) | 2563 | ((tty->termios->c_cflag & CRTSCTS) == 0)) |
@@ -3106,8 +2567,6 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios) | |||
3106 | (tty->termios->c_cflag & CLOCAL)) | 2567 | (tty->termios->c_cflag & CLOCAL)) |
3107 | wake_up_interruptible(&ch->open_wait); | 2568 | wake_up_interruptible(&ch->open_wait); |
3108 | 2569 | ||
3109 | restore_flags(flags); | ||
3110 | |||
3111 | } /* End if channel valid */ | 2570 | } /* End if channel valid */ |
3112 | 2571 | ||
3113 | } /* End pc_set_termios */ | 2572 | } /* End pc_set_termios */ |
@@ -3116,29 +2575,18 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios) | |||
3116 | 2575 | ||
3117 | static void do_softint(void *private_) | 2576 | static void do_softint(void *private_) |
3118 | { /* Begin do_softint */ | 2577 | { /* Begin do_softint */ |
3119 | |||
3120 | struct channel *ch = (struct channel *) private_; | 2578 | struct channel *ch = (struct channel *) private_; |
3121 | |||
3122 | |||
3123 | /* Called in response to a modem change event */ | 2579 | /* Called in response to a modem change event */ |
3124 | 2580 | if (ch && ch->magic == EPCA_MAGIC) { /* Begin EPCA_MAGIC */ | |
3125 | if (ch && ch->magic == EPCA_MAGIC) | ||
3126 | { /* Begin EPCA_MAGIC */ | ||
3127 | |||
3128 | struct tty_struct *tty = ch->tty; | 2581 | struct tty_struct *tty = ch->tty; |
3129 | 2582 | ||
3130 | if (tty && tty->driver_data) | 2583 | if (tty && tty->driver_data) { |
3131 | { | 2584 | if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) { /* Begin if clear_bit */ |
3132 | if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) | ||
3133 | { /* Begin if clear_bit */ | ||
3134 | |||
3135 | tty_hangup(tty); /* FIXME: module removal race here - AKPM */ | 2585 | tty_hangup(tty); /* FIXME: module removal race here - AKPM */ |
3136 | wake_up_interruptible(&ch->open_wait); | 2586 | wake_up_interruptible(&ch->open_wait); |
3137 | ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; | 2587 | ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; |
3138 | |||
3139 | } /* End if clear_bit */ | 2588 | } /* End if clear_bit */ |
3140 | } | 2589 | } |
3141 | |||
3142 | } /* End EPCA_MAGIC */ | 2590 | } /* End EPCA_MAGIC */ |
3143 | } /* End do_softint */ | 2591 | } /* End do_softint */ |
3144 | 2592 | ||
@@ -3154,82 +2602,49 @@ static void pc_stop(struct tty_struct *tty) | |||
3154 | 2602 | ||
3155 | struct channel *ch; | 2603 | struct channel *ch; |
3156 | unsigned long flags; | 2604 | unsigned long flags; |
3157 | |||
3158 | /* --------------------------------------------------------- | 2605 | /* --------------------------------------------------------- |
3159 | verifyChannel returns the channel from the tty struct | 2606 | verifyChannel returns the channel from the tty struct |
3160 | if it is valid. This serves as a sanity check. | 2607 | if it is valid. This serves as a sanity check. |
3161 | ------------------------------------------------------------- */ | 2608 | ------------------------------------------------------------- */ |
3162 | 2609 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if valid channel */ | |
3163 | if ((ch = verifyChannel(tty)) != NULL) | 2610 | spin_lock_irqsave(&epca_lock, flags); |
3164 | { /* Begin if valid channel */ | 2611 | if ((ch->statusflags & TXSTOPPED) == 0) { /* Begin if transmit stop requested */ |
3165 | |||
3166 | save_flags(flags); | ||
3167 | cli(); | ||
3168 | |||
3169 | if ((ch->statusflags & TXSTOPPED) == 0) | ||
3170 | { /* Begin if transmit stop requested */ | ||
3171 | |||
3172 | globalwinon(ch); | 2612 | globalwinon(ch); |
3173 | |||
3174 | /* STOP transmitting now !! */ | 2613 | /* STOP transmitting now !! */ |
3175 | |||
3176 | fepcmd(ch, PAUSETX, 0, 0, 0, 0); | 2614 | fepcmd(ch, PAUSETX, 0, 0, 0, 0); |
3177 | |||
3178 | ch->statusflags |= TXSTOPPED; | 2615 | ch->statusflags |= TXSTOPPED; |
3179 | memoff(ch); | 2616 | memoff(ch); |
3180 | |||
3181 | } /* End if transmit stop requested */ | 2617 | } /* End if transmit stop requested */ |
3182 | 2618 | spin_unlock_irqrestore(&epca_lock, flags); | |
3183 | restore_flags(flags); | ||
3184 | |||
3185 | } /* End if valid channel */ | 2619 | } /* End if valid channel */ |
3186 | |||
3187 | } /* End pc_stop */ | 2620 | } /* End pc_stop */ |
3188 | 2621 | ||
3189 | /* --------------------- Begin pc_start ----------------------- */ | 2622 | /* --------------------- Begin pc_start ----------------------- */ |
3190 | 2623 | ||
3191 | static void pc_start(struct tty_struct *tty) | 2624 | static void pc_start(struct tty_struct *tty) |
3192 | { /* Begin pc_start */ | 2625 | { /* Begin pc_start */ |
3193 | |||
3194 | struct channel *ch; | 2626 | struct channel *ch; |
3195 | |||
3196 | /* --------------------------------------------------------- | 2627 | /* --------------------------------------------------------- |
3197 | verifyChannel returns the channel from the tty struct | 2628 | verifyChannel returns the channel from the tty struct |
3198 | if it is valid. This serves as a sanity check. | 2629 | if it is valid. This serves as a sanity check. |
3199 | ------------------------------------------------------------- */ | 2630 | ------------------------------------------------------------- */ |
3200 | 2631 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ | |
3201 | if ((ch = verifyChannel(tty)) != NULL) | ||
3202 | { /* Begin if channel valid */ | ||
3203 | |||
3204 | unsigned long flags; | 2632 | unsigned long flags; |
3205 | 2633 | spin_lock_irqsave(&epca_lock, flags); | |
3206 | save_flags(flags); | ||
3207 | cli(); | ||
3208 | |||
3209 | /* Just in case output was resumed because of a change in Digi-flow */ | 2634 | /* Just in case output was resumed because of a change in Digi-flow */ |
3210 | if (ch->statusflags & TXSTOPPED) | 2635 | if (ch->statusflags & TXSTOPPED) { /* Begin transmit resume requested */ |
3211 | { /* Begin transmit resume requested */ | 2636 | struct board_chan *bc; |
3212 | |||
3213 | volatile struct board_chan *bc; | ||
3214 | |||
3215 | globalwinon(ch); | 2637 | globalwinon(ch); |
3216 | bc = ch->brdchan; | 2638 | bc = ch->brdchan; |
3217 | if (ch->statusflags & LOWWAIT) | 2639 | if (ch->statusflags & LOWWAIT) |
3218 | bc->ilow = 1; | 2640 | writeb(1, &bc->ilow); |
3219 | |||
3220 | /* Okay, you can start transmitting again... */ | 2641 | /* Okay, you can start transmitting again... */ |
3221 | |||
3222 | fepcmd(ch, RESUMETX, 0, 0, 0, 0); | 2642 | fepcmd(ch, RESUMETX, 0, 0, 0, 0); |
3223 | |||
3224 | ch->statusflags &= ~TXSTOPPED; | 2643 | ch->statusflags &= ~TXSTOPPED; |
3225 | memoff(ch); | 2644 | memoff(ch); |
3226 | |||
3227 | } /* End transmit resume requested */ | 2645 | } /* End transmit resume requested */ |
3228 | 2646 | spin_unlock_irqrestore(&epca_lock, flags); | |
3229 | restore_flags(flags); | ||
3230 | |||
3231 | } /* End if channel valid */ | 2647 | } /* End if channel valid */ |
3232 | |||
3233 | } /* End pc_start */ | 2648 | } /* End pc_start */ |
3234 | 2649 | ||
3235 | /* ------------------------------------------------------------------ | 2650 | /* ------------------------------------------------------------------ |
@@ -3244,86 +2659,55 @@ ______________________________________________________________________ */ | |||
3244 | 2659 | ||
3245 | static void pc_throttle(struct tty_struct * tty) | 2660 | static void pc_throttle(struct tty_struct * tty) |
3246 | { /* Begin pc_throttle */ | 2661 | { /* Begin pc_throttle */ |
3247 | |||
3248 | struct channel *ch; | 2662 | struct channel *ch; |
3249 | unsigned long flags; | 2663 | unsigned long flags; |
3250 | |||
3251 | /* --------------------------------------------------------- | 2664 | /* --------------------------------------------------------- |
3252 | verifyChannel returns the channel from the tty struct | 2665 | verifyChannel returns the channel from the tty struct |
3253 | if it is valid. This serves as a sanity check. | 2666 | if it is valid. This serves as a sanity check. |
3254 | ------------------------------------------------------------- */ | 2667 | ------------------------------------------------------------- */ |
3255 | 2668 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ | |
3256 | if ((ch = verifyChannel(tty)) != NULL) | 2669 | spin_lock_irqsave(&epca_lock, flags); |
3257 | { /* Begin if channel valid */ | 2670 | if ((ch->statusflags & RXSTOPPED) == 0) { |
3258 | |||
3259 | |||
3260 | save_flags(flags); | ||
3261 | cli(); | ||
3262 | |||
3263 | if ((ch->statusflags & RXSTOPPED) == 0) | ||
3264 | { | ||
3265 | globalwinon(ch); | 2671 | globalwinon(ch); |
3266 | fepcmd(ch, PAUSERX, 0, 0, 0, 0); | 2672 | fepcmd(ch, PAUSERX, 0, 0, 0, 0); |
3267 | |||
3268 | ch->statusflags |= RXSTOPPED; | 2673 | ch->statusflags |= RXSTOPPED; |
3269 | memoff(ch); | 2674 | memoff(ch); |
3270 | } | 2675 | } |
3271 | restore_flags(flags); | 2676 | spin_unlock_irqrestore(&epca_lock, flags); |
3272 | |||
3273 | } /* End if channel valid */ | 2677 | } /* End if channel valid */ |
3274 | |||
3275 | } /* End pc_throttle */ | 2678 | } /* End pc_throttle */ |
3276 | 2679 | ||
3277 | /* --------------------- Begin unthrottle ----------------------- */ | 2680 | /* --------------------- Begin unthrottle ----------------------- */ |
3278 | 2681 | ||
3279 | static void pc_unthrottle(struct tty_struct *tty) | 2682 | static void pc_unthrottle(struct tty_struct *tty) |
3280 | { /* Begin pc_unthrottle */ | 2683 | { /* Begin pc_unthrottle */ |
3281 | |||
3282 | struct channel *ch; | 2684 | struct channel *ch; |
3283 | unsigned long flags; | 2685 | unsigned long flags; |
3284 | volatile struct board_chan *bc; | ||
3285 | |||
3286 | |||
3287 | /* --------------------------------------------------------- | 2686 | /* --------------------------------------------------------- |
3288 | verifyChannel returns the channel from the tty struct | 2687 | verifyChannel returns the channel from the tty struct |
3289 | if it is valid. This serves as a sanity check. | 2688 | if it is valid. This serves as a sanity check. |
3290 | ------------------------------------------------------------- */ | 2689 | ------------------------------------------------------------- */ |
3291 | 2690 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ | |
3292 | if ((ch = verifyChannel(tty)) != NULL) | ||
3293 | { /* Begin if channel valid */ | ||
3294 | |||
3295 | |||
3296 | /* Just in case output was resumed because of a change in Digi-flow */ | 2691 | /* Just in case output was resumed because of a change in Digi-flow */ |
3297 | save_flags(flags); | 2692 | spin_lock_irqsave(&epca_lock, flags); |
3298 | cli(); | 2693 | if (ch->statusflags & RXSTOPPED) { |
3299 | |||
3300 | if (ch->statusflags & RXSTOPPED) | ||
3301 | { | ||
3302 | |||
3303 | globalwinon(ch); | 2694 | globalwinon(ch); |
3304 | bc = ch->brdchan; | ||
3305 | fepcmd(ch, RESUMERX, 0, 0, 0, 0); | 2695 | fepcmd(ch, RESUMERX, 0, 0, 0, 0); |
3306 | |||
3307 | ch->statusflags &= ~RXSTOPPED; | 2696 | ch->statusflags &= ~RXSTOPPED; |
3308 | memoff(ch); | 2697 | memoff(ch); |
3309 | } | 2698 | } |
3310 | restore_flags(flags); | 2699 | spin_unlock_irqrestore(&epca_lock, flags); |
3311 | |||
3312 | } /* End if channel valid */ | 2700 | } /* End if channel valid */ |
3313 | |||
3314 | } /* End pc_unthrottle */ | 2701 | } /* End pc_unthrottle */ |
3315 | 2702 | ||
3316 | /* --------------------- Begin digi_send_break ----------------------- */ | 2703 | /* --------------------- Begin digi_send_break ----------------------- */ |
3317 | 2704 | ||
3318 | void digi_send_break(struct channel *ch, int msec) | 2705 | void digi_send_break(struct channel *ch, int msec) |
3319 | { /* Begin digi_send_break */ | 2706 | { /* Begin digi_send_break */ |
3320 | |||
3321 | unsigned long flags; | 2707 | unsigned long flags; |
3322 | 2708 | ||
3323 | save_flags(flags); | 2709 | spin_lock_irqsave(&epca_lock, flags); |
3324 | cli(); | ||
3325 | globalwinon(ch); | 2710 | globalwinon(ch); |
3326 | |||
3327 | /* -------------------------------------------------------------------- | 2711 | /* -------------------------------------------------------------------- |
3328 | Maybe I should send an infinite break here, schedule() for | 2712 | Maybe I should send an infinite break here, schedule() for |
3329 | msec amount of time, and then stop the break. This way, | 2713 | msec amount of time, and then stop the break. This way, |
@@ -3331,36 +2715,28 @@ void digi_send_break(struct channel *ch, int msec) | |||
3331 | to be called (i.e. via an ioctl()) more than once in msec amount | 2715 | to be called (i.e. via an ioctl()) more than once in msec amount |
3332 | of time. Try this for now... | 2716 | of time. Try this for now... |
3333 | ------------------------------------------------------------------------ */ | 2717 | ------------------------------------------------------------------------ */ |
3334 | |||
3335 | fepcmd(ch, SENDBREAK, msec, 0, 10, 0); | 2718 | fepcmd(ch, SENDBREAK, msec, 0, 10, 0); |
3336 | memoff(ch); | 2719 | memoff(ch); |
3337 | 2720 | spin_unlock_irqrestore(&epca_lock, flags); | |
3338 | restore_flags(flags); | ||
3339 | |||
3340 | } /* End digi_send_break */ | 2721 | } /* End digi_send_break */ |
3341 | 2722 | ||
3342 | /* --------------------- Begin setup_empty_event ----------------------- */ | 2723 | /* --------------------- Begin setup_empty_event ----------------------- */ |
3343 | 2724 | ||
2725 | /* Caller MUST hold the lock */ | ||
2726 | |||
3344 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch) | 2727 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch) |
3345 | { /* Begin setup_empty_event */ | 2728 | { /* Begin setup_empty_event */ |
3346 | 2729 | ||
3347 | volatile struct board_chan *bc = ch->brdchan; | 2730 | struct board_chan *bc = ch->brdchan; |
3348 | unsigned long int flags; | ||
3349 | 2731 | ||
3350 | save_flags(flags); | ||
3351 | cli(); | ||
3352 | globalwinon(ch); | 2732 | globalwinon(ch); |
3353 | ch->statusflags |= EMPTYWAIT; | 2733 | ch->statusflags |= EMPTYWAIT; |
3354 | |||
3355 | /* ------------------------------------------------------------------ | 2734 | /* ------------------------------------------------------------------ |
3356 | When set the iempty flag request a event to be generated when the | 2735 | When set the iempty flag request a event to be generated when the |
3357 | transmit buffer is empty (If there is no BREAK in progress). | 2736 | transmit buffer is empty (If there is no BREAK in progress). |
3358 | --------------------------------------------------------------------- */ | 2737 | --------------------------------------------------------------------- */ |
3359 | 2738 | writeb(1, &bc->iempty); | |
3360 | bc->iempty = 1; | ||
3361 | memoff(ch); | 2739 | memoff(ch); |
3362 | restore_flags(flags); | ||
3363 | |||
3364 | } /* End setup_empty_event */ | 2740 | } /* End setup_empty_event */ |
3365 | 2741 | ||
3366 | /* --------------------- Begin get_termio ----------------------- */ | 2742 | /* --------------------- Begin get_termio ----------------------- */ |
@@ -3369,10 +2745,10 @@ static int get_termio(struct tty_struct * tty, struct termio __user * termio) | |||
3369 | { /* Begin get_termio */ | 2745 | { /* Begin get_termio */ |
3370 | return kernel_termios_to_user_termio(termio, tty->termios); | 2746 | return kernel_termios_to_user_termio(termio, tty->termios); |
3371 | } /* End get_termio */ | 2747 | } /* End get_termio */ |
2748 | |||
3372 | /* ---------------------- Begin epca_setup -------------------------- */ | 2749 | /* ---------------------- Begin epca_setup -------------------------- */ |
3373 | void epca_setup(char *str, int *ints) | 2750 | void epca_setup(char *str, int *ints) |
3374 | { /* Begin epca_setup */ | 2751 | { /* Begin epca_setup */ |
3375 | |||
3376 | struct board_info board; | 2752 | struct board_info board; |
3377 | int index, loop, last; | 2753 | int index, loop, last; |
3378 | char *temp, *t2; | 2754 | char *temp, *t2; |
@@ -3394,49 +2770,41 @@ void epca_setup(char *str, int *ints) | |||
3394 | for (last = 0, index = 1; index <= ints[0]; index++) | 2770 | for (last = 0, index = 1; index <= ints[0]; index++) |
3395 | switch(index) | 2771 | switch(index) |
3396 | { /* Begin parse switch */ | 2772 | { /* Begin parse switch */ |
3397 | |||
3398 | case 1: | 2773 | case 1: |
3399 | board.status = ints[index]; | 2774 | board.status = ints[index]; |
3400 | |||
3401 | /* --------------------------------------------------------- | 2775 | /* --------------------------------------------------------- |
3402 | We check for 2 (As opposed to 1; because 2 is a flag | 2776 | We check for 2 (As opposed to 1; because 2 is a flag |
3403 | instructing the driver to ignore epcaconfig.) For this | 2777 | instructing the driver to ignore epcaconfig.) For this |
3404 | reason we check for 2. | 2778 | reason we check for 2. |
3405 | ------------------------------------------------------------ */ | 2779 | ------------------------------------------------------------ */ |
3406 | if (board.status == 2) | 2780 | if (board.status == 2) { /* Begin ignore epcaconfig as well as lilo cmd line */ |
3407 | { /* Begin ignore epcaconfig as well as lilo cmd line */ | ||
3408 | nbdevs = 0; | 2781 | nbdevs = 0; |
3409 | num_cards = 0; | 2782 | num_cards = 0; |
3410 | return; | 2783 | return; |
3411 | } /* End ignore epcaconfig as well as lilo cmd line */ | 2784 | } /* End ignore epcaconfig as well as lilo cmd line */ |
3412 | 2785 | ||
3413 | if (board.status > 2) | 2786 | if (board.status > 2) { |
3414 | { | 2787 | printk(KERN_ERR "epca_setup: Invalid board status 0x%x\n", board.status); |
3415 | printk(KERN_ERR "<Error> - epca_setup: Invalid board status 0x%x\n", board.status); | ||
3416 | invalid_lilo_config = 1; | 2788 | invalid_lilo_config = 1; |
3417 | setup_error_code |= INVALID_BOARD_STATUS; | 2789 | setup_error_code |= INVALID_BOARD_STATUS; |
3418 | return; | 2790 | return; |
3419 | } | 2791 | } |
3420 | last = index; | 2792 | last = index; |
3421 | break; | 2793 | break; |
3422 | |||
3423 | case 2: | 2794 | case 2: |
3424 | board.type = ints[index]; | 2795 | board.type = ints[index]; |
3425 | if (board.type >= PCIXEM) | 2796 | if (board.type >= PCIXEM) { |
3426 | { | 2797 | printk(KERN_ERR "epca_setup: Invalid board type 0x%x\n", board.type); |
3427 | printk(KERN_ERR "<Error> - epca_setup: Invalid board type 0x%x\n", board.type); | ||
3428 | invalid_lilo_config = 1; | 2798 | invalid_lilo_config = 1; |
3429 | setup_error_code |= INVALID_BOARD_TYPE; | 2799 | setup_error_code |= INVALID_BOARD_TYPE; |
3430 | return; | 2800 | return; |
3431 | } | 2801 | } |
3432 | last = index; | 2802 | last = index; |
3433 | break; | 2803 | break; |
3434 | |||
3435 | case 3: | 2804 | case 3: |
3436 | board.altpin = ints[index]; | 2805 | board.altpin = ints[index]; |
3437 | if (board.altpin > 1) | 2806 | if (board.altpin > 1) { |
3438 | { | 2807 | printk(KERN_ERR "epca_setup: Invalid board altpin 0x%x\n", board.altpin); |
3439 | printk(KERN_ERR "<Error> - epca_setup: Invalid board altpin 0x%x\n", board.altpin); | ||
3440 | invalid_lilo_config = 1; | 2808 | invalid_lilo_config = 1; |
3441 | setup_error_code |= INVALID_ALTPIN; | 2809 | setup_error_code |= INVALID_ALTPIN; |
3442 | return; | 2810 | return; |
@@ -3446,9 +2814,8 @@ void epca_setup(char *str, int *ints) | |||
3446 | 2814 | ||
3447 | case 4: | 2815 | case 4: |
3448 | board.numports = ints[index]; | 2816 | board.numports = ints[index]; |
3449 | if ((board.numports < 2) || (board.numports > 256)) | 2817 | if (board.numports < 2 || board.numports > 256) { |
3450 | { | 2818 | printk(KERN_ERR "epca_setup: Invalid board numports 0x%x\n", board.numports); |
3451 | printk(KERN_ERR "<Error> - epca_setup: Invalid board numports 0x%x\n", board.numports); | ||
3452 | invalid_lilo_config = 1; | 2819 | invalid_lilo_config = 1; |
3453 | setup_error_code |= INVALID_NUM_PORTS; | 2820 | setup_error_code |= INVALID_NUM_PORTS; |
3454 | return; | 2821 | return; |
@@ -3458,10 +2825,9 @@ void epca_setup(char *str, int *ints) | |||
3458 | break; | 2825 | break; |
3459 | 2826 | ||
3460 | case 5: | 2827 | case 5: |
3461 | board.port = (unsigned char *)ints[index]; | 2828 | board.port = ints[index]; |
3462 | if (ints[index] <= 0) | 2829 | if (ints[index] <= 0) { |
3463 | { | 2830 | printk(KERN_ERR "epca_setup: Invalid io port 0x%x\n", (unsigned int)board.port); |
3464 | printk(KERN_ERR "<Error> - epca_setup: Invalid io port 0x%x\n", (unsigned int)board.port); | ||
3465 | invalid_lilo_config = 1; | 2831 | invalid_lilo_config = 1; |
3466 | setup_error_code |= INVALID_PORT_BASE; | 2832 | setup_error_code |= INVALID_PORT_BASE; |
3467 | return; | 2833 | return; |
@@ -3470,10 +2836,9 @@ void epca_setup(char *str, int *ints) | |||
3470 | break; | 2836 | break; |
3471 | 2837 | ||
3472 | case 6: | 2838 | case 6: |
3473 | board.membase = (unsigned char *)ints[index]; | 2839 | board.membase = ints[index]; |
3474 | if (ints[index] <= 0) | 2840 | if (ints[index] <= 0) { |
3475 | { | 2841 | printk(KERN_ERR "epca_setup: Invalid memory base 0x%x\n",(unsigned int)board.membase); |
3476 | printk(KERN_ERR "<Error> - epca_setup: Invalid memory base 0x%x\n",(unsigned int)board.membase); | ||
3477 | invalid_lilo_config = 1; | 2842 | invalid_lilo_config = 1; |
3478 | setup_error_code |= INVALID_MEM_BASE; | 2843 | setup_error_code |= INVALID_MEM_BASE; |
3479 | return; | 2844 | return; |
@@ -3487,21 +2852,16 @@ void epca_setup(char *str, int *ints) | |||
3487 | 2852 | ||
3488 | } /* End parse switch */ | 2853 | } /* End parse switch */ |
3489 | 2854 | ||
3490 | while (str && *str) | 2855 | while (str && *str) { /* Begin while there is a string arg */ |
3491 | { /* Begin while there is a string arg */ | ||
3492 | |||
3493 | /* find the next comma or terminator */ | 2856 | /* find the next comma or terminator */ |
3494 | temp = str; | 2857 | temp = str; |
3495 | |||
3496 | /* While string is not null, and a comma hasn't been found */ | 2858 | /* While string is not null, and a comma hasn't been found */ |
3497 | while (*temp && (*temp != ',')) | 2859 | while (*temp && (*temp != ',')) |
3498 | temp++; | 2860 | temp++; |
3499 | |||
3500 | if (!*temp) | 2861 | if (!*temp) |
3501 | temp = NULL; | 2862 | temp = NULL; |
3502 | else | 2863 | else |
3503 | *temp++ = 0; | 2864 | *temp++ = 0; |
3504 | |||
3505 | /* Set index to the number of args + 1 */ | 2865 | /* Set index to the number of args + 1 */ |
3506 | index = last + 1; | 2866 | index = last + 1; |
3507 | 2867 | ||
@@ -3511,12 +2871,10 @@ void epca_setup(char *str, int *ints) | |||
3511 | len = strlen(str); | 2871 | len = strlen(str); |
3512 | if (strncmp("Disable", str, len) == 0) | 2872 | if (strncmp("Disable", str, len) == 0) |
3513 | board.status = 0; | 2873 | board.status = 0; |
3514 | else | 2874 | else if (strncmp("Enable", str, len) == 0) |
3515 | if (strncmp("Enable", str, len) == 0) | ||
3516 | board.status = 1; | 2875 | board.status = 1; |
3517 | else | 2876 | else { |
3518 | { | 2877 | printk(KERN_ERR "epca_setup: Invalid status %s\n", str); |
3519 | printk(KERN_ERR "<Error> - epca_setup: Invalid status %s\n", str); | ||
3520 | invalid_lilo_config = 1; | 2878 | invalid_lilo_config = 1; |
3521 | setup_error_code |= INVALID_BOARD_STATUS; | 2879 | setup_error_code |= INVALID_BOARD_STATUS; |
3522 | return; | 2880 | return; |
@@ -3525,22 +2883,17 @@ void epca_setup(char *str, int *ints) | |||
3525 | break; | 2883 | break; |
3526 | 2884 | ||
3527 | case 2: | 2885 | case 2: |
3528 | |||
3529 | for(loop = 0; loop < EPCA_NUM_TYPES; loop++) | 2886 | for(loop = 0; loop < EPCA_NUM_TYPES; loop++) |
3530 | if (strcmp(board_desc[loop], str) == 0) | 2887 | if (strcmp(board_desc[loop], str) == 0) |
3531 | break; | 2888 | break; |
3532 | |||
3533 | |||
3534 | /* --------------------------------------------------------------- | 2889 | /* --------------------------------------------------------------- |
3535 | If the index incremented above refers to a legitamate board | 2890 | If the index incremented above refers to a legitamate board |
3536 | type set it here. | 2891 | type set it here. |
3537 | ------------------------------------------------------------------*/ | 2892 | ------------------------------------------------------------------*/ |
3538 | |||
3539 | if (index < EPCA_NUM_TYPES) | 2893 | if (index < EPCA_NUM_TYPES) |
3540 | board.type = loop; | 2894 | board.type = loop; |
3541 | else | 2895 | else { |
3542 | { | 2896 | printk(KERN_ERR "epca_setup: Invalid board type: %s\n", str); |
3543 | printk(KERN_ERR "<Error> - epca_setup: Invalid board type: %s\n", str); | ||
3544 | invalid_lilo_config = 1; | 2897 | invalid_lilo_config = 1; |
3545 | setup_error_code |= INVALID_BOARD_TYPE; | 2898 | setup_error_code |= INVALID_BOARD_TYPE; |
3546 | return; | 2899 | return; |
@@ -3552,12 +2905,10 @@ void epca_setup(char *str, int *ints) | |||
3552 | len = strlen(str); | 2905 | len = strlen(str); |
3553 | if (strncmp("Disable", str, len) == 0) | 2906 | if (strncmp("Disable", str, len) == 0) |
3554 | board.altpin = 0; | 2907 | board.altpin = 0; |
3555 | else | 2908 | else if (strncmp("Enable", str, len) == 0) |
3556 | if (strncmp("Enable", str, len) == 0) | ||
3557 | board.altpin = 1; | 2909 | board.altpin = 1; |
3558 | else | 2910 | else { |
3559 | { | 2911 | printk(KERN_ERR "epca_setup: Invalid altpin %s\n", str); |
3560 | printk(KERN_ERR "<Error> - epca_setup: Invalid altpin %s\n", str); | ||
3561 | invalid_lilo_config = 1; | 2912 | invalid_lilo_config = 1; |
3562 | setup_error_code |= INVALID_ALTPIN; | 2913 | setup_error_code |= INVALID_ALTPIN; |
3563 | return; | 2914 | return; |
@@ -3570,9 +2921,8 @@ void epca_setup(char *str, int *ints) | |||
3570 | while (isdigit(*t2)) | 2921 | while (isdigit(*t2)) |
3571 | t2++; | 2922 | t2++; |
3572 | 2923 | ||
3573 | if (*t2) | 2924 | if (*t2) { |
3574 | { | 2925 | printk(KERN_ERR "epca_setup: Invalid port count %s\n", str); |
3575 | printk(KERN_ERR "<Error> - epca_setup: Invalid port count %s\n", str); | ||
3576 | invalid_lilo_config = 1; | 2926 | invalid_lilo_config = 1; |
3577 | setup_error_code |= INVALID_NUM_PORTS; | 2927 | setup_error_code |= INVALID_NUM_PORTS; |
3578 | return; | 2928 | return; |
@@ -3601,15 +2951,14 @@ void epca_setup(char *str, int *ints) | |||
3601 | while (isxdigit(*t2)) | 2951 | while (isxdigit(*t2)) |
3602 | t2++; | 2952 | t2++; |
3603 | 2953 | ||
3604 | if (*t2) | 2954 | if (*t2) { |
3605 | { | 2955 | printk(KERN_ERR "epca_setup: Invalid i/o address %s\n", str); |
3606 | printk(KERN_ERR "<Error> - epca_setup: Invalid i/o address %s\n", str); | ||
3607 | invalid_lilo_config = 1; | 2956 | invalid_lilo_config = 1; |
3608 | setup_error_code |= INVALID_PORT_BASE; | 2957 | setup_error_code |= INVALID_PORT_BASE; |
3609 | return; | 2958 | return; |
3610 | } | 2959 | } |
3611 | 2960 | ||
3612 | board.port = (unsigned char *)simple_strtoul(str, NULL, 16); | 2961 | board.port = simple_strtoul(str, NULL, 16); |
3613 | last = index; | 2962 | last = index; |
3614 | break; | 2963 | break; |
3615 | 2964 | ||
@@ -3618,52 +2967,38 @@ void epca_setup(char *str, int *ints) | |||
3618 | while (isxdigit(*t2)) | 2967 | while (isxdigit(*t2)) |
3619 | t2++; | 2968 | t2++; |
3620 | 2969 | ||
3621 | if (*t2) | 2970 | if (*t2) { |
3622 | { | 2971 | printk(KERN_ERR "epca_setup: Invalid memory base %s\n",str); |
3623 | printk(KERN_ERR "<Error> - epca_setup: Invalid memory base %s\n",str); | ||
3624 | invalid_lilo_config = 1; | 2972 | invalid_lilo_config = 1; |
3625 | setup_error_code |= INVALID_MEM_BASE; | 2973 | setup_error_code |= INVALID_MEM_BASE; |
3626 | return; | 2974 | return; |
3627 | } | 2975 | } |
3628 | 2976 | board.membase = simple_strtoul(str, NULL, 16); | |
3629 | board.membase = (unsigned char *)simple_strtoul(str, NULL, 16); | ||
3630 | last = index; | 2977 | last = index; |
3631 | break; | 2978 | break; |
3632 | |||
3633 | default: | 2979 | default: |
3634 | printk(KERN_ERR "PC/Xx: Too many string parms\n"); | 2980 | printk(KERN_ERR "epca: Too many string parms\n"); |
3635 | return; | 2981 | return; |
3636 | } | 2982 | } |
3637 | str = temp; | 2983 | str = temp; |
3638 | |||
3639 | } /* End while there is a string arg */ | 2984 | } /* End while there is a string arg */ |
3640 | 2985 | ||
3641 | 2986 | if (last < 6) { | |
3642 | if (last < 6) | 2987 | printk(KERN_ERR "epca: Insufficient parms specified\n"); |
3643 | { | ||
3644 | printk(KERN_ERR "PC/Xx: Insufficient parms specified\n"); | ||
3645 | return; | 2988 | return; |
3646 | } | 2989 | } |
3647 | 2990 | ||
3648 | /* I should REALLY validate the stuff here */ | 2991 | /* I should REALLY validate the stuff here */ |
3649 | |||
3650 | /* Copies our local copy of board into boards */ | 2992 | /* Copies our local copy of board into boards */ |
3651 | memcpy((void *)&boards[num_cards],(void *)&board, sizeof(board)); | 2993 | memcpy((void *)&boards[num_cards],(void *)&board, sizeof(board)); |
3652 | |||
3653 | |||
3654 | /* Does this get called once per lilo arg are what ? */ | 2994 | /* Does this get called once per lilo arg are what ? */ |
3655 | |||
3656 | printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n", | 2995 | printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n", |
3657 | num_cards, board_desc[board.type], | 2996 | num_cards, board_desc[board.type], |
3658 | board.numports, (int)board.port, (unsigned int) board.membase); | 2997 | board.numports, (int)board.port, (unsigned int) board.membase); |
3659 | |||
3660 | num_cards++; | 2998 | num_cards++; |
3661 | |||
3662 | } /* End epca_setup */ | 2999 | } /* End epca_setup */ |
3663 | 3000 | ||
3664 | 3001 | ||
3665 | |||
3666 | #ifdef ENABLE_PCI | ||
3667 | /* ------------------------ Begin init_PCI --------------------------- */ | 3002 | /* ------------------------ Begin init_PCI --------------------------- */ |
3668 | 3003 | ||
3669 | enum epic_board_types { | 3004 | enum epic_board_types { |
@@ -3685,7 +3020,6 @@ static struct { | |||
3685 | { PCIXRJ, 2, }, | 3020 | { PCIXRJ, 2, }, |
3686 | }; | 3021 | }; |
3687 | 3022 | ||
3688 | |||
3689 | static int __devinit epca_init_one (struct pci_dev *pdev, | 3023 | static int __devinit epca_init_one (struct pci_dev *pdev, |
3690 | const struct pci_device_id *ent) | 3024 | const struct pci_device_id *ent) |
3691 | { | 3025 | { |
@@ -3711,10 +3045,8 @@ static int __devinit epca_init_one (struct pci_dev *pdev, | |||
3711 | boards[board_idx].status = ENABLED; | 3045 | boards[board_idx].status = ENABLED; |
3712 | boards[board_idx].type = epca_info_tbl[info_idx].board_type; | 3046 | boards[board_idx].type = epca_info_tbl[info_idx].board_type; |
3713 | boards[board_idx].numports = 0x0; | 3047 | boards[board_idx].numports = 0x0; |
3714 | boards[board_idx].port = | 3048 | boards[board_idx].port = addr + PCI_IO_OFFSET; |
3715 | (unsigned char *)((char *) addr + PCI_IO_OFFSET); | 3049 | boards[board_idx].membase = addr; |
3716 | boards[board_idx].membase = | ||
3717 | (unsigned char *)((char *) addr); | ||
3718 | 3050 | ||
3719 | if (!request_mem_region (addr + PCI_IO_OFFSET, 0x200000, "epca")) { | 3051 | if (!request_mem_region (addr + PCI_IO_OFFSET, 0x200000, "epca")) { |
3720 | printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", | 3052 | printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", |
@@ -3775,15 +3107,13 @@ static struct pci_device_id epca_pci_tbl[] = { | |||
3775 | MODULE_DEVICE_TABLE(pci, epca_pci_tbl); | 3107 | MODULE_DEVICE_TABLE(pci, epca_pci_tbl); |
3776 | 3108 | ||
3777 | int __init init_PCI (void) | 3109 | int __init init_PCI (void) |
3778 | { /* Begin init_PCI */ | 3110 | { /* Begin init_PCI */ |
3779 | memset (&epca_driver, 0, sizeof (epca_driver)); | 3111 | memset (&epca_driver, 0, sizeof (epca_driver)); |
3780 | epca_driver.name = "epca"; | 3112 | epca_driver.name = "epca"; |
3781 | epca_driver.id_table = epca_pci_tbl; | 3113 | epca_driver.id_table = epca_pci_tbl; |
3782 | epca_driver.probe = epca_init_one; | 3114 | epca_driver.probe = epca_init_one; |
3783 | 3115 | ||
3784 | return pci_register_driver(&epca_driver); | 3116 | return pci_register_driver(&epca_driver); |
3785 | } /* End init_PCI */ | 3117 | } |
3786 | |||
3787 | #endif /* ENABLE_PCI */ | ||
3788 | 3118 | ||
3789 | MODULE_LICENSE("GPL"); | 3119 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/char/epca.h b/drivers/char/epca.h index 52205ef71314..20eeb5a70e1a 100644 --- a/drivers/char/epca.h +++ b/drivers/char/epca.h | |||
@@ -85,73 +85,73 @@ static char *board_desc[] = | |||
85 | struct channel | 85 | struct channel |
86 | { | 86 | { |
87 | long magic; | 87 | long magic; |
88 | unchar boardnum; | 88 | unsigned char boardnum; |
89 | unchar channelnum; | 89 | unsigned char channelnum; |
90 | unchar omodem; /* FEP output modem status */ | 90 | unsigned char omodem; /* FEP output modem status */ |
91 | unchar imodem; /* FEP input modem status */ | 91 | unsigned char imodem; /* FEP input modem status */ |
92 | unchar modemfake; /* Modem values to be forced */ | 92 | unsigned char modemfake; /* Modem values to be forced */ |
93 | unchar modem; /* Force values */ | 93 | unsigned char modem; /* Force values */ |
94 | unchar hflow; | 94 | unsigned char hflow; |
95 | unchar dsr; | 95 | unsigned char dsr; |
96 | unchar dcd; | 96 | unsigned char dcd; |
97 | unchar m_rts ; /* The bits used in whatever FEP */ | 97 | unsigned char m_rts ; /* The bits used in whatever FEP */ |
98 | unchar m_dcd ; /* is indiginous to this board to */ | 98 | unsigned char m_dcd ; /* is indiginous to this board to */ |
99 | unchar m_dsr ; /* represent each of the physical */ | 99 | unsigned char m_dsr ; /* represent each of the physical */ |
100 | unchar m_cts ; /* handshake lines */ | 100 | unsigned char m_cts ; /* handshake lines */ |
101 | unchar m_ri ; | 101 | unsigned char m_ri ; |
102 | unchar m_dtr ; | 102 | unsigned char m_dtr ; |
103 | unchar stopc; | 103 | unsigned char stopc; |
104 | unchar startc; | 104 | unsigned char startc; |
105 | unchar stopca; | 105 | unsigned char stopca; |
106 | unchar startca; | 106 | unsigned char startca; |
107 | unchar fepstopc; | 107 | unsigned char fepstopc; |
108 | unchar fepstartc; | 108 | unsigned char fepstartc; |
109 | unchar fepstopca; | 109 | unsigned char fepstopca; |
110 | unchar fepstartca; | 110 | unsigned char fepstartca; |
111 | unchar txwin; | 111 | unsigned char txwin; |
112 | unchar rxwin; | 112 | unsigned char rxwin; |
113 | ushort fepiflag; | 113 | unsigned short fepiflag; |
114 | ushort fepcflag; | 114 | unsigned short fepcflag; |
115 | ushort fepoflag; | 115 | unsigned short fepoflag; |
116 | ushort txbufhead; | 116 | unsigned short txbufhead; |
117 | ushort txbufsize; | 117 | unsigned short txbufsize; |
118 | ushort rxbufhead; | 118 | unsigned short rxbufhead; |
119 | ushort rxbufsize; | 119 | unsigned short rxbufsize; |
120 | int close_delay; | 120 | int close_delay; |
121 | int count; | 121 | int count; |
122 | int blocked_open; | 122 | int blocked_open; |
123 | ulong event; | 123 | unsigned long event; |
124 | int asyncflags; | 124 | int asyncflags; |
125 | uint dev; | 125 | uint dev; |
126 | ulong statusflags; | 126 | unsigned long statusflags; |
127 | ulong c_iflag; | 127 | unsigned long c_iflag; |
128 | ulong c_cflag; | 128 | unsigned long c_cflag; |
129 | ulong c_lflag; | 129 | unsigned long c_lflag; |
130 | ulong c_oflag; | 130 | unsigned long c_oflag; |
131 | unchar *txptr; | 131 | unsigned char *txptr; |
132 | unchar *rxptr; | 132 | unsigned char *rxptr; |
133 | unchar *tmp_buf; | 133 | unsigned char *tmp_buf; |
134 | struct board_info *board; | 134 | struct board_info *board; |
135 | volatile struct board_chan *brdchan; | 135 | struct board_chan *brdchan; |
136 | struct digi_struct digiext; | 136 | struct digi_struct digiext; |
137 | struct tty_struct *tty; | 137 | struct tty_struct *tty; |
138 | wait_queue_head_t open_wait; | 138 | wait_queue_head_t open_wait; |
139 | wait_queue_head_t close_wait; | 139 | wait_queue_head_t close_wait; |
140 | struct work_struct tqueue; | 140 | struct work_struct tqueue; |
141 | volatile struct global_data *mailbox; | 141 | struct global_data *mailbox; |
142 | }; | 142 | }; |
143 | 143 | ||
144 | struct board_info | 144 | struct board_info |
145 | { | 145 | { |
146 | unchar status; | 146 | unsigned char status; |
147 | unchar type; | 147 | unsigned char type; |
148 | unchar altpin; | 148 | unsigned char altpin; |
149 | ushort numports; | 149 | unsigned short numports; |
150 | unchar *port; | 150 | unsigned long port; |
151 | unchar *membase; | 151 | unsigned long membase; |
152 | unchar __iomem *re_map_port; | 152 | unsigned char __iomem *re_map_port; |
153 | unchar *re_map_membase; | 153 | unsigned char *re_map_membase; |
154 | ulong memory_seg; | 154 | unsigned long memory_seg; |
155 | void ( * memwinon ) (struct board_info *, unsigned int) ; | 155 | void ( * memwinon ) (struct board_info *, unsigned int) ; |
156 | void ( * memwinoff ) (struct board_info *, unsigned int) ; | 156 | void ( * memwinoff ) (struct board_info *, unsigned int) ; |
157 | void ( * globalwinon ) (struct channel *) ; | 157 | void ( * globalwinon ) (struct channel *) ; |
@@ -160,6 +160,6 @@ struct board_info | |||
160 | void ( * memoff ) (struct channel *) ; | 160 | void ( * memoff ) (struct channel *) ; |
161 | void ( * assertgwinon ) (struct channel *) ; | 161 | void ( * assertgwinon ) (struct channel *) ; |
162 | void ( * assertmemoff ) (struct channel *) ; | 162 | void ( * assertmemoff ) (struct channel *) ; |
163 | unchar poller_inhibited ; | 163 | unsigned char poller_inhibited ; |
164 | }; | 164 | }; |
165 | 165 | ||
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c index 81d811edf3c5..a54bc93353af 100644 --- a/drivers/char/hangcheck-timer.c +++ b/drivers/char/hangcheck-timer.c | |||
@@ -149,8 +149,7 @@ static unsigned long long hangcheck_tsc, hangcheck_tsc_margin; | |||
149 | 149 | ||
150 | static void hangcheck_fire(unsigned long); | 150 | static void hangcheck_fire(unsigned long); |
151 | 151 | ||
152 | static struct timer_list hangcheck_ticktock = | 152 | static DEFINE_TIMER(hangcheck_ticktock, hangcheck_fire, 0, 0); |
153 | TIMER_INITIALIZER(hangcheck_fire, 0, 0); | ||
154 | 153 | ||
155 | 154 | ||
156 | static void hangcheck_fire(unsigned long data) | 155 | static void hangcheck_fire(unsigned long data) |
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index 762fa430fb5b..5fe8461271fc 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c | |||
@@ -44,7 +44,7 @@ | |||
44 | /* | 44 | /* |
45 | * The High Precision Event Timer driver. | 45 | * The High Precision Event Timer driver. |
46 | * This driver is closely modelled after the rtc.c driver. | 46 | * This driver is closely modelled after the rtc.c driver. |
47 | * http://www.intel.com/labs/platcomp/hpet/hpetspec.htm | 47 | * http://www.intel.com/hardwaredesign/hpetspec.htm |
48 | */ | 48 | */ |
49 | #define HPET_USER_FREQ (64) | 49 | #define HPET_USER_FREQ (64) |
50 | #define HPET_DRIFT (500) | 50 | #define HPET_DRIFT (500) |
@@ -712,7 +712,7 @@ static void hpet_register_interpolator(struct hpets *hpetp) | |||
712 | ti->shift = 10; | 712 | ti->shift = 10; |
713 | ti->addr = &hpetp->hp_hpet->hpet_mc; | 713 | ti->addr = &hpetp->hp_hpet->hpet_mc; |
714 | ti->frequency = hpet_time_div(hpets->hp_period); | 714 | ti->frequency = hpet_time_div(hpets->hp_period); |
715 | ti->drift = ti->frequency * HPET_DRIFT / 1000000; | 715 | ti->drift = HPET_DRIFT; |
716 | ti->mask = -1; | 716 | ti->mask = -1; |
717 | 717 | ||
718 | hpetp->hp_interpolator = ti; | 718 | hpetp->hp_interpolator = ti; |
@@ -906,11 +906,15 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data) | |||
906 | if (irqp->number_of_interrupts > 0) { | 906 | if (irqp->number_of_interrupts > 0) { |
907 | hdp->hd_nirqs = irqp->number_of_interrupts; | 907 | hdp->hd_nirqs = irqp->number_of_interrupts; |
908 | 908 | ||
909 | for (i = 0; i < hdp->hd_nirqs; i++) | 909 | for (i = 0; i < hdp->hd_nirqs; i++) { |
910 | hdp->hd_irq[i] = | 910 | int rc = |
911 | acpi_register_gsi(irqp->interrupts[i], | 911 | acpi_register_gsi(irqp->interrupts[i], |
912 | irqp->edge_level, | 912 | irqp->edge_level, |
913 | irqp->active_high_low); | 913 | irqp->active_high_low); |
914 | if (rc < 0) | ||
915 | return AE_ERROR; | ||
916 | hdp->hd_irq[i] = rc; | ||
917 | } | ||
914 | } | 918 | } |
915 | } | 919 | } |
916 | 920 | ||
diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c index cf0cd58d6305..9e4e26aef94e 100644 --- a/drivers/char/ip2main.c +++ b/drivers/char/ip2main.c | |||
@@ -120,7 +120,6 @@ | |||
120 | 120 | ||
121 | #include <linux/vmalloc.h> | 121 | #include <linux/vmalloc.h> |
122 | #include <linux/init.h> | 122 | #include <linux/init.h> |
123 | #include <asm/serial.h> | ||
124 | 123 | ||
125 | #include <asm/uaccess.h> | 124 | #include <asm/uaccess.h> |
126 | 125 | ||
@@ -255,7 +254,7 @@ static unsigned long bh_counter = 0; | |||
255 | * selected, the board is serviced periodically to see if anything needs doing. | 254 | * selected, the board is serviced periodically to see if anything needs doing. |
256 | */ | 255 | */ |
257 | #define POLL_TIMEOUT (jiffies + 1) | 256 | #define POLL_TIMEOUT (jiffies + 1) |
258 | static struct timer_list PollTimer = TIMER_INITIALIZER(ip2_poll, 0, 0); | 257 | static DEFINE_TIMER(PollTimer, ip2_poll, 0, 0); |
259 | static char TimerOn; | 258 | static char TimerOn; |
260 | 259 | ||
261 | #ifdef IP2DEBUG_TRACE | 260 | #ifdef IP2DEBUG_TRACE |
diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c index 5ce9c6269033..33862670e285 100644 --- a/drivers/char/ipmi/ipmi_bt_sm.c +++ b/drivers/char/ipmi/ipmi_bt_sm.c | |||
@@ -31,8 +31,6 @@ | |||
31 | #include <linux/ipmi_msgdefs.h> /* for completion codes */ | 31 | #include <linux/ipmi_msgdefs.h> /* for completion codes */ |
32 | #include "ipmi_si_sm.h" | 32 | #include "ipmi_si_sm.h" |
33 | 33 | ||
34 | #define IPMI_BT_VERSION "v33" | ||
35 | |||
36 | static int bt_debug = 0x00; /* Production value 0, see following flags */ | 34 | static int bt_debug = 0x00; /* Production value 0, see following flags */ |
37 | 35 | ||
38 | #define BT_DEBUG_ENABLE 1 | 36 | #define BT_DEBUG_ENABLE 1 |
@@ -163,7 +161,8 @@ static int bt_start_transaction(struct si_sm_data *bt, | |||
163 | { | 161 | { |
164 | unsigned int i; | 162 | unsigned int i; |
165 | 163 | ||
166 | if ((size < 2) || (size > IPMI_MAX_MSG_LENGTH)) return -1; | 164 | if ((size < 2) || (size > IPMI_MAX_MSG_LENGTH)) |
165 | return -1; | ||
167 | 166 | ||
168 | if ((bt->state != BT_STATE_IDLE) && (bt->state != BT_STATE_HOSED)) | 167 | if ((bt->state != BT_STATE_IDLE) && (bt->state != BT_STATE_HOSED)) |
169 | return -2; | 168 | return -2; |
@@ -171,7 +170,8 @@ static int bt_start_transaction(struct si_sm_data *bt, | |||
171 | if (bt_debug & BT_DEBUG_MSG) { | 170 | if (bt_debug & BT_DEBUG_MSG) { |
172 | printk(KERN_WARNING "+++++++++++++++++++++++++++++++++++++\n"); | 171 | printk(KERN_WARNING "+++++++++++++++++++++++++++++++++++++\n"); |
173 | printk(KERN_WARNING "BT: write seq=0x%02X:", bt->seq); | 172 | printk(KERN_WARNING "BT: write seq=0x%02X:", bt->seq); |
174 | for (i = 0; i < size; i ++) printk (" %02x", data[i]); | 173 | for (i = 0; i < size; i ++) |
174 | printk (" %02x", data[i]); | ||
175 | printk("\n"); | 175 | printk("\n"); |
176 | } | 176 | } |
177 | bt->write_data[0] = size + 1; /* all data plus seq byte */ | 177 | bt->write_data[0] = size + 1; /* all data plus seq byte */ |
@@ -210,15 +210,18 @@ static int bt_get_result(struct si_sm_data *bt, | |||
210 | } else { | 210 | } else { |
211 | data[0] = bt->read_data[1]; | 211 | data[0] = bt->read_data[1]; |
212 | data[1] = bt->read_data[3]; | 212 | data[1] = bt->read_data[3]; |
213 | if (length < msg_len) bt->truncated = 1; | 213 | if (length < msg_len) |
214 | bt->truncated = 1; | ||
214 | if (bt->truncated) { /* can be set in read_all_bytes() */ | 215 | if (bt->truncated) { /* can be set in read_all_bytes() */ |
215 | data[2] = IPMI_ERR_MSG_TRUNCATED; | 216 | data[2] = IPMI_ERR_MSG_TRUNCATED; |
216 | msg_len = 3; | 217 | msg_len = 3; |
217 | } else memcpy(data + 2, bt->read_data + 4, msg_len - 2); | 218 | } else |
219 | memcpy(data + 2, bt->read_data + 4, msg_len - 2); | ||
218 | 220 | ||
219 | if (bt_debug & BT_DEBUG_MSG) { | 221 | if (bt_debug & BT_DEBUG_MSG) { |
220 | printk (KERN_WARNING "BT: res (raw)"); | 222 | printk (KERN_WARNING "BT: res (raw)"); |
221 | for (i = 0; i < msg_len; i++) printk(" %02x", data[i]); | 223 | for (i = 0; i < msg_len; i++) |
224 | printk(" %02x", data[i]); | ||
222 | printk ("\n"); | 225 | printk ("\n"); |
223 | } | 226 | } |
224 | } | 227 | } |
@@ -231,8 +234,10 @@ static int bt_get_result(struct si_sm_data *bt, | |||
231 | 234 | ||
232 | static void reset_flags(struct si_sm_data *bt) | 235 | static void reset_flags(struct si_sm_data *bt) |
233 | { | 236 | { |
234 | if (BT_STATUS & BT_H_BUSY) BT_CONTROL(BT_H_BUSY); | 237 | if (BT_STATUS & BT_H_BUSY) |
235 | if (BT_STATUS & BT_B_BUSY) BT_CONTROL(BT_B_BUSY); | 238 | BT_CONTROL(BT_H_BUSY); |
239 | if (BT_STATUS & BT_B_BUSY) | ||
240 | BT_CONTROL(BT_B_BUSY); | ||
236 | BT_CONTROL(BT_CLR_WR_PTR); | 241 | BT_CONTROL(BT_CLR_WR_PTR); |
237 | BT_CONTROL(BT_SMS_ATN); | 242 | BT_CONTROL(BT_SMS_ATN); |
238 | #ifdef DEVELOPMENT_ONLY_NOT_FOR_PRODUCTION | 243 | #ifdef DEVELOPMENT_ONLY_NOT_FOR_PRODUCTION |
@@ -241,7 +246,8 @@ static void reset_flags(struct si_sm_data *bt) | |||
241 | BT_CONTROL(BT_H_BUSY); | 246 | BT_CONTROL(BT_H_BUSY); |
242 | BT_CONTROL(BT_B2H_ATN); | 247 | BT_CONTROL(BT_B2H_ATN); |
243 | BT_CONTROL(BT_CLR_RD_PTR); | 248 | BT_CONTROL(BT_CLR_RD_PTR); |
244 | for (i = 0; i < IPMI_MAX_MSG_LENGTH + 2; i++) BMC2HOST; | 249 | for (i = 0; i < IPMI_MAX_MSG_LENGTH + 2; i++) |
250 | BMC2HOST; | ||
245 | BT_CONTROL(BT_H_BUSY); | 251 | BT_CONTROL(BT_H_BUSY); |
246 | } | 252 | } |
247 | #endif | 253 | #endif |
@@ -258,7 +264,8 @@ static inline void write_all_bytes(struct si_sm_data *bt) | |||
258 | printk (" %02x", bt->write_data[i]); | 264 | printk (" %02x", bt->write_data[i]); |
259 | printk ("\n"); | 265 | printk ("\n"); |
260 | } | 266 | } |
261 | for (i = 0; i < bt->write_count; i++) HOST2BMC(bt->write_data[i]); | 267 | for (i = 0; i < bt->write_count; i++) |
268 | HOST2BMC(bt->write_data[i]); | ||
262 | } | 269 | } |
263 | 270 | ||
264 | static inline int read_all_bytes(struct si_sm_data *bt) | 271 | static inline int read_all_bytes(struct si_sm_data *bt) |
@@ -278,7 +285,8 @@ static inline int read_all_bytes(struct si_sm_data *bt) | |||
278 | bt->truncated = 1; | 285 | bt->truncated = 1; |
279 | return 1; /* let next XACTION START clean it up */ | 286 | return 1; /* let next XACTION START clean it up */ |
280 | } | 287 | } |
281 | for (i = 1; i <= bt->read_count; i++) bt->read_data[i] = BMC2HOST; | 288 | for (i = 1; i <= bt->read_count; i++) |
289 | bt->read_data[i] = BMC2HOST; | ||
282 | bt->read_count++; /* account for the length byte */ | 290 | bt->read_count++; /* account for the length byte */ |
283 | 291 | ||
284 | if (bt_debug & BT_DEBUG_MSG) { | 292 | if (bt_debug & BT_DEBUG_MSG) { |
@@ -295,7 +303,8 @@ static inline int read_all_bytes(struct si_sm_data *bt) | |||
295 | ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8))) | 303 | ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8))) |
296 | return 1; | 304 | return 1; |
297 | 305 | ||
298 | if (bt_debug & BT_DEBUG_MSG) printk(KERN_WARNING "BT: bad packet: " | 306 | if (bt_debug & BT_DEBUG_MSG) |
307 | printk(KERN_WARNING "BT: bad packet: " | ||
299 | "want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n", | 308 | "want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n", |
300 | bt->write_data[1], bt->write_data[2], bt->write_data[3], | 309 | bt->write_data[1], bt->write_data[2], bt->write_data[3], |
301 | bt->read_data[1], bt->read_data[2], bt->read_data[3]); | 310 | bt->read_data[1], bt->read_data[2], bt->read_data[3]); |
@@ -359,7 +368,8 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) | |||
359 | time); | 368 | time); |
360 | bt->last_state = bt->state; | 369 | bt->last_state = bt->state; |
361 | 370 | ||
362 | if (bt->state == BT_STATE_HOSED) return SI_SM_HOSED; | 371 | if (bt->state == BT_STATE_HOSED) |
372 | return SI_SM_HOSED; | ||
363 | 373 | ||
364 | if (bt->state != BT_STATE_IDLE) { /* do timeout test */ | 374 | if (bt->state != BT_STATE_IDLE) { /* do timeout test */ |
365 | 375 | ||
@@ -371,7 +381,8 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) | |||
371 | /* FIXME: bt_event is sometimes called with time > BT_NORMAL_TIMEOUT | 381 | /* FIXME: bt_event is sometimes called with time > BT_NORMAL_TIMEOUT |
372 | (noticed in ipmi_smic_sm.c January 2004) */ | 382 | (noticed in ipmi_smic_sm.c January 2004) */ |
373 | 383 | ||
374 | if ((time <= 0) || (time >= BT_NORMAL_TIMEOUT)) time = 100; | 384 | if ((time <= 0) || (time >= BT_NORMAL_TIMEOUT)) |
385 | time = 100; | ||
375 | bt->timeout -= time; | 386 | bt->timeout -= time; |
376 | if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) { | 387 | if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) { |
377 | error_recovery(bt, "timed out"); | 388 | error_recovery(bt, "timed out"); |
@@ -393,12 +404,14 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) | |||
393 | BT_CONTROL(BT_H_BUSY); | 404 | BT_CONTROL(BT_H_BUSY); |
394 | break; | 405 | break; |
395 | } | 406 | } |
396 | if (status & BT_B2H_ATN) break; | 407 | if (status & BT_B2H_ATN) |
408 | break; | ||
397 | bt->state = BT_STATE_WRITE_BYTES; | 409 | bt->state = BT_STATE_WRITE_BYTES; |
398 | return SI_SM_CALL_WITHOUT_DELAY; /* for logging */ | 410 | return SI_SM_CALL_WITHOUT_DELAY; /* for logging */ |
399 | 411 | ||
400 | case BT_STATE_WRITE_BYTES: | 412 | case BT_STATE_WRITE_BYTES: |
401 | if (status & (BT_B_BUSY | BT_H2B_ATN)) break; | 413 | if (status & (BT_B_BUSY | BT_H2B_ATN)) |
414 | break; | ||
402 | BT_CONTROL(BT_CLR_WR_PTR); | 415 | BT_CONTROL(BT_CLR_WR_PTR); |
403 | write_all_bytes(bt); | 416 | write_all_bytes(bt); |
404 | BT_CONTROL(BT_H2B_ATN); /* clears too fast to catch? */ | 417 | BT_CONTROL(BT_H2B_ATN); /* clears too fast to catch? */ |
@@ -406,7 +419,8 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) | |||
406 | return SI_SM_CALL_WITHOUT_DELAY; /* it MIGHT sail through */ | 419 | return SI_SM_CALL_WITHOUT_DELAY; /* it MIGHT sail through */ |
407 | 420 | ||
408 | case BT_STATE_WRITE_CONSUME: /* BMCs usually blow right thru here */ | 421 | case BT_STATE_WRITE_CONSUME: /* BMCs usually blow right thru here */ |
409 | if (status & (BT_H2B_ATN | BT_B_BUSY)) break; | 422 | if (status & (BT_H2B_ATN | BT_B_BUSY)) |
423 | break; | ||
410 | bt->state = BT_STATE_B2H_WAIT; | 424 | bt->state = BT_STATE_B2H_WAIT; |
411 | /* fall through with status */ | 425 | /* fall through with status */ |
412 | 426 | ||
@@ -415,15 +429,18 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) | |||
415 | generation of B2H_ATN so ALWAYS return CALL_WITH_DELAY. */ | 429 | generation of B2H_ATN so ALWAYS return CALL_WITH_DELAY. */ |
416 | 430 | ||
417 | case BT_STATE_B2H_WAIT: | 431 | case BT_STATE_B2H_WAIT: |
418 | if (!(status & BT_B2H_ATN)) break; | 432 | if (!(status & BT_B2H_ATN)) |
433 | break; | ||
419 | 434 | ||
420 | /* Assume ordered, uncached writes: no need to wait */ | 435 | /* Assume ordered, uncached writes: no need to wait */ |
421 | if (!(status & BT_H_BUSY)) BT_CONTROL(BT_H_BUSY); /* set */ | 436 | if (!(status & BT_H_BUSY)) |
437 | BT_CONTROL(BT_H_BUSY); /* set */ | ||
422 | BT_CONTROL(BT_B2H_ATN); /* clear it, ACK to the BMC */ | 438 | BT_CONTROL(BT_B2H_ATN); /* clear it, ACK to the BMC */ |
423 | BT_CONTROL(BT_CLR_RD_PTR); /* reset the queue */ | 439 | BT_CONTROL(BT_CLR_RD_PTR); /* reset the queue */ |
424 | i = read_all_bytes(bt); | 440 | i = read_all_bytes(bt); |
425 | BT_CONTROL(BT_H_BUSY); /* clear */ | 441 | BT_CONTROL(BT_H_BUSY); /* clear */ |
426 | if (!i) break; /* Try this state again */ | 442 | if (!i) /* Try this state again */ |
443 | break; | ||
427 | bt->state = BT_STATE_READ_END; | 444 | bt->state = BT_STATE_READ_END; |
428 | return SI_SM_CALL_WITHOUT_DELAY; /* for logging */ | 445 | return SI_SM_CALL_WITHOUT_DELAY; /* for logging */ |
429 | 446 | ||
@@ -436,7 +453,8 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) | |||
436 | 453 | ||
437 | #ifdef MAKE_THIS_TRUE_IF_NECESSARY | 454 | #ifdef MAKE_THIS_TRUE_IF_NECESSARY |
438 | 455 | ||
439 | if (status & BT_H_BUSY) break; | 456 | if (status & BT_H_BUSY) |
457 | break; | ||
440 | #endif | 458 | #endif |
441 | bt->seq++; | 459 | bt->seq++; |
442 | bt->state = BT_STATE_IDLE; | 460 | bt->state = BT_STATE_IDLE; |
@@ -459,7 +477,8 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) | |||
459 | break; | 477 | break; |
460 | 478 | ||
461 | case BT_STATE_RESET3: | 479 | case BT_STATE_RESET3: |
462 | if (bt->timeout > 0) return SI_SM_CALL_WITH_DELAY; | 480 | if (bt->timeout > 0) |
481 | return SI_SM_CALL_WITH_DELAY; | ||
463 | bt->state = BT_STATE_RESTART; /* printk in debug modes */ | 482 | bt->state = BT_STATE_RESTART; /* printk in debug modes */ |
464 | break; | 483 | break; |
465 | 484 | ||
@@ -485,7 +504,8 @@ static int bt_detect(struct si_sm_data *bt) | |||
485 | but that's what you get from reading a bogus address, so we | 504 | but that's what you get from reading a bogus address, so we |
486 | test that first. The calling routine uses negative logic. */ | 505 | test that first. The calling routine uses negative logic. */ |
487 | 506 | ||
488 | if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF)) return 1; | 507 | if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF)) |
508 | return 1; | ||
489 | reset_flags(bt); | 509 | reset_flags(bt); |
490 | return 0; | 510 | return 0; |
491 | } | 511 | } |
@@ -501,7 +521,6 @@ static int bt_size(void) | |||
501 | 521 | ||
502 | struct si_sm_handlers bt_smi_handlers = | 522 | struct si_sm_handlers bt_smi_handlers = |
503 | { | 523 | { |
504 | .version = IPMI_BT_VERSION, | ||
505 | .init_data = bt_init_data, | 524 | .init_data = bt_init_data, |
506 | .start_transaction = bt_start_transaction, | 525 | .start_transaction = bt_start_transaction, |
507 | .get_result = bt_get_result, | 526 | .get_result = bt_get_result, |
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index e0a53570fea1..a09ff1080687 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c | |||
@@ -47,8 +47,6 @@ | |||
47 | #include <linux/device.h> | 47 | #include <linux/device.h> |
48 | #include <linux/compat.h> | 48 | #include <linux/compat.h> |
49 | 49 | ||
50 | #define IPMI_DEVINTF_VERSION "v33" | ||
51 | |||
52 | struct ipmi_file_private | 50 | struct ipmi_file_private |
53 | { | 51 | { |
54 | ipmi_user_t user; | 52 | ipmi_user_t user; |
@@ -411,6 +409,7 @@ static int ipmi_ioctl(struct inode *inode, | |||
411 | break; | 409 | break; |
412 | } | 410 | } |
413 | 411 | ||
412 | /* The next four are legacy, not per-channel. */ | ||
414 | case IPMICTL_SET_MY_ADDRESS_CMD: | 413 | case IPMICTL_SET_MY_ADDRESS_CMD: |
415 | { | 414 | { |
416 | unsigned int val; | 415 | unsigned int val; |
@@ -420,22 +419,25 @@ static int ipmi_ioctl(struct inode *inode, | |||
420 | break; | 419 | break; |
421 | } | 420 | } |
422 | 421 | ||
423 | ipmi_set_my_address(priv->user, val); | 422 | rv = ipmi_set_my_address(priv->user, 0, val); |
424 | rv = 0; | ||
425 | break; | 423 | break; |
426 | } | 424 | } |
427 | 425 | ||
428 | case IPMICTL_GET_MY_ADDRESS_CMD: | 426 | case IPMICTL_GET_MY_ADDRESS_CMD: |
429 | { | 427 | { |
430 | unsigned int val; | 428 | unsigned int val; |
429 | unsigned char rval; | ||
430 | |||
431 | rv = ipmi_get_my_address(priv->user, 0, &rval); | ||
432 | if (rv) | ||
433 | break; | ||
431 | 434 | ||
432 | val = ipmi_get_my_address(priv->user); | 435 | val = rval; |
433 | 436 | ||
434 | if (copy_to_user(arg, &val, sizeof(val))) { | 437 | if (copy_to_user(arg, &val, sizeof(val))) { |
435 | rv = -EFAULT; | 438 | rv = -EFAULT; |
436 | break; | 439 | break; |
437 | } | 440 | } |
438 | rv = 0; | ||
439 | break; | 441 | break; |
440 | } | 442 | } |
441 | 443 | ||
@@ -448,24 +450,94 @@ static int ipmi_ioctl(struct inode *inode, | |||
448 | break; | 450 | break; |
449 | } | 451 | } |
450 | 452 | ||
451 | ipmi_set_my_LUN(priv->user, val); | 453 | rv = ipmi_set_my_LUN(priv->user, 0, val); |
452 | rv = 0; | ||
453 | break; | 454 | break; |
454 | } | 455 | } |
455 | 456 | ||
456 | case IPMICTL_GET_MY_LUN_CMD: | 457 | case IPMICTL_GET_MY_LUN_CMD: |
457 | { | 458 | { |
458 | unsigned int val; | 459 | unsigned int val; |
460 | unsigned char rval; | ||
459 | 461 | ||
460 | val = ipmi_get_my_LUN(priv->user); | 462 | rv = ipmi_get_my_LUN(priv->user, 0, &rval); |
463 | if (rv) | ||
464 | break; | ||
465 | |||
466 | val = rval; | ||
467 | |||
468 | if (copy_to_user(arg, &val, sizeof(val))) { | ||
469 | rv = -EFAULT; | ||
470 | break; | ||
471 | } | ||
472 | break; | ||
473 | } | ||
474 | |||
475 | case IPMICTL_SET_MY_CHANNEL_ADDRESS_CMD: | ||
476 | { | ||
477 | struct ipmi_channel_lun_address_set val; | ||
478 | |||
479 | if (copy_from_user(&val, arg, sizeof(val))) { | ||
480 | rv = -EFAULT; | ||
481 | break; | ||
482 | } | ||
483 | |||
484 | return ipmi_set_my_address(priv->user, val.channel, val.value); | ||
485 | break; | ||
486 | } | ||
487 | |||
488 | case IPMICTL_GET_MY_CHANNEL_ADDRESS_CMD: | ||
489 | { | ||
490 | struct ipmi_channel_lun_address_set val; | ||
491 | |||
492 | if (copy_from_user(&val, arg, sizeof(val))) { | ||
493 | rv = -EFAULT; | ||
494 | break; | ||
495 | } | ||
496 | |||
497 | rv = ipmi_get_my_address(priv->user, val.channel, &val.value); | ||
498 | if (rv) | ||
499 | break; | ||
500 | |||
501 | if (copy_to_user(arg, &val, sizeof(val))) { | ||
502 | rv = -EFAULT; | ||
503 | break; | ||
504 | } | ||
505 | break; | ||
506 | } | ||
507 | |||
508 | case IPMICTL_SET_MY_CHANNEL_LUN_CMD: | ||
509 | { | ||
510 | struct ipmi_channel_lun_address_set val; | ||
511 | |||
512 | if (copy_from_user(&val, arg, sizeof(val))) { | ||
513 | rv = -EFAULT; | ||
514 | break; | ||
515 | } | ||
516 | |||
517 | rv = ipmi_set_my_LUN(priv->user, val.channel, val.value); | ||
518 | break; | ||
519 | } | ||
520 | |||
521 | case IPMICTL_GET_MY_CHANNEL_LUN_CMD: | ||
522 | { | ||
523 | struct ipmi_channel_lun_address_set val; | ||
524 | |||
525 | if (copy_from_user(&val, arg, sizeof(val))) { | ||
526 | rv = -EFAULT; | ||
527 | break; | ||
528 | } | ||
529 | |||
530 | rv = ipmi_get_my_LUN(priv->user, val.channel, &val.value); | ||
531 | if (rv) | ||
532 | break; | ||
461 | 533 | ||
462 | if (copy_to_user(arg, &val, sizeof(val))) { | 534 | if (copy_to_user(arg, &val, sizeof(val))) { |
463 | rv = -EFAULT; | 535 | rv = -EFAULT; |
464 | break; | 536 | break; |
465 | } | 537 | } |
466 | rv = 0; | ||
467 | break; | 538 | break; |
468 | } | 539 | } |
540 | |||
469 | case IPMICTL_SET_TIMING_PARMS_CMD: | 541 | case IPMICTL_SET_TIMING_PARMS_CMD: |
470 | { | 542 | { |
471 | struct ipmi_timing_parms parms; | 543 | struct ipmi_timing_parms parms; |
@@ -663,7 +735,8 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd, | |||
663 | case COMPAT_IPMICTL_RECEIVE_MSG: | 735 | case COMPAT_IPMICTL_RECEIVE_MSG: |
664 | case COMPAT_IPMICTL_RECEIVE_MSG_TRUNC: | 736 | case COMPAT_IPMICTL_RECEIVE_MSG_TRUNC: |
665 | { | 737 | { |
666 | struct ipmi_recv *precv64, recv64; | 738 | struct ipmi_recv __user *precv64; |
739 | struct ipmi_recv recv64; | ||
667 | 740 | ||
668 | if (get_compat_ipmi_recv(&recv64, compat_ptr(arg))) | 741 | if (get_compat_ipmi_recv(&recv64, compat_ptr(arg))) |
669 | return -EFAULT; | 742 | return -EFAULT; |
@@ -676,7 +749,7 @@ static long compat_ipmi_ioctl(struct file *filep, unsigned int cmd, | |||
676 | ((cmd == COMPAT_IPMICTL_RECEIVE_MSG) | 749 | ((cmd == COMPAT_IPMICTL_RECEIVE_MSG) |
677 | ? IPMICTL_RECEIVE_MSG | 750 | ? IPMICTL_RECEIVE_MSG |
678 | : IPMICTL_RECEIVE_MSG_TRUNC), | 751 | : IPMICTL_RECEIVE_MSG_TRUNC), |
679 | (long) precv64); | 752 | (unsigned long) precv64); |
680 | if (rc != 0) | 753 | if (rc != 0) |
681 | return rc; | 754 | return rc; |
682 | 755 | ||
@@ -748,8 +821,7 @@ static __init int init_ipmi_devintf(void) | |||
748 | if (ipmi_major < 0) | 821 | if (ipmi_major < 0) |
749 | return -EINVAL; | 822 | return -EINVAL; |
750 | 823 | ||
751 | printk(KERN_INFO "ipmi device interface version " | 824 | printk(KERN_INFO "ipmi device interface\n"); |
752 | IPMI_DEVINTF_VERSION "\n"); | ||
753 | 825 | ||
754 | ipmi_class = class_create(THIS_MODULE, "ipmi"); | 826 | ipmi_class = class_create(THIS_MODULE, "ipmi"); |
755 | if (IS_ERR(ipmi_class)) { | 827 | if (IS_ERR(ipmi_class)) { |
@@ -792,3 +864,5 @@ static __exit void cleanup_ipmi(void) | |||
792 | module_exit(cleanup_ipmi); | 864 | module_exit(cleanup_ipmi); |
793 | 865 | ||
794 | MODULE_LICENSE("GPL"); | 866 | MODULE_LICENSE("GPL"); |
867 | MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); | ||
868 | MODULE_DESCRIPTION("Linux device interface for the IPMI message handler."); | ||
diff --git a/drivers/char/ipmi/ipmi_kcs_sm.c b/drivers/char/ipmi/ipmi_kcs_sm.c index 48cce24329be..d21853a594a3 100644 --- a/drivers/char/ipmi/ipmi_kcs_sm.c +++ b/drivers/char/ipmi/ipmi_kcs_sm.c | |||
@@ -42,8 +42,6 @@ | |||
42 | #include <linux/ipmi_msgdefs.h> /* for completion codes */ | 42 | #include <linux/ipmi_msgdefs.h> /* for completion codes */ |
43 | #include "ipmi_si_sm.h" | 43 | #include "ipmi_si_sm.h" |
44 | 44 | ||
45 | #define IPMI_KCS_VERSION "v33" | ||
46 | |||
47 | /* Set this if you want a printout of why the state machine was hosed | 45 | /* Set this if you want a printout of why the state machine was hosed |
48 | when it gets hosed. */ | 46 | when it gets hosed. */ |
49 | #define DEBUG_HOSED_REASON | 47 | #define DEBUG_HOSED_REASON |
@@ -489,7 +487,6 @@ static void kcs_cleanup(struct si_sm_data *kcs) | |||
489 | 487 | ||
490 | struct si_sm_handlers kcs_smi_handlers = | 488 | struct si_sm_handlers kcs_smi_handlers = |
491 | { | 489 | { |
492 | .version = IPMI_KCS_VERSION, | ||
493 | .init_data = init_kcs_data, | 490 | .init_data = init_kcs_data, |
494 | .start_transaction = start_kcs_transaction, | 491 | .start_transaction = start_kcs_transaction, |
495 | .get_result = get_kcs_result, | 492 | .get_result = get_kcs_result, |
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index e16c13fe698d..463351d4f942 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -47,7 +47,8 @@ | |||
47 | #include <linux/proc_fs.h> | 47 | #include <linux/proc_fs.h> |
48 | 48 | ||
49 | #define PFX "IPMI message handler: " | 49 | #define PFX "IPMI message handler: " |
50 | #define IPMI_MSGHANDLER_VERSION "v33" | 50 | |
51 | #define IPMI_DRIVER_VERSION "36.0" | ||
51 | 52 | ||
52 | static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void); | 53 | static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void); |
53 | static int ipmi_init_msghandler(void); | 54 | static int ipmi_init_msghandler(void); |
@@ -116,7 +117,7 @@ struct seq_table | |||
116 | do { \ | 117 | do { \ |
117 | seq = ((msgid >> 26) & 0x3f); \ | 118 | seq = ((msgid >> 26) & 0x3f); \ |
118 | seqid = (msgid & 0x3fffff); \ | 119 | seqid = (msgid & 0x3fffff); \ |
119 | } while(0) | 120 | } while (0) |
120 | 121 | ||
121 | #define NEXT_SEQID(seqid) (((seqid) + 1) & 0x3fffff) | 122 | #define NEXT_SEQID(seqid) (((seqid) + 1) & 0x3fffff) |
122 | 123 | ||
@@ -124,6 +125,14 @@ struct ipmi_channel | |||
124 | { | 125 | { |
125 | unsigned char medium; | 126 | unsigned char medium; |
126 | unsigned char protocol; | 127 | unsigned char protocol; |
128 | |||
129 | /* My slave address. This is initialized to IPMI_BMC_SLAVE_ADDR, | ||
130 | but may be changed by the user. */ | ||
131 | unsigned char address; | ||
132 | |||
133 | /* My LUN. This should generally stay the SMS LUN, but just in | ||
134 | case... */ | ||
135 | unsigned char lun; | ||
127 | }; | 136 | }; |
128 | 137 | ||
129 | #ifdef CONFIG_PROC_FS | 138 | #ifdef CONFIG_PROC_FS |
@@ -135,7 +144,7 @@ struct ipmi_proc_entry | |||
135 | #endif | 144 | #endif |
136 | 145 | ||
137 | #define IPMI_IPMB_NUM_SEQ 64 | 146 | #define IPMI_IPMB_NUM_SEQ 64 |
138 | #define IPMI_MAX_CHANNELS 8 | 147 | #define IPMI_MAX_CHANNELS 16 |
139 | struct ipmi_smi | 148 | struct ipmi_smi |
140 | { | 149 | { |
141 | /* What interface number are we? */ | 150 | /* What interface number are we? */ |
@@ -193,20 +202,6 @@ struct ipmi_smi | |||
193 | struct list_head waiting_events; | 202 | struct list_head waiting_events; |
194 | unsigned int waiting_events_count; /* How many events in queue? */ | 203 | unsigned int waiting_events_count; /* How many events in queue? */ |
195 | 204 | ||
196 | /* This will be non-null if someone registers to receive all | ||
197 | IPMI commands (this is for interface emulation). There | ||
198 | may not be any things in the cmd_rcvrs list above when | ||
199 | this is registered. */ | ||
200 | ipmi_user_t all_cmd_rcvr; | ||
201 | |||
202 | /* My slave address. This is initialized to IPMI_BMC_SLAVE_ADDR, | ||
203 | but may be changed by the user. */ | ||
204 | unsigned char my_address; | ||
205 | |||
206 | /* My LUN. This should generally stay the SMS LUN, but just in | ||
207 | case... */ | ||
208 | unsigned char my_lun; | ||
209 | |||
210 | /* The event receiver for my BMC, only really used at panic | 205 | /* The event receiver for my BMC, only really used at panic |
211 | shutdown as a place to store this. */ | 206 | shutdown as a place to store this. */ |
212 | unsigned char event_receiver; | 207 | unsigned char event_receiver; |
@@ -218,7 +213,7 @@ struct ipmi_smi | |||
218 | interface comes in with a NULL user, call this routine with | 213 | interface comes in with a NULL user, call this routine with |
219 | it. Note that the message will still be freed by the | 214 | it. Note that the message will still be freed by the |
220 | caller. This only works on the system interface. */ | 215 | caller. This only works on the system interface. */ |
221 | void (*null_user_handler)(ipmi_smi_t intf, struct ipmi_smi_msg *msg); | 216 | void (*null_user_handler)(ipmi_smi_t intf, struct ipmi_recv_msg *msg); |
222 | 217 | ||
223 | /* When we are scanning the channels for an SMI, this will | 218 | /* When we are scanning the channels for an SMI, this will |
224 | tell which channel we are scanning. */ | 219 | tell which channel we are scanning. */ |
@@ -325,7 +320,7 @@ int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher) | |||
325 | down_read(&interfaces_sem); | 320 | down_read(&interfaces_sem); |
326 | down_write(&smi_watchers_sem); | 321 | down_write(&smi_watchers_sem); |
327 | list_add(&(watcher->link), &smi_watchers); | 322 | list_add(&(watcher->link), &smi_watchers); |
328 | for (i=0; i<MAX_IPMI_INTERFACES; i++) { | 323 | for (i = 0; i < MAX_IPMI_INTERFACES; i++) { |
329 | if (ipmi_interfaces[i] != NULL) { | 324 | if (ipmi_interfaces[i] != NULL) { |
330 | watcher->new_smi(i); | 325 | watcher->new_smi(i); |
331 | } | 326 | } |
@@ -458,7 +453,27 @@ unsigned int ipmi_addr_length(int addr_type) | |||
458 | 453 | ||
459 | static void deliver_response(struct ipmi_recv_msg *msg) | 454 | static void deliver_response(struct ipmi_recv_msg *msg) |
460 | { | 455 | { |
461 | msg->user->handler->ipmi_recv_hndl(msg, msg->user->handler_data); | 456 | if (! msg->user) { |
457 | ipmi_smi_t intf = msg->user_msg_data; | ||
458 | unsigned long flags; | ||
459 | |||
460 | /* Special handling for NULL users. */ | ||
461 | if (intf->null_user_handler) { | ||
462 | intf->null_user_handler(intf, msg); | ||
463 | spin_lock_irqsave(&intf->counter_lock, flags); | ||
464 | intf->handled_local_responses++; | ||
465 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
466 | } else { | ||
467 | /* No handler, so give up. */ | ||
468 | spin_lock_irqsave(&intf->counter_lock, flags); | ||
469 | intf->unhandled_local_responses++; | ||
470 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
471 | } | ||
472 | ipmi_free_recv_msg(msg); | ||
473 | } else { | ||
474 | msg->user->handler->ipmi_recv_hndl(msg, | ||
475 | msg->user->handler_data); | ||
476 | } | ||
462 | } | 477 | } |
463 | 478 | ||
464 | /* Find the next sequence number not being used and add the given | 479 | /* Find the next sequence number not being used and add the given |
@@ -475,9 +490,9 @@ static int intf_next_seq(ipmi_smi_t intf, | |||
475 | int rv = 0; | 490 | int rv = 0; |
476 | unsigned int i; | 491 | unsigned int i; |
477 | 492 | ||
478 | for (i=intf->curr_seq; | 493 | for (i = intf->curr_seq; |
479 | (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq; | 494 | (i+1)%IPMI_IPMB_NUM_SEQ != intf->curr_seq; |
480 | i=(i+1)%IPMI_IPMB_NUM_SEQ) | 495 | i = (i+1)%IPMI_IPMB_NUM_SEQ) |
481 | { | 496 | { |
482 | if (! intf->seq_table[i].inuse) | 497 | if (! intf->seq_table[i].inuse) |
483 | break; | 498 | break; |
@@ -712,7 +727,7 @@ static int ipmi_destroy_user_nolock(ipmi_user_t user) | |||
712 | 727 | ||
713 | /* Remove the user from the interfaces sequence table. */ | 728 | /* Remove the user from the interfaces sequence table. */ |
714 | spin_lock_irqsave(&(user->intf->seq_lock), flags); | 729 | spin_lock_irqsave(&(user->intf->seq_lock), flags); |
715 | for (i=0; i<IPMI_IPMB_NUM_SEQ; i++) { | 730 | for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) { |
716 | if (user->intf->seq_table[i].inuse | 731 | if (user->intf->seq_table[i].inuse |
717 | && (user->intf->seq_table[i].recv_msg->user == user)) | 732 | && (user->intf->seq_table[i].recv_msg->user == user)) |
718 | { | 733 | { |
@@ -766,26 +781,44 @@ void ipmi_get_version(ipmi_user_t user, | |||
766 | *minor = user->intf->version_minor; | 781 | *minor = user->intf->version_minor; |
767 | } | 782 | } |
768 | 783 | ||
769 | void ipmi_set_my_address(ipmi_user_t user, | 784 | int ipmi_set_my_address(ipmi_user_t user, |
770 | unsigned char address) | 785 | unsigned int channel, |
786 | unsigned char address) | ||
771 | { | 787 | { |
772 | user->intf->my_address = address; | 788 | if (channel >= IPMI_MAX_CHANNELS) |
789 | return -EINVAL; | ||
790 | user->intf->channels[channel].address = address; | ||
791 | return 0; | ||
773 | } | 792 | } |
774 | 793 | ||
775 | unsigned char ipmi_get_my_address(ipmi_user_t user) | 794 | int ipmi_get_my_address(ipmi_user_t user, |
795 | unsigned int channel, | ||
796 | unsigned char *address) | ||
776 | { | 797 | { |
777 | return user->intf->my_address; | 798 | if (channel >= IPMI_MAX_CHANNELS) |
799 | return -EINVAL; | ||
800 | *address = user->intf->channels[channel].address; | ||
801 | return 0; | ||
778 | } | 802 | } |
779 | 803 | ||
780 | void ipmi_set_my_LUN(ipmi_user_t user, | 804 | int ipmi_set_my_LUN(ipmi_user_t user, |
781 | unsigned char LUN) | 805 | unsigned int channel, |
806 | unsigned char LUN) | ||
782 | { | 807 | { |
783 | user->intf->my_lun = LUN & 0x3; | 808 | if (channel >= IPMI_MAX_CHANNELS) |
809 | return -EINVAL; | ||
810 | user->intf->channels[channel].lun = LUN & 0x3; | ||
811 | return 0; | ||
784 | } | 812 | } |
785 | 813 | ||
786 | unsigned char ipmi_get_my_LUN(ipmi_user_t user) | 814 | int ipmi_get_my_LUN(ipmi_user_t user, |
815 | unsigned int channel, | ||
816 | unsigned char *address) | ||
787 | { | 817 | { |
788 | return user->intf->my_lun; | 818 | if (channel >= IPMI_MAX_CHANNELS) |
819 | return -EINVAL; | ||
820 | *address = user->intf->channels[channel].lun; | ||
821 | return 0; | ||
789 | } | 822 | } |
790 | 823 | ||
791 | int ipmi_set_gets_events(ipmi_user_t user, int val) | 824 | int ipmi_set_gets_events(ipmi_user_t user, int val) |
@@ -828,11 +861,6 @@ int ipmi_register_for_cmd(ipmi_user_t user, | |||
828 | 861 | ||
829 | read_lock(&(user->intf->users_lock)); | 862 | read_lock(&(user->intf->users_lock)); |
830 | write_lock_irqsave(&(user->intf->cmd_rcvr_lock), flags); | 863 | write_lock_irqsave(&(user->intf->cmd_rcvr_lock), flags); |
831 | if (user->intf->all_cmd_rcvr != NULL) { | ||
832 | rv = -EBUSY; | ||
833 | goto out_unlock; | ||
834 | } | ||
835 | |||
836 | /* Make sure the command/netfn is not already registered. */ | 864 | /* Make sure the command/netfn is not already registered. */ |
837 | list_for_each_entry(cmp, &(user->intf->cmd_rcvrs), link) { | 865 | list_for_each_entry(cmp, &(user->intf->cmd_rcvrs), link) { |
838 | if ((cmp->netfn == netfn) && (cmp->cmd == cmd)) { | 866 | if ((cmp->netfn == netfn) && (cmp->cmd == cmd)) { |
@@ -847,7 +875,7 @@ int ipmi_register_for_cmd(ipmi_user_t user, | |||
847 | rcvr->user = user; | 875 | rcvr->user = user; |
848 | list_add_tail(&(rcvr->link), &(user->intf->cmd_rcvrs)); | 876 | list_add_tail(&(rcvr->link), &(user->intf->cmd_rcvrs)); |
849 | } | 877 | } |
850 | out_unlock: | 878 | |
851 | write_unlock_irqrestore(&(user->intf->cmd_rcvr_lock), flags); | 879 | write_unlock_irqrestore(&(user->intf->cmd_rcvr_lock), flags); |
852 | read_unlock(&(user->intf->users_lock)); | 880 | read_unlock(&(user->intf->users_lock)); |
853 | 881 | ||
@@ -1213,7 +1241,7 @@ static inline int i_ipmi_request(ipmi_user_t user, | |||
1213 | unsigned char ipmb_seq; | 1241 | unsigned char ipmb_seq; |
1214 | long seqid; | 1242 | long seqid; |
1215 | 1243 | ||
1216 | if (addr->channel > IPMI_NUM_CHANNELS) { | 1244 | if (addr->channel >= IPMI_NUM_CHANNELS) { |
1217 | spin_lock_irqsave(&intf->counter_lock, flags); | 1245 | spin_lock_irqsave(&intf->counter_lock, flags); |
1218 | intf->sent_invalid_commands++; | 1246 | intf->sent_invalid_commands++; |
1219 | spin_unlock_irqrestore(&intf->counter_lock, flags); | 1247 | spin_unlock_irqrestore(&intf->counter_lock, flags); |
@@ -1331,7 +1359,7 @@ static inline int i_ipmi_request(ipmi_user_t user, | |||
1331 | #ifdef DEBUG_MSGING | 1359 | #ifdef DEBUG_MSGING |
1332 | { | 1360 | { |
1333 | int m; | 1361 | int m; |
1334 | for (m=0; m<smi_msg->data_size; m++) | 1362 | for (m = 0; m < smi_msg->data_size; m++) |
1335 | printk(" %2.2x", smi_msg->data[m]); | 1363 | printk(" %2.2x", smi_msg->data[m]); |
1336 | printk("\n"); | 1364 | printk("\n"); |
1337 | } | 1365 | } |
@@ -1346,6 +1374,18 @@ static inline int i_ipmi_request(ipmi_user_t user, | |||
1346 | return rv; | 1374 | return rv; |
1347 | } | 1375 | } |
1348 | 1376 | ||
1377 | static int check_addr(ipmi_smi_t intf, | ||
1378 | struct ipmi_addr *addr, | ||
1379 | unsigned char *saddr, | ||
1380 | unsigned char *lun) | ||
1381 | { | ||
1382 | if (addr->channel >= IPMI_MAX_CHANNELS) | ||
1383 | return -EINVAL; | ||
1384 | *lun = intf->channels[addr->channel].lun; | ||
1385 | *saddr = intf->channels[addr->channel].address; | ||
1386 | return 0; | ||
1387 | } | ||
1388 | |||
1349 | int ipmi_request_settime(ipmi_user_t user, | 1389 | int ipmi_request_settime(ipmi_user_t user, |
1350 | struct ipmi_addr *addr, | 1390 | struct ipmi_addr *addr, |
1351 | long msgid, | 1391 | long msgid, |
@@ -1355,6 +1395,14 @@ int ipmi_request_settime(ipmi_user_t user, | |||
1355 | int retries, | 1395 | int retries, |
1356 | unsigned int retry_time_ms) | 1396 | unsigned int retry_time_ms) |
1357 | { | 1397 | { |
1398 | unsigned char saddr, lun; | ||
1399 | int rv; | ||
1400 | |||
1401 | if (! user) | ||
1402 | return -EINVAL; | ||
1403 | rv = check_addr(user->intf, addr, &saddr, &lun); | ||
1404 | if (rv) | ||
1405 | return rv; | ||
1358 | return i_ipmi_request(user, | 1406 | return i_ipmi_request(user, |
1359 | user->intf, | 1407 | user->intf, |
1360 | addr, | 1408 | addr, |
@@ -1363,8 +1411,8 @@ int ipmi_request_settime(ipmi_user_t user, | |||
1363 | user_msg_data, | 1411 | user_msg_data, |
1364 | NULL, NULL, | 1412 | NULL, NULL, |
1365 | priority, | 1413 | priority, |
1366 | user->intf->my_address, | 1414 | saddr, |
1367 | user->intf->my_lun, | 1415 | lun, |
1368 | retries, | 1416 | retries, |
1369 | retry_time_ms); | 1417 | retry_time_ms); |
1370 | } | 1418 | } |
@@ -1378,6 +1426,14 @@ int ipmi_request_supply_msgs(ipmi_user_t user, | |||
1378 | struct ipmi_recv_msg *supplied_recv, | 1426 | struct ipmi_recv_msg *supplied_recv, |
1379 | int priority) | 1427 | int priority) |
1380 | { | 1428 | { |
1429 | unsigned char saddr, lun; | ||
1430 | int rv; | ||
1431 | |||
1432 | if (! user) | ||
1433 | return -EINVAL; | ||
1434 | rv = check_addr(user->intf, addr, &saddr, &lun); | ||
1435 | if (rv) | ||
1436 | return rv; | ||
1381 | return i_ipmi_request(user, | 1437 | return i_ipmi_request(user, |
1382 | user->intf, | 1438 | user->intf, |
1383 | addr, | 1439 | addr, |
@@ -1387,8 +1443,8 @@ int ipmi_request_supply_msgs(ipmi_user_t user, | |||
1387 | supplied_smi, | 1443 | supplied_smi, |
1388 | supplied_recv, | 1444 | supplied_recv, |
1389 | priority, | 1445 | priority, |
1390 | user->intf->my_address, | 1446 | saddr, |
1391 | user->intf->my_lun, | 1447 | lun, |
1392 | -1, 0); | 1448 | -1, 0); |
1393 | } | 1449 | } |
1394 | 1450 | ||
@@ -1397,8 +1453,15 @@ static int ipmb_file_read_proc(char *page, char **start, off_t off, | |||
1397 | { | 1453 | { |
1398 | char *out = (char *) page; | 1454 | char *out = (char *) page; |
1399 | ipmi_smi_t intf = data; | 1455 | ipmi_smi_t intf = data; |
1456 | int i; | ||
1457 | int rv= 0; | ||
1400 | 1458 | ||
1401 | return sprintf(out, "%x\n", intf->my_address); | 1459 | for (i = 0; i < IPMI_MAX_CHANNELS; i++) |
1460 | rv += sprintf(out+rv, "%x ", intf->channels[i].address); | ||
1461 | out[rv-1] = '\n'; /* Replace the final space with a newline */ | ||
1462 | out[rv] = '\0'; | ||
1463 | rv++; | ||
1464 | return rv; | ||
1402 | } | 1465 | } |
1403 | 1466 | ||
1404 | static int version_file_read_proc(char *page, char **start, off_t off, | 1467 | static int version_file_read_proc(char *page, char **start, off_t off, |
@@ -1588,29 +1651,30 @@ send_channel_info_cmd(ipmi_smi_t intf, int chan) | |||
1588 | (struct ipmi_addr *) &si, | 1651 | (struct ipmi_addr *) &si, |
1589 | 0, | 1652 | 0, |
1590 | &msg, | 1653 | &msg, |
1591 | NULL, | 1654 | intf, |
1592 | NULL, | 1655 | NULL, |
1593 | NULL, | 1656 | NULL, |
1594 | 0, | 1657 | 0, |
1595 | intf->my_address, | 1658 | intf->channels[0].address, |
1596 | intf->my_lun, | 1659 | intf->channels[0].lun, |
1597 | -1, 0); | 1660 | -1, 0); |
1598 | } | 1661 | } |
1599 | 1662 | ||
1600 | static void | 1663 | static void |
1601 | channel_handler(ipmi_smi_t intf, struct ipmi_smi_msg *msg) | 1664 | channel_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg) |
1602 | { | 1665 | { |
1603 | int rv = 0; | 1666 | int rv = 0; |
1604 | int chan; | 1667 | int chan; |
1605 | 1668 | ||
1606 | if ((msg->rsp[0] == (IPMI_NETFN_APP_RESPONSE << 2)) | 1669 | if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) |
1607 | && (msg->rsp[1] == IPMI_GET_CHANNEL_INFO_CMD)) | 1670 | && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE) |
1671 | && (msg->msg.cmd == IPMI_GET_CHANNEL_INFO_CMD)) | ||
1608 | { | 1672 | { |
1609 | /* It's the one we want */ | 1673 | /* It's the one we want */ |
1610 | if (msg->rsp[2] != 0) { | 1674 | if (msg->msg.data[0] != 0) { |
1611 | /* Got an error from the channel, just go on. */ | 1675 | /* Got an error from the channel, just go on. */ |
1612 | 1676 | ||
1613 | if (msg->rsp[2] == IPMI_INVALID_COMMAND_ERR) { | 1677 | if (msg->msg.data[0] == IPMI_INVALID_COMMAND_ERR) { |
1614 | /* If the MC does not support this | 1678 | /* If the MC does not support this |
1615 | command, that is legal. We just | 1679 | command, that is legal. We just |
1616 | assume it has one IPMB at channel | 1680 | assume it has one IPMB at channel |
@@ -1627,13 +1691,13 @@ channel_handler(ipmi_smi_t intf, struct ipmi_smi_msg *msg) | |||
1627 | } | 1691 | } |
1628 | goto next_channel; | 1692 | goto next_channel; |
1629 | } | 1693 | } |
1630 | if (msg->rsp_size < 6) { | 1694 | if (msg->msg.data_len < 4) { |
1631 | /* Message not big enough, just go on. */ | 1695 | /* Message not big enough, just go on. */ |
1632 | goto next_channel; | 1696 | goto next_channel; |
1633 | } | 1697 | } |
1634 | chan = intf->curr_channel; | 1698 | chan = intf->curr_channel; |
1635 | intf->channels[chan].medium = msg->rsp[4] & 0x7f; | 1699 | intf->channels[chan].medium = msg->msg.data[2] & 0x7f; |
1636 | intf->channels[chan].protocol = msg->rsp[5] & 0x1f; | 1700 | intf->channels[chan].protocol = msg->msg.data[3] & 0x1f; |
1637 | 1701 | ||
1638 | next_channel: | 1702 | next_channel: |
1639 | intf->curr_channel++; | 1703 | intf->curr_channel++; |
@@ -1691,22 +1755,24 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, | |||
1691 | rv = -ENOMEM; | 1755 | rv = -ENOMEM; |
1692 | 1756 | ||
1693 | down_write(&interfaces_sem); | 1757 | down_write(&interfaces_sem); |
1694 | for (i=0; i<MAX_IPMI_INTERFACES; i++) { | 1758 | for (i = 0; i < MAX_IPMI_INTERFACES; i++) { |
1695 | if (ipmi_interfaces[i] == NULL) { | 1759 | if (ipmi_interfaces[i] == NULL) { |
1696 | new_intf->intf_num = i; | 1760 | new_intf->intf_num = i; |
1697 | new_intf->version_major = version_major; | 1761 | new_intf->version_major = version_major; |
1698 | new_intf->version_minor = version_minor; | 1762 | new_intf->version_minor = version_minor; |
1699 | if (slave_addr == 0) | 1763 | for (j = 0; j < IPMI_MAX_CHANNELS; j++) { |
1700 | new_intf->my_address = IPMI_BMC_SLAVE_ADDR; | 1764 | new_intf->channels[j].address |
1701 | else | 1765 | = IPMI_BMC_SLAVE_ADDR; |
1702 | new_intf->my_address = slave_addr; | 1766 | new_intf->channels[j].lun = 2; |
1703 | new_intf->my_lun = 2; /* the SMS LUN. */ | 1767 | } |
1768 | if (slave_addr != 0) | ||
1769 | new_intf->channels[0].address = slave_addr; | ||
1704 | rwlock_init(&(new_intf->users_lock)); | 1770 | rwlock_init(&(new_intf->users_lock)); |
1705 | INIT_LIST_HEAD(&(new_intf->users)); | 1771 | INIT_LIST_HEAD(&(new_intf->users)); |
1706 | new_intf->handlers = handlers; | 1772 | new_intf->handlers = handlers; |
1707 | new_intf->send_info = send_info; | 1773 | new_intf->send_info = send_info; |
1708 | spin_lock_init(&(new_intf->seq_lock)); | 1774 | spin_lock_init(&(new_intf->seq_lock)); |
1709 | for (j=0; j<IPMI_IPMB_NUM_SEQ; j++) { | 1775 | for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) { |
1710 | new_intf->seq_table[j].inuse = 0; | 1776 | new_intf->seq_table[j].inuse = 0; |
1711 | new_intf->seq_table[j].seqid = 0; | 1777 | new_intf->seq_table[j].seqid = 0; |
1712 | } | 1778 | } |
@@ -1722,7 +1788,6 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers, | |||
1722 | rwlock_init(&(new_intf->cmd_rcvr_lock)); | 1788 | rwlock_init(&(new_intf->cmd_rcvr_lock)); |
1723 | init_waitqueue_head(&new_intf->waitq); | 1789 | init_waitqueue_head(&new_intf->waitq); |
1724 | INIT_LIST_HEAD(&(new_intf->cmd_rcvrs)); | 1790 | INIT_LIST_HEAD(&(new_intf->cmd_rcvrs)); |
1725 | new_intf->all_cmd_rcvr = NULL; | ||
1726 | 1791 | ||
1727 | spin_lock_init(&(new_intf->counter_lock)); | 1792 | spin_lock_init(&(new_intf->counter_lock)); |
1728 | 1793 | ||
@@ -1814,7 +1879,7 @@ static void clean_up_interface_data(ipmi_smi_t intf) | |||
1814 | free_recv_msg_list(&(intf->waiting_events)); | 1879 | free_recv_msg_list(&(intf->waiting_events)); |
1815 | free_cmd_rcvr_list(&(intf->cmd_rcvrs)); | 1880 | free_cmd_rcvr_list(&(intf->cmd_rcvrs)); |
1816 | 1881 | ||
1817 | for (i=0; i<IPMI_IPMB_NUM_SEQ; i++) { | 1882 | for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) { |
1818 | if ((intf->seq_table[i].inuse) | 1883 | if ((intf->seq_table[i].inuse) |
1819 | && (intf->seq_table[i].recv_msg)) | 1884 | && (intf->seq_table[i].recv_msg)) |
1820 | { | 1885 | { |
@@ -1833,7 +1898,7 @@ int ipmi_unregister_smi(ipmi_smi_t intf) | |||
1833 | down_write(&interfaces_sem); | 1898 | down_write(&interfaces_sem); |
1834 | if (list_empty(&(intf->users))) | 1899 | if (list_empty(&(intf->users))) |
1835 | { | 1900 | { |
1836 | for (i=0; i<MAX_IPMI_INTERFACES; i++) { | 1901 | for (i = 0; i < MAX_IPMI_INTERFACES; i++) { |
1837 | if (ipmi_interfaces[i] == intf) { | 1902 | if (ipmi_interfaces[i] == intf) { |
1838 | remove_proc_entries(intf); | 1903 | remove_proc_entries(intf); |
1839 | spin_lock_irqsave(&interfaces_lock, flags); | 1904 | spin_lock_irqsave(&interfaces_lock, flags); |
@@ -1960,15 +2025,11 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, | |||
1960 | 2025 | ||
1961 | read_lock(&(intf->cmd_rcvr_lock)); | 2026 | read_lock(&(intf->cmd_rcvr_lock)); |
1962 | 2027 | ||
1963 | if (intf->all_cmd_rcvr) { | 2028 | /* Find the command/netfn. */ |
1964 | user = intf->all_cmd_rcvr; | 2029 | list_for_each_entry(rcvr, &(intf->cmd_rcvrs), link) { |
1965 | } else { | 2030 | if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)) { |
1966 | /* Find the command/netfn. */ | 2031 | user = rcvr->user; |
1967 | list_for_each_entry(rcvr, &(intf->cmd_rcvrs), link) { | 2032 | break; |
1968 | if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)) { | ||
1969 | user = rcvr->user; | ||
1970 | break; | ||
1971 | } | ||
1972 | } | 2033 | } |
1973 | } | 2034 | } |
1974 | read_unlock(&(intf->cmd_rcvr_lock)); | 2035 | read_unlock(&(intf->cmd_rcvr_lock)); |
@@ -1985,7 +2046,7 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, | |||
1985 | msg->data[3] = msg->rsp[6]; | 2046 | msg->data[3] = msg->rsp[6]; |
1986 | msg->data[4] = ((netfn + 1) << 2) | (msg->rsp[7] & 0x3); | 2047 | msg->data[4] = ((netfn + 1) << 2) | (msg->rsp[7] & 0x3); |
1987 | msg->data[5] = ipmb_checksum(&(msg->data[3]), 2); | 2048 | msg->data[5] = ipmb_checksum(&(msg->data[3]), 2); |
1988 | msg->data[6] = intf->my_address; | 2049 | msg->data[6] = intf->channels[msg->rsp[3] & 0xf].address; |
1989 | /* rqseq/lun */ | 2050 | /* rqseq/lun */ |
1990 | msg->data[7] = (msg->rsp[7] & 0xfc) | (msg->rsp[4] & 0x3); | 2051 | msg->data[7] = (msg->rsp[7] & 0xfc) | (msg->rsp[4] & 0x3); |
1991 | msg->data[8] = msg->rsp[8]; /* cmd */ | 2052 | msg->data[8] = msg->rsp[8]; /* cmd */ |
@@ -1997,7 +2058,7 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf, | |||
1997 | { | 2058 | { |
1998 | int m; | 2059 | int m; |
1999 | printk("Invalid command:"); | 2060 | printk("Invalid command:"); |
2000 | for (m=0; m<msg->data_size; m++) | 2061 | for (m = 0; m < msg->data_size; m++) |
2001 | printk(" %2.2x", msg->data[m]); | 2062 | printk(" %2.2x", msg->data[m]); |
2002 | printk("\n"); | 2063 | printk("\n"); |
2003 | } | 2064 | } |
@@ -2145,15 +2206,11 @@ static int handle_lan_get_msg_cmd(ipmi_smi_t intf, | |||
2145 | 2206 | ||
2146 | read_lock(&(intf->cmd_rcvr_lock)); | 2207 | read_lock(&(intf->cmd_rcvr_lock)); |
2147 | 2208 | ||
2148 | if (intf->all_cmd_rcvr) { | 2209 | /* Find the command/netfn. */ |
2149 | user = intf->all_cmd_rcvr; | 2210 | list_for_each_entry(rcvr, &(intf->cmd_rcvrs), link) { |
2150 | } else { | 2211 | if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)) { |
2151 | /* Find the command/netfn. */ | 2212 | user = rcvr->user; |
2152 | list_for_each_entry(rcvr, &(intf->cmd_rcvrs), link) { | 2213 | break; |
2153 | if ((rcvr->netfn == netfn) && (rcvr->cmd == cmd)) { | ||
2154 | user = rcvr->user; | ||
2155 | break; | ||
2156 | } | ||
2157 | } | 2214 | } |
2158 | } | 2215 | } |
2159 | read_unlock(&(intf->cmd_rcvr_lock)); | 2216 | read_unlock(&(intf->cmd_rcvr_lock)); |
@@ -2330,6 +2387,14 @@ static int handle_bmc_rsp(ipmi_smi_t intf, | |||
2330 | unsigned long flags; | 2387 | unsigned long flags; |
2331 | 2388 | ||
2332 | recv_msg = (struct ipmi_recv_msg *) msg->user_data; | 2389 | recv_msg = (struct ipmi_recv_msg *) msg->user_data; |
2390 | if (recv_msg == NULL) | ||
2391 | { | ||
2392 | printk(KERN_WARNING"IPMI message received with no owner. This\n" | ||
2393 | "could be because of a malformed message, or\n" | ||
2394 | "because of a hardware error. Contact your\n" | ||
2395 | "hardware vender for assistance\n"); | ||
2396 | return 0; | ||
2397 | } | ||
2333 | 2398 | ||
2334 | /* Make sure the user still exists. */ | 2399 | /* Make sure the user still exists. */ |
2335 | list_for_each_entry(user, &(intf->users), link) { | 2400 | list_for_each_entry(user, &(intf->users), link) { |
@@ -2340,19 +2405,11 @@ static int handle_bmc_rsp(ipmi_smi_t intf, | |||
2340 | } | 2405 | } |
2341 | } | 2406 | } |
2342 | 2407 | ||
2343 | if (!found) { | 2408 | if ((! found) && recv_msg->user) { |
2344 | /* Special handling for NULL users. */ | 2409 | /* The user for the message went away, so give up. */ |
2345 | if (!recv_msg->user && intf->null_user_handler){ | 2410 | spin_lock_irqsave(&intf->counter_lock, flags); |
2346 | intf->null_user_handler(intf, msg); | 2411 | intf->unhandled_local_responses++; |
2347 | spin_lock_irqsave(&intf->counter_lock, flags); | 2412 | spin_unlock_irqrestore(&intf->counter_lock, flags); |
2348 | intf->handled_local_responses++; | ||
2349 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
2350 | }else{ | ||
2351 | /* The user for the message went away, so give up. */ | ||
2352 | spin_lock_irqsave(&intf->counter_lock, flags); | ||
2353 | intf->unhandled_local_responses++; | ||
2354 | spin_unlock_irqrestore(&intf->counter_lock, flags); | ||
2355 | } | ||
2356 | ipmi_free_recv_msg(recv_msg); | 2413 | ipmi_free_recv_msg(recv_msg); |
2357 | } else { | 2414 | } else { |
2358 | struct ipmi_system_interface_addr *smi_addr; | 2415 | struct ipmi_system_interface_addr *smi_addr; |
@@ -2392,7 +2449,7 @@ static int handle_new_recv_msg(ipmi_smi_t intf, | |||
2392 | #ifdef DEBUG_MSGING | 2449 | #ifdef DEBUG_MSGING |
2393 | int m; | 2450 | int m; |
2394 | printk("Recv:"); | 2451 | printk("Recv:"); |
2395 | for (m=0; m<msg->rsp_size; m++) | 2452 | for (m = 0; m < msg->rsp_size; m++) |
2396 | printk(" %2.2x", msg->rsp[m]); | 2453 | printk(" %2.2x", msg->rsp[m]); |
2397 | printk("\n"); | 2454 | printk("\n"); |
2398 | #endif | 2455 | #endif |
@@ -2626,7 +2683,7 @@ smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg, | |||
2626 | { | 2683 | { |
2627 | int m; | 2684 | int m; |
2628 | printk("Resend: "); | 2685 | printk("Resend: "); |
2629 | for (m=0; m<smi_msg->data_size; m++) | 2686 | for (m = 0; m < smi_msg->data_size; m++) |
2630 | printk(" %2.2x", smi_msg->data[m]); | 2687 | printk(" %2.2x", smi_msg->data[m]); |
2631 | printk("\n"); | 2688 | printk("\n"); |
2632 | } | 2689 | } |
@@ -2647,7 +2704,7 @@ ipmi_timeout_handler(long timeout_period) | |||
2647 | INIT_LIST_HEAD(&timeouts); | 2704 | INIT_LIST_HEAD(&timeouts); |
2648 | 2705 | ||
2649 | spin_lock(&interfaces_lock); | 2706 | spin_lock(&interfaces_lock); |
2650 | for (i=0; i<MAX_IPMI_INTERFACES; i++) { | 2707 | for (i = 0; i < MAX_IPMI_INTERFACES; i++) { |
2651 | intf = ipmi_interfaces[i]; | 2708 | intf = ipmi_interfaces[i]; |
2652 | if (intf == NULL) | 2709 | if (intf == NULL) |
2653 | continue; | 2710 | continue; |
@@ -2672,7 +2729,7 @@ ipmi_timeout_handler(long timeout_period) | |||
2672 | have timed out, putting them in the timeouts | 2729 | have timed out, putting them in the timeouts |
2673 | list. */ | 2730 | list. */ |
2674 | spin_lock_irqsave(&(intf->seq_lock), flags); | 2731 | spin_lock_irqsave(&(intf->seq_lock), flags); |
2675 | for (j=0; j<IPMI_IPMB_NUM_SEQ; j++) { | 2732 | for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) { |
2676 | struct seq_table *ent = &(intf->seq_table[j]); | 2733 | struct seq_table *ent = &(intf->seq_table[j]); |
2677 | if (!ent->inuse) | 2734 | if (!ent->inuse) |
2678 | continue; | 2735 | continue; |
@@ -2712,7 +2769,7 @@ ipmi_timeout_handler(long timeout_period) | |||
2712 | spin_unlock(&intf->counter_lock); | 2769 | spin_unlock(&intf->counter_lock); |
2713 | smi_msg = smi_from_recv_msg(intf, | 2770 | smi_msg = smi_from_recv_msg(intf, |
2714 | ent->recv_msg, j, ent->seqid); | 2771 | ent->recv_msg, j, ent->seqid); |
2715 | if(!smi_msg) | 2772 | if (! smi_msg) |
2716 | continue; | 2773 | continue; |
2717 | 2774 | ||
2718 | spin_unlock_irqrestore(&(intf->seq_lock),flags); | 2775 | spin_unlock_irqrestore(&(intf->seq_lock),flags); |
@@ -2743,7 +2800,7 @@ static void ipmi_request_event(void) | |||
2743 | int i; | 2800 | int i; |
2744 | 2801 | ||
2745 | spin_lock(&interfaces_lock); | 2802 | spin_lock(&interfaces_lock); |
2746 | for (i=0; i<MAX_IPMI_INTERFACES; i++) { | 2803 | for (i = 0; i < MAX_IPMI_INTERFACES; i++) { |
2747 | intf = ipmi_interfaces[i]; | 2804 | intf = ipmi_interfaces[i]; |
2748 | if (intf == NULL) | 2805 | if (intf == NULL) |
2749 | continue; | 2806 | continue; |
@@ -2838,28 +2895,30 @@ static void dummy_recv_done_handler(struct ipmi_recv_msg *msg) | |||
2838 | } | 2895 | } |
2839 | 2896 | ||
2840 | #ifdef CONFIG_IPMI_PANIC_STRING | 2897 | #ifdef CONFIG_IPMI_PANIC_STRING |
2841 | static void event_receiver_fetcher(ipmi_smi_t intf, struct ipmi_smi_msg *msg) | 2898 | static void event_receiver_fetcher(ipmi_smi_t intf, struct ipmi_recv_msg *msg) |
2842 | { | 2899 | { |
2843 | if ((msg->rsp[0] == (IPMI_NETFN_SENSOR_EVENT_RESPONSE << 2)) | 2900 | if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) |
2844 | && (msg->rsp[1] == IPMI_GET_EVENT_RECEIVER_CMD) | 2901 | && (msg->msg.netfn == IPMI_NETFN_SENSOR_EVENT_RESPONSE) |
2845 | && (msg->rsp[2] == IPMI_CC_NO_ERROR)) | 2902 | && (msg->msg.cmd == IPMI_GET_EVENT_RECEIVER_CMD) |
2903 | && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) | ||
2846 | { | 2904 | { |
2847 | /* A get event receiver command, save it. */ | 2905 | /* A get event receiver command, save it. */ |
2848 | intf->event_receiver = msg->rsp[3]; | 2906 | intf->event_receiver = msg->msg.data[1]; |
2849 | intf->event_receiver_lun = msg->rsp[4] & 0x3; | 2907 | intf->event_receiver_lun = msg->msg.data[2] & 0x3; |
2850 | } | 2908 | } |
2851 | } | 2909 | } |
2852 | 2910 | ||
2853 | static void device_id_fetcher(ipmi_smi_t intf, struct ipmi_smi_msg *msg) | 2911 | static void device_id_fetcher(ipmi_smi_t intf, struct ipmi_recv_msg *msg) |
2854 | { | 2912 | { |
2855 | if ((msg->rsp[0] == (IPMI_NETFN_APP_RESPONSE << 2)) | 2913 | if ((msg->addr.addr_type == IPMI_SYSTEM_INTERFACE_ADDR_TYPE) |
2856 | && (msg->rsp[1] == IPMI_GET_DEVICE_ID_CMD) | 2914 | && (msg->msg.netfn == IPMI_NETFN_APP_RESPONSE) |
2857 | && (msg->rsp[2] == IPMI_CC_NO_ERROR)) | 2915 | && (msg->msg.cmd == IPMI_GET_DEVICE_ID_CMD) |
2916 | && (msg->msg.data[0] == IPMI_CC_NO_ERROR)) | ||
2858 | { | 2917 | { |
2859 | /* A get device id command, save if we are an event | 2918 | /* A get device id command, save if we are an event |
2860 | receiver or generator. */ | 2919 | receiver or generator. */ |
2861 | intf->local_sel_device = (msg->rsp[8] >> 2) & 1; | 2920 | intf->local_sel_device = (msg->msg.data[6] >> 2) & 1; |
2862 | intf->local_event_generator = (msg->rsp[8] >> 5) & 1; | 2921 | intf->local_event_generator = (msg->msg.data[6] >> 5) & 1; |
2863 | } | 2922 | } |
2864 | } | 2923 | } |
2865 | #endif | 2924 | #endif |
@@ -2903,7 +2962,7 @@ static void send_panic_events(char *str) | |||
2903 | recv_msg.done = dummy_recv_done_handler; | 2962 | recv_msg.done = dummy_recv_done_handler; |
2904 | 2963 | ||
2905 | /* For every registered interface, send the event. */ | 2964 | /* For every registered interface, send the event. */ |
2906 | for (i=0; i<MAX_IPMI_INTERFACES; i++) { | 2965 | for (i = 0; i < MAX_IPMI_INTERFACES; i++) { |
2907 | intf = ipmi_interfaces[i]; | 2966 | intf = ipmi_interfaces[i]; |
2908 | if (intf == NULL) | 2967 | if (intf == NULL) |
2909 | continue; | 2968 | continue; |
@@ -2915,12 +2974,12 @@ static void send_panic_events(char *str) | |||
2915 | &addr, | 2974 | &addr, |
2916 | 0, | 2975 | 0, |
2917 | &msg, | 2976 | &msg, |
2918 | NULL, | 2977 | intf, |
2919 | &smi_msg, | 2978 | &smi_msg, |
2920 | &recv_msg, | 2979 | &recv_msg, |
2921 | 0, | 2980 | 0, |
2922 | intf->my_address, | 2981 | intf->channels[0].address, |
2923 | intf->my_lun, | 2982 | intf->channels[0].lun, |
2924 | 0, 1); /* Don't retry, and don't wait. */ | 2983 | 0, 1); /* Don't retry, and don't wait. */ |
2925 | } | 2984 | } |
2926 | 2985 | ||
@@ -2930,7 +2989,7 @@ static void send_panic_events(char *str) | |||
2930 | if (!str) | 2989 | if (!str) |
2931 | return; | 2990 | return; |
2932 | 2991 | ||
2933 | for (i=0; i<MAX_IPMI_INTERFACES; i++) { | 2992 | for (i = 0; i < MAX_IPMI_INTERFACES; i++) { |
2934 | char *p = str; | 2993 | char *p = str; |
2935 | struct ipmi_ipmb_addr *ipmb; | 2994 | struct ipmi_ipmb_addr *ipmb; |
2936 | int j; | 2995 | int j; |
@@ -2961,12 +3020,12 @@ static void send_panic_events(char *str) | |||
2961 | &addr, | 3020 | &addr, |
2962 | 0, | 3021 | 0, |
2963 | &msg, | 3022 | &msg, |
2964 | NULL, | 3023 | intf, |
2965 | &smi_msg, | 3024 | &smi_msg, |
2966 | &recv_msg, | 3025 | &recv_msg, |
2967 | 0, | 3026 | 0, |
2968 | intf->my_address, | 3027 | intf->channels[0].address, |
2969 | intf->my_lun, | 3028 | intf->channels[0].lun, |
2970 | 0, 1); /* Don't retry, and don't wait. */ | 3029 | 0, 1); /* Don't retry, and don't wait. */ |
2971 | 3030 | ||
2972 | if (intf->local_event_generator) { | 3031 | if (intf->local_event_generator) { |
@@ -2981,12 +3040,12 @@ static void send_panic_events(char *str) | |||
2981 | &addr, | 3040 | &addr, |
2982 | 0, | 3041 | 0, |
2983 | &msg, | 3042 | &msg, |
2984 | NULL, | 3043 | intf, |
2985 | &smi_msg, | 3044 | &smi_msg, |
2986 | &recv_msg, | 3045 | &recv_msg, |
2987 | 0, | 3046 | 0, |
2988 | intf->my_address, | 3047 | intf->channels[0].address, |
2989 | intf->my_lun, | 3048 | intf->channels[0].lun, |
2990 | 0, 1); /* no retry, and no wait. */ | 3049 | 0, 1); /* no retry, and no wait. */ |
2991 | } | 3050 | } |
2992 | intf->null_user_handler = NULL; | 3051 | intf->null_user_handler = NULL; |
@@ -2996,7 +3055,7 @@ static void send_panic_events(char *str) | |||
2996 | be zero, and it must not be my address. */ | 3055 | be zero, and it must not be my address. */ |
2997 | if (((intf->event_receiver & 1) == 0) | 3056 | if (((intf->event_receiver & 1) == 0) |
2998 | && (intf->event_receiver != 0) | 3057 | && (intf->event_receiver != 0) |
2999 | && (intf->event_receiver != intf->my_address)) | 3058 | && (intf->event_receiver != intf->channels[0].address)) |
3000 | { | 3059 | { |
3001 | /* The event receiver is valid, send an IPMB | 3060 | /* The event receiver is valid, send an IPMB |
3002 | message. */ | 3061 | message. */ |
@@ -3031,7 +3090,7 @@ static void send_panic_events(char *str) | |||
3031 | data[0] = 0; | 3090 | data[0] = 0; |
3032 | data[1] = 0; | 3091 | data[1] = 0; |
3033 | data[2] = 0xf0; /* OEM event without timestamp. */ | 3092 | data[2] = 0xf0; /* OEM event without timestamp. */ |
3034 | data[3] = intf->my_address; | 3093 | data[3] = intf->channels[0].address; |
3035 | data[4] = j++; /* sequence # */ | 3094 | data[4] = j++; /* sequence # */ |
3036 | /* Always give 11 bytes, so strncpy will fill | 3095 | /* Always give 11 bytes, so strncpy will fill |
3037 | it with zeroes for me. */ | 3096 | it with zeroes for me. */ |
@@ -3043,12 +3102,12 @@ static void send_panic_events(char *str) | |||
3043 | &addr, | 3102 | &addr, |
3044 | 0, | 3103 | 0, |
3045 | &msg, | 3104 | &msg, |
3046 | NULL, | 3105 | intf, |
3047 | &smi_msg, | 3106 | &smi_msg, |
3048 | &recv_msg, | 3107 | &recv_msg, |
3049 | 0, | 3108 | 0, |
3050 | intf->my_address, | 3109 | intf->channels[0].address, |
3051 | intf->my_lun, | 3110 | intf->channels[0].lun, |
3052 | 0, 1); /* no retry, and no wait. */ | 3111 | 0, 1); /* no retry, and no wait. */ |
3053 | } | 3112 | } |
3054 | } | 3113 | } |
@@ -3070,7 +3129,7 @@ static int panic_event(struct notifier_block *this, | |||
3070 | has_paniced = 1; | 3129 | has_paniced = 1; |
3071 | 3130 | ||
3072 | /* For every registered interface, set it to run to completion. */ | 3131 | /* For every registered interface, set it to run to completion. */ |
3073 | for (i=0; i<MAX_IPMI_INTERFACES; i++) { | 3132 | for (i = 0; i < MAX_IPMI_INTERFACES; i++) { |
3074 | intf = ipmi_interfaces[i]; | 3133 | intf = ipmi_interfaces[i]; |
3075 | if (intf == NULL) | 3134 | if (intf == NULL) |
3076 | continue; | 3135 | continue; |
@@ -3099,9 +3158,9 @@ static int ipmi_init_msghandler(void) | |||
3099 | return 0; | 3158 | return 0; |
3100 | 3159 | ||
3101 | printk(KERN_INFO "ipmi message handler version " | 3160 | printk(KERN_INFO "ipmi message handler version " |
3102 | IPMI_MSGHANDLER_VERSION "\n"); | 3161 | IPMI_DRIVER_VERSION "\n"); |
3103 | 3162 | ||
3104 | for (i=0; i<MAX_IPMI_INTERFACES; i++) { | 3163 | for (i = 0; i < MAX_IPMI_INTERFACES; i++) { |
3105 | ipmi_interfaces[i] = NULL; | 3164 | ipmi_interfaces[i] = NULL; |
3106 | } | 3165 | } |
3107 | 3166 | ||
@@ -3171,6 +3230,9 @@ module_exit(cleanup_ipmi); | |||
3171 | 3230 | ||
3172 | module_init(ipmi_init_msghandler_mod); | 3231 | module_init(ipmi_init_msghandler_mod); |
3173 | MODULE_LICENSE("GPL"); | 3232 | MODULE_LICENSE("GPL"); |
3233 | MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); | ||
3234 | MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI interface."); | ||
3235 | MODULE_VERSION(IPMI_DRIVER_VERSION); | ||
3174 | 3236 | ||
3175 | EXPORT_SYMBOL(ipmi_create_user); | 3237 | EXPORT_SYMBOL(ipmi_create_user); |
3176 | EXPORT_SYMBOL(ipmi_destroy_user); | 3238 | EXPORT_SYMBOL(ipmi_destroy_user); |
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c index f951c30236c9..e82a96ba396b 100644 --- a/drivers/char/ipmi/ipmi_poweroff.c +++ b/drivers/char/ipmi/ipmi_poweroff.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <linux/ipmi_smi.h> | 42 | #include <linux/ipmi_smi.h> |
43 | 43 | ||
44 | #define PFX "IPMI poweroff: " | 44 | #define PFX "IPMI poweroff: " |
45 | #define IPMI_POWEROFF_VERSION "v33" | ||
46 | 45 | ||
47 | /* Where to we insert our poweroff function? */ | 46 | /* Where to we insert our poweroff function? */ |
48 | extern void (*pm_power_off)(void); | 47 | extern void (*pm_power_off)(void); |
@@ -53,16 +52,17 @@ extern void (*pm_power_off)(void); | |||
53 | #define IPMI_CHASSIS_POWER_CYCLE 0x02 /* power cycle */ | 52 | #define IPMI_CHASSIS_POWER_CYCLE 0x02 /* power cycle */ |
54 | 53 | ||
55 | /* the IPMI data command */ | 54 | /* the IPMI data command */ |
56 | static int poweroff_control = IPMI_CHASSIS_POWER_DOWN; | 55 | static int poweroff_powercycle; |
57 | 56 | ||
58 | /* parameter definition to allow user to flag power cycle */ | 57 | /* parameter definition to allow user to flag power cycle */ |
59 | module_param(poweroff_control, int, IPMI_CHASSIS_POWER_DOWN); | 58 | module_param(poweroff_powercycle, int, 0); |
60 | MODULE_PARM_DESC(poweroff_control, " Set to 2 to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down."); | 59 | MODULE_PARM_DESC(poweroff_powercycles, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down."); |
61 | 60 | ||
62 | /* Stuff from the get device id command. */ | 61 | /* Stuff from the get device id command. */ |
63 | static unsigned int mfg_id; | 62 | static unsigned int mfg_id; |
64 | static unsigned int prod_id; | 63 | static unsigned int prod_id; |
65 | static unsigned char capabilities; | 64 | static unsigned char capabilities; |
65 | static unsigned char ipmi_version; | ||
66 | 66 | ||
67 | /* We use our own messages for this operation, we don't let the system | 67 | /* We use our own messages for this operation, we don't let the system |
68 | allocate them, since we may be in a panic situation. The whole | 68 | allocate them, since we may be in a panic situation. The whole |
@@ -338,6 +338,25 @@ static void ipmi_poweroff_cpi1 (ipmi_user_t user) | |||
338 | } | 338 | } |
339 | 339 | ||
340 | /* | 340 | /* |
341 | * ipmi_dell_chassis_detect() | ||
342 | * Dell systems with IPMI < 1.5 don't set the chassis capability bit | ||
343 | * but they can handle a chassis poweroff or powercycle command. | ||
344 | */ | ||
345 | |||
346 | #define DELL_IANA_MFR_ID {0xA2, 0x02, 0x00} | ||
347 | static int ipmi_dell_chassis_detect (ipmi_user_t user) | ||
348 | { | ||
349 | const char ipmi_version_major = ipmi_version & 0xF; | ||
350 | const char ipmi_version_minor = (ipmi_version >> 4) & 0xF; | ||
351 | const char mfr[3]=DELL_IANA_MFR_ID; | ||
352 | if (!memcmp(mfr, &mfg_id, sizeof(mfr)) && | ||
353 | ipmi_version_major <= 1 && | ||
354 | ipmi_version_minor < 5) | ||
355 | return 1; | ||
356 | return 0; | ||
357 | } | ||
358 | |||
359 | /* | ||
341 | * Standard chassis support | 360 | * Standard chassis support |
342 | */ | 361 | */ |
343 | 362 | ||
@@ -366,37 +385,34 @@ static void ipmi_poweroff_chassis (ipmi_user_t user) | |||
366 | 385 | ||
367 | powercyclefailed: | 386 | powercyclefailed: |
368 | printk(KERN_INFO PFX "Powering %s via IPMI chassis control command\n", | 387 | printk(KERN_INFO PFX "Powering %s via IPMI chassis control command\n", |
369 | ((poweroff_control != IPMI_CHASSIS_POWER_CYCLE) ? "down" : "cycle")); | 388 | (poweroff_powercycle ? "cycle" : "down")); |
370 | 389 | ||
371 | /* | 390 | /* |
372 | * Power down | 391 | * Power down |
373 | */ | 392 | */ |
374 | send_msg.netfn = IPMI_NETFN_CHASSIS_REQUEST; | 393 | send_msg.netfn = IPMI_NETFN_CHASSIS_REQUEST; |
375 | send_msg.cmd = IPMI_CHASSIS_CONTROL_CMD; | 394 | send_msg.cmd = IPMI_CHASSIS_CONTROL_CMD; |
376 | data[0] = poweroff_control; | 395 | if (poweroff_powercycle) |
396 | data[0] = IPMI_CHASSIS_POWER_CYCLE; | ||
397 | else | ||
398 | data[0] = IPMI_CHASSIS_POWER_DOWN; | ||
377 | send_msg.data = data; | 399 | send_msg.data = data; |
378 | send_msg.data_len = sizeof(data); | 400 | send_msg.data_len = sizeof(data); |
379 | rv = ipmi_request_in_rc_mode(user, | 401 | rv = ipmi_request_in_rc_mode(user, |
380 | (struct ipmi_addr *) &smi_addr, | 402 | (struct ipmi_addr *) &smi_addr, |
381 | &send_msg); | 403 | &send_msg); |
382 | if (rv) { | 404 | if (rv) { |
383 | switch (poweroff_control) { | 405 | if (poweroff_powercycle) { |
384 | case IPMI_CHASSIS_POWER_CYCLE: | 406 | /* power cycle failed, default to power down */ |
385 | /* power cycle failed, default to power down */ | 407 | printk(KERN_ERR PFX "Unable to send chassis power " \ |
386 | printk(KERN_ERR PFX "Unable to send chassis power " \ | 408 | "cycle message, IPMI error 0x%x\n", rv); |
387 | "cycle message, IPMI error 0x%x\n", rv); | 409 | poweroff_powercycle = 0; |
388 | poweroff_control = IPMI_CHASSIS_POWER_DOWN; | 410 | goto powercyclefailed; |
389 | goto powercyclefailed; | ||
390 | |||
391 | case IPMI_CHASSIS_POWER_DOWN: | ||
392 | default: | ||
393 | printk(KERN_ERR PFX "Unable to send chassis power " \ | ||
394 | "down message, IPMI error 0x%x\n", rv); | ||
395 | break; | ||
396 | } | 411 | } |
397 | } | ||
398 | 412 | ||
399 | return; | 413 | printk(KERN_ERR PFX "Unable to send chassis power " \ |
414 | "down message, IPMI error 0x%x\n", rv); | ||
415 | } | ||
400 | } | 416 | } |
401 | 417 | ||
402 | 418 | ||
@@ -414,6 +430,9 @@ static struct poweroff_function poweroff_functions[] = { | |||
414 | { .platform_type = "CPI1", | 430 | { .platform_type = "CPI1", |
415 | .detect = ipmi_cpi1_detect, | 431 | .detect = ipmi_cpi1_detect, |
416 | .poweroff_func = ipmi_poweroff_cpi1 }, | 432 | .poweroff_func = ipmi_poweroff_cpi1 }, |
433 | { .platform_type = "chassis", | ||
434 | .detect = ipmi_dell_chassis_detect, | ||
435 | .poweroff_func = ipmi_poweroff_chassis }, | ||
417 | /* Chassis should generally be last, other things should override | 436 | /* Chassis should generally be last, other things should override |
418 | it. */ | 437 | it. */ |
419 | { .platform_type = "chassis", | 438 | { .platform_type = "chassis", |
@@ -499,10 +518,11 @@ static void ipmi_po_new_smi(int if_num) | |||
499 | prod_id = (halt_recv_msg.msg.data[10] | 518 | prod_id = (halt_recv_msg.msg.data[10] |
500 | | (halt_recv_msg.msg.data[11] << 8)); | 519 | | (halt_recv_msg.msg.data[11] << 8)); |
501 | capabilities = halt_recv_msg.msg.data[6]; | 520 | capabilities = halt_recv_msg.msg.data[6]; |
521 | ipmi_version = halt_recv_msg.msg.data[5]; | ||
502 | 522 | ||
503 | 523 | ||
504 | /* Scan for a poweroff method */ | 524 | /* Scan for a poweroff method */ |
505 | for (i=0; i<NUM_PO_FUNCS; i++) { | 525 | for (i = 0; i < NUM_PO_FUNCS; i++) { |
506 | if (poweroff_functions[i].detect(ipmi_user)) | 526 | if (poweroff_functions[i].detect(ipmi_user)) |
507 | goto found; | 527 | goto found; |
508 | } | 528 | } |
@@ -538,39 +558,35 @@ static struct ipmi_smi_watcher smi_watcher = | |||
538 | 558 | ||
539 | 559 | ||
540 | #ifdef CONFIG_PROC_FS | 560 | #ifdef CONFIG_PROC_FS |
541 | /* displays properties to proc */ | 561 | #include <linux/sysctl.h> |
542 | static int proc_read_chassctrl(char *page, char **start, off_t off, int count, | 562 | |
543 | int *eof, void *data) | 563 | static ctl_table ipmi_table[] = { |
544 | { | 564 | { .ctl_name = DEV_IPMI_POWEROFF_POWERCYCLE, |
545 | return sprintf(page, "%d\t[ 0=powerdown 2=powercycle ]\n", | 565 | .procname = "poweroff_powercycle", |
546 | poweroff_control); | 566 | .data = &poweroff_powercycle, |
547 | } | 567 | .maxlen = sizeof(poweroff_powercycle), |
568 | .mode = 0644, | ||
569 | .proc_handler = &proc_dointvec }, | ||
570 | { } | ||
571 | }; | ||
548 | 572 | ||
549 | /* process property writes from proc */ | 573 | static ctl_table ipmi_dir_table[] = { |
550 | static int proc_write_chassctrl(struct file *file, const char *buffer, | 574 | { .ctl_name = DEV_IPMI, |
551 | unsigned long count, void *data) | 575 | .procname = "ipmi", |
552 | { | 576 | .mode = 0555, |
553 | int rv = count; | 577 | .child = ipmi_table }, |
554 | unsigned int newval = 0; | 578 | { } |
555 | 579 | }; | |
556 | sscanf(buffer, "%d", &newval); | ||
557 | switch (newval) { | ||
558 | case IPMI_CHASSIS_POWER_CYCLE: | ||
559 | printk(KERN_INFO PFX "power cycle is now enabled\n"); | ||
560 | poweroff_control = newval; | ||
561 | break; | ||
562 | |||
563 | case IPMI_CHASSIS_POWER_DOWN: | ||
564 | poweroff_control = IPMI_CHASSIS_POWER_DOWN; | ||
565 | break; | ||
566 | |||
567 | default: | ||
568 | rv = -EINVAL; | ||
569 | break; | ||
570 | } | ||
571 | 580 | ||
572 | return rv; | 581 | static ctl_table ipmi_root_table[] = { |
573 | } | 582 | { .ctl_name = CTL_DEV, |
583 | .procname = "dev", | ||
584 | .mode = 0555, | ||
585 | .child = ipmi_dir_table }, | ||
586 | { } | ||
587 | }; | ||
588 | |||
589 | static struct ctl_table_header *ipmi_table_header; | ||
574 | #endif /* CONFIG_PROC_FS */ | 590 | #endif /* CONFIG_PROC_FS */ |
575 | 591 | ||
576 | /* | 592 | /* |
@@ -578,42 +594,32 @@ static int proc_write_chassctrl(struct file *file, const char *buffer, | |||
578 | */ | 594 | */ |
579 | static int ipmi_poweroff_init (void) | 595 | static int ipmi_poweroff_init (void) |
580 | { | 596 | { |
581 | int rv; | 597 | int rv; |
582 | struct proc_dir_entry *file; | ||
583 | 598 | ||
584 | printk ("Copyright (C) 2004 MontaVista Software -" | 599 | printk ("Copyright (C) 2004 MontaVista Software -" |
585 | " IPMI Powerdown via sys_reboot version " | 600 | " IPMI Powerdown via sys_reboot.\n"); |
586 | IPMI_POWEROFF_VERSION ".\n"); | 601 | |
587 | 602 | if (poweroff_powercycle) | |
588 | switch (poweroff_control) { | 603 | printk(KERN_INFO PFX "Power cycle is enabled.\n"); |
589 | case IPMI_CHASSIS_POWER_CYCLE: | 604 | |
590 | printk(KERN_INFO PFX "Power cycle is enabled.\n"); | 605 | #ifdef CONFIG_PROC_FS |
591 | break; | 606 | ipmi_table_header = register_sysctl_table(ipmi_root_table, 1); |
592 | 607 | if (!ipmi_table_header) { | |
593 | case IPMI_CHASSIS_POWER_DOWN: | 608 | printk(KERN_ERR PFX "Unable to register powercycle sysctl\n"); |
594 | default: | 609 | rv = -ENOMEM; |
595 | poweroff_control = IPMI_CHASSIS_POWER_DOWN; | 610 | goto out_err; |
596 | break; | ||
597 | } | 611 | } |
612 | #endif | ||
598 | 613 | ||
614 | #ifdef CONFIG_PROC_FS | ||
599 | rv = ipmi_smi_watcher_register(&smi_watcher); | 615 | rv = ipmi_smi_watcher_register(&smi_watcher); |
616 | #endif | ||
600 | if (rv) { | 617 | if (rv) { |
618 | unregister_sysctl_table(ipmi_table_header); | ||
601 | printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv); | 619 | printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv); |
602 | goto out_err; | 620 | goto out_err; |
603 | } | 621 | } |
604 | 622 | ||
605 | #ifdef CONFIG_PROC_FS | ||
606 | file = create_proc_entry("poweroff_control", 0, proc_ipmi_root); | ||
607 | if (!file) { | ||
608 | printk(KERN_ERR PFX "Unable to create proc power control\n"); | ||
609 | } else { | ||
610 | file->nlink = 1; | ||
611 | file->read_proc = proc_read_chassctrl; | ||
612 | file->write_proc = proc_write_chassctrl; | ||
613 | file->owner = THIS_MODULE; | ||
614 | } | ||
615 | #endif | ||
616 | |||
617 | out_err: | 623 | out_err: |
618 | return rv; | 624 | return rv; |
619 | } | 625 | } |
@@ -624,7 +630,7 @@ static __exit void ipmi_poweroff_cleanup(void) | |||
624 | int rv; | 630 | int rv; |
625 | 631 | ||
626 | #ifdef CONFIG_PROC_FS | 632 | #ifdef CONFIG_PROC_FS |
627 | remove_proc_entry("poweroff_control", proc_ipmi_root); | 633 | unregister_sysctl_table(ipmi_table_header); |
628 | #endif | 634 | #endif |
629 | 635 | ||
630 | ipmi_smi_watcher_unregister(&smi_watcher); | 636 | ipmi_smi_watcher_unregister(&smi_watcher); |
@@ -642,3 +648,5 @@ module_exit(ipmi_poweroff_cleanup); | |||
642 | 648 | ||
643 | module_init(ipmi_poweroff_init); | 649 | module_init(ipmi_poweroff_init); |
644 | MODULE_LICENSE("GPL"); | 650 | MODULE_LICENSE("GPL"); |
651 | MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); | ||
652 | MODULE_DESCRIPTION("IPMI Poweroff extension to sys_reboot"); | ||
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index a44b97304e95..278f84104996 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -61,11 +61,11 @@ | |||
61 | # endif | 61 | # endif |
62 | static inline void add_usec_to_timer(struct timer_list *t, long v) | 62 | static inline void add_usec_to_timer(struct timer_list *t, long v) |
63 | { | 63 | { |
64 | t->sub_expires += nsec_to_arch_cycle(v * 1000); | 64 | t->arch_cycle_expires += nsec_to_arch_cycle(v * 1000); |
65 | while (t->sub_expires >= arch_cycles_per_jiffy) | 65 | while (t->arch_cycle_expires >= arch_cycles_per_jiffy) |
66 | { | 66 | { |
67 | t->expires++; | 67 | t->expires++; |
68 | t->sub_expires -= arch_cycles_per_jiffy; | 68 | t->arch_cycle_expires -= arch_cycles_per_jiffy; |
69 | } | 69 | } |
70 | } | 70 | } |
71 | #endif | 71 | #endif |
@@ -75,8 +75,7 @@ static inline void add_usec_to_timer(struct timer_list *t, long v) | |||
75 | #include <asm/io.h> | 75 | #include <asm/io.h> |
76 | #include "ipmi_si_sm.h" | 76 | #include "ipmi_si_sm.h" |
77 | #include <linux/init.h> | 77 | #include <linux/init.h> |
78 | 78 | #include <linux/dmi.h> | |
79 | #define IPMI_SI_VERSION "v33" | ||
80 | 79 | ||
81 | /* Measure times between events in the driver. */ | 80 | /* Measure times between events in the driver. */ |
82 | #undef DEBUG_TIMING | 81 | #undef DEBUG_TIMING |
@@ -109,6 +108,21 @@ enum si_type { | |||
109 | SI_KCS, SI_SMIC, SI_BT | 108 | SI_KCS, SI_SMIC, SI_BT |
110 | }; | 109 | }; |
111 | 110 | ||
111 | struct ipmi_device_id { | ||
112 | unsigned char device_id; | ||
113 | unsigned char device_revision; | ||
114 | unsigned char firmware_revision_1; | ||
115 | unsigned char firmware_revision_2; | ||
116 | unsigned char ipmi_version; | ||
117 | unsigned char additional_device_support; | ||
118 | unsigned char manufacturer_id[3]; | ||
119 | unsigned char product_id[2]; | ||
120 | unsigned char aux_firmware_revision[4]; | ||
121 | } __attribute__((packed)); | ||
122 | |||
123 | #define ipmi_version_major(v) ((v)->ipmi_version & 0xf) | ||
124 | #define ipmi_version_minor(v) ((v)->ipmi_version >> 4) | ||
125 | |||
112 | struct smi_info | 126 | struct smi_info |
113 | { | 127 | { |
114 | ipmi_smi_t intf; | 128 | ipmi_smi_t intf; |
@@ -131,12 +145,24 @@ struct smi_info | |||
131 | void (*irq_cleanup)(struct smi_info *info); | 145 | void (*irq_cleanup)(struct smi_info *info); |
132 | unsigned int io_size; | 146 | unsigned int io_size; |
133 | 147 | ||
148 | /* Per-OEM handler, called from handle_flags(). | ||
149 | Returns 1 when handle_flags() needs to be re-run | ||
150 | or 0 indicating it set si_state itself. | ||
151 | */ | ||
152 | int (*oem_data_avail_handler)(struct smi_info *smi_info); | ||
153 | |||
134 | /* Flags from the last GET_MSG_FLAGS command, used when an ATTN | 154 | /* Flags from the last GET_MSG_FLAGS command, used when an ATTN |
135 | is set to hold the flags until we are done handling everything | 155 | is set to hold the flags until we are done handling everything |
136 | from the flags. */ | 156 | from the flags. */ |
137 | #define RECEIVE_MSG_AVAIL 0x01 | 157 | #define RECEIVE_MSG_AVAIL 0x01 |
138 | #define EVENT_MSG_BUFFER_FULL 0x02 | 158 | #define EVENT_MSG_BUFFER_FULL 0x02 |
139 | #define WDT_PRE_TIMEOUT_INT 0x08 | 159 | #define WDT_PRE_TIMEOUT_INT 0x08 |
160 | #define OEM0_DATA_AVAIL 0x20 | ||
161 | #define OEM1_DATA_AVAIL 0x40 | ||
162 | #define OEM2_DATA_AVAIL 0x80 | ||
163 | #define OEM_DATA_AVAIL (OEM0_DATA_AVAIL | \ | ||
164 | OEM1_DATA_AVAIL | \ | ||
165 | OEM2_DATA_AVAIL) | ||
140 | unsigned char msg_flags; | 166 | unsigned char msg_flags; |
141 | 167 | ||
142 | /* If set to true, this will request events the next time the | 168 | /* If set to true, this will request events the next time the |
@@ -175,11 +201,7 @@ struct smi_info | |||
175 | interrupts. */ | 201 | interrupts. */ |
176 | int interrupt_disabled; | 202 | int interrupt_disabled; |
177 | 203 | ||
178 | unsigned char ipmi_si_dev_rev; | 204 | struct ipmi_device_id device_id; |
179 | unsigned char ipmi_si_fw_rev_major; | ||
180 | unsigned char ipmi_si_fw_rev_minor; | ||
181 | unsigned char ipmi_version_major; | ||
182 | unsigned char ipmi_version_minor; | ||
183 | 205 | ||
184 | /* Slave address, could be reported from DMI. */ | 206 | /* Slave address, could be reported from DMI. */ |
185 | unsigned char slave_addr; | 207 | unsigned char slave_addr; |
@@ -245,7 +267,7 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info) | |||
245 | entry = smi_info->xmit_msgs.next; | 267 | entry = smi_info->xmit_msgs.next; |
246 | } | 268 | } |
247 | 269 | ||
248 | if (!entry) { | 270 | if (! entry) { |
249 | smi_info->curr_msg = NULL; | 271 | smi_info->curr_msg = NULL; |
250 | rv = SI_SM_IDLE; | 272 | rv = SI_SM_IDLE; |
251 | } else { | 273 | } else { |
@@ -306,7 +328,7 @@ static void start_clear_flags(struct smi_info *smi_info) | |||
306 | memory, we will re-enable the interrupt. */ | 328 | memory, we will re-enable the interrupt. */ |
307 | static inline void disable_si_irq(struct smi_info *smi_info) | 329 | static inline void disable_si_irq(struct smi_info *smi_info) |
308 | { | 330 | { |
309 | if ((smi_info->irq) && (!smi_info->interrupt_disabled)) { | 331 | if ((smi_info->irq) && (! smi_info->interrupt_disabled)) { |
310 | disable_irq_nosync(smi_info->irq); | 332 | disable_irq_nosync(smi_info->irq); |
311 | smi_info->interrupt_disabled = 1; | 333 | smi_info->interrupt_disabled = 1; |
312 | } | 334 | } |
@@ -322,6 +344,7 @@ static inline void enable_si_irq(struct smi_info *smi_info) | |||
322 | 344 | ||
323 | static void handle_flags(struct smi_info *smi_info) | 345 | static void handle_flags(struct smi_info *smi_info) |
324 | { | 346 | { |
347 | retry: | ||
325 | if (smi_info->msg_flags & WDT_PRE_TIMEOUT_INT) { | 348 | if (smi_info->msg_flags & WDT_PRE_TIMEOUT_INT) { |
326 | /* Watchdog pre-timeout */ | 349 | /* Watchdog pre-timeout */ |
327 | spin_lock(&smi_info->count_lock); | 350 | spin_lock(&smi_info->count_lock); |
@@ -336,7 +359,7 @@ static void handle_flags(struct smi_info *smi_info) | |||
336 | } else if (smi_info->msg_flags & RECEIVE_MSG_AVAIL) { | 359 | } else if (smi_info->msg_flags & RECEIVE_MSG_AVAIL) { |
337 | /* Messages available. */ | 360 | /* Messages available. */ |
338 | smi_info->curr_msg = ipmi_alloc_smi_msg(); | 361 | smi_info->curr_msg = ipmi_alloc_smi_msg(); |
339 | if (!smi_info->curr_msg) { | 362 | if (! smi_info->curr_msg) { |
340 | disable_si_irq(smi_info); | 363 | disable_si_irq(smi_info); |
341 | smi_info->si_state = SI_NORMAL; | 364 | smi_info->si_state = SI_NORMAL; |
342 | return; | 365 | return; |
@@ -355,7 +378,7 @@ static void handle_flags(struct smi_info *smi_info) | |||
355 | } else if (smi_info->msg_flags & EVENT_MSG_BUFFER_FULL) { | 378 | } else if (smi_info->msg_flags & EVENT_MSG_BUFFER_FULL) { |
356 | /* Events available. */ | 379 | /* Events available. */ |
357 | smi_info->curr_msg = ipmi_alloc_smi_msg(); | 380 | smi_info->curr_msg = ipmi_alloc_smi_msg(); |
358 | if (!smi_info->curr_msg) { | 381 | if (! smi_info->curr_msg) { |
359 | disable_si_irq(smi_info); | 382 | disable_si_irq(smi_info); |
360 | smi_info->si_state = SI_NORMAL; | 383 | smi_info->si_state = SI_NORMAL; |
361 | return; | 384 | return; |
@@ -371,6 +394,10 @@ static void handle_flags(struct smi_info *smi_info) | |||
371 | smi_info->curr_msg->data, | 394 | smi_info->curr_msg->data, |
372 | smi_info->curr_msg->data_size); | 395 | smi_info->curr_msg->data_size); |
373 | smi_info->si_state = SI_GETTING_EVENTS; | 396 | smi_info->si_state = SI_GETTING_EVENTS; |
397 | } else if (smi_info->msg_flags & OEM_DATA_AVAIL) { | ||
398 | if (smi_info->oem_data_avail_handler) | ||
399 | if (smi_info->oem_data_avail_handler(smi_info)) | ||
400 | goto retry; | ||
374 | } else { | 401 | } else { |
375 | smi_info->si_state = SI_NORMAL; | 402 | smi_info->si_state = SI_NORMAL; |
376 | } | 403 | } |
@@ -387,7 +414,7 @@ static void handle_transaction_done(struct smi_info *smi_info) | |||
387 | #endif | 414 | #endif |
388 | switch (smi_info->si_state) { | 415 | switch (smi_info->si_state) { |
389 | case SI_NORMAL: | 416 | case SI_NORMAL: |
390 | if (!smi_info->curr_msg) | 417 | if (! smi_info->curr_msg) |
391 | break; | 418 | break; |
392 | 419 | ||
393 | smi_info->curr_msg->rsp_size | 420 | smi_info->curr_msg->rsp_size |
@@ -761,18 +788,20 @@ static void si_restart_short_timer(struct smi_info *smi_info) | |||
761 | #if defined(CONFIG_HIGH_RES_TIMERS) | 788 | #if defined(CONFIG_HIGH_RES_TIMERS) |
762 | unsigned long flags; | 789 | unsigned long flags; |
763 | unsigned long jiffies_now; | 790 | unsigned long jiffies_now; |
791 | unsigned long seq; | ||
764 | 792 | ||
765 | if (del_timer(&(smi_info->si_timer))) { | 793 | if (del_timer(&(smi_info->si_timer))) { |
766 | /* If we don't delete the timer, then it will go off | 794 | /* If we don't delete the timer, then it will go off |
767 | immediately, anyway. So we only process if we | 795 | immediately, anyway. So we only process if we |
768 | actually delete the timer. */ | 796 | actually delete the timer. */ |
769 | 797 | ||
770 | /* We already have irqsave on, so no need for it | 798 | do { |
771 | here. */ | 799 | seq = read_seqbegin_irqsave(&xtime_lock, flags); |
772 | read_lock(&xtime_lock); | 800 | jiffies_now = jiffies; |
773 | jiffies_now = jiffies; | 801 | smi_info->si_timer.expires = jiffies_now; |
774 | smi_info->si_timer.expires = jiffies_now; | 802 | smi_info->si_timer.arch_cycle_expires |
775 | smi_info->si_timer.sub_expires = get_arch_cycles(jiffies_now); | 803 | = get_arch_cycles(jiffies_now); |
804 | } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); | ||
776 | 805 | ||
777 | add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC); | 806 | add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC); |
778 | 807 | ||
@@ -826,15 +855,19 @@ static void smi_timeout(unsigned long data) | |||
826 | /* If the state machine asks for a short delay, then shorten | 855 | /* If the state machine asks for a short delay, then shorten |
827 | the timer timeout. */ | 856 | the timer timeout. */ |
828 | if (smi_result == SI_SM_CALL_WITH_DELAY) { | 857 | if (smi_result == SI_SM_CALL_WITH_DELAY) { |
858 | #if defined(CONFIG_HIGH_RES_TIMERS) | ||
859 | unsigned long seq; | ||
860 | #endif | ||
829 | spin_lock_irqsave(&smi_info->count_lock, flags); | 861 | spin_lock_irqsave(&smi_info->count_lock, flags); |
830 | smi_info->short_timeouts++; | 862 | smi_info->short_timeouts++; |
831 | spin_unlock_irqrestore(&smi_info->count_lock, flags); | 863 | spin_unlock_irqrestore(&smi_info->count_lock, flags); |
832 | #if defined(CONFIG_HIGH_RES_TIMERS) | 864 | #if defined(CONFIG_HIGH_RES_TIMERS) |
833 | read_lock(&xtime_lock); | 865 | do { |
834 | smi_info->si_timer.expires = jiffies; | 866 | seq = read_seqbegin_irqsave(&xtime_lock, flags); |
835 | smi_info->si_timer.sub_expires | 867 | smi_info->si_timer.expires = jiffies; |
836 | = get_arch_cycles(smi_info->si_timer.expires); | 868 | smi_info->si_timer.arch_cycle_expires |
837 | read_unlock(&xtime_lock); | 869 | = get_arch_cycles(smi_info->si_timer.expires); |
870 | } while (read_seqretry_irqrestore(&xtime_lock, seq, flags)); | ||
838 | add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC); | 871 | add_usec_to_timer(&smi_info->si_timer, SI_SHORT_TIMEOUT_USEC); |
839 | #else | 872 | #else |
840 | smi_info->si_timer.expires = jiffies + 1; | 873 | smi_info->si_timer.expires = jiffies + 1; |
@@ -845,7 +878,7 @@ static void smi_timeout(unsigned long data) | |||
845 | spin_unlock_irqrestore(&smi_info->count_lock, flags); | 878 | spin_unlock_irqrestore(&smi_info->count_lock, flags); |
846 | smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES; | 879 | smi_info->si_timer.expires = jiffies + SI_TIMEOUT_JIFFIES; |
847 | #if defined(CONFIG_HIGH_RES_TIMERS) | 880 | #if defined(CONFIG_HIGH_RES_TIMERS) |
848 | smi_info->si_timer.sub_expires = 0; | 881 | smi_info->si_timer.arch_cycle_expires = 0; |
849 | #endif | 882 | #endif |
850 | } | 883 | } |
851 | 884 | ||
@@ -986,7 +1019,7 @@ MODULE_PARM_DESC(slave_addrs, "Set the default IPMB slave address for" | |||
986 | #define IPMI_MEM_ADDR_SPACE 1 | 1019 | #define IPMI_MEM_ADDR_SPACE 1 |
987 | #define IPMI_IO_ADDR_SPACE 2 | 1020 | #define IPMI_IO_ADDR_SPACE 2 |
988 | 1021 | ||
989 | #if defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_X86) || defined(CONFIG_PCI) | 1022 | #if defined(CONFIG_ACPI) || defined(CONFIG_X86) || defined(CONFIG_PCI) |
990 | static int is_new_interface(int intf, u8 addr_space, unsigned long base_addr) | 1023 | static int is_new_interface(int intf, u8 addr_space, unsigned long base_addr) |
991 | { | 1024 | { |
992 | int i; | 1025 | int i; |
@@ -1014,7 +1047,7 @@ static int std_irq_setup(struct smi_info *info) | |||
1014 | { | 1047 | { |
1015 | int rv; | 1048 | int rv; |
1016 | 1049 | ||
1017 | if (!info->irq) | 1050 | if (! info->irq) |
1018 | return 0; | 1051 | return 0; |
1019 | 1052 | ||
1020 | if (info->si_type == SI_BT) { | 1053 | if (info->si_type == SI_BT) { |
@@ -1023,7 +1056,7 @@ static int std_irq_setup(struct smi_info *info) | |||
1023 | SA_INTERRUPT, | 1056 | SA_INTERRUPT, |
1024 | DEVICE_NAME, | 1057 | DEVICE_NAME, |
1025 | info); | 1058 | info); |
1026 | if (!rv) | 1059 | if (! rv) |
1027 | /* Enable the interrupt in the BT interface. */ | 1060 | /* Enable the interrupt in the BT interface. */ |
1028 | info->io.outputb(&info->io, IPMI_BT_INTMASK_REG, | 1061 | info->io.outputb(&info->io, IPMI_BT_INTMASK_REG, |
1029 | IPMI_BT_INTMASK_ENABLE_IRQ_BIT); | 1062 | IPMI_BT_INTMASK_ENABLE_IRQ_BIT); |
@@ -1048,7 +1081,7 @@ static int std_irq_setup(struct smi_info *info) | |||
1048 | 1081 | ||
1049 | static void std_irq_cleanup(struct smi_info *info) | 1082 | static void std_irq_cleanup(struct smi_info *info) |
1050 | { | 1083 | { |
1051 | if (!info->irq) | 1084 | if (! info->irq) |
1052 | return; | 1085 | return; |
1053 | 1086 | ||
1054 | if (info->si_type == SI_BT) | 1087 | if (info->si_type == SI_BT) |
@@ -1121,7 +1154,7 @@ static int port_setup(struct smi_info *info) | |||
1121 | unsigned int *addr = info->io.info; | 1154 | unsigned int *addr = info->io.info; |
1122 | int mapsize; | 1155 | int mapsize; |
1123 | 1156 | ||
1124 | if (!addr || (!*addr)) | 1157 | if (! addr || (! *addr)) |
1125 | return -ENODEV; | 1158 | return -ENODEV; |
1126 | 1159 | ||
1127 | info->io_cleanup = port_cleanup; | 1160 | info->io_cleanup = port_cleanup; |
@@ -1164,15 +1197,15 @@ static int try_init_port(int intf_num, struct smi_info **new_info) | |||
1164 | { | 1197 | { |
1165 | struct smi_info *info; | 1198 | struct smi_info *info; |
1166 | 1199 | ||
1167 | if (!ports[intf_num]) | 1200 | if (! ports[intf_num]) |
1168 | return -ENODEV; | 1201 | return -ENODEV; |
1169 | 1202 | ||
1170 | if (!is_new_interface(intf_num, IPMI_IO_ADDR_SPACE, | 1203 | if (! is_new_interface(intf_num, IPMI_IO_ADDR_SPACE, |
1171 | ports[intf_num])) | 1204 | ports[intf_num])) |
1172 | return -ENODEV; | 1205 | return -ENODEV; |
1173 | 1206 | ||
1174 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 1207 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
1175 | if (!info) { | 1208 | if (! info) { |
1176 | printk(KERN_ERR "ipmi_si: Could not allocate SI data (1)\n"); | 1209 | printk(KERN_ERR "ipmi_si: Could not allocate SI data (1)\n"); |
1177 | return -ENOMEM; | 1210 | return -ENOMEM; |
1178 | } | 1211 | } |
@@ -1182,10 +1215,10 @@ static int try_init_port(int intf_num, struct smi_info **new_info) | |||
1182 | info->io.info = &(ports[intf_num]); | 1215 | info->io.info = &(ports[intf_num]); |
1183 | info->io.addr = NULL; | 1216 | info->io.addr = NULL; |
1184 | info->io.regspacing = regspacings[intf_num]; | 1217 | info->io.regspacing = regspacings[intf_num]; |
1185 | if (!info->io.regspacing) | 1218 | if (! info->io.regspacing) |
1186 | info->io.regspacing = DEFAULT_REGSPACING; | 1219 | info->io.regspacing = DEFAULT_REGSPACING; |
1187 | info->io.regsize = regsizes[intf_num]; | 1220 | info->io.regsize = regsizes[intf_num]; |
1188 | if (!info->io.regsize) | 1221 | if (! info->io.regsize) |
1189 | info->io.regsize = DEFAULT_REGSPACING; | 1222 | info->io.regsize = DEFAULT_REGSPACING; |
1190 | info->io.regshift = regshifts[intf_num]; | 1223 | info->io.regshift = regshifts[intf_num]; |
1191 | info->irq = 0; | 1224 | info->irq = 0; |
@@ -1270,7 +1303,7 @@ static int mem_setup(struct smi_info *info) | |||
1270 | unsigned long *addr = info->io.info; | 1303 | unsigned long *addr = info->io.info; |
1271 | int mapsize; | 1304 | int mapsize; |
1272 | 1305 | ||
1273 | if (!addr || (!*addr)) | 1306 | if (! addr || (! *addr)) |
1274 | return -ENODEV; | 1307 | return -ENODEV; |
1275 | 1308 | ||
1276 | info->io_cleanup = mem_cleanup; | 1309 | info->io_cleanup = mem_cleanup; |
@@ -1325,15 +1358,15 @@ static int try_init_mem(int intf_num, struct smi_info **new_info) | |||
1325 | { | 1358 | { |
1326 | struct smi_info *info; | 1359 | struct smi_info *info; |
1327 | 1360 | ||
1328 | if (!addrs[intf_num]) | 1361 | if (! addrs[intf_num]) |
1329 | return -ENODEV; | 1362 | return -ENODEV; |
1330 | 1363 | ||
1331 | if (!is_new_interface(intf_num, IPMI_MEM_ADDR_SPACE, | 1364 | if (! is_new_interface(intf_num, IPMI_MEM_ADDR_SPACE, |
1332 | addrs[intf_num])) | 1365 | addrs[intf_num])) |
1333 | return -ENODEV; | 1366 | return -ENODEV; |
1334 | 1367 | ||
1335 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 1368 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
1336 | if (!info) { | 1369 | if (! info) { |
1337 | printk(KERN_ERR "ipmi_si: Could not allocate SI data (2)\n"); | 1370 | printk(KERN_ERR "ipmi_si: Could not allocate SI data (2)\n"); |
1338 | return -ENOMEM; | 1371 | return -ENOMEM; |
1339 | } | 1372 | } |
@@ -1343,10 +1376,10 @@ static int try_init_mem(int intf_num, struct smi_info **new_info) | |||
1343 | info->io.info = &addrs[intf_num]; | 1376 | info->io.info = &addrs[intf_num]; |
1344 | info->io.addr = NULL; | 1377 | info->io.addr = NULL; |
1345 | info->io.regspacing = regspacings[intf_num]; | 1378 | info->io.regspacing = regspacings[intf_num]; |
1346 | if (!info->io.regspacing) | 1379 | if (! info->io.regspacing) |
1347 | info->io.regspacing = DEFAULT_REGSPACING; | 1380 | info->io.regspacing = DEFAULT_REGSPACING; |
1348 | info->io.regsize = regsizes[intf_num]; | 1381 | info->io.regsize = regsizes[intf_num]; |
1349 | if (!info->io.regsize) | 1382 | if (! info->io.regsize) |
1350 | info->io.regsize = DEFAULT_REGSPACING; | 1383 | info->io.regsize = DEFAULT_REGSPACING; |
1351 | info->io.regshift = regshifts[intf_num]; | 1384 | info->io.regshift = regshifts[intf_num]; |
1352 | info->irq = 0; | 1385 | info->irq = 0; |
@@ -1362,7 +1395,7 @@ static int try_init_mem(int intf_num, struct smi_info **new_info) | |||
1362 | } | 1395 | } |
1363 | 1396 | ||
1364 | 1397 | ||
1365 | #ifdef CONFIG_ACPI_INTERPRETER | 1398 | #ifdef CONFIG_ACPI |
1366 | 1399 | ||
1367 | #include <linux/acpi.h> | 1400 | #include <linux/acpi.h> |
1368 | 1401 | ||
@@ -1404,7 +1437,7 @@ static int acpi_gpe_irq_setup(struct smi_info *info) | |||
1404 | { | 1437 | { |
1405 | acpi_status status; | 1438 | acpi_status status; |
1406 | 1439 | ||
1407 | if (!info->irq) | 1440 | if (! info->irq) |
1408 | return 0; | 1441 | return 0; |
1409 | 1442 | ||
1410 | /* FIXME - is level triggered right? */ | 1443 | /* FIXME - is level triggered right? */ |
@@ -1428,7 +1461,7 @@ static int acpi_gpe_irq_setup(struct smi_info *info) | |||
1428 | 1461 | ||
1429 | static void acpi_gpe_irq_cleanup(struct smi_info *info) | 1462 | static void acpi_gpe_irq_cleanup(struct smi_info *info) |
1430 | { | 1463 | { |
1431 | if (!info->irq) | 1464 | if (! info->irq) |
1432 | return; | 1465 | return; |
1433 | 1466 | ||
1434 | acpi_remove_gpe_handler(NULL, info->irq, &ipmi_acpi_gpe); | 1467 | acpi_remove_gpe_handler(NULL, info->irq, &ipmi_acpi_gpe); |
@@ -1484,6 +1517,9 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info) | |||
1484 | char *io_type; | 1517 | char *io_type; |
1485 | u8 addr_space; | 1518 | u8 addr_space; |
1486 | 1519 | ||
1520 | if (acpi_disabled) | ||
1521 | return -ENODEV; | ||
1522 | |||
1487 | if (acpi_failure) | 1523 | if (acpi_failure) |
1488 | return -ENODEV; | 1524 | return -ENODEV; |
1489 | 1525 | ||
@@ -1504,10 +1540,10 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info) | |||
1504 | addr_space = IPMI_MEM_ADDR_SPACE; | 1540 | addr_space = IPMI_MEM_ADDR_SPACE; |
1505 | else | 1541 | else |
1506 | addr_space = IPMI_IO_ADDR_SPACE; | 1542 | addr_space = IPMI_IO_ADDR_SPACE; |
1507 | if (!is_new_interface(-1, addr_space, spmi->addr.address)) | 1543 | if (! is_new_interface(-1, addr_space, spmi->addr.address)) |
1508 | return -ENODEV; | 1544 | return -ENODEV; |
1509 | 1545 | ||
1510 | if (!spmi->addr.register_bit_width) { | 1546 | if (! spmi->addr.register_bit_width) { |
1511 | acpi_failure = 1; | 1547 | acpi_failure = 1; |
1512 | return -ENODEV; | 1548 | return -ENODEV; |
1513 | } | 1549 | } |
@@ -1534,7 +1570,7 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info) | |||
1534 | } | 1570 | } |
1535 | 1571 | ||
1536 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 1572 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
1537 | if (!info) { | 1573 | if (! info) { |
1538 | printk(KERN_ERR "ipmi_si: Could not allocate SI data (3)\n"); | 1574 | printk(KERN_ERR "ipmi_si: Could not allocate SI data (3)\n"); |
1539 | return -ENOMEM; | 1575 | return -ENOMEM; |
1540 | } | 1576 | } |
@@ -1610,22 +1646,15 @@ typedef struct dmi_ipmi_data | |||
1610 | static dmi_ipmi_data_t dmi_data[SI_MAX_DRIVERS]; | 1646 | static dmi_ipmi_data_t dmi_data[SI_MAX_DRIVERS]; |
1611 | static int dmi_data_entries; | 1647 | static int dmi_data_entries; |
1612 | 1648 | ||
1613 | typedef struct dmi_header | 1649 | static int __init decode_dmi(struct dmi_header *dm, int intf_num) |
1614 | { | ||
1615 | u8 type; | ||
1616 | u8 length; | ||
1617 | u16 handle; | ||
1618 | } dmi_header_t; | ||
1619 | |||
1620 | static int decode_dmi(dmi_header_t __iomem *dm, int intf_num) | ||
1621 | { | 1650 | { |
1622 | u8 __iomem *data = (u8 __iomem *)dm; | 1651 | u8 *data = (u8 *)dm; |
1623 | unsigned long base_addr; | 1652 | unsigned long base_addr; |
1624 | u8 reg_spacing; | 1653 | u8 reg_spacing; |
1625 | u8 len = readb(&dm->length); | 1654 | u8 len = dm->length; |
1626 | dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num; | 1655 | dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num; |
1627 | 1656 | ||
1628 | ipmi_data->type = readb(&data[4]); | 1657 | ipmi_data->type = data[4]; |
1629 | 1658 | ||
1630 | memcpy(&base_addr, data+8, sizeof(unsigned long)); | 1659 | memcpy(&base_addr, data+8, sizeof(unsigned long)); |
1631 | if (len >= 0x11) { | 1660 | if (len >= 0x11) { |
@@ -1640,12 +1669,12 @@ static int decode_dmi(dmi_header_t __iomem *dm, int intf_num) | |||
1640 | } | 1669 | } |
1641 | /* If bit 4 of byte 0x10 is set, then the lsb for the address | 1670 | /* If bit 4 of byte 0x10 is set, then the lsb for the address |
1642 | is odd. */ | 1671 | is odd. */ |
1643 | ipmi_data->base_addr = base_addr | ((readb(&data[0x10]) & 0x10) >> 4); | 1672 | ipmi_data->base_addr = base_addr | ((data[0x10] & 0x10) >> 4); |
1644 | 1673 | ||
1645 | ipmi_data->irq = readb(&data[0x11]); | 1674 | ipmi_data->irq = data[0x11]; |
1646 | 1675 | ||
1647 | /* The top two bits of byte 0x10 hold the register spacing. */ | 1676 | /* The top two bits of byte 0x10 hold the register spacing. */ |
1648 | reg_spacing = (readb(&data[0x10]) & 0xC0) >> 6; | 1677 | reg_spacing = (data[0x10] & 0xC0) >> 6; |
1649 | switch(reg_spacing){ | 1678 | switch(reg_spacing){ |
1650 | case 0x00: /* Byte boundaries */ | 1679 | case 0x00: /* Byte boundaries */ |
1651 | ipmi_data->offset = 1; | 1680 | ipmi_data->offset = 1; |
@@ -1673,7 +1702,7 @@ static int decode_dmi(dmi_header_t __iomem *dm, int intf_num) | |||
1673 | ipmi_data->offset = 1; | 1702 | ipmi_data->offset = 1; |
1674 | } | 1703 | } |
1675 | 1704 | ||
1676 | ipmi_data->slave_addr = readb(&data[6]); | 1705 | ipmi_data->slave_addr = data[6]; |
1677 | 1706 | ||
1678 | if (is_new_interface(-1, ipmi_data->addr_space,ipmi_data->base_addr)) { | 1707 | if (is_new_interface(-1, ipmi_data->addr_space,ipmi_data->base_addr)) { |
1679 | dmi_data_entries++; | 1708 | dmi_data_entries++; |
@@ -1685,94 +1714,29 @@ static int decode_dmi(dmi_header_t __iomem *dm, int intf_num) | |||
1685 | return -1; | 1714 | return -1; |
1686 | } | 1715 | } |
1687 | 1716 | ||
1688 | static int dmi_table(u32 base, int len, int num) | 1717 | static void __init dmi_find_bmc(void) |
1689 | { | 1718 | { |
1690 | u8 __iomem *buf; | 1719 | struct dmi_device *dev = NULL; |
1691 | struct dmi_header __iomem *dm; | ||
1692 | u8 __iomem *data; | ||
1693 | int i=1; | ||
1694 | int status=-1; | ||
1695 | int intf_num = 0; | 1720 | int intf_num = 0; |
1696 | 1721 | ||
1697 | buf = ioremap(base, len); | 1722 | while ((dev = dmi_find_device(DMI_DEV_TYPE_IPMI, NULL, dev))) { |
1698 | if(buf==NULL) | 1723 | if (intf_num >= SI_MAX_DRIVERS) |
1699 | return -1; | 1724 | break; |
1700 | |||
1701 | data = buf; | ||
1702 | |||
1703 | while(i<num && (data - buf) < len) | ||
1704 | { | ||
1705 | dm=(dmi_header_t __iomem *)data; | ||
1706 | |||
1707 | if((data-buf+readb(&dm->length)) >= len) | ||
1708 | break; | ||
1709 | |||
1710 | if (readb(&dm->type) == 38) { | ||
1711 | if (decode_dmi(dm, intf_num) == 0) { | ||
1712 | intf_num++; | ||
1713 | if (intf_num >= SI_MAX_DRIVERS) | ||
1714 | break; | ||
1715 | } | ||
1716 | } | ||
1717 | |||
1718 | data+=readb(&dm->length); | ||
1719 | while((data-buf) < len && (readb(data)||readb(data+1))) | ||
1720 | data++; | ||
1721 | data+=2; | ||
1722 | i++; | ||
1723 | } | ||
1724 | iounmap(buf); | ||
1725 | |||
1726 | return status; | ||
1727 | } | ||
1728 | |||
1729 | static inline int dmi_checksum(u8 *buf) | ||
1730 | { | ||
1731 | u8 sum=0; | ||
1732 | int a; | ||
1733 | |||
1734 | for(a=0; a<15; a++) | ||
1735 | sum+=buf[a]; | ||
1736 | return (sum==0); | ||
1737 | } | ||
1738 | |||
1739 | static int dmi_decode(void) | ||
1740 | { | ||
1741 | u8 buf[15]; | ||
1742 | u32 fp=0xF0000; | ||
1743 | |||
1744 | #ifdef CONFIG_SIMNOW | ||
1745 | return -1; | ||
1746 | #endif | ||
1747 | |||
1748 | while(fp < 0xFFFFF) | ||
1749 | { | ||
1750 | isa_memcpy_fromio(buf, fp, 15); | ||
1751 | if(memcmp(buf, "_DMI_", 5)==0 && dmi_checksum(buf)) | ||
1752 | { | ||
1753 | u16 num=buf[13]<<8|buf[12]; | ||
1754 | u16 len=buf[7]<<8|buf[6]; | ||
1755 | u32 base=buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8]; | ||
1756 | 1725 | ||
1757 | if(dmi_table(base, len, num) == 0) | 1726 | decode_dmi((struct dmi_header *) dev->device_data, intf_num++); |
1758 | return 0; | ||
1759 | } | ||
1760 | fp+=16; | ||
1761 | } | 1727 | } |
1762 | |||
1763 | return -1; | ||
1764 | } | 1728 | } |
1765 | 1729 | ||
1766 | static int try_init_smbios(int intf_num, struct smi_info **new_info) | 1730 | static int try_init_smbios(int intf_num, struct smi_info **new_info) |
1767 | { | 1731 | { |
1768 | struct smi_info *info; | 1732 | struct smi_info *info; |
1769 | dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num; | 1733 | dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num; |
1770 | char *io_type; | 1734 | char *io_type; |
1771 | 1735 | ||
1772 | if (intf_num >= dmi_data_entries) | 1736 | if (intf_num >= dmi_data_entries) |
1773 | return -ENODEV; | 1737 | return -ENODEV; |
1774 | 1738 | ||
1775 | switch(ipmi_data->type) { | 1739 | switch (ipmi_data->type) { |
1776 | case 0x01: /* KCS */ | 1740 | case 0x01: /* KCS */ |
1777 | si_type[intf_num] = "kcs"; | 1741 | si_type[intf_num] = "kcs"; |
1778 | break; | 1742 | break; |
@@ -1787,7 +1751,7 @@ static int try_init_smbios(int intf_num, struct smi_info **new_info) | |||
1787 | } | 1751 | } |
1788 | 1752 | ||
1789 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 1753 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
1790 | if (!info) { | 1754 | if (! info) { |
1791 | printk(KERN_ERR "ipmi_si: Could not allocate SI data (4)\n"); | 1755 | printk(KERN_ERR "ipmi_si: Could not allocate SI data (4)\n"); |
1792 | return -ENOMEM; | 1756 | return -ENOMEM; |
1793 | } | 1757 | } |
@@ -1811,7 +1775,7 @@ static int try_init_smbios(int intf_num, struct smi_info **new_info) | |||
1811 | 1775 | ||
1812 | regspacings[intf_num] = ipmi_data->offset; | 1776 | regspacings[intf_num] = ipmi_data->offset; |
1813 | info->io.regspacing = regspacings[intf_num]; | 1777 | info->io.regspacing = regspacings[intf_num]; |
1814 | if (!info->io.regspacing) | 1778 | if (! info->io.regspacing) |
1815 | info->io.regspacing = DEFAULT_REGSPACING; | 1779 | info->io.regspacing = DEFAULT_REGSPACING; |
1816 | info->io.regsize = DEFAULT_REGSPACING; | 1780 | info->io.regsize = DEFAULT_REGSPACING; |
1817 | info->io.regshift = regshifts[intf_num]; | 1781 | info->io.regshift = regshifts[intf_num]; |
@@ -1853,14 +1817,14 @@ static int find_pci_smic(int intf_num, struct smi_info **new_info) | |||
1853 | 1817 | ||
1854 | pci_smic_checked = 1; | 1818 | pci_smic_checked = 1; |
1855 | 1819 | ||
1856 | if ((pci_dev = pci_get_device(PCI_HP_VENDOR_ID, PCI_MMC_DEVICE_ID, | 1820 | pci_dev = pci_get_device(PCI_HP_VENDOR_ID, PCI_MMC_DEVICE_ID, NULL); |
1857 | NULL))) | 1821 | if (! pci_dev) { |
1858 | ; | 1822 | pci_dev = pci_get_class(PCI_ERMC_CLASSCODE, NULL); |
1859 | else if ((pci_dev = pci_get_class(PCI_ERMC_CLASSCODE, NULL)) && | 1823 | if (pci_dev && (pci_dev->subsystem_vendor == PCI_HP_VENDOR_ID)) |
1860 | pci_dev->subsystem_vendor == PCI_HP_VENDOR_ID) | 1824 | fe_rmc = 1; |
1861 | fe_rmc = 1; | 1825 | else |
1862 | else | 1826 | return -ENODEV; |
1863 | return -ENODEV; | 1827 | } |
1864 | 1828 | ||
1865 | error = pci_read_config_word(pci_dev, PCI_MMC_ADDR_CW, &base_addr); | 1829 | error = pci_read_config_word(pci_dev, PCI_MMC_ADDR_CW, &base_addr); |
1866 | if (error) | 1830 | if (error) |
@@ -1873,7 +1837,7 @@ static int find_pci_smic(int intf_num, struct smi_info **new_info) | |||
1873 | } | 1837 | } |
1874 | 1838 | ||
1875 | /* Bit 0: 1 specifies programmed I/O, 0 specifies memory mapped I/O */ | 1839 | /* Bit 0: 1 specifies programmed I/O, 0 specifies memory mapped I/O */ |
1876 | if (!(base_addr & 0x0001)) | 1840 | if (! (base_addr & 0x0001)) |
1877 | { | 1841 | { |
1878 | pci_dev_put(pci_dev); | 1842 | pci_dev_put(pci_dev); |
1879 | printk(KERN_ERR | 1843 | printk(KERN_ERR |
@@ -1883,17 +1847,17 @@ static int find_pci_smic(int intf_num, struct smi_info **new_info) | |||
1883 | } | 1847 | } |
1884 | 1848 | ||
1885 | base_addr &= 0xFFFE; | 1849 | base_addr &= 0xFFFE; |
1886 | if (!fe_rmc) | 1850 | if (! fe_rmc) |
1887 | /* Data register starts at base address + 1 in eRMC */ | 1851 | /* Data register starts at base address + 1 in eRMC */ |
1888 | ++base_addr; | 1852 | ++base_addr; |
1889 | 1853 | ||
1890 | if (!is_new_interface(-1, IPMI_IO_ADDR_SPACE, base_addr)) { | 1854 | if (! is_new_interface(-1, IPMI_IO_ADDR_SPACE, base_addr)) { |
1891 | pci_dev_put(pci_dev); | 1855 | pci_dev_put(pci_dev); |
1892 | return -ENODEV; | 1856 | return -ENODEV; |
1893 | } | 1857 | } |
1894 | 1858 | ||
1895 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 1859 | info = kmalloc(sizeof(*info), GFP_KERNEL); |
1896 | if (!info) { | 1860 | if (! info) { |
1897 | pci_dev_put(pci_dev); | 1861 | pci_dev_put(pci_dev); |
1898 | printk(KERN_ERR "ipmi_si: Could not allocate SI data (5)\n"); | 1862 | printk(KERN_ERR "ipmi_si: Could not allocate SI data (5)\n"); |
1899 | return -ENOMEM; | 1863 | return -ENOMEM; |
@@ -1904,7 +1868,7 @@ static int find_pci_smic(int intf_num, struct smi_info **new_info) | |||
1904 | ports[intf_num] = base_addr; | 1868 | ports[intf_num] = base_addr; |
1905 | info->io.info = &(ports[intf_num]); | 1869 | info->io.info = &(ports[intf_num]); |
1906 | info->io.regspacing = regspacings[intf_num]; | 1870 | info->io.regspacing = regspacings[intf_num]; |
1907 | if (!info->io.regspacing) | 1871 | if (! info->io.regspacing) |
1908 | info->io.regspacing = DEFAULT_REGSPACING; | 1872 | info->io.regspacing = DEFAULT_REGSPACING; |
1909 | info->io.regsize = DEFAULT_REGSPACING; | 1873 | info->io.regsize = DEFAULT_REGSPACING; |
1910 | info->io.regshift = regshifts[intf_num]; | 1874 | info->io.regshift = regshifts[intf_num]; |
@@ -1925,7 +1889,7 @@ static int find_pci_smic(int intf_num, struct smi_info **new_info) | |||
1925 | static int try_init_plug_and_play(int intf_num, struct smi_info **new_info) | 1889 | static int try_init_plug_and_play(int intf_num, struct smi_info **new_info) |
1926 | { | 1890 | { |
1927 | #ifdef CONFIG_PCI | 1891 | #ifdef CONFIG_PCI |
1928 | if (find_pci_smic(intf_num, new_info)==0) | 1892 | if (find_pci_smic(intf_num, new_info) == 0) |
1929 | return 0; | 1893 | return 0; |
1930 | #endif | 1894 | #endif |
1931 | /* Include other methods here. */ | 1895 | /* Include other methods here. */ |
@@ -1943,7 +1907,7 @@ static int try_get_dev_id(struct smi_info *smi_info) | |||
1943 | int rv = 0; | 1907 | int rv = 0; |
1944 | 1908 | ||
1945 | resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL); | 1909 | resp = kmalloc(IPMI_MAX_MSG_LENGTH, GFP_KERNEL); |
1946 | if (!resp) | 1910 | if (! resp) |
1947 | return -ENOMEM; | 1911 | return -ENOMEM; |
1948 | 1912 | ||
1949 | /* Do a Get Device ID command, since it comes back with some | 1913 | /* Do a Get Device ID command, since it comes back with some |
@@ -1992,11 +1956,8 @@ static int try_get_dev_id(struct smi_info *smi_info) | |||
1992 | } | 1956 | } |
1993 | 1957 | ||
1994 | /* Record info from the get device id, in case we need it. */ | 1958 | /* Record info from the get device id, in case we need it. */ |
1995 | smi_info->ipmi_si_dev_rev = resp[4] & 0xf; | 1959 | memcpy(&smi_info->device_id, &resp[3], |
1996 | smi_info->ipmi_si_fw_rev_major = resp[5] & 0x7f; | 1960 | min_t(unsigned long, resp_len-3, sizeof(smi_info->device_id))); |
1997 | smi_info->ipmi_si_fw_rev_minor = resp[6]; | ||
1998 | smi_info->ipmi_version_major = resp[7] & 0xf; | ||
1999 | smi_info->ipmi_version_minor = resp[7] >> 4; | ||
2000 | 1961 | ||
2001 | out: | 1962 | out: |
2002 | kfree(resp); | 1963 | kfree(resp); |
@@ -2028,7 +1989,7 @@ static int stat_file_read_proc(char *page, char **start, off_t off, | |||
2028 | struct smi_info *smi = data; | 1989 | struct smi_info *smi = data; |
2029 | 1990 | ||
2030 | out += sprintf(out, "interrupts_enabled: %d\n", | 1991 | out += sprintf(out, "interrupts_enabled: %d\n", |
2031 | smi->irq && !smi->interrupt_disabled); | 1992 | smi->irq && ! smi->interrupt_disabled); |
2032 | out += sprintf(out, "short_timeouts: %ld\n", | 1993 | out += sprintf(out, "short_timeouts: %ld\n", |
2033 | smi->short_timeouts); | 1994 | smi->short_timeouts); |
2034 | out += sprintf(out, "long_timeouts: %ld\n", | 1995 | out += sprintf(out, "long_timeouts: %ld\n", |
@@ -2057,6 +2018,73 @@ static int stat_file_read_proc(char *page, char **start, off_t off, | |||
2057 | return (out - ((char *) page)); | 2018 | return (out - ((char *) page)); |
2058 | } | 2019 | } |
2059 | 2020 | ||
2021 | /* | ||
2022 | * oem_data_avail_to_receive_msg_avail | ||
2023 | * @info - smi_info structure with msg_flags set | ||
2024 | * | ||
2025 | * Converts flags from OEM_DATA_AVAIL to RECEIVE_MSG_AVAIL | ||
2026 | * Returns 1 indicating need to re-run handle_flags(). | ||
2027 | */ | ||
2028 | static int oem_data_avail_to_receive_msg_avail(struct smi_info *smi_info) | ||
2029 | { | ||
2030 | smi_info->msg_flags = ((smi_info->msg_flags & ~OEM_DATA_AVAIL) | | ||
2031 | RECEIVE_MSG_AVAIL); | ||
2032 | return 1; | ||
2033 | } | ||
2034 | |||
2035 | /* | ||
2036 | * setup_dell_poweredge_oem_data_handler | ||
2037 | * @info - smi_info.device_id must be populated | ||
2038 | * | ||
2039 | * Systems that match, but have firmware version < 1.40 may assert | ||
2040 | * OEM0_DATA_AVAIL on their own, without being told via Set Flags that | ||
2041 | * it's safe to do so. Such systems will de-assert OEM1_DATA_AVAIL | ||
2042 | * upon receipt of IPMI_GET_MSG_CMD, so we should treat these flags | ||
2043 | * as RECEIVE_MSG_AVAIL instead. | ||
2044 | * | ||
2045 | * As Dell has no plans to release IPMI 1.5 firmware that *ever* | ||
2046 | * assert the OEM[012] bits, and if it did, the driver would have to | ||
2047 | * change to handle that properly, we don't actually check for the | ||
2048 | * firmware version. | ||
2049 | * Device ID = 0x20 BMC on PowerEdge 8G servers | ||
2050 | * Device Revision = 0x80 | ||
2051 | * Firmware Revision1 = 0x01 BMC version 1.40 | ||
2052 | * Firmware Revision2 = 0x40 BCD encoded | ||
2053 | * IPMI Version = 0x51 IPMI 1.5 | ||
2054 | * Manufacturer ID = A2 02 00 Dell IANA | ||
2055 | * | ||
2056 | */ | ||
2057 | #define DELL_POWEREDGE_8G_BMC_DEVICE_ID 0x20 | ||
2058 | #define DELL_POWEREDGE_8G_BMC_DEVICE_REV 0x80 | ||
2059 | #define DELL_POWEREDGE_8G_BMC_IPMI_VERSION 0x51 | ||
2060 | #define DELL_IANA_MFR_ID {0xA2, 0x02, 0x00} | ||
2061 | static void setup_dell_poweredge_oem_data_handler(struct smi_info *smi_info) | ||
2062 | { | ||
2063 | struct ipmi_device_id *id = &smi_info->device_id; | ||
2064 | const char mfr[3]=DELL_IANA_MFR_ID; | ||
2065 | if (! memcmp(mfr, id->manufacturer_id, sizeof(mfr)) | ||
2066 | && (id->device_id == DELL_POWEREDGE_8G_BMC_DEVICE_ID) | ||
2067 | && (id->device_revision == DELL_POWEREDGE_8G_BMC_DEVICE_REV) | ||
2068 | && (id->ipmi_version == DELL_POWEREDGE_8G_BMC_IPMI_VERSION)) | ||
2069 | { | ||
2070 | smi_info->oem_data_avail_handler = | ||
2071 | oem_data_avail_to_receive_msg_avail; | ||
2072 | } | ||
2073 | } | ||
2074 | |||
2075 | /* | ||
2076 | * setup_oem_data_handler | ||
2077 | * @info - smi_info.device_id must be filled in already | ||
2078 | * | ||
2079 | * Fills in smi_info.device_id.oem_data_available_handler | ||
2080 | * when we know what function to use there. | ||
2081 | */ | ||
2082 | |||
2083 | static void setup_oem_data_handler(struct smi_info *smi_info) | ||
2084 | { | ||
2085 | setup_dell_poweredge_oem_data_handler(smi_info); | ||
2086 | } | ||
2087 | |||
2060 | /* Returns 0 if initialized, or negative on an error. */ | 2088 | /* Returns 0 if initialized, or negative on an error. */ |
2061 | static int init_one_smi(int intf_num, struct smi_info **smi) | 2089 | static int init_one_smi(int intf_num, struct smi_info **smi) |
2062 | { | 2090 | { |
@@ -2067,20 +2095,16 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2067 | rv = try_init_mem(intf_num, &new_smi); | 2095 | rv = try_init_mem(intf_num, &new_smi); |
2068 | if (rv) | 2096 | if (rv) |
2069 | rv = try_init_port(intf_num, &new_smi); | 2097 | rv = try_init_port(intf_num, &new_smi); |
2070 | #ifdef CONFIG_ACPI_INTERPRETER | 2098 | #ifdef CONFIG_ACPI |
2071 | if ((rv) && (si_trydefaults)) { | 2099 | if (rv && si_trydefaults) |
2072 | rv = try_init_acpi(intf_num, &new_smi); | 2100 | rv = try_init_acpi(intf_num, &new_smi); |
2073 | } | ||
2074 | #endif | 2101 | #endif |
2075 | #ifdef CONFIG_X86 | 2102 | #ifdef CONFIG_X86 |
2076 | if ((rv) && (si_trydefaults)) { | 2103 | if (rv && si_trydefaults) |
2077 | rv = try_init_smbios(intf_num, &new_smi); | 2104 | rv = try_init_smbios(intf_num, &new_smi); |
2078 | } | ||
2079 | #endif | 2105 | #endif |
2080 | if ((rv) && (si_trydefaults)) { | 2106 | if (rv && si_trydefaults) |
2081 | rv = try_init_plug_and_play(intf_num, &new_smi); | 2107 | rv = try_init_plug_and_play(intf_num, &new_smi); |
2082 | } | ||
2083 | |||
2084 | 2108 | ||
2085 | if (rv) | 2109 | if (rv) |
2086 | return rv; | 2110 | return rv; |
@@ -2090,7 +2114,7 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2090 | new_smi->si_sm = NULL; | 2114 | new_smi->si_sm = NULL; |
2091 | new_smi->handlers = NULL; | 2115 | new_smi->handlers = NULL; |
2092 | 2116 | ||
2093 | if (!new_smi->irq_setup) { | 2117 | if (! new_smi->irq_setup) { |
2094 | new_smi->irq = irqs[intf_num]; | 2118 | new_smi->irq = irqs[intf_num]; |
2095 | new_smi->irq_setup = std_irq_setup; | 2119 | new_smi->irq_setup = std_irq_setup; |
2096 | new_smi->irq_cleanup = std_irq_cleanup; | 2120 | new_smi->irq_cleanup = std_irq_cleanup; |
@@ -2124,7 +2148,7 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2124 | 2148 | ||
2125 | /* Allocate the state machine's data and initialize it. */ | 2149 | /* Allocate the state machine's data and initialize it. */ |
2126 | new_smi->si_sm = kmalloc(new_smi->handlers->size(), GFP_KERNEL); | 2150 | new_smi->si_sm = kmalloc(new_smi->handlers->size(), GFP_KERNEL); |
2127 | if (!new_smi->si_sm) { | 2151 | if (! new_smi->si_sm) { |
2128 | printk(" Could not allocate state machine memory\n"); | 2152 | printk(" Could not allocate state machine memory\n"); |
2129 | rv = -ENOMEM; | 2153 | rv = -ENOMEM; |
2130 | goto out_err; | 2154 | goto out_err; |
@@ -2155,6 +2179,8 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2155 | if (rv) | 2179 | if (rv) |
2156 | goto out_err; | 2180 | goto out_err; |
2157 | 2181 | ||
2182 | setup_oem_data_handler(new_smi); | ||
2183 | |||
2158 | /* Try to claim any interrupts. */ | 2184 | /* Try to claim any interrupts. */ |
2159 | new_smi->irq_setup(new_smi); | 2185 | new_smi->irq_setup(new_smi); |
2160 | 2186 | ||
@@ -2188,8 +2214,8 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2188 | 2214 | ||
2189 | rv = ipmi_register_smi(&handlers, | 2215 | rv = ipmi_register_smi(&handlers, |
2190 | new_smi, | 2216 | new_smi, |
2191 | new_smi->ipmi_version_major, | 2217 | ipmi_version_major(&new_smi->device_id), |
2192 | new_smi->ipmi_version_minor, | 2218 | ipmi_version_minor(&new_smi->device_id), |
2193 | new_smi->slave_addr, | 2219 | new_smi->slave_addr, |
2194 | &(new_smi->intf)); | 2220 | &(new_smi->intf)); |
2195 | if (rv) { | 2221 | if (rv) { |
@@ -2230,7 +2256,7 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2230 | 2256 | ||
2231 | /* Wait for the timer to stop. This avoids problems with race | 2257 | /* Wait for the timer to stop. This avoids problems with race |
2232 | conditions removing the timer here. */ | 2258 | conditions removing the timer here. */ |
2233 | while (!new_smi->timer_stopped) { | 2259 | while (! new_smi->timer_stopped) { |
2234 | set_current_state(TASK_UNINTERRUPTIBLE); | 2260 | set_current_state(TASK_UNINTERRUPTIBLE); |
2235 | schedule_timeout(1); | 2261 | schedule_timeout(1); |
2236 | } | 2262 | } |
@@ -2270,7 +2296,7 @@ static __init int init_ipmi_si(void) | |||
2270 | /* Parse out the si_type string into its components. */ | 2296 | /* Parse out the si_type string into its components. */ |
2271 | str = si_type_str; | 2297 | str = si_type_str; |
2272 | if (*str != '\0') { | 2298 | if (*str != '\0') { |
2273 | for (i=0; (i<SI_MAX_PARMS) && (*str != '\0'); i++) { | 2299 | for (i = 0; (i < SI_MAX_PARMS) && (*str != '\0'); i++) { |
2274 | si_type[i] = str; | 2300 | si_type[i] = str; |
2275 | str = strchr(str, ','); | 2301 | str = strchr(str, ','); |
2276 | if (str) { | 2302 | if (str) { |
@@ -2282,22 +2308,14 @@ static __init int init_ipmi_si(void) | |||
2282 | } | 2308 | } |
2283 | } | 2309 | } |
2284 | 2310 | ||
2285 | printk(KERN_INFO "IPMI System Interface driver version " | 2311 | printk(KERN_INFO "IPMI System Interface driver.\n"); |
2286 | IPMI_SI_VERSION); | ||
2287 | if (kcs_smi_handlers.version) | ||
2288 | printk(", KCS version %s", kcs_smi_handlers.version); | ||
2289 | if (smic_smi_handlers.version) | ||
2290 | printk(", SMIC version %s", smic_smi_handlers.version); | ||
2291 | if (bt_smi_handlers.version) | ||
2292 | printk(", BT version %s", bt_smi_handlers.version); | ||
2293 | printk("\n"); | ||
2294 | 2312 | ||
2295 | #ifdef CONFIG_X86 | 2313 | #ifdef CONFIG_X86 |
2296 | dmi_decode(); | 2314 | dmi_find_bmc(); |
2297 | #endif | 2315 | #endif |
2298 | 2316 | ||
2299 | rv = init_one_smi(0, &(smi_infos[pos])); | 2317 | rv = init_one_smi(0, &(smi_infos[pos])); |
2300 | if (rv && !ports[0] && si_trydefaults) { | 2318 | if (rv && ! ports[0] && si_trydefaults) { |
2301 | /* If we are trying defaults and the initial port is | 2319 | /* If we are trying defaults and the initial port is |
2302 | not set, then set it. */ | 2320 | not set, then set it. */ |
2303 | si_type[0] = "kcs"; | 2321 | si_type[0] = "kcs"; |
@@ -2319,7 +2337,7 @@ static __init int init_ipmi_si(void) | |||
2319 | if (rv == 0) | 2337 | if (rv == 0) |
2320 | pos++; | 2338 | pos++; |
2321 | 2339 | ||
2322 | for (i=1; i < SI_MAX_PARMS; i++) { | 2340 | for (i = 1; i < SI_MAX_PARMS; i++) { |
2323 | rv = init_one_smi(i, &(smi_infos[pos])); | 2341 | rv = init_one_smi(i, &(smi_infos[pos])); |
2324 | if (rv == 0) | 2342 | if (rv == 0) |
2325 | pos++; | 2343 | pos++; |
@@ -2361,14 +2379,14 @@ static void __exit cleanup_one_si(struct smi_info *to_clean) | |||
2361 | 2379 | ||
2362 | /* Wait for the timer to stop. This avoids problems with race | 2380 | /* Wait for the timer to stop. This avoids problems with race |
2363 | conditions removing the timer here. */ | 2381 | conditions removing the timer here. */ |
2364 | while (!to_clean->timer_stopped) { | 2382 | while (! to_clean->timer_stopped) { |
2365 | set_current_state(TASK_UNINTERRUPTIBLE); | 2383 | set_current_state(TASK_UNINTERRUPTIBLE); |
2366 | schedule_timeout(1); | 2384 | schedule_timeout(1); |
2367 | } | 2385 | } |
2368 | 2386 | ||
2369 | /* Interrupts and timeouts are stopped, now make sure the | 2387 | /* Interrupts and timeouts are stopped, now make sure the |
2370 | interface is in a clean state. */ | 2388 | interface is in a clean state. */ |
2371 | while ((to_clean->curr_msg) || (to_clean->si_state != SI_NORMAL)) { | 2389 | while (to_clean->curr_msg || (to_clean->si_state != SI_NORMAL)) { |
2372 | poll(to_clean); | 2390 | poll(to_clean); |
2373 | set_current_state(TASK_UNINTERRUPTIBLE); | 2391 | set_current_state(TASK_UNINTERRUPTIBLE); |
2374 | schedule_timeout(1); | 2392 | schedule_timeout(1); |
@@ -2392,13 +2410,15 @@ static __exit void cleanup_ipmi_si(void) | |||
2392 | { | 2410 | { |
2393 | int i; | 2411 | int i; |
2394 | 2412 | ||
2395 | if (!initialized) | 2413 | if (! initialized) |
2396 | return; | 2414 | return; |
2397 | 2415 | ||
2398 | for (i=0; i<SI_MAX_DRIVERS; i++) { | 2416 | for (i = 0; i < SI_MAX_DRIVERS; i++) { |
2399 | cleanup_one_si(smi_infos[i]); | 2417 | cleanup_one_si(smi_infos[i]); |
2400 | } | 2418 | } |
2401 | } | 2419 | } |
2402 | module_exit(cleanup_ipmi_si); | 2420 | module_exit(cleanup_ipmi_si); |
2403 | 2421 | ||
2404 | MODULE_LICENSE("GPL"); | 2422 | MODULE_LICENSE("GPL"); |
2423 | MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); | ||
2424 | MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT system interfaces."); | ||
diff --git a/drivers/char/ipmi/ipmi_smic_sm.c b/drivers/char/ipmi/ipmi_smic_sm.c index ae18747e670b..add2aa2732f0 100644 --- a/drivers/char/ipmi/ipmi_smic_sm.c +++ b/drivers/char/ipmi/ipmi_smic_sm.c | |||
@@ -46,8 +46,6 @@ | |||
46 | #include <linux/ipmi_msgdefs.h> /* for completion codes */ | 46 | #include <linux/ipmi_msgdefs.h> /* for completion codes */ |
47 | #include "ipmi_si_sm.h" | 47 | #include "ipmi_si_sm.h" |
48 | 48 | ||
49 | #define IPMI_SMIC_VERSION "v33" | ||
50 | |||
51 | /* smic_debug is a bit-field | 49 | /* smic_debug is a bit-field |
52 | * SMIC_DEBUG_ENABLE - turned on for now | 50 | * SMIC_DEBUG_ENABLE - turned on for now |
53 | * SMIC_DEBUG_MSG - commands and their responses | 51 | * SMIC_DEBUG_MSG - commands and their responses |
@@ -588,7 +586,6 @@ static int smic_size(void) | |||
588 | 586 | ||
589 | struct si_sm_handlers smic_smi_handlers = | 587 | struct si_sm_handlers smic_smi_handlers = |
590 | { | 588 | { |
591 | .version = IPMI_SMIC_VERSION, | ||
592 | .init_data = init_smic_data, | 589 | .init_data = init_smic_data, |
593 | .start_transaction = start_smic_transaction, | 590 | .start_transaction = start_smic_transaction, |
594 | .get_result = smic_get_result, | 591 | .get_result = smic_get_result, |
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index d35a953961cb..e71aaae855ad 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c | |||
@@ -53,8 +53,6 @@ | |||
53 | 53 | ||
54 | #define PFX "IPMI Watchdog: " | 54 | #define PFX "IPMI Watchdog: " |
55 | 55 | ||
56 | #define IPMI_WATCHDOG_VERSION "v33" | ||
57 | |||
58 | /* | 56 | /* |
59 | * The IPMI command/response information for the watchdog timer. | 57 | * The IPMI command/response information for the watchdog timer. |
60 | */ | 58 | */ |
@@ -259,7 +257,7 @@ static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg, | |||
259 | 257 | ||
260 | data[1] = 0; | 258 | data[1] = 0; |
261 | WDOG_SET_TIMEOUT_ACT(data[1], ipmi_watchdog_state); | 259 | WDOG_SET_TIMEOUT_ACT(data[1], ipmi_watchdog_state); |
262 | if (pretimeout > 0) { | 260 | if ((pretimeout > 0) && (ipmi_watchdog_state != WDOG_TIMEOUT_NONE)) { |
263 | WDOG_SET_PRETIMEOUT_ACT(data[1], preaction_val); | 261 | WDOG_SET_PRETIMEOUT_ACT(data[1], preaction_val); |
264 | data[2] = pretimeout; | 262 | data[2] = pretimeout; |
265 | } else { | 263 | } else { |
@@ -659,19 +657,18 @@ static ssize_t ipmi_read(struct file *file, | |||
659 | 657 | ||
660 | static int ipmi_open(struct inode *ino, struct file *filep) | 658 | static int ipmi_open(struct inode *ino, struct file *filep) |
661 | { | 659 | { |
662 | switch (iminor(ino)) | 660 | switch (iminor(ino)) { |
663 | { | 661 | case WATCHDOG_MINOR: |
664 | case WATCHDOG_MINOR: | 662 | if (test_and_set_bit(0, &ipmi_wdog_open)) |
665 | if(test_and_set_bit(0, &ipmi_wdog_open)) | ||
666 | return -EBUSY; | 663 | return -EBUSY; |
667 | 664 | ||
668 | /* Don't start the timer now, let it start on the | 665 | /* Don't start the timer now, let it start on the |
669 | first heartbeat. */ | 666 | first heartbeat. */ |
670 | ipmi_start_timer_on_heartbeat = 1; | 667 | ipmi_start_timer_on_heartbeat = 1; |
671 | return nonseekable_open(ino, filep); | 668 | return nonseekable_open(ino, filep); |
672 | 669 | ||
673 | default: | 670 | default: |
674 | return (-ENODEV); | 671 | return (-ENODEV); |
675 | } | 672 | } |
676 | } | 673 | } |
677 | 674 | ||
@@ -817,15 +814,19 @@ static void ipmi_register_watchdog(int ipmi_intf) | |||
817 | static int | 814 | static int |
818 | ipmi_nmi(void *dev_id, struct pt_regs *regs, int cpu, int handled) | 815 | ipmi_nmi(void *dev_id, struct pt_regs *regs, int cpu, int handled) |
819 | { | 816 | { |
817 | /* If we are not expecting a timeout, ignore it. */ | ||
818 | if (ipmi_watchdog_state == WDOG_TIMEOUT_NONE) | ||
819 | return NOTIFY_DONE; | ||
820 | |||
820 | /* If no one else handled the NMI, we assume it was the IPMI | 821 | /* If no one else handled the NMI, we assume it was the IPMI |
821 | watchdog. */ | 822 | watchdog. */ |
822 | if ((!handled) && (preop_val == WDOG_PREOP_PANIC)) | 823 | if ((!handled) && (preop_val == WDOG_PREOP_PANIC)) { |
824 | /* On some machines, the heartbeat will give | ||
825 | an error and not work unless we re-enable | ||
826 | the timer. So do so. */ | ||
827 | pretimeout_since_last_heartbeat = 1; | ||
823 | panic(PFX "pre-timeout"); | 828 | panic(PFX "pre-timeout"); |
824 | 829 | } | |
825 | /* On some machines, the heartbeat will give | ||
826 | an error and not work unless we re-enable | ||
827 | the timer. So do so. */ | ||
828 | pretimeout_since_last_heartbeat = 1; | ||
829 | 830 | ||
830 | return NOTIFY_DONE; | 831 | return NOTIFY_DONE; |
831 | } | 832 | } |
@@ -924,9 +925,6 @@ static int __init ipmi_wdog_init(void) | |||
924 | { | 925 | { |
925 | int rv; | 926 | int rv; |
926 | 927 | ||
927 | printk(KERN_INFO PFX "driver version " | ||
928 | IPMI_WATCHDOG_VERSION "\n"); | ||
929 | |||
930 | if (strcmp(action, "reset") == 0) { | 928 | if (strcmp(action, "reset") == 0) { |
931 | action_val = WDOG_TIMEOUT_RESET; | 929 | action_val = WDOG_TIMEOUT_RESET; |
932 | } else if (strcmp(action, "none") == 0) { | 930 | } else if (strcmp(action, "none") == 0) { |
@@ -1011,6 +1009,8 @@ static int __init ipmi_wdog_init(void) | |||
1011 | register_reboot_notifier(&wdog_reboot_notifier); | 1009 | register_reboot_notifier(&wdog_reboot_notifier); |
1012 | notifier_chain_register(&panic_notifier_list, &wdog_panic_notifier); | 1010 | notifier_chain_register(&panic_notifier_list, &wdog_panic_notifier); |
1013 | 1011 | ||
1012 | printk(KERN_INFO PFX "driver initialized\n"); | ||
1013 | |||
1014 | return 0; | 1014 | return 0; |
1015 | } | 1015 | } |
1016 | 1016 | ||
@@ -1062,3 +1062,5 @@ static void __exit ipmi_wdog_exit(void) | |||
1062 | module_exit(ipmi_wdog_exit); | 1062 | module_exit(ipmi_wdog_exit); |
1063 | module_init(ipmi_wdog_init); | 1063 | module_init(ipmi_wdog_init); |
1064 | MODULE_LICENSE("GPL"); | 1064 | MODULE_LICENSE("GPL"); |
1065 | MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); | ||
1066 | MODULE_DESCRIPTION("watchdog timer based upon the IPMI interface."); | ||
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index 52a073eee201..9c19e5435a11 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c | |||
@@ -780,7 +780,7 @@ static struct file_operations stli_fsiomem = { | |||
780 | * much cheaper on host cpu than using interrupts. It turns out to | 780 | * much cheaper on host cpu than using interrupts. It turns out to |
781 | * not increase character latency by much either... | 781 | * not increase character latency by much either... |
782 | */ | 782 | */ |
783 | static struct timer_list stli_timerlist = TIMER_INITIALIZER(stli_poll, 0, 0); | 783 | static DEFINE_TIMER(stli_timerlist, stli_poll, 0, 0); |
784 | 784 | ||
785 | static int stli_timeron; | 785 | static int stli_timeron; |
786 | 786 | ||
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 1ddaabeb8ef8..b12d58ee532b 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c | |||
@@ -233,8 +233,7 @@ static void kd_nosound(unsigned long ignored) | |||
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | static struct timer_list kd_mksound_timer = | 236 | static DEFINE_TIMER(kd_mksound_timer, kd_nosound, 0, 0); |
237 | TIMER_INITIALIZER(kd_nosound, 0, 0); | ||
238 | 237 | ||
239 | void kd_mksound(unsigned int hz, unsigned int ticks) | 238 | void kd_mksound(unsigned int hz, unsigned int ticks) |
240 | { | 239 | { |
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c index 115dbb35334b..3fa64c631108 100644 --- a/drivers/char/mbcs.c +++ b/drivers/char/mbcs.c | |||
@@ -750,7 +750,7 @@ static int mbcs_probe(struct cx_dev *dev, const struct cx_device_id *id) | |||
750 | 750 | ||
751 | dev->soft = NULL; | 751 | dev->soft = NULL; |
752 | 752 | ||
753 | soft = kcalloc(1, sizeof(struct mbcs_soft), GFP_KERNEL); | 753 | soft = kzalloc(sizeof(struct mbcs_soft), GFP_KERNEL); |
754 | if (soft == NULL) | 754 | if (soft == NULL) |
755 | return -ENOMEM; | 755 | return -ENOMEM; |
756 | 756 | ||
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 850a78c9c4bc..f182752fe918 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -35,10 +35,6 @@ | |||
35 | # include <linux/efi.h> | 35 | # include <linux/efi.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #if defined(CONFIG_S390_TAPE) && defined(CONFIG_S390_TAPE_CHAR) | ||
39 | extern void tapechar_init(void); | ||
40 | #endif | ||
41 | |||
42 | /* | 38 | /* |
43 | * Architectures vary in how they handle caching for addresses | 39 | * Architectures vary in how they handle caching for addresses |
44 | * outside of main memory. | 40 | * outside of main memory. |
diff --git a/drivers/char/misc.c b/drivers/char/misc.c index 931efd58f87a..0c8375165e29 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c | |||
@@ -63,8 +63,6 @@ static DECLARE_MUTEX(misc_sem); | |||
63 | #define DYNAMIC_MINORS 64 /* like dynamic majors */ | 63 | #define DYNAMIC_MINORS 64 /* like dynamic majors */ |
64 | static unsigned char misc_minors[DYNAMIC_MINORS / 8]; | 64 | static unsigned char misc_minors[DYNAMIC_MINORS / 8]; |
65 | 65 | ||
66 | extern int rtc_DP8570A_init(void); | ||
67 | extern int rtc_MK48T08_init(void); | ||
68 | extern int pmu_device_init(void); | 66 | extern int pmu_device_init(void); |
69 | 67 | ||
70 | #ifdef CONFIG_PROC_FS | 68 | #ifdef CONFIG_PROC_FS |
@@ -303,12 +301,7 @@ static int __init misc_init(void) | |||
303 | misc_class = class_create(THIS_MODULE, "misc"); | 301 | misc_class = class_create(THIS_MODULE, "misc"); |
304 | if (IS_ERR(misc_class)) | 302 | if (IS_ERR(misc_class)) |
305 | return PTR_ERR(misc_class); | 303 | return PTR_ERR(misc_class); |
306 | #ifdef CONFIG_MVME16x | 304 | |
307 | rtc_MK48T08_init(); | ||
308 | #endif | ||
309 | #ifdef CONFIG_BVME6000 | ||
310 | rtc_DP8570A_init(); | ||
311 | #endif | ||
312 | if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) { | 305 | if (register_chrdev(MISC_MAJOR,"misc",&misc_fops)) { |
313 | printk("unable to get major %d for misc devices\n", | 306 | printk("unable to get major %d for misc devices\n", |
314 | MISC_MAJOR); | 307 | MISC_MAJOR); |
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 95f7046ff059..79e490ef2cf2 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -339,7 +339,7 @@ static int __init moxa_init(void) | |||
339 | 339 | ||
340 | init_MUTEX(&moxaBuffSem); | 340 | init_MUTEX(&moxaBuffSem); |
341 | moxaDriver->owner = THIS_MODULE; | 341 | moxaDriver->owner = THIS_MODULE; |
342 | moxaDriver->name = "ttya"; | 342 | moxaDriver->name = "ttyMX"; |
343 | moxaDriver->devfs_name = "tts/a"; | 343 | moxaDriver->devfs_name = "tts/a"; |
344 | moxaDriver->major = ttymajor; | 344 | moxaDriver->major = ttymajor; |
345 | moxaDriver->minor_start = 0; | 345 | moxaDriver->minor_start = 0; |
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index f022f0944434..d0ef1ae41298 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -63,7 +63,6 @@ | |||
63 | #include <asm/system.h> | 63 | #include <asm/system.h> |
64 | #include <asm/io.h> | 64 | #include <asm/io.h> |
65 | #include <asm/irq.h> | 65 | #include <asm/irq.h> |
66 | #include <asm/segment.h> | ||
67 | #include <asm/bitops.h> | 66 | #include <asm/bitops.h> |
68 | #include <asm/uaccess.h> | 67 | #include <asm/uaccess.h> |
69 | 68 | ||
diff --git a/drivers/char/pty.c b/drivers/char/pty.c index da32889d22c0..49f3997fd251 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c | |||
@@ -149,15 +149,14 @@ static int pty_write_room(struct tty_struct *tty) | |||
149 | static int pty_chars_in_buffer(struct tty_struct *tty) | 149 | static int pty_chars_in_buffer(struct tty_struct *tty) |
150 | { | 150 | { |
151 | struct tty_struct *to = tty->link; | 151 | struct tty_struct *to = tty->link; |
152 | ssize_t (*chars_in_buffer)(struct tty_struct *); | ||
153 | int count; | 152 | int count; |
154 | 153 | ||
155 | /* We should get the line discipline lock for "tty->link" */ | 154 | /* We should get the line discipline lock for "tty->link" */ |
156 | if (!to || !(chars_in_buffer = to->ldisc.chars_in_buffer)) | 155 | if (!to || !to->ldisc.chars_in_buffer) |
157 | return 0; | 156 | return 0; |
158 | 157 | ||
159 | /* The ldisc must report 0 if no characters available to be read */ | 158 | /* The ldisc must report 0 if no characters available to be read */ |
160 | count = chars_in_buffer(to); | 159 | count = to->ldisc.chars_in_buffer(to); |
161 | 160 | ||
162 | if (tty->driver->subtype == PTY_TYPE_SLAVE) return count; | 161 | if (tty->driver->subtype == PTY_TYPE_SLAVE) return count; |
163 | 162 | ||
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index cd4fe8b1709f..63fff7c1244a 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c | |||
@@ -938,10 +938,9 @@ found: | |||
938 | 938 | ||
939 | /* | 939 | /* |
940 | * XXX Interrupt pin #7 in Espresso is shared between RTC and | 940 | * XXX Interrupt pin #7 in Espresso is shared between RTC and |
941 | * PCI Slot 2 INTA# (and some INTx# in Slot 1). SA_INTERRUPT here | 941 | * PCI Slot 2 INTA# (and some INTx# in Slot 1). |
942 | * is asking for trouble with add-on boards. Change to SA_SHIRQ. | ||
943 | */ | 942 | */ |
944 | if (request_irq(rtc_irq, rtc_interrupt, SA_INTERRUPT, "rtc", (void *)&rtc_port)) { | 943 | if (request_irq(rtc_irq, rtc_interrupt, SA_SHIRQ, "rtc", (void *)&rtc_port)) { |
945 | /* | 944 | /* |
946 | * Standard way for sparc to print irq's is to use | 945 | * Standard way for sparc to print irq's is to use |
947 | * __irq_itoa(). I think for EBus it's ok to use %d. | 946 | * __irq_itoa(). I think for EBus it's ok to use %d. |
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index cefbe985e55c..36ae9ad2598c 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
@@ -98,12 +98,13 @@ MODULE_PARM_DESC(useinput, | |||
98 | 98 | ||
99 | #define SONYPI_DEVICE_MODEL_TYPE1 1 | 99 | #define SONYPI_DEVICE_MODEL_TYPE1 1 |
100 | #define SONYPI_DEVICE_MODEL_TYPE2 2 | 100 | #define SONYPI_DEVICE_MODEL_TYPE2 2 |
101 | #define SONYPI_DEVICE_MODEL_TYPE3 3 | ||
101 | 102 | ||
102 | /* type1 models use those */ | 103 | /* type1 models use those */ |
103 | #define SONYPI_IRQ_PORT 0x8034 | 104 | #define SONYPI_IRQ_PORT 0x8034 |
104 | #define SONYPI_IRQ_SHIFT 22 | 105 | #define SONYPI_IRQ_SHIFT 22 |
105 | #define SONYPI_BASE 0x50 | 106 | #define SONYPI_TYPE1_BASE 0x50 |
106 | #define SONYPI_G10A (SONYPI_BASE+0x14) | 107 | #define SONYPI_G10A (SONYPI_TYPE1_BASE+0x14) |
107 | #define SONYPI_TYPE1_REGION_SIZE 0x08 | 108 | #define SONYPI_TYPE1_REGION_SIZE 0x08 |
108 | #define SONYPI_TYPE1_EVTYPE_OFFSET 0x04 | 109 | #define SONYPI_TYPE1_EVTYPE_OFFSET 0x04 |
109 | 110 | ||
@@ -114,6 +115,13 @@ MODULE_PARM_DESC(useinput, | |||
114 | #define SONYPI_TYPE2_REGION_SIZE 0x20 | 115 | #define SONYPI_TYPE2_REGION_SIZE 0x20 |
115 | #define SONYPI_TYPE2_EVTYPE_OFFSET 0x12 | 116 | #define SONYPI_TYPE2_EVTYPE_OFFSET 0x12 |
116 | 117 | ||
118 | /* type3 series specifics */ | ||
119 | #define SONYPI_TYPE3_BASE 0x40 | ||
120 | #define SONYPI_TYPE3_GID2 (SONYPI_TYPE3_BASE+0x48) /* 16 bits */ | ||
121 | #define SONYPI_TYPE3_MISC (SONYPI_TYPE3_BASE+0x6d) /* 8 bits */ | ||
122 | #define SONYPI_TYPE3_REGION_SIZE 0x20 | ||
123 | #define SONYPI_TYPE3_EVTYPE_OFFSET 0x12 | ||
124 | |||
117 | /* battery / brightness addresses */ | 125 | /* battery / brightness addresses */ |
118 | #define SONYPI_BAT_FLAGS 0x81 | 126 | #define SONYPI_BAT_FLAGS 0x81 |
119 | #define SONYPI_LCD_LIGHT 0x96 | 127 | #define SONYPI_LCD_LIGHT 0x96 |
@@ -159,6 +167,10 @@ static struct sonypi_ioport_list sonypi_type2_ioport_list[] = { | |||
159 | { 0x0, 0x0 } | 167 | { 0x0, 0x0 } |
160 | }; | 168 | }; |
161 | 169 | ||
170 | /* same as in type 2 models */ | ||
171 | static struct sonypi_ioport_list *sonypi_type3_ioport_list = | ||
172 | sonypi_type2_ioport_list; | ||
173 | |||
162 | /* The set of possible interrupts */ | 174 | /* The set of possible interrupts */ |
163 | struct sonypi_irq_list { | 175 | struct sonypi_irq_list { |
164 | u16 irq; | 176 | u16 irq; |
@@ -180,6 +192,9 @@ static struct sonypi_irq_list sonypi_type2_irq_list[] = { | |||
180 | { 0, 0x00 } /* no IRQ, 0x00 in SIRQ in AML */ | 192 | { 0, 0x00 } /* no IRQ, 0x00 in SIRQ in AML */ |
181 | }; | 193 | }; |
182 | 194 | ||
195 | /* same as in type2 models */ | ||
196 | static struct sonypi_irq_list *sonypi_type3_irq_list = sonypi_type2_irq_list; | ||
197 | |||
183 | #define SONYPI_CAMERA_BRIGHTNESS 0 | 198 | #define SONYPI_CAMERA_BRIGHTNESS 0 |
184 | #define SONYPI_CAMERA_CONTRAST 1 | 199 | #define SONYPI_CAMERA_CONTRAST 1 |
185 | #define SONYPI_CAMERA_HUE 2 | 200 | #define SONYPI_CAMERA_HUE 2 |
@@ -223,6 +238,7 @@ static struct sonypi_irq_list sonypi_type2_irq_list[] = { | |||
223 | #define SONYPI_MEYE_MASK 0x00000400 | 238 | #define SONYPI_MEYE_MASK 0x00000400 |
224 | #define SONYPI_MEMORYSTICK_MASK 0x00000800 | 239 | #define SONYPI_MEMORYSTICK_MASK 0x00000800 |
225 | #define SONYPI_BATTERY_MASK 0x00001000 | 240 | #define SONYPI_BATTERY_MASK 0x00001000 |
241 | #define SONYPI_WIRELESS_MASK 0x00002000 | ||
226 | 242 | ||
227 | struct sonypi_event { | 243 | struct sonypi_event { |
228 | u8 data; | 244 | u8 data; |
@@ -305,6 +321,13 @@ static struct sonypi_event sonypi_blueev[] = { | |||
305 | { 0, 0 } | 321 | { 0, 0 } |
306 | }; | 322 | }; |
307 | 323 | ||
324 | /* The set of possible wireless events */ | ||
325 | static struct sonypi_event sonypi_wlessev[] = { | ||
326 | { 0x59, SONYPI_EVENT_WIRELESS_ON }, | ||
327 | { 0x5a, SONYPI_EVENT_WIRELESS_OFF }, | ||
328 | { 0, 0 } | ||
329 | }; | ||
330 | |||
308 | /* The set of possible back button events */ | 331 | /* The set of possible back button events */ |
309 | static struct sonypi_event sonypi_backev[] = { | 332 | static struct sonypi_event sonypi_backev[] = { |
310 | { 0x20, SONYPI_EVENT_BACK_PRESSED }, | 333 | { 0x20, SONYPI_EVENT_BACK_PRESSED }, |
@@ -383,7 +406,6 @@ static struct sonypi_eventtypes { | |||
383 | { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_BLUETOOTH_MASK, sonypi_blueev }, | 406 | { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_BLUETOOTH_MASK, sonypi_blueev }, |
384 | { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_PKEY_MASK, sonypi_pkeyev }, | 407 | { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_PKEY_MASK, sonypi_pkeyev }, |
385 | { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_BACK_MASK, sonypi_backev }, | 408 | { SONYPI_DEVICE_MODEL_TYPE2, 0x11, SONYPI_BACK_MASK, sonypi_backev }, |
386 | { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_HELP_MASK, sonypi_helpev }, | ||
387 | { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_HELP_MASK, sonypi_helpev }, | 409 | { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_HELP_MASK, sonypi_helpev }, |
388 | { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_ZOOM_MASK, sonypi_zoomev }, | 410 | { SONYPI_DEVICE_MODEL_TYPE2, 0x21, SONYPI_ZOOM_MASK, sonypi_zoomev }, |
389 | { SONYPI_DEVICE_MODEL_TYPE2, 0x20, SONYPI_THUMBPHRASE_MASK, sonypi_thumbphraseev }, | 411 | { SONYPI_DEVICE_MODEL_TYPE2, 0x20, SONYPI_THUMBPHRASE_MASK, sonypi_thumbphraseev }, |
@@ -391,6 +413,12 @@ static struct sonypi_eventtypes { | |||
391 | { SONYPI_DEVICE_MODEL_TYPE2, 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev }, | 413 | { SONYPI_DEVICE_MODEL_TYPE2, 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev }, |
392 | { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_PKEY_MASK, sonypi_pkeyev }, | 414 | { SONYPI_DEVICE_MODEL_TYPE2, 0x31, SONYPI_PKEY_MASK, sonypi_pkeyev }, |
393 | 415 | ||
416 | { SONYPI_DEVICE_MODEL_TYPE3, 0, 0xffffffff, sonypi_releaseev }, | ||
417 | { SONYPI_DEVICE_MODEL_TYPE3, 0x21, SONYPI_FNKEY_MASK, sonypi_fnkeyev }, | ||
418 | { SONYPI_DEVICE_MODEL_TYPE3, 0x31, SONYPI_WIRELESS_MASK, sonypi_wlessev }, | ||
419 | { SONYPI_DEVICE_MODEL_TYPE3, 0x31, SONYPI_MEMORYSTICK_MASK, sonypi_memorystickev }, | ||
420 | { SONYPI_DEVICE_MODEL_TYPE3, 0x41, SONYPI_BATTERY_MASK, sonypi_batteryev }, | ||
421 | { SONYPI_DEVICE_MODEL_TYPE3, 0x31, SONYPI_PKEY_MASK, sonypi_pkeyev }, | ||
394 | { 0 } | 422 | { 0 } |
395 | }; | 423 | }; |
396 | 424 | ||
@@ -563,6 +591,23 @@ static void sonypi_type2_srs(void) | |||
563 | udelay(10); | 591 | udelay(10); |
564 | } | 592 | } |
565 | 593 | ||
594 | static void sonypi_type3_srs(void) | ||
595 | { | ||
596 | u16 v16; | ||
597 | u8 v8; | ||
598 | |||
599 | /* This model type uses the same initialiazation of | ||
600 | * the embedded controller as the type2 models. */ | ||
601 | sonypi_type2_srs(); | ||
602 | |||
603 | /* Initialization of PCI config space of the LPC interface bridge. */ | ||
604 | v16 = (sonypi_device.ioport1 & 0xFFF0) | 0x01; | ||
605 | pci_write_config_word(sonypi_device.dev, SONYPI_TYPE3_GID2, v16); | ||
606 | pci_read_config_byte(sonypi_device.dev, SONYPI_TYPE3_MISC, &v8); | ||
607 | v8 = (v8 & 0xCF) | 0x10; | ||
608 | pci_write_config_byte(sonypi_device.dev, SONYPI_TYPE3_MISC, v8); | ||
609 | } | ||
610 | |||
566 | /* Disables the device - this comes from the AML code in the ACPI bios */ | 611 | /* Disables the device - this comes from the AML code in the ACPI bios */ |
567 | static void sonypi_type1_dis(void) | 612 | static void sonypi_type1_dis(void) |
568 | { | 613 | { |
@@ -587,6 +632,13 @@ static void sonypi_type2_dis(void) | |||
587 | printk(KERN_WARNING "ec_write failed\n"); | 632 | printk(KERN_WARNING "ec_write failed\n"); |
588 | } | 633 | } |
589 | 634 | ||
635 | static void sonypi_type3_dis(void) | ||
636 | { | ||
637 | sonypi_type2_dis(); | ||
638 | udelay(10); | ||
639 | pci_write_config_word(sonypi_device.dev, SONYPI_TYPE3_GID2, 0); | ||
640 | } | ||
641 | |||
590 | static u8 sonypi_call1(u8 dev) | 642 | static u8 sonypi_call1(u8 dev) |
591 | { | 643 | { |
592 | u8 v1, v2; | 644 | u8 v1, v2; |
@@ -1067,10 +1119,17 @@ static struct miscdevice sonypi_misc_device = { | |||
1067 | 1119 | ||
1068 | static void sonypi_enable(unsigned int camera_on) | 1120 | static void sonypi_enable(unsigned int camera_on) |
1069 | { | 1121 | { |
1070 | if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) | 1122 | switch (sonypi_device.model) { |
1071 | sonypi_type2_srs(); | 1123 | case SONYPI_DEVICE_MODEL_TYPE1: |
1072 | else | ||
1073 | sonypi_type1_srs(); | 1124 | sonypi_type1_srs(); |
1125 | break; | ||
1126 | case SONYPI_DEVICE_MODEL_TYPE2: | ||
1127 | sonypi_type2_srs(); | ||
1128 | break; | ||
1129 | case SONYPI_DEVICE_MODEL_TYPE3: | ||
1130 | sonypi_type3_srs(); | ||
1131 | break; | ||
1132 | } | ||
1074 | 1133 | ||
1075 | sonypi_call1(0x82); | 1134 | sonypi_call1(0x82); |
1076 | sonypi_call2(0x81, 0xff); | 1135 | sonypi_call2(0x81, 0xff); |
@@ -1094,10 +1153,18 @@ static int sonypi_disable(void) | |||
1094 | if (!SONYPI_ACPI_ACTIVE && fnkeyinit) | 1153 | if (!SONYPI_ACPI_ACTIVE && fnkeyinit) |
1095 | outb(0xf1, 0xb2); | 1154 | outb(0xf1, 0xb2); |
1096 | 1155 | ||
1097 | if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) | 1156 | switch (sonypi_device.model) { |
1098 | sonypi_type2_dis(); | 1157 | case SONYPI_DEVICE_MODEL_TYPE1: |
1099 | else | ||
1100 | sonypi_type1_dis(); | 1158 | sonypi_type1_dis(); |
1159 | break; | ||
1160 | case SONYPI_DEVICE_MODEL_TYPE2: | ||
1161 | sonypi_type2_dis(); | ||
1162 | break; | ||
1163 | case SONYPI_DEVICE_MODEL_TYPE3: | ||
1164 | sonypi_type3_dis(); | ||
1165 | break; | ||
1166 | } | ||
1167 | |||
1101 | return 0; | 1168 | return 0; |
1102 | } | 1169 | } |
1103 | 1170 | ||
@@ -1143,12 +1210,16 @@ static int __devinit sonypi_probe(void) | |||
1143 | struct sonypi_irq_list *irq_list; | 1210 | struct sonypi_irq_list *irq_list; |
1144 | struct pci_dev *pcidev; | 1211 | struct pci_dev *pcidev; |
1145 | 1212 | ||
1146 | pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, | 1213 | if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, |
1147 | PCI_DEVICE_ID_INTEL_82371AB_3, NULL); | 1214 | PCI_DEVICE_ID_INTEL_82371AB_3, NULL))) |
1215 | sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE1; | ||
1216 | else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, | ||
1217 | PCI_DEVICE_ID_INTEL_ICH6_1, NULL))) | ||
1218 | sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE3; | ||
1219 | else | ||
1220 | sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE2; | ||
1148 | 1221 | ||
1149 | sonypi_device.dev = pcidev; | 1222 | sonypi_device.dev = pcidev; |
1150 | sonypi_device.model = pcidev ? | ||
1151 | SONYPI_DEVICE_MODEL_TYPE1 : SONYPI_DEVICE_MODEL_TYPE2; | ||
1152 | 1223 | ||
1153 | spin_lock_init(&sonypi_device.fifo_lock); | 1224 | spin_lock_init(&sonypi_device.fifo_lock); |
1154 | sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL, | 1225 | sonypi_device.fifo = kfifo_alloc(SONYPI_BUF_SIZE, GFP_KERNEL, |
@@ -1176,16 +1247,22 @@ static int __devinit sonypi_probe(void) | |||
1176 | goto out_miscreg; | 1247 | goto out_miscreg; |
1177 | } | 1248 | } |
1178 | 1249 | ||
1179 | if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) { | 1250 | |
1251 | if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE1) { | ||
1252 | ioport_list = sonypi_type1_ioport_list; | ||
1253 | sonypi_device.region_size = SONYPI_TYPE1_REGION_SIZE; | ||
1254 | sonypi_device.evtype_offset = SONYPI_TYPE1_EVTYPE_OFFSET; | ||
1255 | irq_list = sonypi_type1_irq_list; | ||
1256 | } else if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) { | ||
1180 | ioport_list = sonypi_type2_ioport_list; | 1257 | ioport_list = sonypi_type2_ioport_list; |
1181 | sonypi_device.region_size = SONYPI_TYPE2_REGION_SIZE; | 1258 | sonypi_device.region_size = SONYPI_TYPE2_REGION_SIZE; |
1182 | sonypi_device.evtype_offset = SONYPI_TYPE2_EVTYPE_OFFSET; | 1259 | sonypi_device.evtype_offset = SONYPI_TYPE2_EVTYPE_OFFSET; |
1183 | irq_list = sonypi_type2_irq_list; | 1260 | irq_list = sonypi_type2_irq_list; |
1184 | } else { | 1261 | } else { |
1185 | ioport_list = sonypi_type1_ioport_list; | 1262 | ioport_list = sonypi_type3_ioport_list; |
1186 | sonypi_device.region_size = SONYPI_TYPE1_REGION_SIZE; | 1263 | sonypi_device.region_size = SONYPI_TYPE3_REGION_SIZE; |
1187 | sonypi_device.evtype_offset = SONYPI_TYPE1_EVTYPE_OFFSET; | 1264 | sonypi_device.evtype_offset = SONYPI_TYPE3_EVTYPE_OFFSET; |
1188 | irq_list = sonypi_type1_irq_list; | 1265 | irq_list = sonypi_type3_irq_list; |
1189 | } | 1266 | } |
1190 | 1267 | ||
1191 | for (i = 0; ioport_list[i].port1; i++) { | 1268 | for (i = 0; ioport_list[i].port1; i++) { |
@@ -1274,11 +1351,10 @@ static int __devinit sonypi_probe(void) | |||
1274 | 1351 | ||
1275 | printk(KERN_INFO "sonypi: Sony Programmable I/O Controller Driver" | 1352 | printk(KERN_INFO "sonypi: Sony Programmable I/O Controller Driver" |
1276 | "v%s.\n", SONYPI_DRIVER_VERSION); | 1353 | "v%s.\n", SONYPI_DRIVER_VERSION); |
1277 | printk(KERN_INFO "sonypi: detected %s model, " | 1354 | printk(KERN_INFO "sonypi: detected type%d model, " |
1278 | "verbose = %d, fnkeyinit = %s, camera = %s, " | 1355 | "verbose = %d, fnkeyinit = %s, camera = %s, " |
1279 | "compat = %s, mask = 0x%08lx, useinput = %s, acpi = %s\n", | 1356 | "compat = %s, mask = 0x%08lx, useinput = %s, acpi = %s\n", |
1280 | (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE1) ? | 1357 | sonypi_device.model, |
1281 | "type1" : "type2", | ||
1282 | verbose, | 1358 | verbose, |
1283 | fnkeyinit ? "on" : "off", | 1359 | fnkeyinit ? "on" : "off", |
1284 | camera ? "on" : "off", | 1360 | camera ? "on" : "off", |
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 37c8bea8e2b0..ea2d54be4843 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/char/synclink.c | 2 | * linux/drivers/char/synclink.c |
3 | * | 3 | * |
4 | * $Id: synclink.c,v 4.28 2004/08/11 19:30:01 paulkf Exp $ | 4 | * $Id: synclink.c,v 4.37 2005/09/07 13:13:19 paulkf Exp $ |
5 | * | 5 | * |
6 | * Device driver for Microgate SyncLink ISA and PCI | 6 | * Device driver for Microgate SyncLink ISA and PCI |
7 | * high speed multiprotocol serial adapters. | 7 | * high speed multiprotocol serial adapters. |
@@ -141,9 +141,9 @@ static MGSL_PARAMS default_params = { | |||
141 | typedef struct _DMABUFFERENTRY | 141 | typedef struct _DMABUFFERENTRY |
142 | { | 142 | { |
143 | u32 phys_addr; /* 32-bit flat physical address of data buffer */ | 143 | u32 phys_addr; /* 32-bit flat physical address of data buffer */ |
144 | u16 count; /* buffer size/data count */ | 144 | volatile u16 count; /* buffer size/data count */ |
145 | u16 status; /* Control/status field */ | 145 | volatile u16 status; /* Control/status field */ |
146 | u16 rcc; /* character count field */ | 146 | volatile u16 rcc; /* character count field */ |
147 | u16 reserved; /* padding required by 16C32 */ | 147 | u16 reserved; /* padding required by 16C32 */ |
148 | u32 link; /* 32-bit flat link to next buffer entry */ | 148 | u32 link; /* 32-bit flat link to next buffer entry */ |
149 | char *virt_addr; /* virtual address of data buffer */ | 149 | char *virt_addr; /* virtual address of data buffer */ |
@@ -896,7 +896,7 @@ module_param_array(txdmabufs, int, NULL, 0); | |||
896 | module_param_array(txholdbufs, int, NULL, 0); | 896 | module_param_array(txholdbufs, int, NULL, 0); |
897 | 897 | ||
898 | static char *driver_name = "SyncLink serial driver"; | 898 | static char *driver_name = "SyncLink serial driver"; |
899 | static char *driver_version = "$Revision: 4.28 $"; | 899 | static char *driver_version = "$Revision: 4.37 $"; |
900 | 900 | ||
901 | static int synclink_init_one (struct pci_dev *dev, | 901 | static int synclink_init_one (struct pci_dev *dev, |
902 | const struct pci_device_id *ent); | 902 | const struct pci_device_id *ent); |
@@ -1814,6 +1814,8 @@ static int startup(struct mgsl_struct * info) | |||
1814 | 1814 | ||
1815 | info->pending_bh = 0; | 1815 | info->pending_bh = 0; |
1816 | 1816 | ||
1817 | memset(&info->icount, 0, sizeof(info->icount)); | ||
1818 | |||
1817 | init_timer(&info->tx_timer); | 1819 | init_timer(&info->tx_timer); |
1818 | info->tx_timer.data = (unsigned long)info; | 1820 | info->tx_timer.data = (unsigned long)info; |
1819 | info->tx_timer.function = mgsl_tx_timeout; | 1821 | info->tx_timer.function = mgsl_tx_timeout; |
@@ -2470,12 +2472,12 @@ static int mgsl_get_stats(struct mgsl_struct * info, struct mgsl_icount __user * | |||
2470 | printk("%s(%d):mgsl_get_params(%s)\n", | 2472 | printk("%s(%d):mgsl_get_params(%s)\n", |
2471 | __FILE__,__LINE__, info->device_name); | 2473 | __FILE__,__LINE__, info->device_name); |
2472 | 2474 | ||
2473 | COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount)); | 2475 | if (!user_icount) { |
2474 | if (err) { | 2476 | memset(&info->icount, 0, sizeof(info->icount)); |
2475 | if ( debug_level >= DEBUG_LEVEL_INFO ) | 2477 | } else { |
2476 | printk( "%s(%d):mgsl_get_stats(%s) user buffer copy failed\n", | 2478 | COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); |
2477 | __FILE__,__LINE__,info->device_name); | 2479 | if (err) |
2478 | return -EFAULT; | 2480 | return -EFAULT; |
2479 | } | 2481 | } |
2480 | 2482 | ||
2481 | return 0; | 2483 | return 0; |
@@ -6149,6 +6151,11 @@ static void usc_set_async_mode( struct mgsl_struct *info ) | |||
6149 | usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) & ~BIT12)); | 6151 | usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) & ~BIT12)); |
6150 | } | 6152 | } |
6151 | 6153 | ||
6154 | if (info->params.loopback) { | ||
6155 | info->loopback_bits = 0x300; | ||
6156 | outw(0x0300, info->io_base + CCAR); | ||
6157 | } | ||
6158 | |||
6152 | } /* end of usc_set_async_mode() */ | 6159 | } /* end of usc_set_async_mode() */ |
6153 | 6160 | ||
6154 | /* usc_loopback_frame() | 6161 | /* usc_loopback_frame() |
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index ec949e4c070f..6fb165cf8a61 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: synclinkmp.c,v 4.34 2005/03/04 15:07:10 paulkf Exp $ | 2 | * $Id: synclinkmp.c,v 4.38 2005/07/15 13:29:44 paulkf Exp $ |
3 | * | 3 | * |
4 | * Device driver for Microgate SyncLink Multiport | 4 | * Device driver for Microgate SyncLink Multiport |
5 | * high speed multiprotocol serial adapter. | 5 | * high speed multiprotocol serial adapter. |
@@ -55,7 +55,6 @@ | |||
55 | #include <linux/netdevice.h> | 55 | #include <linux/netdevice.h> |
56 | #include <linux/vmalloc.h> | 56 | #include <linux/vmalloc.h> |
57 | #include <linux/init.h> | 57 | #include <linux/init.h> |
58 | #include <asm/serial.h> | ||
59 | #include <linux/delay.h> | 58 | #include <linux/delay.h> |
60 | #include <linux/ioctl.h> | 59 | #include <linux/ioctl.h> |
61 | 60 | ||
@@ -487,7 +486,7 @@ module_param_array(maxframe, int, NULL, 0); | |||
487 | module_param_array(dosyncppp, int, NULL, 0); | 486 | module_param_array(dosyncppp, int, NULL, 0); |
488 | 487 | ||
489 | static char *driver_name = "SyncLink MultiPort driver"; | 488 | static char *driver_name = "SyncLink MultiPort driver"; |
490 | static char *driver_version = "$Revision: 4.34 $"; | 489 | static char *driver_version = "$Revision: 4.38 $"; |
491 | 490 | ||
492 | static int synclinkmp_init_one(struct pci_dev *dev,const struct pci_device_id *ent); | 491 | static int synclinkmp_init_one(struct pci_dev *dev,const struct pci_device_id *ent); |
493 | static void synclinkmp_remove_one(struct pci_dev *dev); | 492 | static void synclinkmp_remove_one(struct pci_dev *dev); |
@@ -556,7 +555,6 @@ static int set_txidle(SLMP_INFO *info, int idle_mode); | |||
556 | static int tx_enable(SLMP_INFO *info, int enable); | 555 | static int tx_enable(SLMP_INFO *info, int enable); |
557 | static int tx_abort(SLMP_INFO *info); | 556 | static int tx_abort(SLMP_INFO *info); |
558 | static int rx_enable(SLMP_INFO *info, int enable); | 557 | static int rx_enable(SLMP_INFO *info, int enable); |
559 | static int map_status(int signals); | ||
560 | static int modem_input_wait(SLMP_INFO *info,int arg); | 558 | static int modem_input_wait(SLMP_INFO *info,int arg); |
561 | static int wait_mgsl_event(SLMP_INFO *info, int __user *mask_ptr); | 559 | static int wait_mgsl_event(SLMP_INFO *info, int __user *mask_ptr); |
562 | static int tiocmget(struct tty_struct *tty, struct file *file); | 560 | static int tiocmget(struct tty_struct *tty, struct file *file); |
@@ -645,7 +643,7 @@ static unsigned char tx_active_fifo_level = 16; // tx request FIFO activation le | |||
645 | static unsigned char tx_negate_fifo_level = 32; // tx request FIFO negation level in bytes | 643 | static unsigned char tx_negate_fifo_level = 32; // tx request FIFO negation level in bytes |
646 | 644 | ||
647 | static u32 misc_ctrl_value = 0x007e4040; | 645 | static u32 misc_ctrl_value = 0x007e4040; |
648 | static u32 lcr1_brdr_value = 0x00800029; | 646 | static u32 lcr1_brdr_value = 0x00800028; |
649 | 647 | ||
650 | static u32 read_ahead_count = 8; | 648 | static u32 read_ahead_count = 8; |
651 | 649 | ||
@@ -2750,6 +2748,8 @@ static int startup(SLMP_INFO * info) | |||
2750 | 2748 | ||
2751 | info->pending_bh = 0; | 2749 | info->pending_bh = 0; |
2752 | 2750 | ||
2751 | memset(&info->icount, 0, sizeof(info->icount)); | ||
2752 | |||
2753 | /* program hardware for current parameters */ | 2753 | /* program hardware for current parameters */ |
2754 | reset_port(info); | 2754 | reset_port(info); |
2755 | 2755 | ||
@@ -2953,12 +2953,12 @@ static int get_stats(SLMP_INFO * info, struct mgsl_icount __user *user_icount) | |||
2953 | printk("%s(%d):%s get_params()\n", | 2953 | printk("%s(%d):%s get_params()\n", |
2954 | __FILE__,__LINE__, info->device_name); | 2954 | __FILE__,__LINE__, info->device_name); |
2955 | 2955 | ||
2956 | COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount)); | 2956 | if (!user_icount) { |
2957 | if (err) { | 2957 | memset(&info->icount, 0, sizeof(info->icount)); |
2958 | if ( debug_level >= DEBUG_LEVEL_INFO ) | 2958 | } else { |
2959 | printk( "%s(%d):%s get_stats() user buffer copy failed\n", | 2959 | COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); |
2960 | __FILE__,__LINE__,info->device_name); | 2960 | if (err) |
2961 | return -EFAULT; | 2961 | return -EFAULT; |
2962 | } | 2962 | } |
2963 | 2963 | ||
2964 | return 0; | 2964 | return 0; |
@@ -3109,16 +3109,6 @@ static int rx_enable(SLMP_INFO * info, int enable) | |||
3109 | return 0; | 3109 | return 0; |
3110 | } | 3110 | } |
3111 | 3111 | ||
3112 | static int map_status(int signals) | ||
3113 | { | ||
3114 | /* Map status bits to API event bits */ | ||
3115 | |||
3116 | return ((signals & SerialSignal_DSR) ? MgslEvent_DsrActive : MgslEvent_DsrInactive) + | ||
3117 | ((signals & SerialSignal_CTS) ? MgslEvent_CtsActive : MgslEvent_CtsInactive) + | ||
3118 | ((signals & SerialSignal_DCD) ? MgslEvent_DcdActive : MgslEvent_DcdInactive) + | ||
3119 | ((signals & SerialSignal_RI) ? MgslEvent_RiActive : MgslEvent_RiInactive); | ||
3120 | } | ||
3121 | |||
3122 | /* wait for specified event to occur | 3112 | /* wait for specified event to occur |
3123 | */ | 3113 | */ |
3124 | static int wait_mgsl_event(SLMP_INFO * info, int __user *mask_ptr) | 3114 | static int wait_mgsl_event(SLMP_INFO * info, int __user *mask_ptr) |
@@ -3145,7 +3135,7 @@ static int wait_mgsl_event(SLMP_INFO * info, int __user *mask_ptr) | |||
3145 | 3135 | ||
3146 | /* return immediately if state matches requested events */ | 3136 | /* return immediately if state matches requested events */ |
3147 | get_signals(info); | 3137 | get_signals(info); |
3148 | s = map_status(info->serial_signals); | 3138 | s = info->serial_signals; |
3149 | 3139 | ||
3150 | events = mask & | 3140 | events = mask & |
3151 | ( ((s & SerialSignal_DSR) ? MgslEvent_DsrActive:MgslEvent_DsrInactive) + | 3141 | ( ((s & SerialSignal_DSR) ? MgslEvent_DsrActive:MgslEvent_DsrInactive) + |
@@ -4489,11 +4479,13 @@ void async_mode(SLMP_INFO *info) | |||
4489 | /* MD2, Mode Register 2 | 4479 | /* MD2, Mode Register 2 |
4490 | * | 4480 | * |
4491 | * 07..02 Reserved, must be 0 | 4481 | * 07..02 Reserved, must be 0 |
4492 | * 01..00 CNCT<1..0> Channel connection, 0=normal | 4482 | * 01..00 CNCT<1..0> Channel connection, 00=normal 11=local loopback |
4493 | * | 4483 | * |
4494 | * 0000 0000 | 4484 | * 0000 0000 |
4495 | */ | 4485 | */ |
4496 | RegValue = 0x00; | 4486 | RegValue = 0x00; |
4487 | if (info->params.loopback) | ||
4488 | RegValue |= (BIT1 + BIT0); | ||
4497 | write_reg(info, MD2, RegValue); | 4489 | write_reg(info, MD2, RegValue); |
4498 | 4490 | ||
4499 | /* RXS, Receive clock source | 4491 | /* RXS, Receive clock source |
@@ -4574,9 +4566,6 @@ void async_mode(SLMP_INFO *info) | |||
4574 | write_reg(info, IE2, info->ie2_value); | 4566 | write_reg(info, IE2, info->ie2_value); |
4575 | 4567 | ||
4576 | set_rate( info, info->params.data_rate * 16 ); | 4568 | set_rate( info, info->params.data_rate * 16 ); |
4577 | |||
4578 | if (info->params.loopback) | ||
4579 | enable_loopback(info,1); | ||
4580 | } | 4569 | } |
4581 | 4570 | ||
4582 | /* Program the SCA for HDLC communications. | 4571 | /* Program the SCA for HDLC communications. |
diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig index 79e9832ef1f3..b58adfe3ed19 100644 --- a/drivers/char/tpm/Kconfig +++ b/drivers/char/tpm/Kconfig | |||
@@ -17,7 +17,7 @@ config TCG_TPM | |||
17 | obtained at: <http://sourceforge.net/projects/trousers>. To | 17 | obtained at: <http://sourceforge.net/projects/trousers>. To |
18 | compile this driver as a module, choose M here; the module | 18 | compile this driver as a module, choose M here; the module |
19 | will be called tpm. If unsure, say N. | 19 | will be called tpm. If unsure, say N. |
20 | Note: For more TPM drivers enable CONFIG_PNP, CONFIG_ACPI_BUS | 20 | Note: For more TPM drivers enable CONFIG_PNP, CONFIG_ACPI |
21 | and CONFIG_PNPACPI. | 21 | and CONFIG_PNPACPI. |
22 | 22 | ||
23 | config TCG_NSC | 23 | config TCG_NSC |
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c index cc2cc77fd174..c0d64914595f 100644 --- a/drivers/char/tpm/tpm_atmel.c +++ b/drivers/char/tpm/tpm_atmel.c | |||
@@ -206,6 +206,9 @@ static struct pci_device_id tpm_pci_tbl[] __devinitdata = { | |||
206 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0)}, | 206 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0)}, |
207 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12)}, | 207 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12)}, |
208 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0)}, | 208 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0)}, |
209 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0)}, | ||
210 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1)}, | ||
211 | {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0)}, | ||
209 | {PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_LPC)}, | 212 | {PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_LPC)}, |
210 | {PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6LPC)}, | 213 | {PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6LPC)}, |
211 | {0,} | 214 | {0,} |
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c index dc8c540391fd..939e51e119e6 100644 --- a/drivers/char/tpm/tpm_infineon.c +++ b/drivers/char/tpm/tpm_infineon.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * License. | 14 | * License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <acpi/acpi_bus.h> | ||
18 | #include <linux/pnp.h> | 17 | #include <linux/pnp.h> |
19 | #include "tpm.h" | 18 | #include "tpm.h" |
20 | 19 | ||
@@ -29,9 +28,10 @@ | |||
29 | #define TPM_MAX_TRIES 5000 | 28 | #define TPM_MAX_TRIES 5000 |
30 | #define TPM_INFINEON_DEV_VEN_VALUE 0x15D1 | 29 | #define TPM_INFINEON_DEV_VEN_VALUE 0x15D1 |
31 | 30 | ||
32 | /* These values will be filled after ACPI-call */ | 31 | /* These values will be filled after PnP-call */ |
33 | static int TPM_INF_DATA = 0; | 32 | static int TPM_INF_DATA = 0; |
34 | static int TPM_INF_ADDR = 0; | 33 | static int TPM_INF_ADDR = 0; |
34 | static int pnp_registered = 0; | ||
35 | 35 | ||
36 | /* TPM header definitions */ | 36 | /* TPM header definitions */ |
37 | enum infineon_tpm_header { | 37 | enum infineon_tpm_header { |
@@ -356,24 +356,26 @@ static const struct pnp_device_id tpm_pnp_tbl[] = { | |||
356 | {"IFX0102", 0}, | 356 | {"IFX0102", 0}, |
357 | {"", 0} | 357 | {"", 0} |
358 | }; | 358 | }; |
359 | MODULE_DEVICE_TABLE(pnp, tpm_pnp_tbl); | ||
359 | 360 | ||
360 | static int __devinit tpm_inf_acpi_probe(struct pnp_dev *dev, | 361 | static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, |
361 | const struct pnp_device_id *dev_id) | 362 | const struct pnp_device_id *dev_id) |
362 | { | 363 | { |
363 | TPM_INF_ADDR = (pnp_port_start(dev, 0) & 0xff); | 364 | if (pnp_port_valid(dev, 0)) { |
364 | TPM_INF_DATA = ((TPM_INF_ADDR + 1) & 0xff); | 365 | TPM_INF_ADDR = (pnp_port_start(dev, 0) & 0xff); |
365 | tpm_inf.base = pnp_port_start(dev, 1); | 366 | TPM_INF_DATA = ((TPM_INF_ADDR + 1) & 0xff); |
366 | dev_info(&dev->dev, "Found %s with ID %s\n", | 367 | tpm_inf.base = pnp_port_start(dev, 1); |
367 | dev->name, dev_id->id); | 368 | dev_info(&dev->dev, "Found %s with ID %s\n", |
368 | if (!((tpm_inf.base >> 8) & 0xff)) | 369 | dev->name, dev_id->id); |
369 | tpm_inf.base = 0; | 370 | return 0; |
370 | return 0; | 371 | } |
372 | return -ENODEV; | ||
371 | } | 373 | } |
372 | 374 | ||
373 | static struct pnp_driver tpm_inf_pnp = { | 375 | static struct pnp_driver tpm_inf_pnp = { |
374 | .name = "tpm_inf_pnp", | 376 | .name = "tpm_inf_pnp", |
375 | .id_table = tpm_pnp_tbl, | 377 | .id_table = tpm_pnp_tbl, |
376 | .probe = tpm_inf_acpi_probe, | 378 | .probe = tpm_inf_pnp_probe, |
377 | }; | 379 | }; |
378 | 380 | ||
379 | static int __devinit tpm_inf_probe(struct pci_dev *pci_dev, | 381 | static int __devinit tpm_inf_probe(struct pci_dev *pci_dev, |
@@ -386,19 +388,30 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev, | |||
386 | int productid[2]; | 388 | int productid[2]; |
387 | char chipname[20]; | 389 | char chipname[20]; |
388 | 390 | ||
389 | if (pci_enable_device(pci_dev)) | 391 | rc = pci_enable_device(pci_dev); |
390 | return -EIO; | 392 | if (rc) |
393 | return rc; | ||
391 | 394 | ||
392 | dev_info(&pci_dev->dev, "LPC-bus found at 0x%x\n", pci_id->device); | 395 | dev_info(&pci_dev->dev, "LPC-bus found at 0x%x\n", pci_id->device); |
393 | 396 | ||
394 | /* read IO-ports from ACPI */ | 397 | /* read IO-ports from PnP */ |
395 | pnp_register_driver(&tpm_inf_pnp); | 398 | rc = pnp_register_driver(&tpm_inf_pnp); |
396 | pnp_unregister_driver(&tpm_inf_pnp); | 399 | if (rc < 0) { |
400 | dev_err(&pci_dev->dev, | ||
401 | "Error %x from pnp_register_driver!\n",rc); | ||
402 | goto error2; | ||
403 | } | ||
404 | if (!rc) { | ||
405 | dev_info(&pci_dev->dev, "No Infineon TPM found!\n"); | ||
406 | goto error; | ||
407 | } else { | ||
408 | pnp_registered = 1; | ||
409 | } | ||
397 | 410 | ||
398 | /* Make sure, we have received valid config ports */ | 411 | /* Make sure, we have received valid config ports */ |
399 | if (!TPM_INF_ADDR) { | 412 | if (!TPM_INF_ADDR) { |
400 | pci_disable_device(pci_dev); | 413 | dev_err(&pci_dev->dev, "No valid IO-ports received!\n"); |
401 | return -EIO; | 414 | goto error; |
402 | } | 415 | } |
403 | 416 | ||
404 | /* query chip for its vendor, its version number a.s.o. */ | 417 | /* query chip for its vendor, its version number a.s.o. */ |
@@ -418,23 +431,21 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev, | |||
418 | 431 | ||
419 | switch ((productid[0] << 8) | productid[1]) { | 432 | switch ((productid[0] << 8) | productid[1]) { |
420 | case 6: | 433 | case 6: |
421 | sprintf(chipname, " (SLD 9630 TT 1.1)"); | 434 | snprintf(chipname, sizeof(chipname), " (SLD 9630 TT 1.1)"); |
422 | break; | 435 | break; |
423 | case 11: | 436 | case 11: |
424 | sprintf(chipname, " (SLB 9635 TT 1.2)"); | 437 | snprintf(chipname, sizeof(chipname), " (SLB 9635 TT 1.2)"); |
425 | break; | 438 | break; |
426 | default: | 439 | default: |
427 | sprintf(chipname, " (unknown chip)"); | 440 | snprintf(chipname, sizeof(chipname), " (unknown chip)"); |
428 | break; | 441 | break; |
429 | } | 442 | } |
430 | chipname[19] = 0; | ||
431 | 443 | ||
432 | if ((vendorid[0] << 8 | vendorid[1]) == (TPM_INFINEON_DEV_VEN_VALUE)) { | 444 | if ((vendorid[0] << 8 | vendorid[1]) == (TPM_INFINEON_DEV_VEN_VALUE)) { |
433 | 445 | ||
434 | if (tpm_inf.base == 0) { | 446 | if (tpm_inf.base == 0) { |
435 | dev_err(&pci_dev->dev, "No IO-ports found!\n"); | 447 | dev_err(&pci_dev->dev, "No IO-ports found!\n"); |
436 | pci_disable_device(pci_dev); | 448 | goto error; |
437 | return -EIO; | ||
438 | } | 449 | } |
439 | /* configure TPM with IO-ports */ | 450 | /* configure TPM with IO-ports */ |
440 | outb(IOLIMH, TPM_INF_ADDR); | 451 | outb(IOLIMH, TPM_INF_ADDR); |
@@ -452,8 +463,7 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev, | |||
452 | dev_err(&pci_dev->dev, | 463 | dev_err(&pci_dev->dev, |
453 | "Could not set IO-ports to %04x\n", | 464 | "Could not set IO-ports to %04x\n", |
454 | tpm_inf.base); | 465 | tpm_inf.base); |
455 | pci_disable_device(pci_dev); | 466 | goto error; |
456 | return -EIO; | ||
457 | } | 467 | } |
458 | 468 | ||
459 | /* activate register */ | 469 | /* activate register */ |
@@ -479,14 +489,16 @@ static int __devinit tpm_inf_probe(struct pci_dev *pci_dev, | |||
479 | productid[0], productid[1], chipname); | 489 | productid[0], productid[1], chipname); |
480 | 490 | ||
481 | rc = tpm_register_hardware(pci_dev, &tpm_inf); | 491 | rc = tpm_register_hardware(pci_dev, &tpm_inf); |
482 | if (rc < 0) { | 492 | if (rc < 0) |
483 | pci_disable_device(pci_dev); | 493 | goto error; |
484 | return -ENODEV; | ||
485 | } | ||
486 | return 0; | 494 | return 0; |
487 | } else { | 495 | } else { |
488 | dev_info(&pci_dev->dev, "No Infineon TPM found!\n"); | 496 | dev_info(&pci_dev->dev, "No Infineon TPM found!\n"); |
497 | error: | ||
498 | pnp_unregister_driver(&tpm_inf_pnp); | ||
499 | error2: | ||
489 | pci_disable_device(pci_dev); | 500 | pci_disable_device(pci_dev); |
501 | pnp_registered = 0; | ||
490 | return -ENODEV; | 502 | return -ENODEV; |
491 | } | 503 | } |
492 | } | 504 | } |
@@ -521,6 +533,8 @@ static int __init init_inf(void) | |||
521 | 533 | ||
522 | static void __exit cleanup_inf(void) | 534 | static void __exit cleanup_inf(void) |
523 | { | 535 | { |
536 | if (pnp_registered) | ||
537 | pnp_unregister_driver(&tpm_inf_pnp); | ||
524 | pci_unregister_driver(&inf_pci_driver); | 538 | pci_unregister_driver(&inf_pci_driver); |
525 | } | 539 | } |
526 | 540 | ||
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 6e4be3bb2d89..e5953f3433f3 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -153,7 +153,6 @@ static int tty_release(struct inode *, struct file *); | |||
153 | int tty_ioctl(struct inode * inode, struct file * file, | 153 | int tty_ioctl(struct inode * inode, struct file * file, |
154 | unsigned int cmd, unsigned long arg); | 154 | unsigned int cmd, unsigned long arg); |
155 | static int tty_fasync(int fd, struct file * filp, int on); | 155 | static int tty_fasync(int fd, struct file * filp, int on); |
156 | extern void rs_360_init(void); | ||
157 | static void release_mem(struct tty_struct *tty, int idx); | 156 | static void release_mem(struct tty_struct *tty, int idx); |
158 | 157 | ||
159 | 158 | ||
@@ -470,21 +469,19 @@ static void tty_ldisc_enable(struct tty_struct *tty) | |||
470 | 469 | ||
471 | static int tty_set_ldisc(struct tty_struct *tty, int ldisc) | 470 | static int tty_set_ldisc(struct tty_struct *tty, int ldisc) |
472 | { | 471 | { |
473 | int retval = 0; | 472 | int retval = 0; |
474 | struct tty_ldisc o_ldisc; | 473 | struct tty_ldisc o_ldisc; |
475 | char buf[64]; | 474 | char buf[64]; |
476 | int work; | 475 | int work; |
477 | unsigned long flags; | 476 | unsigned long flags; |
478 | struct tty_ldisc *ld; | 477 | struct tty_ldisc *ld; |
478 | struct tty_struct *o_tty; | ||
479 | 479 | ||
480 | if ((ldisc < N_TTY) || (ldisc >= NR_LDISCS)) | 480 | if ((ldisc < N_TTY) || (ldisc >= NR_LDISCS)) |
481 | return -EINVAL; | 481 | return -EINVAL; |
482 | 482 | ||
483 | restart: | 483 | restart: |
484 | 484 | ||
485 | if (tty->ldisc.num == ldisc) | ||
486 | return 0; /* We are already in the desired discipline */ | ||
487 | |||
488 | ld = tty_ldisc_get(ldisc); | 485 | ld = tty_ldisc_get(ldisc); |
489 | /* Eduardo Blanco <ejbs@cs.cs.com.uy> */ | 486 | /* Eduardo Blanco <ejbs@cs.cs.com.uy> */ |
490 | /* Cyrus Durgin <cider@speakeasy.org> */ | 487 | /* Cyrus Durgin <cider@speakeasy.org> */ |
@@ -495,45 +492,74 @@ restart: | |||
495 | if (ld == NULL) | 492 | if (ld == NULL) |
496 | return -EINVAL; | 493 | return -EINVAL; |
497 | 494 | ||
498 | o_ldisc = tty->ldisc; | ||
499 | |||
500 | tty_wait_until_sent(tty, 0); | 495 | tty_wait_until_sent(tty, 0); |
501 | 496 | ||
497 | if (tty->ldisc.num == ldisc) { | ||
498 | tty_ldisc_put(ldisc); | ||
499 | return 0; | ||
500 | } | ||
501 | |||
502 | o_ldisc = tty->ldisc; | ||
503 | o_tty = tty->link; | ||
504 | |||
502 | /* | 505 | /* |
503 | * Make sure we don't change while someone holds a | 506 | * Make sure we don't change while someone holds a |
504 | * reference to the line discipline. The TTY_LDISC bit | 507 | * reference to the line discipline. The TTY_LDISC bit |
505 | * prevents anyone taking a reference once it is clear. | 508 | * prevents anyone taking a reference once it is clear. |
506 | * We need the lock to avoid racing reference takers. | 509 | * We need the lock to avoid racing reference takers. |
507 | */ | 510 | */ |
508 | 511 | ||
509 | spin_lock_irqsave(&tty_ldisc_lock, flags); | 512 | spin_lock_irqsave(&tty_ldisc_lock, flags); |
510 | if(tty->ldisc.refcount) | 513 | if (tty->ldisc.refcount || (o_tty && o_tty->ldisc.refcount)) { |
511 | { | 514 | if(tty->ldisc.refcount) { |
512 | /* Free the new ldisc we grabbed. Must drop the lock | 515 | /* Free the new ldisc we grabbed. Must drop the lock |
513 | first. */ | 516 | first. */ |
517 | spin_unlock_irqrestore(&tty_ldisc_lock, flags); | ||
518 | tty_ldisc_put(ldisc); | ||
519 | /* | ||
520 | * There are several reasons we may be busy, including | ||
521 | * random momentary I/O traffic. We must therefore | ||
522 | * retry. We could distinguish between blocking ops | ||
523 | * and retries if we made tty_ldisc_wait() smarter. That | ||
524 | * is up for discussion. | ||
525 | */ | ||
526 | if (wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0) | ||
527 | return -ERESTARTSYS; | ||
528 | goto restart; | ||
529 | } | ||
530 | if(o_tty && o_tty->ldisc.refcount) { | ||
531 | spin_unlock_irqrestore(&tty_ldisc_lock, flags); | ||
532 | tty_ldisc_put(ldisc); | ||
533 | if (wait_event_interruptible(tty_ldisc_wait, o_tty->ldisc.refcount == 0) < 0) | ||
534 | return -ERESTARTSYS; | ||
535 | goto restart; | ||
536 | } | ||
537 | } | ||
538 | |||
539 | /* if the TTY_LDISC bit is set, then we are racing against another ldisc change */ | ||
540 | |||
541 | if (!test_bit(TTY_LDISC, &tty->flags)) { | ||
514 | spin_unlock_irqrestore(&tty_ldisc_lock, flags); | 542 | spin_unlock_irqrestore(&tty_ldisc_lock, flags); |
515 | tty_ldisc_put(ldisc); | 543 | tty_ldisc_put(ldisc); |
516 | /* | 544 | ld = tty_ldisc_ref_wait(tty); |
517 | * There are several reasons we may be busy, including | 545 | tty_ldisc_deref(ld); |
518 | * random momentary I/O traffic. We must therefore | ||
519 | * retry. We could distinguish between blocking ops | ||
520 | * and retries if we made tty_ldisc_wait() smarter. That | ||
521 | * is up for discussion. | ||
522 | */ | ||
523 | if(wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0) | ||
524 | return -ERESTARTSYS; | ||
525 | goto restart; | 546 | goto restart; |
526 | } | 547 | } |
527 | clear_bit(TTY_LDISC, &tty->flags); | 548 | |
549 | clear_bit(TTY_LDISC, &tty->flags); | ||
528 | clear_bit(TTY_DONT_FLIP, &tty->flags); | 550 | clear_bit(TTY_DONT_FLIP, &tty->flags); |
551 | if (o_tty) { | ||
552 | clear_bit(TTY_LDISC, &o_tty->flags); | ||
553 | clear_bit(TTY_DONT_FLIP, &o_tty->flags); | ||
554 | } | ||
529 | spin_unlock_irqrestore(&tty_ldisc_lock, flags); | 555 | spin_unlock_irqrestore(&tty_ldisc_lock, flags); |
530 | 556 | ||
531 | /* | 557 | /* |
532 | * From this point on we know nobody has an ldisc | 558 | * From this point on we know nobody has an ldisc |
533 | * usage reference, nor can they obtain one until | 559 | * usage reference, nor can they obtain one until |
534 | * we say so later on. | 560 | * we say so later on. |
535 | */ | 561 | */ |
536 | 562 | ||
537 | work = cancel_delayed_work(&tty->flip.work); | 563 | work = cancel_delayed_work(&tty->flip.work); |
538 | /* | 564 | /* |
539 | * Wait for ->hangup_work and ->flip.work handlers to terminate | 565 | * Wait for ->hangup_work and ->flip.work handlers to terminate |
@@ -584,10 +610,12 @@ restart: | |||
584 | */ | 610 | */ |
585 | 611 | ||
586 | tty_ldisc_enable(tty); | 612 | tty_ldisc_enable(tty); |
613 | if (o_tty) | ||
614 | tty_ldisc_enable(o_tty); | ||
587 | 615 | ||
588 | /* Restart it in case no characters kick it off. Safe if | 616 | /* Restart it in case no characters kick it off. Safe if |
589 | already running */ | 617 | already running */ |
590 | if(work) | 618 | if (work) |
591 | schedule_delayed_work(&tty->flip.work, 1); | 619 | schedule_delayed_work(&tty->flip.work, 1); |
592 | return retval; | 620 | return retval; |
593 | } | 621 | } |
@@ -2426,6 +2454,7 @@ static void __do_SAK(void *arg) | |||
2426 | int i; | 2454 | int i; |
2427 | struct file *filp; | 2455 | struct file *filp; |
2428 | struct tty_ldisc *disc; | 2456 | struct tty_ldisc *disc; |
2457 | struct fdtable *fdt; | ||
2429 | 2458 | ||
2430 | if (!tty) | 2459 | if (!tty) |
2431 | return; | 2460 | return; |
@@ -2451,8 +2480,9 @@ static void __do_SAK(void *arg) | |||
2451 | } | 2480 | } |
2452 | task_lock(p); | 2481 | task_lock(p); |
2453 | if (p->files) { | 2482 | if (p->files) { |
2454 | spin_lock(&p->files->file_lock); | 2483 | rcu_read_lock(); |
2455 | for (i=0; i < p->files->max_fds; i++) { | 2484 | fdt = files_fdtable(p->files); |
2485 | for (i=0; i < fdt->max_fds; i++) { | ||
2456 | filp = fcheck_files(p->files, i); | 2486 | filp = fcheck_files(p->files, i); |
2457 | if (!filp) | 2487 | if (!filp) |
2458 | continue; | 2488 | continue; |
@@ -2465,7 +2495,7 @@ static void __do_SAK(void *arg) | |||
2465 | break; | 2495 | break; |
2466 | } | 2496 | } |
2467 | } | 2497 | } |
2468 | spin_unlock(&p->files->file_lock); | 2498 | rcu_read_unlock(); |
2469 | } | 2499 | } |
2470 | task_unlock(p); | 2500 | task_unlock(p); |
2471 | } while_each_task_pid(session, PIDTYPE_SID, p); | 2501 | } while_each_task_pid(session, PIDTYPE_SID, p); |
@@ -2911,11 +2941,6 @@ void __init console_init(void) | |||
2911 | #ifdef CONFIG_EARLY_PRINTK | 2941 | #ifdef CONFIG_EARLY_PRINTK |
2912 | disable_early_printk(); | 2942 | disable_early_printk(); |
2913 | #endif | 2943 | #endif |
2914 | #ifdef CONFIG_SERIAL_68360 | ||
2915 | /* This is not a console initcall. I know not what it's doing here. | ||
2916 | So I haven't moved it. dwmw2 */ | ||
2917 | rs_360_init(); | ||
2918 | #endif | ||
2919 | call = __con_initcall_start; | 2944 | call = __con_initcall_start; |
2920 | while (call < __con_initcall_end) { | 2945 | while (call < __con_initcall_end) { |
2921 | (*call)(); | 2946 | (*call)(); |
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 665103ccaee8..1e33cb032e07 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -434,21 +434,25 @@ void invert_screen(struct vc_data *vc, int offset, int count, int viewed) | |||
434 | /* used by selection: complement pointer position */ | 434 | /* used by selection: complement pointer position */ |
435 | void complement_pos(struct vc_data *vc, int offset) | 435 | void complement_pos(struct vc_data *vc, int offset) |
436 | { | 436 | { |
437 | static unsigned short *p; | 437 | static int old_offset = -1; |
438 | static unsigned short old; | 438 | static unsigned short old; |
439 | static unsigned short oldx, oldy; | 439 | static unsigned short oldx, oldy; |
440 | 440 | ||
441 | WARN_CONSOLE_UNLOCKED(); | 441 | WARN_CONSOLE_UNLOCKED(); |
442 | 442 | ||
443 | if (p) { | 443 | if (old_offset != -1 && old_offset >= 0 && |
444 | scr_writew(old, p); | 444 | old_offset < vc->vc_screenbuf_size) { |
445 | scr_writew(old, screenpos(vc, old_offset, 1)); | ||
445 | if (DO_UPDATE(vc)) | 446 | if (DO_UPDATE(vc)) |
446 | vc->vc_sw->con_putc(vc, old, oldy, oldx); | 447 | vc->vc_sw->con_putc(vc, old, oldy, oldx); |
447 | } | 448 | } |
448 | if (offset == -1) | 449 | |
449 | p = NULL; | 450 | old_offset = offset; |
450 | else { | 451 | |
452 | if (offset != -1 && offset >= 0 && | ||
453 | offset < vc->vc_screenbuf_size) { | ||
451 | unsigned short new; | 454 | unsigned short new; |
455 | unsigned short *p; | ||
452 | p = screenpos(vc, offset, 1); | 456 | p = screenpos(vc, offset, 1); |
453 | old = scr_readw(p); | 457 | old = scr_readw(p); |
454 | new = old ^ vc->vc_complement_mask; | 458 | new = old ^ vc->vc_complement_mask; |
@@ -459,6 +463,7 @@ void complement_pos(struct vc_data *vc, int offset) | |||
459 | vc->vc_sw->con_putc(vc, new, oldy, oldx); | 463 | vc->vc_sw->con_putc(vc, new, oldy, oldx); |
460 | } | 464 | } |
461 | } | 465 | } |
466 | |||
462 | } | 467 | } |
463 | 468 | ||
464 | static void insert_char(struct vc_data *vc, unsigned int nr) | 469 | static void insert_char(struct vc_data *vc, unsigned int nr) |
@@ -746,6 +751,7 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) | |||
746 | unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; | 751 | unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; |
747 | unsigned int old_cols, old_rows, old_row_size, old_screen_size; | 752 | unsigned int old_cols, old_rows, old_row_size, old_screen_size; |
748 | unsigned int new_cols, new_rows, new_row_size, new_screen_size; | 753 | unsigned int new_cols, new_rows, new_row_size, new_screen_size; |
754 | unsigned int end; | ||
749 | unsigned short *newscreen; | 755 | unsigned short *newscreen; |
750 | 756 | ||
751 | WARN_CONSOLE_UNLOCKED(); | 757 | WARN_CONSOLE_UNLOCKED(); |
@@ -789,20 +795,44 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) | |||
789 | old_origin = vc->vc_origin; | 795 | old_origin = vc->vc_origin; |
790 | new_origin = (long) newscreen; | 796 | new_origin = (long) newscreen; |
791 | new_scr_end = new_origin + new_screen_size; | 797 | new_scr_end = new_origin + new_screen_size; |
792 | if (new_rows < old_rows) | 798 | |
793 | old_origin += (old_rows - new_rows) * old_row_size; | 799 | if (vc->vc_y > new_rows) { |
800 | if (old_rows - vc->vc_y < new_rows) { | ||
801 | /* | ||
802 | * Cursor near the bottom, copy contents from the | ||
803 | * bottom of buffer | ||
804 | */ | ||
805 | old_origin += (old_rows - new_rows) * old_row_size; | ||
806 | end = vc->vc_scr_end; | ||
807 | } else { | ||
808 | /* | ||
809 | * Cursor is in no man's land, copy 1/2 screenful | ||
810 | * from the top and bottom of cursor position | ||
811 | */ | ||
812 | old_origin += (vc->vc_y - new_rows/2) * old_row_size; | ||
813 | end = old_origin + new_screen_size; | ||
814 | } | ||
815 | } else | ||
816 | /* | ||
817 | * Cursor near the top, copy contents from the top of buffer | ||
818 | */ | ||
819 | end = (old_rows > new_rows) ? old_origin + new_screen_size : | ||
820 | vc->vc_scr_end; | ||
794 | 821 | ||
795 | update_attr(vc); | 822 | update_attr(vc); |
796 | 823 | ||
797 | while (old_origin < vc->vc_scr_end) { | 824 | while (old_origin < end) { |
798 | scr_memcpyw((unsigned short *) new_origin, (unsigned short *) old_origin, rlth); | 825 | scr_memcpyw((unsigned short *) new_origin, |
826 | (unsigned short *) old_origin, rlth); | ||
799 | if (rrem) | 827 | if (rrem) |
800 | scr_memsetw((void *)(new_origin + rlth), vc->vc_video_erase_char, rrem); | 828 | scr_memsetw((void *)(new_origin + rlth), |
829 | vc->vc_video_erase_char, rrem); | ||
801 | old_origin += old_row_size; | 830 | old_origin += old_row_size; |
802 | new_origin += new_row_size; | 831 | new_origin += new_row_size; |
803 | } | 832 | } |
804 | if (new_scr_end > new_origin) | 833 | if (new_scr_end > new_origin) |
805 | scr_memsetw((void *)new_origin, vc->vc_video_erase_char, new_scr_end - new_origin); | 834 | scr_memsetw((void *)new_origin, vc->vc_video_erase_char, |
835 | new_scr_end - new_origin); | ||
806 | if (vc->vc_kmalloced) | 836 | if (vc->vc_kmalloced) |
807 | kfree(vc->vc_screenbuf); | 837 | kfree(vc->vc_screenbuf); |
808 | vc->vc_screenbuf = newscreen; | 838 | vc->vc_screenbuf = newscreen; |
@@ -2272,7 +2302,9 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) | |||
2272 | ret = paste_selection(tty); | 2302 | ret = paste_selection(tty); |
2273 | break; | 2303 | break; |
2274 | case TIOCL_UNBLANKSCREEN: | 2304 | case TIOCL_UNBLANKSCREEN: |
2305 | acquire_console_sem(); | ||
2275 | unblank_screen(); | 2306 | unblank_screen(); |
2307 | release_console_sem(); | ||
2276 | break; | 2308 | break; |
2277 | case TIOCL_SELLOADLUT: | 2309 | case TIOCL_SELLOADLUT: |
2278 | ret = sel_loadlut(p); | 2310 | ret = sel_loadlut(p); |
@@ -2317,8 +2349,10 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) | |||
2317 | } | 2349 | } |
2318 | break; | 2350 | break; |
2319 | case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */ | 2351 | case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */ |
2352 | acquire_console_sem(); | ||
2320 | ignore_poke = 1; | 2353 | ignore_poke = 1; |
2321 | do_blank_screen(0); | 2354 | do_blank_screen(0); |
2355 | release_console_sem(); | ||
2322 | break; | 2356 | break; |
2323 | case TIOCL_BLANKEDSCREEN: | 2357 | case TIOCL_BLANKEDSCREEN: |
2324 | ret = console_blanked; | 2358 | ret = console_blanked; |
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index b53e2e2b5aee..c3898afce3ae 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig | |||
@@ -346,6 +346,13 @@ config 8xx_WDT | |||
346 | tristate "MPC8xx Watchdog Timer" | 346 | tristate "MPC8xx Watchdog Timer" |
347 | depends on WATCHDOG && 8xx | 347 | depends on WATCHDOG && 8xx |
348 | 348 | ||
349 | config BOOKE_WDT | ||
350 | tristate "PowerPC Book-E Watchdog Timer" | ||
351 | depends on WATCHDOG && (BOOKE || 4xx) | ||
352 | ---help--- | ||
353 | Please see Documentation/watchdog/watchdog-api.txt for | ||
354 | more information. | ||
355 | |||
349 | # MIPS Architecture | 356 | # MIPS Architecture |
350 | 357 | ||
351 | config INDYDOG | 358 | config INDYDOG |
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index c1838834ea7f..cfeac6f10137 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile | |||
@@ -2,42 +2,68 @@ | |||
2 | # Makefile for the WatchDog device drivers. | 2 | # Makefile for the WatchDog device drivers. |
3 | # | 3 | # |
4 | 4 | ||
5 | # Only one watchdog can succeed. We probe the ISA/PCI/USB based | ||
6 | # watchdog-cards first, then the architecture specific watchdog | ||
7 | # drivers and then the architecture independant "softdog" driver. | ||
8 | # This means that if your ISA/PCI/USB card isn't detected that | ||
9 | # you can fall back to an architecture specific driver and if | ||
10 | # that also fails then you can fall back to the software watchdog | ||
11 | # to give you some cover. | ||
12 | |||
13 | # ISA-based Watchdog Cards | ||
5 | obj-$(CONFIG_PCWATCHDOG) += pcwd.o | 14 | obj-$(CONFIG_PCWATCHDOG) += pcwd.o |
6 | obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o | ||
7 | obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o | ||
8 | obj-$(CONFIG_IB700_WDT) += ib700wdt.o | ||
9 | obj-$(CONFIG_MIXCOMWD) += mixcomwd.o | 15 | obj-$(CONFIG_MIXCOMWD) += mixcomwd.o |
10 | obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o | ||
11 | obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o | ||
12 | obj-$(CONFIG_WDT) += wdt.o | 16 | obj-$(CONFIG_WDT) += wdt.o |
17 | |||
18 | # PCI-based Watchdog Cards | ||
19 | obj-$(CONFIG_PCIPCWATCHDOG) += pcwd_pci.o | ||
13 | obj-$(CONFIG_WDTPCI) += wdt_pci.o | 20 | obj-$(CONFIG_WDTPCI) += wdt_pci.o |
21 | |||
22 | # USB-based Watchdog Cards | ||
23 | obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o | ||
24 | |||
25 | # ARM Architecture | ||
14 | obj-$(CONFIG_21285_WATCHDOG) += wdt285.o | 26 | obj-$(CONFIG_21285_WATCHDOG) += wdt285.o |
15 | obj-$(CONFIG_977_WATCHDOG) += wdt977.o | 27 | obj-$(CONFIG_977_WATCHDOG) += wdt977.o |
16 | obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o | 28 | obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o |
17 | obj-$(CONFIG_MACHZ_WDT) += machzwd.o | 29 | obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o |
18 | obj-$(CONFIG_SH_WDT) += shwdt.o | ||
19 | obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o | 30 | obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o |
20 | obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o | 31 | obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o |
21 | obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o | 32 | |
22 | obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o | 33 | # X86 (i386 + ia64 + x86_64) Architecture |
23 | obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o | 34 | obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o |
24 | obj-$(CONFIG_SC520_WDT) += sc520_wdt.o | 35 | obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o |
25 | obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o | ||
26 | obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o | 36 | obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o |
27 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o | 37 | obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o |
38 | obj-$(CONFIG_SC520_WDT) += sc520_wdt.o | ||
39 | obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o | ||
40 | obj-$(CONFIG_IB700_WDT) += ib700wdt.o | ||
28 | obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o | 41 | obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o |
42 | obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o | ||
43 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o | ||
44 | obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o | ||
45 | obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o | ||
29 | obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o | 46 | obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o |
30 | obj-$(CONFIG_INDYDOG) += indydog.o | 47 | obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o |
31 | obj-$(CONFIG_PCIPCWATCHDOG) += pcwd_pci.o | 48 | obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o |
32 | obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o | 49 | obj-$(CONFIG_MACHZ_WDT) += machzwd.o |
33 | obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o | 50 | |
34 | obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o | 51 | # PowerPC Architecture |
35 | obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o | 52 | obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o |
53 | |||
54 | # PPC64 Architecture | ||
36 | obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o | 55 | obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o |
56 | obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o | ||
57 | |||
58 | # MIPS Architecture | ||
59 | obj-$(CONFIG_INDYDOG) += indydog.o | ||
60 | |||
61 | # S390 Architecture | ||
62 | |||
63 | # SUPERH Architecture | ||
64 | obj-$(CONFIG_SH_WDT) += shwdt.o | ||
37 | 65 | ||
38 | # Only one watchdog can succeed. We probe the hardware watchdog | 66 | # SPARC64 Architecture |
39 | # drivers first, then the softdog driver. This means if your hardware | ||
40 | # watchdog dies or is 'borrowed' for some reason the software watchdog | ||
41 | # still gives you some cover. | ||
42 | 67 | ||
68 | # Architecture Independant | ||
43 | obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o | 69 | obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o |
diff --git a/drivers/char/watchdog/booke_wdt.c b/drivers/char/watchdog/booke_wdt.c new file mode 100644 index 000000000000..abc30cca6645 --- /dev/null +++ b/drivers/char/watchdog/booke_wdt.c | |||
@@ -0,0 +1,192 @@ | |||
1 | /* | ||
2 | * drivers/char/watchdog/booke_wdt.c | ||
3 | * | ||
4 | * Watchdog timer for PowerPC Book-E systems | ||
5 | * | ||
6 | * Author: Matthew McClintock | ||
7 | * Maintainer: Kumar Gala <kumar.gala@freescale.com> | ||
8 | * | ||
9 | * Copyright 2005 Freescale Semiconductor Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License as published by the | ||
13 | * Free Software Foundation; either version 2 of the License, or (at your | ||
14 | * option) any later version. | ||
15 | */ | ||
16 | |||
17 | #include <linux/config.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/fs.h> | ||
20 | #include <linux/miscdevice.h> | ||
21 | #include <linux/notifier.h> | ||
22 | #include <linux/watchdog.h> | ||
23 | |||
24 | #include <asm/reg_booke.h> | ||
25 | #include <asm/uaccess.h> | ||
26 | #include <asm/system.h> | ||
27 | |||
28 | /* If the kernel parameter wdt_enable=1, the watchdog will be enabled at boot. | ||
29 | * Also, the wdt_period sets the watchdog timer period timeout. | ||
30 | * For E500 cpus the wdt_period sets which bit changing from 0->1 will | ||
31 | * trigger a watchog timeout. This watchdog timeout will occur 3 times, the | ||
32 | * first time nothing will happen, the second time a watchdog exception will | ||
33 | * occur, and the final time the board will reset. | ||
34 | */ | ||
35 | |||
36 | #ifdef CONFIG_FSL_BOOKE | ||
37 | #define WDT_PERIOD_DEFAULT 63 /* Ex. wdt_period=28 bus=333Mhz , reset=~40sec */ | ||
38 | #else | ||
39 | #define WDT_PERIOD_DEFAULT 4 /* Refer to the PPC40x and PPC4xx manuals */ | ||
40 | #endif /* for timing information */ | ||
41 | |||
42 | u32 booke_wdt_enabled = 0; | ||
43 | u32 booke_wdt_period = WDT_PERIOD_DEFAULT; | ||
44 | |||
45 | #ifdef CONFIG_FSL_BOOKE | ||
46 | #define WDTP(x) ((((63-x)&0x3)<<30)|(((63-x)&0x3c)<<15)) | ||
47 | #else | ||
48 | #define WDTP(x) (TCR_WP(x)) | ||
49 | #endif | ||
50 | |||
51 | /* | ||
52 | * booke_wdt_enable: | ||
53 | */ | ||
54 | static __inline__ void booke_wdt_enable(void) | ||
55 | { | ||
56 | u32 val; | ||
57 | |||
58 | val = mfspr(SPRN_TCR); | ||
59 | val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period)); | ||
60 | |||
61 | mtspr(SPRN_TCR, val); | ||
62 | } | ||
63 | |||
64 | /* | ||
65 | * booke_wdt_ping: | ||
66 | */ | ||
67 | static __inline__ void booke_wdt_ping(void) | ||
68 | { | ||
69 | mtspr(SPRN_TSR, TSR_ENW|TSR_WIS); | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * booke_wdt_write: | ||
74 | */ | ||
75 | static ssize_t booke_wdt_write (struct file *file, const char *buf, | ||
76 | size_t count, loff_t *ppos) | ||
77 | { | ||
78 | booke_wdt_ping(); | ||
79 | return count; | ||
80 | } | ||
81 | |||
82 | static struct watchdog_info ident = { | ||
83 | .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, | ||
84 | .firmware_version = 0, | ||
85 | .identity = "PowerPC Book-E Watchdog", | ||
86 | }; | ||
87 | |||
88 | /* | ||
89 | * booke_wdt_ioctl: | ||
90 | */ | ||
91 | static int booke_wdt_ioctl (struct inode *inode, struct file *file, | ||
92 | unsigned int cmd, unsigned long arg) | ||
93 | { | ||
94 | u32 tmp = 0; | ||
95 | |||
96 | switch (cmd) { | ||
97 | case WDIOC_GETSUPPORT: | ||
98 | if (copy_to_user ((struct watchdog_info *) arg, &ident, | ||
99 | sizeof(struct watchdog_info))) | ||
100 | return -EFAULT; | ||
101 | case WDIOC_GETSTATUS: | ||
102 | return put_user(ident.options, (u32 *) arg); | ||
103 | case WDIOC_GETBOOTSTATUS: | ||
104 | /* XXX: something is clearing TSR */ | ||
105 | tmp = mfspr(SPRN_TSR) & TSR_WRS(3); | ||
106 | /* returns 1 if last reset was caused by the WDT */ | ||
107 | return (tmp ? 1 : 0); | ||
108 | case WDIOC_KEEPALIVE: | ||
109 | booke_wdt_ping(); | ||
110 | return 0; | ||
111 | case WDIOC_SETTIMEOUT: | ||
112 | if (get_user(booke_wdt_period, (u32 *) arg)) | ||
113 | return -EFAULT; | ||
114 | mtspr(SPRN_TCR, (mfspr(SPRN_TCR)&~WDTP(0))|WDTP(booke_wdt_period)); | ||
115 | return 0; | ||
116 | case WDIOC_GETTIMEOUT: | ||
117 | return put_user(booke_wdt_period, (u32 *) arg); | ||
118 | case WDIOC_SETOPTIONS: | ||
119 | if (get_user(tmp, (u32 *) arg)) | ||
120 | return -EINVAL; | ||
121 | if (tmp == WDIOS_ENABLECARD) { | ||
122 | booke_wdt_ping(); | ||
123 | break; | ||
124 | } else | ||
125 | return -EINVAL; | ||
126 | return 0; | ||
127 | default: | ||
128 | return -ENOIOCTLCMD; | ||
129 | } | ||
130 | |||
131 | return 0; | ||
132 | } | ||
133 | /* | ||
134 | * booke_wdt_open: | ||
135 | */ | ||
136 | static int booke_wdt_open (struct inode *inode, struct file *file) | ||
137 | { | ||
138 | if (booke_wdt_enabled == 0) { | ||
139 | booke_wdt_enabled = 1; | ||
140 | booke_wdt_enable(); | ||
141 | printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n", | ||
142 | booke_wdt_period); | ||
143 | } | ||
144 | |||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | static struct file_operations booke_wdt_fops = { | ||
149 | .owner = THIS_MODULE, | ||
150 | .llseek = no_llseek, | ||
151 | .write = booke_wdt_write, | ||
152 | .ioctl = booke_wdt_ioctl, | ||
153 | .open = booke_wdt_open, | ||
154 | }; | ||
155 | |||
156 | static struct miscdevice booke_wdt_miscdev = { | ||
157 | .minor = WATCHDOG_MINOR, | ||
158 | .name = "watchdog", | ||
159 | .fops = &booke_wdt_fops, | ||
160 | }; | ||
161 | |||
162 | static void __exit booke_wdt_exit(void) | ||
163 | { | ||
164 | misc_deregister(&booke_wdt_miscdev); | ||
165 | } | ||
166 | |||
167 | /* | ||
168 | * booke_wdt_init: | ||
169 | */ | ||
170 | static int __init booke_wdt_init(void) | ||
171 | { | ||
172 | int ret = 0; | ||
173 | |||
174 | printk (KERN_INFO "PowerPC Book-E Watchdog Timer Loaded\n"); | ||
175 | ident.firmware_version = cpu_specs[0].pvr_value; | ||
176 | |||
177 | ret = misc_register(&booke_wdt_miscdev); | ||
178 | if (ret) { | ||
179 | printk (KERN_CRIT "Cannot register miscdev on minor=%d (err=%d)\n", | ||
180 | WATCHDOG_MINOR, ret); | ||
181 | return ret; | ||
182 | } | ||
183 | |||
184 | if (booke_wdt_enabled == 1) { | ||
185 | printk (KERN_INFO "PowerPC Book-E Watchdog Timer Enabled (wdt_period=%d)\n", | ||
186 | booke_wdt_period); | ||
187 | booke_wdt_enable(); | ||
188 | } | ||
189 | |||
190 | return ret; | ||
191 | } | ||
192 | device_initcall(booke_wdt_init); | ||
diff --git a/drivers/char/watchdog/ixp2000_wdt.c b/drivers/char/watchdog/ixp2000_wdt.c index e7640bc4904b..0cfb9b9c4a4b 100644 --- a/drivers/char/watchdog/ixp2000_wdt.c +++ b/drivers/char/watchdog/ixp2000_wdt.c | |||
@@ -182,7 +182,7 @@ static struct file_operations ixp2000_wdt_fops = | |||
182 | static struct miscdevice ixp2000_wdt_miscdev = | 182 | static struct miscdevice ixp2000_wdt_miscdev = |
183 | { | 183 | { |
184 | .minor = WATCHDOG_MINOR, | 184 | .minor = WATCHDOG_MINOR, |
185 | .name = "IXP2000 Watchdog", | 185 | .name = "watchdog", |
186 | .fops = &ixp2000_wdt_fops, | 186 | .fops = &ixp2000_wdt_fops, |
187 | }; | 187 | }; |
188 | 188 | ||
diff --git a/drivers/char/watchdog/ixp4xx_wdt.c b/drivers/char/watchdog/ixp4xx_wdt.c index 8d916afbf4fa..b5be8b11104a 100644 --- a/drivers/char/watchdog/ixp4xx_wdt.c +++ b/drivers/char/watchdog/ixp4xx_wdt.c | |||
@@ -176,7 +176,7 @@ static struct file_operations ixp4xx_wdt_fops = | |||
176 | static struct miscdevice ixp4xx_wdt_miscdev = | 176 | static struct miscdevice ixp4xx_wdt_miscdev = |
177 | { | 177 | { |
178 | .minor = WATCHDOG_MINOR, | 178 | .minor = WATCHDOG_MINOR, |
179 | .name = "IXP4xx Watchdog", | 179 | .name = "watchdog", |
180 | .fops = &ixp4xx_wdt_fops, | 180 | .fops = &ixp4xx_wdt_fops, |
181 | }; | 181 | }; |
182 | 182 | ||
diff --git a/drivers/char/watchdog/mixcomwd.c b/drivers/char/watchdog/mixcomwd.c index c9b301dccec3..7fc2188386d9 100644 --- a/drivers/char/watchdog/mixcomwd.c +++ b/drivers/char/watchdog/mixcomwd.c | |||
@@ -59,7 +59,7 @@ static unsigned long mixcomwd_opened; /* long req'd for setbit --RR */ | |||
59 | 59 | ||
60 | static int watchdog_port; | 60 | static int watchdog_port; |
61 | static int mixcomwd_timer_alive; | 61 | static int mixcomwd_timer_alive; |
62 | static struct timer_list mixcomwd_timer = TIMER_INITIALIZER(NULL, 0, 0); | 62 | static DEFINE_TIMER(mixcomwd_timer, NULL, 0, 0); |
63 | static char expect_close; | 63 | static char expect_close; |
64 | 64 | ||
65 | static int nowayout = WATCHDOG_NOWAYOUT; | 65 | static int nowayout = WATCHDOG_NOWAYOUT; |
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index f85ac898a49a..8b292bf343c4 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c | |||
@@ -27,7 +27,10 @@ | |||
27 | * Fixed tmr_count / wdt_count confusion | 27 | * Fixed tmr_count / wdt_count confusion |
28 | * Added configurable debug | 28 | * Added configurable debug |
29 | * | 29 | * |
30 | * 11-Jan-2004 BJD Fixed divide-by-2 in timeout code | 30 | * 11-Jan-2005 BJD Fixed divide-by-2 in timeout code |
31 | * | ||
32 | * 25-Jan-2005 DA Added suspend/resume support | ||
33 | * Replaced reboot notifier with .shutdown method | ||
31 | * | 34 | * |
32 | * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA | 35 | * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA |
33 | */ | 36 | */ |
@@ -40,8 +43,6 @@ | |||
40 | #include <linux/miscdevice.h> | 43 | #include <linux/miscdevice.h> |
41 | #include <linux/watchdog.h> | 44 | #include <linux/watchdog.h> |
42 | #include <linux/fs.h> | 45 | #include <linux/fs.h> |
43 | #include <linux/notifier.h> | ||
44 | #include <linux/reboot.h> | ||
45 | #include <linux/init.h> | 46 | #include <linux/init.h> |
46 | #include <linux/device.h> | 47 | #include <linux/device.h> |
47 | #include <linux/interrupt.h> | 48 | #include <linux/interrupt.h> |
@@ -317,20 +318,6 @@ static int s3c2410wdt_ioctl(struct inode *inode, struct file *file, | |||
317 | } | 318 | } |
318 | } | 319 | } |
319 | 320 | ||
320 | /* | ||
321 | * Notifier for system down | ||
322 | */ | ||
323 | |||
324 | static int s3c2410wdt_notify_sys(struct notifier_block *this, unsigned long code, | ||
325 | void *unused) | ||
326 | { | ||
327 | if(code==SYS_DOWN || code==SYS_HALT) { | ||
328 | /* Turn the WDT off */ | ||
329 | s3c2410wdt_stop(); | ||
330 | } | ||
331 | return NOTIFY_DONE; | ||
332 | } | ||
333 | |||
334 | /* kernel interface */ | 321 | /* kernel interface */ |
335 | 322 | ||
336 | static struct file_operations s3c2410wdt_fops = { | 323 | static struct file_operations s3c2410wdt_fops = { |
@@ -348,10 +335,6 @@ static struct miscdevice s3c2410wdt_miscdev = { | |||
348 | .fops = &s3c2410wdt_fops, | 335 | .fops = &s3c2410wdt_fops, |
349 | }; | 336 | }; |
350 | 337 | ||
351 | static struct notifier_block s3c2410wdt_notifier = { | ||
352 | .notifier_call = s3c2410wdt_notify_sys, | ||
353 | }; | ||
354 | |||
355 | /* interrupt handler code */ | 338 | /* interrupt handler code */ |
356 | 339 | ||
357 | static irqreturn_t s3c2410wdt_irq(int irqno, void *param, | 340 | static irqreturn_t s3c2410wdt_irq(int irqno, void *param, |
@@ -432,18 +415,10 @@ static int s3c2410wdt_probe(struct device *dev) | |||
432 | } | 415 | } |
433 | } | 416 | } |
434 | 417 | ||
435 | ret = register_reboot_notifier(&s3c2410wdt_notifier); | ||
436 | if (ret) { | ||
437 | printk (KERN_ERR PFX "cannot register reboot notifier (%d)\n", | ||
438 | ret); | ||
439 | return ret; | ||
440 | } | ||
441 | |||
442 | ret = misc_register(&s3c2410wdt_miscdev); | 418 | ret = misc_register(&s3c2410wdt_miscdev); |
443 | if (ret) { | 419 | if (ret) { |
444 | printk (KERN_ERR PFX "cannot register miscdev on minor=%d (%d)\n", | 420 | printk (KERN_ERR PFX "cannot register miscdev on minor=%d (%d)\n", |
445 | WATCHDOG_MINOR, ret); | 421 | WATCHDOG_MINOR, ret); |
446 | unregister_reboot_notifier(&s3c2410wdt_notifier); | ||
447 | return ret; | 422 | return ret; |
448 | } | 423 | } |
449 | 424 | ||
@@ -479,15 +454,63 @@ static int s3c2410wdt_remove(struct device *dev) | |||
479 | return 0; | 454 | return 0; |
480 | } | 455 | } |
481 | 456 | ||
457 | static void s3c2410wdt_shutdown(struct device *dev) | ||
458 | { | ||
459 | s3c2410wdt_stop(); | ||
460 | } | ||
461 | |||
462 | #ifdef CONFIG_PM | ||
463 | |||
464 | static unsigned long wtcon_save; | ||
465 | static unsigned long wtdat_save; | ||
466 | |||
467 | static int s3c2410wdt_suspend(struct device *dev, u32 state, u32 level) | ||
468 | { | ||
469 | if (level == SUSPEND_POWER_DOWN) { | ||
470 | /* Save watchdog state, and turn it off. */ | ||
471 | wtcon_save = readl(wdt_base + S3C2410_WTCON); | ||
472 | wtdat_save = readl(wdt_base + S3C2410_WTDAT); | ||
473 | |||
474 | /* Note that WTCNT doesn't need to be saved. */ | ||
475 | s3c2410wdt_stop(); | ||
476 | } | ||
477 | |||
478 | return 0; | ||
479 | } | ||
480 | |||
481 | static int s3c2410wdt_resume(struct device *dev, u32 level) | ||
482 | { | ||
483 | if (level == RESUME_POWER_ON) { | ||
484 | /* Restore watchdog state. */ | ||
485 | |||
486 | writel(wtdat_save, wdt_base + S3C2410_WTDAT); | ||
487 | writel(wtdat_save, wdt_base + S3C2410_WTCNT); /* Reset count */ | ||
488 | writel(wtcon_save, wdt_base + S3C2410_WTCON); | ||
489 | |||
490 | printk(KERN_INFO PFX "watchdog %sabled\n", | ||
491 | (wtcon_save & S3C2410_WTCON_ENABLE) ? "en" : "dis"); | ||
492 | } | ||
493 | |||
494 | return 0; | ||
495 | } | ||
496 | |||
497 | #else | ||
498 | #define s3c2410wdt_suspend NULL | ||
499 | #define s3c2410wdt_resume NULL | ||
500 | #endif /* CONFIG_PM */ | ||
501 | |||
502 | |||
482 | static struct device_driver s3c2410wdt_driver = { | 503 | static struct device_driver s3c2410wdt_driver = { |
483 | .name = "s3c2410-wdt", | 504 | .name = "s3c2410-wdt", |
484 | .bus = &platform_bus_type, | 505 | .bus = &platform_bus_type, |
485 | .probe = s3c2410wdt_probe, | 506 | .probe = s3c2410wdt_probe, |
486 | .remove = s3c2410wdt_remove, | 507 | .remove = s3c2410wdt_remove, |
508 | .shutdown = s3c2410wdt_shutdown, | ||
509 | .suspend = s3c2410wdt_suspend, | ||
510 | .resume = s3c2410wdt_resume, | ||
487 | }; | 511 | }; |
488 | 512 | ||
489 | 513 | ||
490 | |||
491 | static char banner[] __initdata = KERN_INFO "S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics\n"; | 514 | static char banner[] __initdata = KERN_INFO "S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics\n"; |
492 | 515 | ||
493 | static int __init watchdog_init(void) | 516 | static int __init watchdog_init(void) |
@@ -499,13 +522,13 @@ static int __init watchdog_init(void) | |||
499 | static void __exit watchdog_exit(void) | 522 | static void __exit watchdog_exit(void) |
500 | { | 523 | { |
501 | driver_unregister(&s3c2410wdt_driver); | 524 | driver_unregister(&s3c2410wdt_driver); |
502 | unregister_reboot_notifier(&s3c2410wdt_notifier); | ||
503 | } | 525 | } |
504 | 526 | ||
505 | module_init(watchdog_init); | 527 | module_init(watchdog_init); |
506 | module_exit(watchdog_exit); | 528 | module_exit(watchdog_exit); |
507 | 529 | ||
508 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); | 530 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>, " |
531 | "Dimitry Andric <dimitry.andric@tomtom.com>"); | ||
509 | MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver"); | 532 | MODULE_DESCRIPTION("S3C2410 Watchdog Device Driver"); |
510 | MODULE_LICENSE("GPL"); | 533 | MODULE_LICENSE("GPL"); |
511 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | 534 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); |
diff --git a/drivers/char/watchdog/scx200_wdt.c b/drivers/char/watchdog/scx200_wdt.c index c4568569f3a8..b4a102a2d7e3 100644 --- a/drivers/char/watchdog/scx200_wdt.c +++ b/drivers/char/watchdog/scx200_wdt.c | |||
@@ -206,7 +206,7 @@ static struct file_operations scx200_wdt_fops = { | |||
206 | 206 | ||
207 | static struct miscdevice scx200_wdt_miscdev = { | 207 | static struct miscdevice scx200_wdt_miscdev = { |
208 | .minor = WATCHDOG_MINOR, | 208 | .minor = WATCHDOG_MINOR, |
209 | .name = NAME, | 209 | .name = "watchdog", |
210 | .fops = &scx200_wdt_fops, | 210 | .fops = &scx200_wdt_fops, |
211 | }; | 211 | }; |
212 | 212 | ||
diff --git a/drivers/char/watchdog/softdog.c b/drivers/char/watchdog/softdog.c index 4d7ed931f5c6..20e5eb8667f2 100644 --- a/drivers/char/watchdog/softdog.c +++ b/drivers/char/watchdog/softdog.c | |||
@@ -77,7 +77,7 @@ static void watchdog_fire(unsigned long); | |||
77 | 77 | ||
78 | static struct timer_list watchdog_ticktock = | 78 | static struct timer_list watchdog_ticktock = |
79 | TIMER_INITIALIZER(watchdog_fire, 0, 0); | 79 | TIMER_INITIALIZER(watchdog_fire, 0, 0); |
80 | static unsigned long timer_alive; | 80 | static unsigned long driver_open, orphan_timer; |
81 | static char expect_close; | 81 | static char expect_close; |
82 | 82 | ||
83 | 83 | ||
@@ -87,6 +87,9 @@ static char expect_close; | |||
87 | 87 | ||
88 | static void watchdog_fire(unsigned long data) | 88 | static void watchdog_fire(unsigned long data) |
89 | { | 89 | { |
90 | if (test_and_clear_bit(0, &orphan_timer)) | ||
91 | module_put(THIS_MODULE); | ||
92 | |||
90 | if (soft_noboot) | 93 | if (soft_noboot) |
91 | printk(KERN_CRIT PFX "Triggered - Reboot ignored.\n"); | 94 | printk(KERN_CRIT PFX "Triggered - Reboot ignored.\n"); |
92 | else | 95 | else |
@@ -128,9 +131,9 @@ static int softdog_set_heartbeat(int t) | |||
128 | 131 | ||
129 | static int softdog_open(struct inode *inode, struct file *file) | 132 | static int softdog_open(struct inode *inode, struct file *file) |
130 | { | 133 | { |
131 | if(test_and_set_bit(0, &timer_alive)) | 134 | if (test_and_set_bit(0, &driver_open)) |
132 | return -EBUSY; | 135 | return -EBUSY; |
133 | if (nowayout) | 136 | if (!test_and_clear_bit(0, &orphan_timer)) |
134 | __module_get(THIS_MODULE); | 137 | __module_get(THIS_MODULE); |
135 | /* | 138 | /* |
136 | * Activate timer | 139 | * Activate timer |
@@ -147,11 +150,13 @@ static int softdog_release(struct inode *inode, struct file *file) | |||
147 | */ | 150 | */ |
148 | if (expect_close == 42) { | 151 | if (expect_close == 42) { |
149 | softdog_stop(); | 152 | softdog_stop(); |
153 | module_put(THIS_MODULE); | ||
150 | } else { | 154 | } else { |
151 | printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); | 155 | printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); |
156 | set_bit(0, &orphan_timer); | ||
152 | softdog_keepalive(); | 157 | softdog_keepalive(); |
153 | } | 158 | } |
154 | clear_bit(0, &timer_alive); | 159 | clear_bit(0, &driver_open); |
155 | expect_close = 0; | 160 | expect_close = 0; |
156 | return 0; | 161 | return 0; |
157 | } | 162 | } |
diff --git a/drivers/char/watchdog/w83627hf_wdt.c b/drivers/char/watchdog/w83627hf_wdt.c index 465e0fd0423d..b5d821015421 100644 --- a/drivers/char/watchdog/w83627hf_wdt.c +++ b/drivers/char/watchdog/w83627hf_wdt.c | |||
@@ -93,6 +93,12 @@ w83627hf_init(void) | |||
93 | 93 | ||
94 | w83627hf_select_wd_register(); | 94 | w83627hf_select_wd_register(); |
95 | 95 | ||
96 | outb_p(0xF6, WDT_EFER); /* Select CRF6 */ | ||
97 | t=inb_p(WDT_EFDR); /* read CRF6 */ | ||
98 | if (t != 0) { | ||
99 | printk (KERN_INFO PFX "Watchdog already running. Resetting timeout to %d sec\n", timeout); | ||
100 | outb_p(timeout, WDT_EFDR); /* Write back to CRF6 */ | ||
101 | } | ||
96 | outb_p(0xF5, WDT_EFER); /* Select CRF5 */ | 102 | outb_p(0xF5, WDT_EFER); /* Select CRF5 */ |
97 | t=inb_p(WDT_EFDR); /* read CRF5 */ | 103 | t=inb_p(WDT_EFDR); /* read CRF5 */ |
98 | t&=~0x0C; /* set second mode & disable keyboard turning off watchdog */ | 104 | t&=~0x0C; /* set second mode & disable keyboard turning off watchdog */ |