diff options
author | Dave Airlie <airlied@starflyer.(none)> | 2005-09-24 23:14:45 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2005-09-24 23:14:45 -0400 |
commit | 4e0c1159d83a658d1ffba5bc3442f4ec4cadb436 (patch) | |
tree | 36a5079ba7ba9b9e0f2f633356705b980940eac4 /drivers/char | |
parent | ea98a92ff18c03bf7f4d21536986cbbcb4c10cd9 (diff) | |
parent | ef6bd6eb90ad72ee8ee7ba8b271f27102e9a90c1 (diff) |
update from upstream
Diffstat (limited to 'drivers/char')
66 files changed, 4755 insertions, 2194 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/backend.c b/drivers/char/agp/backend.c index 4d4e602fdc7e..82b43c541c8d 100644 --- a/drivers/char/agp/backend.c +++ b/drivers/char/agp/backend.c | |||
@@ -206,10 +206,9 @@ static void agp_backend_cleanup(struct agp_bridge_data *bridge) | |||
206 | bridge->driver->cleanup(); | 206 | bridge->driver->cleanup(); |
207 | if (bridge->driver->free_gatt_table) | 207 | if (bridge->driver->free_gatt_table) |
208 | bridge->driver->free_gatt_table(bridge); | 208 | bridge->driver->free_gatt_table(bridge); |
209 | if (bridge->key_list) { | 209 | |
210 | vfree(bridge->key_list); | 210 | vfree(bridge->key_list); |
211 | bridge->key_list = NULL; | 211 | bridge->key_list = NULL; |
212 | } | ||
213 | 212 | ||
214 | if (bridge->driver->agp_destroy_page && | 213 | if (bridge->driver->agp_destroy_page && |
215 | bridge->driver->needs_scratch_page) | 214 | bridge->driver->needs_scratch_page) |
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/agp/hp-agp.c b/drivers/char/agp/hp-agp.c index 99762b6c19ae..de5d6d212674 100644 --- a/drivers/char/agp/hp-agp.c +++ b/drivers/char/agp/hp-agp.c | |||
@@ -252,7 +252,7 @@ hp_zx1_configure (void) | |||
252 | readl(hp->ioc_regs+HP_ZX1_PDIR_BASE); | 252 | readl(hp->ioc_regs+HP_ZX1_PDIR_BASE); |
253 | writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG); | 253 | writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG); |
254 | readl(hp->ioc_regs+HP_ZX1_TCNFG); | 254 | readl(hp->ioc_regs+HP_ZX1_TCNFG); |
255 | writel(~(HP_ZX1_IOVA_SIZE-1), hp->ioc_regs+HP_ZX1_IMASK); | 255 | writel((unsigned int)(~(HP_ZX1_IOVA_SIZE-1)), hp->ioc_regs+HP_ZX1_IMASK); |
256 | readl(hp->ioc_regs+HP_ZX1_IMASK); | 256 | readl(hp->ioc_regs+HP_ZX1_IMASK); |
257 | writel(hp->iova_base|1, hp->ioc_regs+HP_ZX1_IBASE); | 257 | writel(hp->iova_base|1, hp->ioc_regs+HP_ZX1_IBASE); |
258 | readl(hp->ioc_regs+HP_ZX1_IBASE); | 258 | readl(hp->ioc_regs+HP_ZX1_IBASE); |
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c index 2a36561eec68..a124f8c5d062 100644 --- a/drivers/char/amiserial.c +++ b/drivers/char/amiserial.c | |||
@@ -2053,10 +2053,6 @@ static int __init rs_init(void) | |||
2053 | state->icount.rx = state->icount.tx = 0; | 2053 | state->icount.rx = state->icount.tx = 0; |
2054 | state->icount.frame = state->icount.parity = 0; | 2054 | state->icount.frame = state->icount.parity = 0; |
2055 | state->icount.overrun = state->icount.brk = 0; | 2055 | state->icount.overrun = state->icount.brk = 0; |
2056 | /* | ||
2057 | if(state->port && check_region(state->port,REGION_LENGTH(state))) | ||
2058 | continue; | ||
2059 | */ | ||
2060 | 2056 | ||
2061 | printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n", | 2057 | printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n", |
2062 | state->line); | 2058 | state->line); |
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c index 11f9ee581124..927a5bbe112c 100644 --- a/drivers/char/applicom.c +++ b/drivers/char/applicom.c | |||
@@ -172,7 +172,7 @@ static int ac_register_board(unsigned long physloc, void __iomem *loc, | |||
172 | 172 | ||
173 | void cleanup_module(void) | 173 | void cleanup_module(void) |
174 | { | 174 | { |
175 | int i; | 175 | unsigned int i; |
176 | 176 | ||
177 | misc_deregister(&ac_miscdev); | 177 | misc_deregister(&ac_miscdev); |
178 | 178 | ||
@@ -195,7 +195,7 @@ int __init applicom_init(void) | |||
195 | int i, numisa = 0; | 195 | int i, numisa = 0; |
196 | struct pci_dev *dev = NULL; | 196 | struct pci_dev *dev = NULL; |
197 | void __iomem *RamIO; | 197 | void __iomem *RamIO; |
198 | int boardno; | 198 | int boardno, ret; |
199 | 199 | ||
200 | printk(KERN_INFO "Applicom driver: $Id: ac.c,v 1.30 2000/03/22 16:03:57 dwmw2 Exp $\n"); | 200 | printk(KERN_INFO "Applicom driver: $Id: ac.c,v 1.30 2000/03/22 16:03:57 dwmw2 Exp $\n"); |
201 | 201 | ||
@@ -294,7 +294,8 @@ int __init applicom_init(void) | |||
294 | } | 294 | } |
295 | 295 | ||
296 | if (!numisa) | 296 | if (!numisa) |
297 | printk(KERN_WARNING"ac.o: No valid ISA Applicom boards found at mem 0x%lx\n",mem); | 297 | printk(KERN_WARNING "ac.o: No valid ISA Applicom boards found " |
298 | "at mem 0x%lx\n", mem); | ||
298 | 299 | ||
299 | fin: | 300 | fin: |
300 | init_waitqueue_head(&FlagSleepRec); | 301 | init_waitqueue_head(&FlagSleepRec); |
@@ -304,7 +305,11 @@ int __init applicom_init(void) | |||
304 | DeviceErrorCount = 0; | 305 | DeviceErrorCount = 0; |
305 | 306 | ||
306 | if (numboards) { | 307 | if (numboards) { |
307 | misc_register(&ac_miscdev); | 308 | ret = misc_register(&ac_miscdev); |
309 | if (ret) { | ||
310 | printk(KERN_WARNING "ac.o: Unable to register misc device\n"); | ||
311 | goto out; | ||
312 | } | ||
308 | for (i = 0; i < MAX_BOARD; i++) { | 313 | for (i = 0; i < MAX_BOARD; i++) { |
309 | int serial; | 314 | int serial; |
310 | char boardname[(SERIAL_NUMBER - TYPE_CARD) + 1]; | 315 | char boardname[(SERIAL_NUMBER - TYPE_CARD) + 1]; |
@@ -337,6 +342,17 @@ int __init applicom_init(void) | |||
337 | 342 | ||
338 | else | 343 | else |
339 | return -ENXIO; | 344 | return -ENXIO; |
345 | |||
346 | out: | ||
347 | for (i = 0; i < MAX_BOARD; i++) { | ||
348 | if (!apbs[i].RamIO) | ||
349 | continue; | ||
350 | if (apbs[i].irq) | ||
351 | free_irq(apbs[i].irq, &dummy); | ||
352 | iounmap(apbs[i].RamIO); | ||
353 | } | ||
354 | pci_disable_device(dev); | ||
355 | return ret; | ||
340 | } | 356 | } |
341 | 357 | ||
342 | 358 | ||
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 c164c76e33f3..cf58a526a030 100644 --- a/drivers/char/drm/drmP.h +++ b/drivers/char/drm/drmP.h | |||
@@ -1083,5 +1083,9 @@ extern void *drm_calloc(size_t nmemb, size_t size, int area); | |||
1083 | extern unsigned long drm_core_get_map_ofs(drm_map_t *map); | 1083 | extern unsigned long drm_core_get_map_ofs(drm_map_t *map); |
1084 | extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); | 1084 | extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); |
1085 | 1085 | ||
1086 | #ifndef pci_pretty_name | ||
1087 | #define pci_pretty_name(dev) "" | ||
1088 | #endif | ||
1089 | |||
1086 | #endif /* __KERNEL__ */ | 1090 | #endif /* __KERNEL__ */ |
1087 | #endif | 1091 | #endif |
diff --git a/drivers/char/epca.c b/drivers/char/epca.c index 6025e1866c7e..407708a001e4 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 __iomem *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 __iomem *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 */ |
@@ -761,32 +685,27 @@ static int pc_write(struct tty_struct * tty, | |||
761 | ------------------------------------------------------------------- */ | 685 | ------------------------------------------------------------------- */ |
762 | 686 | ||
763 | dataLen = min(bytesAvailable, dataLen); | 687 | dataLen = min(bytesAvailable, dataLen); |
764 | memcpy(ch->txptr + head, buf, dataLen); | 688 | memcpy_toio(ch->txptr + head, buf, dataLen); |
765 | buf += dataLen; | 689 | buf += dataLen; |
766 | head += dataLen; | 690 | head += dataLen; |
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 __iomem *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 __iomem *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 __iomem *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 __iomem *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,78 +994,61 @@ 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 | ||
1209 | /* Save boards current modem status */ | 1043 | /* Save boards current modem status */ |
1210 | ch->imodem = bc->mstat; | 1044 | ch->imodem = readb(&bc->mstat); |
1211 | 1045 | ||
1212 | /* ---------------------------------------------------------------- | 1046 | /* ---------------------------------------------------------------- |
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 | void __iomem *memaddr; |
1651 | volatile struct global_data *gd; | 1403 | struct global_data __iomem *gd; |
1652 | struct board_info *bd; | 1404 | struct board_info *bd; |
1653 | volatile struct board_chan *bc; | 1405 | struct board_chan __iomem *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 = 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 = 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,17 @@ 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; |
1496 | u16 tseg, rseg; | ||
1758 | 1497 | ||
1759 | ch->brdchan = bc; | 1498 | ch->brdchan = bc; |
1760 | ch->mailbox = gd; | 1499 | ch->mailbox = gd; |
1761 | INIT_WORK(&ch->tqueue, do_softint, ch); | 1500 | INIT_WORK(&ch->tqueue, do_softint, ch); |
1762 | ch->board = &boards[crd]; | 1501 | ch->board = &boards[crd]; |
1763 | 1502 | ||
1764 | switch (bd->type) | 1503 | spin_lock_irqsave(&epca_lock, flags); |
1765 | { /* Begin switch bd->type */ | 1504 | switch (bd->type) { |
1766 | |||
1767 | /* ---------------------------------------------------------------- | 1505 | /* ---------------------------------------------------------------- |
1768 | Since some of the boards use different bitmaps for their | 1506 | Since some of the boards use different bitmaps for their |
1769 | control signals we cannot hard code these values and retain | 1507 | control signals we cannot hard code these values and retain |
@@ -1796,14 +1534,12 @@ static void post_fep_init(unsigned int crd) | |||
1796 | 1534 | ||
1797 | } /* End switch bd->type */ | 1535 | } /* End switch bd->type */ |
1798 | 1536 | ||
1799 | if (boards[crd].altpin) | 1537 | if (boards[crd].altpin) { |
1800 | { | ||
1801 | ch->dsr = ch->m_dcd; | 1538 | ch->dsr = ch->m_dcd; |
1802 | ch->dcd = ch->m_dsr; | 1539 | ch->dcd = ch->m_dsr; |
1803 | ch->digiext.digi_flags |= DIGI_ALTPIN; | 1540 | ch->digiext.digi_flags |= DIGI_ALTPIN; |
1804 | } | 1541 | } |
1805 | else | 1542 | else { |
1806 | { | ||
1807 | ch->dcd = ch->m_dcd; | 1543 | ch->dcd = ch->m_dcd; |
1808 | ch->dsr = ch->m_dsr; | 1544 | ch->dsr = ch->m_dsr; |
1809 | } | 1545 | } |
@@ -1813,57 +1549,58 @@ static void post_fep_init(unsigned int crd) | |||
1813 | ch->magic = EPCA_MAGIC; | 1549 | ch->magic = EPCA_MAGIC; |
1814 | ch->tty = NULL; | 1550 | ch->tty = NULL; |
1815 | 1551 | ||
1816 | if (shrinkmem) | 1552 | if (shrinkmem) { |
1817 | { | ||
1818 | fepcmd(ch, SETBUFFER, 32, 0, 0, 0); | 1553 | fepcmd(ch, SETBUFFER, 32, 0, 0, 0); |
1819 | shrinkmem = 0; | 1554 | shrinkmem = 0; |
1820 | } | 1555 | } |
1821 | 1556 | ||
1822 | switch (bd->type) | 1557 | tseg = readw(&bc->tseg); |
1823 | { /* Begin switch bd->type */ | 1558 | rseg = readw(&bc->rseg); |
1559 | |||
1560 | switch (bd->type) { | ||
1824 | 1561 | ||
1825 | case PCIXEM: | 1562 | case PCIXEM: |
1826 | case PCIXRJ: | 1563 | case PCIXRJ: |
1827 | case PCIXR: | 1564 | case PCIXR: |
1828 | /* Cover all the 2MEG cards */ | 1565 | /* Cover all the 2MEG cards */ |
1829 | ch->txptr = memaddr + (((bc->tseg) << 4) & 0x1fffff); | 1566 | ch->txptr = memaddr + ((tseg << 4) & 0x1fffff); |
1830 | ch->rxptr = memaddr + (((bc->rseg) << 4) & 0x1fffff); | 1567 | ch->rxptr = memaddr + ((rseg << 4) & 0x1fffff); |
1831 | ch->txwin = FEPWIN | ((bc->tseg) >> 11); | 1568 | ch->txwin = FEPWIN | (tseg >> 11); |
1832 | ch->rxwin = FEPWIN | ((bc->rseg) >> 11); | 1569 | ch->rxwin = FEPWIN | (rseg >> 11); |
1833 | break; | 1570 | break; |
1834 | 1571 | ||
1835 | case PCXEM: | 1572 | case PCXEM: |
1836 | case EISAXEM: | 1573 | case EISAXEM: |
1837 | /* Cover all the 32K windowed cards */ | 1574 | /* Cover all the 32K windowed cards */ |
1838 | /* Mask equal to window size - 1 */ | 1575 | /* Mask equal to window size - 1 */ |
1839 | ch->txptr = memaddr + (((bc->tseg) << 4) & 0x7fff); | 1576 | ch->txptr = memaddr + ((tseg << 4) & 0x7fff); |
1840 | ch->rxptr = memaddr + (((bc->rseg) << 4) & 0x7fff); | 1577 | ch->rxptr = memaddr + ((rseg << 4) & 0x7fff); |
1841 | ch->txwin = FEPWIN | ((bc->tseg) >> 11); | 1578 | ch->txwin = FEPWIN | (tseg >> 11); |
1842 | ch->rxwin = FEPWIN | ((bc->rseg) >> 11); | 1579 | ch->rxwin = FEPWIN | (rseg >> 11); |
1843 | break; | 1580 | break; |
1844 | 1581 | ||
1845 | case PCXEVE: | 1582 | case PCXEVE: |
1846 | case PCXE: | 1583 | case PCXE: |
1847 | ch->txptr = memaddr + (((bc->tseg - bd->memory_seg) << 4) & 0x1fff); | 1584 | ch->txptr = memaddr + (((tseg - bd->memory_seg) << 4) & 0x1fff); |
1848 | ch->txwin = FEPWIN | ((bc->tseg - bd->memory_seg) >> 9); | 1585 | ch->txwin = FEPWIN | ((tseg - bd->memory_seg) >> 9); |
1849 | ch->rxptr = memaddr + (((bc->rseg - bd->memory_seg) << 4) & 0x1fff); | 1586 | ch->rxptr = memaddr + (((rseg - bd->memory_seg) << 4) & 0x1fff); |
1850 | ch->rxwin = FEPWIN | ((bc->rseg - bd->memory_seg) >>9 ); | 1587 | ch->rxwin = FEPWIN | ((rseg - bd->memory_seg) >>9 ); |
1851 | break; | 1588 | break; |
1852 | 1589 | ||
1853 | case PCXI: | 1590 | case PCXI: |
1854 | case PC64XE: | 1591 | case PC64XE: |
1855 | ch->txptr = memaddr + ((bc->tseg - bd->memory_seg) << 4); | 1592 | ch->txptr = memaddr + ((tseg - bd->memory_seg) << 4); |
1856 | ch->rxptr = memaddr + ((bc->rseg - bd->memory_seg) << 4); | 1593 | ch->rxptr = memaddr + ((rseg - bd->memory_seg) << 4); |
1857 | ch->txwin = ch->rxwin = 0; | 1594 | ch->txwin = ch->rxwin = 0; |
1858 | break; | 1595 | break; |
1859 | 1596 | ||
1860 | } /* End switch bd->type */ | 1597 | } /* End switch bd->type */ |
1861 | 1598 | ||
1862 | ch->txbufhead = 0; | 1599 | ch->txbufhead = 0; |
1863 | ch->txbufsize = bc->tmax + 1; | 1600 | ch->txbufsize = readw(&bc->tmax) + 1; |
1864 | 1601 | ||
1865 | ch->rxbufhead = 0; | 1602 | ch->rxbufhead = 0; |
1866 | ch->rxbufsize = bc->rmax + 1; | 1603 | ch->rxbufsize = readw(&bc->rmax) + 1; |
1867 | 1604 | ||
1868 | lowwater = ch->txbufsize >= 2000 ? 1024 : (ch->txbufsize / 2); | 1605 | lowwater = ch->txbufsize >= 2000 ? 1024 : (ch->txbufsize / 2); |
1869 | 1606 | ||
@@ -1878,13 +1615,13 @@ static void post_fep_init(unsigned int crd) | |||
1878 | 1615 | ||
1879 | fepcmd(ch, SRXHWATER, (3 * ch->rxbufsize / 4), 0, 10, 0); | 1616 | fepcmd(ch, SRXHWATER, (3 * ch->rxbufsize / 4), 0, 10, 0); |
1880 | 1617 | ||
1881 | bc->edelay = 100; | 1618 | writew(100, &bc->edelay); |
1882 | bc->idata = 1; | 1619 | writeb(1, &bc->idata); |
1883 | 1620 | ||
1884 | ch->startc = bc->startc; | 1621 | ch->startc = readb(&bc->startc); |
1885 | ch->stopc = bc->stopc; | 1622 | ch->stopc = readb(&bc->stopc); |
1886 | ch->startca = bc->startca; | 1623 | ch->startca = readb(&bc->startca); |
1887 | ch->stopca = bc->stopca; | 1624 | ch->stopca = readb(&bc->stopca); |
1888 | 1625 | ||
1889 | ch->fepcflag = 0; | 1626 | ch->fepcflag = 0; |
1890 | ch->fepiflag = 0; | 1627 | ch->fepiflag = 0; |
@@ -1899,27 +1636,23 @@ static void post_fep_init(unsigned int crd) | |||
1899 | ch->blocked_open = 0; | 1636 | ch->blocked_open = 0; |
1900 | init_waitqueue_head(&ch->open_wait); | 1637 | init_waitqueue_head(&ch->open_wait); |
1901 | init_waitqueue_head(&ch->close_wait); | 1638 | init_waitqueue_head(&ch->close_wait); |
1639 | |||
1640 | spin_unlock_irqrestore(&epca_lock, flags); | ||
1641 | |||
1902 | ch->tmp_buf = kmalloc(ch->txbufsize,GFP_KERNEL); | 1642 | ch->tmp_buf = kmalloc(ch->txbufsize,GFP_KERNEL); |
1903 | if (!(ch->tmp_buf)) | 1643 | if (!ch->tmp_buf) { |
1904 | { | ||
1905 | printk(KERN_ERR "POST FEP INIT : kmalloc failed for port 0x%x\n",i); | 1644 | printk(KERN_ERR "POST FEP INIT : kmalloc failed for port 0x%x\n",i); |
1906 | release_region((int)bd->port, 4); | 1645 | release_region((int)bd->port, 4); |
1907 | while(i-- > 0) | 1646 | while(i-- > 0) |
1908 | kfree((ch--)->tmp_buf); | 1647 | kfree((ch--)->tmp_buf); |
1909 | return; | 1648 | return; |
1910 | } | 1649 | } else |
1911 | else | ||
1912 | memset((void *)ch->tmp_buf,0,ch->txbufsize); | 1650 | memset((void *)ch->tmp_buf,0,ch->txbufsize); |
1913 | } /* End for each port */ | 1651 | } /* End for each port */ |
1914 | 1652 | ||
1915 | printk(KERN_INFO | 1653 | printk(KERN_INFO |
1916 | "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n", | 1654 | "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); | 1655 | 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); | 1656 | memwinoff(bd, 0); |
1924 | 1657 | ||
1925 | } /* End post_fep_init */ | 1658 | } /* End post_fep_init */ |
@@ -1943,9 +1676,6 @@ static void epcapoll(unsigned long ignored) | |||
1943 | buffer empty) and acts on those events. | 1676 | buffer empty) and acts on those events. |
1944 | ----------------------------------------------------------------------- */ | 1677 | ----------------------------------------------------------------------- */ |
1945 | 1678 | ||
1946 | save_flags(flags); | ||
1947 | cli(); | ||
1948 | |||
1949 | for (crd = 0; crd < num_cards; crd++) | 1679 | for (crd = 0; crd < num_cards; crd++) |
1950 | { /* Begin for each card */ | 1680 | { /* Begin for each card */ |
1951 | 1681 | ||
@@ -1961,6 +1691,8 @@ static void epcapoll(unsigned long ignored) | |||
1961 | some legacy boards. | 1691 | some legacy boards. |
1962 | ---------------------------------------------------------------- */ | 1692 | ---------------------------------------------------------------- */ |
1963 | 1693 | ||
1694 | spin_lock_irqsave(&epca_lock, flags); | ||
1695 | |||
1964 | assertmemoff(ch); | 1696 | assertmemoff(ch); |
1965 | 1697 | ||
1966 | globalwinon(ch); | 1698 | globalwinon(ch); |
@@ -1970,21 +1702,19 @@ static void epcapoll(unsigned long ignored) | |||
1970 | the transmit or receive queue. | 1702 | the transmit or receive queue. |
1971 | ------------------------------------------------------------------- */ | 1703 | ------------------------------------------------------------------- */ |
1972 | 1704 | ||
1973 | head = ch->mailbox->ein; | 1705 | head = readw(&ch->mailbox->ein); |
1974 | tail = ch->mailbox->eout; | 1706 | tail = readw(&ch->mailbox->eout); |
1975 | 1707 | ||
1976 | /* If head isn't equal to tail we have an event */ | 1708 | /* If head isn't equal to tail we have an event */ |
1977 | 1709 | ||
1978 | if (head != tail) | 1710 | if (head != tail) |
1979 | doevent(crd); | 1711 | doevent(crd); |
1980 | |||
1981 | memoff(ch); | 1712 | memoff(ch); |
1982 | 1713 | ||
1983 | } /* End for each card */ | 1714 | spin_unlock_irqrestore(&epca_lock, flags); |
1984 | 1715 | ||
1716 | } /* End for each card */ | ||
1985 | mod_timer(&epca_timer, jiffies + (HZ / 25)); | 1717 | mod_timer(&epca_timer, jiffies + (HZ / 25)); |
1986 | |||
1987 | restore_flags(flags); | ||
1988 | } /* End epcapoll */ | 1718 | } /* End epcapoll */ |
1989 | 1719 | ||
1990 | /* --------------------- Begin doevent ------------------------ */ | 1720 | /* --------------------- Begin doevent ------------------------ */ |
@@ -1992,53 +1722,42 @@ static void epcapoll(unsigned long ignored) | |||
1992 | static void doevent(int crd) | 1722 | static void doevent(int crd) |
1993 | { /* Begin doevent */ | 1723 | { /* Begin doevent */ |
1994 | 1724 | ||
1995 | volatile unchar *eventbuf; | 1725 | void __iomem *eventbuf; |
1996 | struct channel *ch, *chan0; | 1726 | struct channel *ch, *chan0; |
1997 | static struct tty_struct *tty; | 1727 | static struct tty_struct *tty; |
1998 | volatile struct board_info *bd; | 1728 | struct board_info *bd; |
1999 | volatile struct board_chan *bc; | 1729 | struct board_chan __iomem *bc; |
2000 | register volatile unsigned int tail, head; | 1730 | unsigned int tail, head; |
2001 | register int event, channel; | 1731 | int event, channel; |
2002 | register int mstat, lstat; | 1732 | int mstat, lstat; |
2003 | 1733 | ||
2004 | /* ------------------------------------------------------------------- | 1734 | /* ------------------------------------------------------------------- |
2005 | This subroutine is called by epcapoll when an event is detected | 1735 | This subroutine is called by epcapoll when an event is detected |
2006 | in the event queue. This routine responds to those events. | 1736 | in the event queue. This routine responds to those events. |
2007 | --------------------------------------------------------------------- */ | 1737 | --------------------------------------------------------------------- */ |
2008 | |||
2009 | bd = &boards[crd]; | 1738 | bd = &boards[crd]; |
2010 | 1739 | ||
2011 | chan0 = card_ptr[crd]; | 1740 | chan0 = card_ptr[crd]; |
2012 | epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range"); | 1741 | epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range"); |
2013 | |||
2014 | assertgwinon(chan0); | 1742 | assertgwinon(chan0); |
2015 | 1743 | 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 */ | 1744 | { /* Begin while something in event queue */ |
2018 | |||
2019 | assertgwinon(chan0); | 1745 | assertgwinon(chan0); |
2020 | 1746 | 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 */ | 1747 | /* Get the channel the event occurred on */ |
2024 | channel = eventbuf[0]; | 1748 | channel = readb(eventbuf); |
2025 | |||
2026 | /* Get the actual event code that occurred */ | 1749 | /* Get the actual event code that occurred */ |
2027 | event = eventbuf[1]; | 1750 | event = readb(eventbuf + 1); |
2028 | |||
2029 | /* ---------------------------------------------------------------- | 1751 | /* ---------------------------------------------------------------- |
2030 | The two assignments below get the current modem status (mstat) | 1752 | The two assignments below get the current modem status (mstat) |
2031 | and the previous modem status (lstat). These are useful becuase | 1753 | and the previous modem status (lstat). These are useful becuase |
2032 | an event could signal a change in modem signals itself. | 1754 | an event could signal a change in modem signals itself. |
2033 | ------------------------------------------------------------------- */ | 1755 | ------------------------------------------------------------------- */ |
2034 | 1756 | mstat = readb(eventbuf + 2); | |
2035 | mstat = eventbuf[2]; | 1757 | lstat = readb(eventbuf + 3); |
2036 | lstat = eventbuf[3]; | ||
2037 | 1758 | ||
2038 | ch = chan0 + channel; | 1759 | ch = chan0 + channel; |
2039 | 1760 | if ((unsigned)channel >= bd->numports || !ch) { | |
2040 | if ((unsigned)channel >= bd->numports || !ch) | ||
2041 | { | ||
2042 | if (channel >= bd->numports) | 1761 | if (channel >= bd->numports) |
2043 | ch = chan0; | 1762 | ch = chan0; |
2044 | bc = ch->brdchan; | 1763 | bc = ch->brdchan; |
@@ -2048,97 +1767,53 @@ static void doevent(int crd) | |||
2048 | if ((bc = ch->brdchan) == NULL) | 1767 | if ((bc = ch->brdchan) == NULL) |
2049 | goto next; | 1768 | goto next; |
2050 | 1769 | ||
2051 | if (event & DATA_IND) | 1770 | if (event & DATA_IND) { /* Begin DATA_IND */ |
2052 | { /* Begin DATA_IND */ | ||
2053 | |||
2054 | receive_data(ch); | 1771 | receive_data(ch); |
2055 | assertgwinon(ch); | 1772 | assertgwinon(ch); |
2056 | |||
2057 | } /* End DATA_IND */ | 1773 | } /* End DATA_IND */ |
2058 | /* else *//* Fix for DCD transition missed bug */ | 1774 | /* else *//* Fix for DCD transition missed bug */ |
2059 | if (event & MODEMCHG_IND) | 1775 | if (event & MODEMCHG_IND) { /* Begin MODEMCHG_IND */ |
2060 | { /* Begin MODEMCHG_IND */ | ||
2061 | |||
2062 | /* A modem signal change has been indicated */ | 1776 | /* A modem signal change has been indicated */ |
2063 | |||
2064 | ch->imodem = mstat; | 1777 | ch->imodem = mstat; |
2065 | 1778 | if (ch->asyncflags & ASYNC_CHECK_CD) { | |
2066 | if (ch->asyncflags & ASYNC_CHECK_CD) | ||
2067 | { | ||
2068 | if (mstat & ch->dcd) /* We are now receiving dcd */ | 1779 | if (mstat & ch->dcd) /* We are now receiving dcd */ |
2069 | wake_up_interruptible(&ch->open_wait); | 1780 | wake_up_interruptible(&ch->open_wait); |
2070 | else | 1781 | else |
2071 | pc_sched_event(ch, EPCA_EVENT_HANGUP); /* No dcd; hangup */ | 1782 | pc_sched_event(ch, EPCA_EVENT_HANGUP); /* No dcd; hangup */ |
2072 | } | 1783 | } |
2073 | |||
2074 | } /* End MODEMCHG_IND */ | 1784 | } /* End MODEMCHG_IND */ |
2075 | |||
2076 | tty = ch->tty; | 1785 | tty = ch->tty; |
2077 | if (tty) | 1786 | if (tty) { /* Begin if valid tty */ |
2078 | { /* Begin if valid tty */ | 1787 | 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 */ | 1788 | /* A break has been indicated */ |
2084 | |||
2085 | tty->flip.count++; | 1789 | tty->flip.count++; |
2086 | *tty->flip.flag_buf_ptr++ = TTY_BREAK; | 1790 | *tty->flip.flag_buf_ptr++ = TTY_BREAK; |
2087 | |||
2088 | *tty->flip.char_buf_ptr++ = 0; | 1791 | *tty->flip.char_buf_ptr++ = 0; |
2089 | |||
2090 | tty_schedule_flip(tty); | 1792 | tty_schedule_flip(tty); |
2091 | 1793 | } 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) | 1794 | if (ch->statusflags & LOWWAIT) |
2098 | { /* Begin if LOWWAIT */ | 1795 | { /* Begin if LOWWAIT */ |
2099 | |||
2100 | ch->statusflags &= ~LOWWAIT; | 1796 | ch->statusflags &= ~LOWWAIT; |
2101 | tty_wakeup(tty); | 1797 | tty_wakeup(tty); |
2102 | wake_up_interruptible(&tty->write_wait); | 1798 | wake_up_interruptible(&tty->write_wait); |
2103 | |||
2104 | } /* End if LOWWAIT */ | 1799 | } /* End if LOWWAIT */ |
2105 | 1800 | } 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 */ | 1801 | /* This event is generated by setup_empty_event */ |
2112 | |||
2113 | ch->statusflags &= ~TXBUSY; | 1802 | ch->statusflags &= ~TXBUSY; |
2114 | if (ch->statusflags & EMPTYWAIT) | 1803 | if (ch->statusflags & EMPTYWAIT) { /* Begin if EMPTYWAIT */ |
2115 | { /* Begin if EMPTYWAIT */ | ||
2116 | |||
2117 | ch->statusflags &= ~EMPTYWAIT; | 1804 | ch->statusflags &= ~EMPTYWAIT; |
2118 | tty_wakeup(tty); | 1805 | tty_wakeup(tty); |
2119 | |||
2120 | wake_up_interruptible(&tty->write_wait); | 1806 | wake_up_interruptible(&tty->write_wait); |
2121 | |||
2122 | } /* End if EMPTYWAIT */ | 1807 | } /* End if EMPTYWAIT */ |
2123 | |||
2124 | } /* End EMPTYTX_IND */ | 1808 | } /* End EMPTYTX_IND */ |
2125 | |||
2126 | } /* End if valid tty */ | 1809 | } /* End if valid tty */ |
2127 | |||
2128 | |||
2129 | next: | 1810 | next: |
2130 | globalwinon(ch); | 1811 | globalwinon(ch); |
2131 | 1812 | BUG_ON(!bc); | |
2132 | if (!bc) | 1813 | writew(1, &bc->idata); |
2133 | printk(KERN_ERR "<Error> - bc == NULL in doevent!\n"); | 1814 | 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); | 1815 | globalwinon(chan0); |
2139 | |||
2140 | } /* End while something in event queue */ | 1816 | } /* End while something in event queue */ |
2141 | |||
2142 | } /* End doevent */ | 1817 | } /* End doevent */ |
2143 | 1818 | ||
2144 | /* --------------------- Begin fepcmd ------------------------ */ | 1819 | /* --------------------- Begin fepcmd ------------------------ */ |
@@ -2146,8 +1821,7 @@ static void doevent(int crd) | |||
2146 | static void fepcmd(struct channel *ch, int cmd, int word_or_byte, | 1821 | static void fepcmd(struct channel *ch, int cmd, int word_or_byte, |
2147 | int byte2, int ncmds, int bytecmd) | 1822 | int byte2, int ncmds, int bytecmd) |
2148 | { /* Begin fepcmd */ | 1823 | { /* Begin fepcmd */ |
2149 | 1824 | unchar __iomem *memaddr; | |
2150 | unchar *memaddr; | ||
2151 | unsigned int head, cmdTail, cmdStart, cmdMax; | 1825 | unsigned int head, cmdTail, cmdStart, cmdMax; |
2152 | long count; | 1826 | long count; |
2153 | int n; | 1827 | int n; |
@@ -2155,93 +1829,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. */ | 1829 | /* This is the routine in which commands may be passed to the card. */ |
2156 | 1830 | ||
2157 | if (ch->board->status == DISABLED) | 1831 | if (ch->board->status == DISABLED) |
2158 | { | ||
2159 | return; | 1832 | return; |
2160 | } | ||
2161 | |||
2162 | assertgwinon(ch); | 1833 | assertgwinon(ch); |
2163 | |||
2164 | /* Remember head (As well as max) is just an offset not a base addr */ | 1834 | /* Remember head (As well as max) is just an offset not a base addr */ |
2165 | head = ch->mailbox->cin; | 1835 | head = readw(&ch->mailbox->cin); |
2166 | |||
2167 | /* cmdStart is a base address */ | 1836 | /* cmdStart is a base address */ |
2168 | cmdStart = ch->mailbox->cstart; | 1837 | cmdStart = readw(&ch->mailbox->cstart); |
2169 | |||
2170 | /* ------------------------------------------------------------------ | 1838 | /* ------------------------------------------------------------------ |
2171 | We do the addition below because we do not want a max pointer | 1839 | 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 | 1840 | relative to cmdStart. We want a max pointer that points at the |
2173 | physical end of the command queue. | 1841 | physical end of the command queue. |
2174 | -------------------------------------------------------------------- */ | 1842 | -------------------------------------------------------------------- */ |
2175 | 1843 | cmdMax = (cmdStart + 4 + readw(&ch->mailbox->cmax)); | |
2176 | cmdMax = (cmdStart + 4 + (ch->mailbox->cmax)); | ||
2177 | |||
2178 | memaddr = ch->board->re_map_membase; | 1844 | memaddr = ch->board->re_map_membase; |
2179 | 1845 | ||
2180 | /* | 1846 | if (head >= (cmdMax - cmdStart) || (head & 03)) { |
2181 | The below command is necessary because newer kernels (2.1.x and | 1847 | 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 | 1848 | 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; | 1849 | return; |
2195 | } | 1850 | } |
2196 | 1851 | if (bytecmd) { | |
2197 | if (bytecmd) | 1852 | writeb(cmd, memaddr + head + cmdStart + 0); |
2198 | { | 1853 | 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 */ | 1854 | /* Below word_or_byte is bits to set */ |
2203 | *(volatile unchar *)(memaddr + head + cmdStart + 2) = (unchar)word_or_byte; | 1855 | writeb(word_or_byte, memaddr + head + cmdStart + 2); |
2204 | /* Below byte2 is bits to reset */ | 1856 | /* Below byte2 is bits to reset */ |
2205 | *(volatile unchar *)(memaddr + head + cmdStart + 3) = (unchar)byte2; | 1857 | writeb(byte2, memaddr + head + cmdStart + 3); |
2206 | 1858 | } else { | |
2207 | } | 1859 | writeb(cmd, memaddr + head + cmdStart + 0); |
2208 | else | 1860 | writeb(ch->channelnum, memaddr + head + cmdStart + 1); |
2209 | { | 1861 | 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 | } | 1862 | } |
2214 | |||
2215 | head = (head + 4) & (cmdMax - cmdStart - 4); | 1863 | head = (head + 4) & (cmdMax - cmdStart - 4); |
2216 | ch->mailbox->cin = head; | 1864 | writew(head, &ch->mailbox->cin); |
2217 | |||
2218 | count = FEPTIMEOUT; | 1865 | count = FEPTIMEOUT; |
2219 | 1866 | ||
2220 | for (;;) | 1867 | for (;;) { /* Begin forever loop */ |
2221 | { /* Begin forever loop */ | ||
2222 | |||
2223 | count--; | 1868 | count--; |
2224 | if (count == 0) | 1869 | if (count == 0) { |
2225 | { | ||
2226 | printk(KERN_ERR "<Error> - Fep not responding in fepcmd()\n"); | 1870 | printk(KERN_ERR "<Error> - Fep not responding in fepcmd()\n"); |
2227 | return; | 1871 | return; |
2228 | } | 1872 | } |
2229 | 1873 | head = readw(&ch->mailbox->cin); | |
2230 | head = ch->mailbox->cin; | 1874 | cmdTail = readw(&ch->mailbox->cout); |
2231 | cmdTail = ch->mailbox->cout; | ||
2232 | |||
2233 | n = (head - cmdTail) & (cmdMax - cmdStart - 4); | 1875 | n = (head - cmdTail) & (cmdMax - cmdStart - 4); |
2234 | |||
2235 | /* ---------------------------------------------------------- | 1876 | /* ---------------------------------------------------------- |
2236 | Basically this will break when the FEP acknowledges the | 1877 | Basically this will break when the FEP acknowledges the |
2237 | command by incrementing cmdTail (Making it equal to head). | 1878 | command by incrementing cmdTail (Making it equal to head). |
2238 | ------------------------------------------------------------- */ | 1879 | ------------------------------------------------------------- */ |
2239 | |||
2240 | if (n <= ncmds * (sizeof(short) * 4)) | 1880 | if (n <= ncmds * (sizeof(short) * 4)) |
2241 | break; /* Well nearly forever :-) */ | 1881 | break; /* Well nearly forever :-) */ |
2242 | |||
2243 | } /* End forever loop */ | 1882 | } /* End forever loop */ |
2244 | |||
2245 | } /* End fepcmd */ | 1883 | } /* End fepcmd */ |
2246 | 1884 | ||
2247 | /* --------------------------------------------------------------------- | 1885 | /* --------------------------------------------------------------------- |
@@ -2255,11 +1893,9 @@ static void fepcmd(struct channel *ch, int cmd, int word_or_byte, | |||
2255 | 1893 | ||
2256 | static unsigned termios2digi_h(struct channel *ch, unsigned cflag) | 1894 | static unsigned termios2digi_h(struct channel *ch, unsigned cflag) |
2257 | { /* Begin termios2digi_h */ | 1895 | { /* Begin termios2digi_h */ |
2258 | |||
2259 | unsigned res = 0; | 1896 | unsigned res = 0; |
2260 | 1897 | ||
2261 | if (cflag & CRTSCTS) | 1898 | if (cflag & CRTSCTS) { |
2262 | { | ||
2263 | ch->digiext.digi_flags |= (RTSPACE | CTSPACE); | 1899 | ch->digiext.digi_flags |= (RTSPACE | CTSPACE); |
2264 | res |= ((ch->m_cts) | (ch->m_rts)); | 1900 | res |= ((ch->m_cts) | (ch->m_rts)); |
2265 | } | 1901 | } |
@@ -2295,7 +1931,6 @@ static unsigned termios2digi_i(struct channel *ch, unsigned iflag) | |||
2295 | 1931 | ||
2296 | unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | | 1932 | unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | |
2297 | INPCK | ISTRIP|IXON|IXANY|IXOFF); | 1933 | INPCK | ISTRIP|IXON|IXANY|IXOFF); |
2298 | |||
2299 | if (ch->digiext.digi_flags & DIGI_AIXON) | 1934 | if (ch->digiext.digi_flags & DIGI_AIXON) |
2300 | res |= IAIXON; | 1935 | res |= IAIXON; |
2301 | return res; | 1936 | return res; |
@@ -2308,28 +1943,15 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2308 | { /* Begin termios2digi_c */ | 1943 | { /* Begin termios2digi_c */ |
2309 | 1944 | ||
2310 | unsigned res = 0; | 1945 | unsigned res = 0; |
2311 | 1946 | 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; | 1947 | ch->digiext.digi_flags |= DIGI_FAST; |
2322 | |||
2323 | /* ------------------------------------------------------------- | 1948 | /* ------------------------------------------------------------- |
2324 | HUPCL bit is used by FEP to indicate fast baud | 1949 | HUPCL bit is used by FEP to indicate fast baud |
2325 | table is to be used. | 1950 | table is to be used. |
2326 | ----------------------------------------------------------------- */ | 1951 | ----------------------------------------------------------------- */ |
2327 | |||
2328 | res |= FEP_HUPCL; | 1952 | res |= FEP_HUPCL; |
2329 | |||
2330 | } /* End detected CBAUDEX */ | 1953 | } /* End detected CBAUDEX */ |
2331 | else ch->digiext.digi_flags &= ~DIGI_FAST; | 1954 | else ch->digiext.digi_flags &= ~DIGI_FAST; |
2332 | |||
2333 | /* ------------------------------------------------------------------- | 1955 | /* ------------------------------------------------------------------- |
2334 | CBAUD has bit position 0x1000 set these days to indicate Linux | 1956 | CBAUD has bit position 0x1000 set these days to indicate Linux |
2335 | baud rate remap. Digi hardware can't handle the bit assignment. | 1957 | baud rate remap. Digi hardware can't handle the bit assignment. |
@@ -2337,7 +1959,6 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2337 | bit out. | 1959 | bit out. |
2338 | ---------------------------------------------------------------------- */ | 1960 | ---------------------------------------------------------------------- */ |
2339 | res |= cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE); | 1961 | res |= cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE); |
2340 | |||
2341 | /* ------------------------------------------------------------- | 1962 | /* ------------------------------------------------------------- |
2342 | This gets a little confusing. The Digi cards have their own | 1963 | This gets a little confusing. The Digi cards have their own |
2343 | representation of c_cflags controling baud rate. For the most | 1964 | representation of c_cflags controling baud rate. For the most |
@@ -2357,10 +1978,8 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2357 | should be checked for a screened out prior to termios2digi_c | 1978 | should be checked for a screened out prior to termios2digi_c |
2358 | returning. Since CLOCAL isn't used by the board this can be | 1979 | 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. | 1980 | ignored as long as the returned value is used only by Digi hardware. |
2360 | ----------------------------------------------------------------- */ | 1981 | ----------------------------------------------------------------- */ |
2361 | 1982 | if (cflag & CBAUDEX) { | |
2362 | if (cflag & CBAUDEX) | ||
2363 | { | ||
2364 | /* ------------------------------------------------------------- | 1983 | /* ------------------------------------------------------------- |
2365 | The below code is trying to guarantee that only baud rates | 1984 | The below code is trying to guarantee that only baud rates |
2366 | 115200 and 230400 are remapped. We use exclusive or because | 1985 | 115200 and 230400 are remapped. We use exclusive or because |
@@ -2371,138 +1990,96 @@ static unsigned termios2digi_c(struct channel *ch, unsigned cflag) | |||
2371 | 1990 | ||
2372 | if ((!((cflag & 0x7) ^ (B115200 & ~CBAUDEX))) || | 1991 | if ((!((cflag & 0x7) ^ (B115200 & ~CBAUDEX))) || |
2373 | (!((cflag & 0x7) ^ (B230400 & ~CBAUDEX)))) | 1992 | (!((cflag & 0x7) ^ (B230400 & ~CBAUDEX)))) |
2374 | { | ||
2375 | res += 1; | 1993 | res += 1; |
2376 | } | ||
2377 | } | 1994 | } |
2378 | |||
2379 | return res; | 1995 | return res; |
2380 | 1996 | ||
2381 | } /* End termios2digi_c */ | 1997 | } /* End termios2digi_c */ |
2382 | 1998 | ||
2383 | /* --------------------- Begin epcaparam ----------------------- */ | 1999 | /* --------------------- Begin epcaparam ----------------------- */ |
2384 | 2000 | ||
2001 | /* Caller must hold the locks */ | ||
2385 | static void epcaparam(struct tty_struct *tty, struct channel *ch) | 2002 | static void epcaparam(struct tty_struct *tty, struct channel *ch) |
2386 | { /* Begin epcaparam */ | 2003 | { /* Begin epcaparam */ |
2387 | 2004 | ||
2388 | unsigned int cmdHead; | 2005 | unsigned int cmdHead; |
2389 | struct termios *ts; | 2006 | struct termios *ts; |
2390 | volatile struct board_chan *bc; | 2007 | struct board_chan __iomem *bc; |
2391 | unsigned mval, hflow, cflag, iflag; | 2008 | unsigned mval, hflow, cflag, iflag; |
2392 | 2009 | ||
2393 | bc = ch->brdchan; | 2010 | bc = ch->brdchan; |
2394 | epcaassert(bc !=0, "bc out of range"); | 2011 | epcaassert(bc !=0, "bc out of range"); |
2395 | 2012 | ||
2396 | assertgwinon(ch); | 2013 | assertgwinon(ch); |
2397 | |||
2398 | ts = tty->termios; | 2014 | ts = tty->termios; |
2399 | 2015 | if ((ts->c_cflag & CBAUD) == 0) { /* Begin CBAUD detected */ | |
2400 | if ((ts->c_cflag & CBAUD) == 0) | 2016 | cmdHead = readw(&bc->rin); |
2401 | { /* Begin CBAUD detected */ | 2017 | writew(cmdHead, &bc->rout); |
2402 | 2018 | cmdHead = readw(&bc->tin); | |
2403 | cmdHead = bc->rin; | ||
2404 | bc->rout = cmdHead; | ||
2405 | cmdHead = bc->tin; | ||
2406 | |||
2407 | /* Changing baud in mid-stream transmission can be wonderful */ | 2019 | /* Changing baud in mid-stream transmission can be wonderful */ |
2408 | /* --------------------------------------------------------------- | 2020 | /* --------------------------------------------------------------- |
2409 | Flush current transmit buffer by setting cmdTail pointer (tout) | 2021 | Flush current transmit buffer by setting cmdTail pointer (tout) |
2410 | to cmdHead pointer (tin). Hopefully the transmit buffer is empty. | 2022 | to cmdHead pointer (tin). Hopefully the transmit buffer is empty. |
2411 | ----------------------------------------------------------------- */ | 2023 | ----------------------------------------------------------------- */ |
2412 | |||
2413 | fepcmd(ch, STOUT, (unsigned) cmdHead, 0, 0, 0); | 2024 | fepcmd(ch, STOUT, (unsigned) cmdHead, 0, 0, 0); |
2414 | mval = 0; | 2025 | mval = 0; |
2415 | 2026 | } else { /* Begin CBAUD not detected */ | |
2416 | } /* End CBAUD detected */ | ||
2417 | else | ||
2418 | { /* Begin CBAUD not detected */ | ||
2419 | |||
2420 | /* ------------------------------------------------------------------- | 2027 | /* ------------------------------------------------------------------- |
2421 | c_cflags have changed but that change had nothing to do with BAUD. | 2028 | c_cflags have changed but that change had nothing to do with BAUD. |
2422 | Propagate the change to the card. | 2029 | Propagate the change to the card. |
2423 | ---------------------------------------------------------------------- */ | 2030 | ---------------------------------------------------------------------- */ |
2424 | |||
2425 | cflag = termios2digi_c(ch, ts->c_cflag); | 2031 | cflag = termios2digi_c(ch, ts->c_cflag); |
2426 | 2032 | if (cflag != ch->fepcflag) { | |
2427 | if (cflag != ch->fepcflag) | ||
2428 | { | ||
2429 | ch->fepcflag = cflag; | 2033 | ch->fepcflag = cflag; |
2430 | /* Set baud rate, char size, stop bits, parity */ | 2034 | /* Set baud rate, char size, stop bits, parity */ |
2431 | fepcmd(ch, SETCTRLFLAGS, (unsigned) cflag, 0, 0, 0); | 2035 | fepcmd(ch, SETCTRLFLAGS, (unsigned) cflag, 0, 0, 0); |
2432 | } | 2036 | } |
2433 | |||
2434 | |||
2435 | /* ---------------------------------------------------------------- | 2037 | /* ---------------------------------------------------------------- |
2436 | If the user has not forced CLOCAL and if the device is not a | 2038 | 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 | 2039 | CALLOUT device (Which is always CLOCAL) we set flags such that |
2438 | the driver will wait on carrier detect. | 2040 | the driver will wait on carrier detect. |
2439 | ------------------------------------------------------------------- */ | 2041 | ------------------------------------------------------------------- */ |
2440 | |||
2441 | if (ts->c_cflag & CLOCAL) | 2042 | 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; | 2043 | ch->asyncflags &= ~ASYNC_CHECK_CD; |
2444 | } /* End it is a cud device or a ttyD device with CLOCAL on */ | ||
2445 | else | 2044 | else |
2446 | { /* Begin it is a ttyD device */ | ||
2447 | ch->asyncflags |= ASYNC_CHECK_CD; | 2045 | ch->asyncflags |= ASYNC_CHECK_CD; |
2448 | } /* End it is a ttyD device */ | ||
2449 | |||
2450 | mval = ch->m_dtr | ch->m_rts; | 2046 | mval = ch->m_dtr | ch->m_rts; |
2451 | |||
2452 | } /* End CBAUD not detected */ | 2047 | } /* End CBAUD not detected */ |
2453 | |||
2454 | iflag = termios2digi_i(ch, ts->c_iflag); | 2048 | iflag = termios2digi_i(ch, ts->c_iflag); |
2455 | |||
2456 | /* Check input mode flags */ | 2049 | /* Check input mode flags */ |
2457 | 2050 | if (iflag != ch->fepiflag) { | |
2458 | if (iflag != ch->fepiflag) | ||
2459 | { | ||
2460 | ch->fepiflag = iflag; | 2051 | ch->fepiflag = iflag; |
2461 | |||
2462 | /* --------------------------------------------------------------- | 2052 | /* --------------------------------------------------------------- |
2463 | Command sets channels iflag structure on the board. Such things | 2053 | Command sets channels iflag structure on the board. Such things |
2464 | as input soft flow control, handling of parity errors, and | 2054 | as input soft flow control, handling of parity errors, and |
2465 | break handling are all set here. | 2055 | break handling are all set here. |
2466 | ------------------------------------------------------------------- */ | 2056 | ------------------------------------------------------------------- */ |
2467 | |||
2468 | /* break handling, parity handling, input stripping, flow control chars */ | 2057 | /* break handling, parity handling, input stripping, flow control chars */ |
2469 | fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0); | 2058 | fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0); |
2470 | } | 2059 | } |
2471 | |||
2472 | /* --------------------------------------------------------------- | 2060 | /* --------------------------------------------------------------- |
2473 | Set the board mint value for this channel. This will cause hardware | 2061 | 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) | 2062 | events to be generated each time the DCD signal (Described in mint) |
2475 | changes. | 2063 | changes. |
2476 | ------------------------------------------------------------------- */ | 2064 | ------------------------------------------------------------------- */ |
2477 | bc->mint = ch->dcd; | 2065 | writeb(ch->dcd, &bc->mint); |
2478 | |||
2479 | if ((ts->c_cflag & CLOCAL) || (ch->digiext.digi_flags & DIGI_FORCEDCD)) | 2066 | if ((ts->c_cflag & CLOCAL) || (ch->digiext.digi_flags & DIGI_FORCEDCD)) |
2480 | if (ch->digiext.digi_flags & DIGI_FORCEDCD) | 2067 | if (ch->digiext.digi_flags & DIGI_FORCEDCD) |
2481 | bc->mint = 0; | 2068 | writeb(0, &bc->mint); |
2482 | 2069 | ch->imodem = readb(&bc->mstat); | |
2483 | ch->imodem = bc->mstat; | ||
2484 | |||
2485 | hflow = termios2digi_h(ch, ts->c_cflag); | 2070 | hflow = termios2digi_h(ch, ts->c_cflag); |
2486 | 2071 | if (hflow != ch->hflow) { | |
2487 | if (hflow != ch->hflow) | ||
2488 | { | ||
2489 | ch->hflow = hflow; | 2072 | ch->hflow = hflow; |
2490 | |||
2491 | /* -------------------------------------------------------------- | 2073 | /* -------------------------------------------------------------- |
2492 | Hard flow control has been selected but the board is not | 2074 | Hard flow control has been selected but the board is not |
2493 | using it. Activate hard flow control now. | 2075 | using it. Activate hard flow control now. |
2494 | ----------------------------------------------------------------- */ | 2076 | ----------------------------------------------------------------- */ |
2495 | |||
2496 | fepcmd(ch, SETHFLOW, hflow, 0xff, 0, 1); | 2077 | fepcmd(ch, SETHFLOW, hflow, 0xff, 0, 1); |
2497 | } | 2078 | } |
2498 | |||
2499 | |||
2500 | mval ^= ch->modemfake & (mval ^ ch->modem); | 2079 | mval ^= ch->modemfake & (mval ^ ch->modem); |
2501 | 2080 | ||
2502 | if (ch->omodem ^ mval) | 2081 | if (ch->omodem ^ mval) { |
2503 | { | ||
2504 | ch->omodem = mval; | 2082 | ch->omodem = mval; |
2505 | |||
2506 | /* -------------------------------------------------------------- | 2083 | /* -------------------------------------------------------------- |
2507 | The below command sets the DTR and RTS mstat structure. If | 2084 | The below command sets the DTR and RTS mstat structure. If |
2508 | hard flow control is NOT active these changes will drive the | 2085 | hard flow control is NOT active these changes will drive the |
@@ -2514,87 +2091,65 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch) | |||
2514 | /* First reset DTR & RTS; then set them */ | 2091 | /* First reset DTR & RTS; then set them */ |
2515 | fepcmd(ch, SETMODEM, 0, ((ch->m_dtr)|(ch->m_rts)), 0, 1); | 2092 | fepcmd(ch, SETMODEM, 0, ((ch->m_dtr)|(ch->m_rts)), 0, 1); |
2516 | fepcmd(ch, SETMODEM, mval, 0, 0, 1); | 2093 | fepcmd(ch, SETMODEM, mval, 0, 0, 1); |
2517 | |||
2518 | } | 2094 | } |
2519 | 2095 | 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; | 2096 | ch->fepstartc = ch->startc; |
2523 | ch->fepstopc = ch->stopc; | 2097 | ch->fepstopc = ch->stopc; |
2524 | |||
2525 | /* ------------------------------------------------------------ | 2098 | /* ------------------------------------------------------------ |
2526 | The XON / XOFF characters have changed; propagate these | 2099 | The XON / XOFF characters have changed; propagate these |
2527 | changes to the card. | 2100 | changes to the card. |
2528 | --------------------------------------------------------------- */ | 2101 | --------------------------------------------------------------- */ |
2529 | |||
2530 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); | 2102 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); |
2531 | } | 2103 | } |
2532 | 2104 | 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; | 2105 | ch->fepstartca = ch->startca; |
2536 | ch->fepstopca = ch->stopca; | 2106 | ch->fepstopca = ch->stopca; |
2537 | |||
2538 | /* --------------------------------------------------------------- | 2107 | /* --------------------------------------------------------------- |
2539 | Similar to the above, this time the auxilarly XON / XOFF | 2108 | Similar to the above, this time the auxilarly XON / XOFF |
2540 | characters have changed; propagate these changes to the card. | 2109 | characters have changed; propagate these changes to the card. |
2541 | ------------------------------------------------------------------ */ | 2110 | ------------------------------------------------------------------ */ |
2542 | |||
2543 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); | 2111 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); |
2544 | } | 2112 | } |
2545 | |||
2546 | } /* End epcaparam */ | 2113 | } /* End epcaparam */ |
2547 | 2114 | ||
2548 | /* --------------------- Begin receive_data ----------------------- */ | 2115 | /* --------------------- Begin receive_data ----------------------- */ |
2549 | 2116 | /* Caller holds lock */ | |
2550 | static void receive_data(struct channel *ch) | 2117 | static void receive_data(struct channel *ch) |
2551 | { /* Begin receive_data */ | 2118 | { /* Begin receive_data */ |
2552 | 2119 | ||
2553 | unchar *rptr; | 2120 | unchar *rptr; |
2554 | struct termios *ts = NULL; | 2121 | struct termios *ts = NULL; |
2555 | struct tty_struct *tty; | 2122 | struct tty_struct *tty; |
2556 | volatile struct board_chan *bc; | 2123 | struct board_chan __iomem *bc; |
2557 | register int dataToRead, wrapgap, bytesAvailable; | 2124 | int dataToRead, wrapgap, bytesAvailable; |
2558 | register unsigned int tail, head; | 2125 | unsigned int tail, head; |
2559 | unsigned int wrapmask; | 2126 | unsigned int wrapmask; |
2560 | int rc; | 2127 | int rc; |
2561 | 2128 | ||
2562 | |||
2563 | /* --------------------------------------------------------------- | 2129 | /* --------------------------------------------------------------- |
2564 | This routine is called by doint when a receive data event | 2130 | This routine is called by doint when a receive data event |
2565 | has taken place. | 2131 | has taken place. |
2566 | ------------------------------------------------------------------- */ | 2132 | ------------------------------------------------------------------- */ |
2567 | 2133 | ||
2568 | globalwinon(ch); | 2134 | globalwinon(ch); |
2569 | |||
2570 | if (ch->statusflags & RXSTOPPED) | 2135 | if (ch->statusflags & RXSTOPPED) |
2571 | return; | 2136 | return; |
2572 | |||
2573 | tty = ch->tty; | 2137 | tty = ch->tty; |
2574 | if (tty) | 2138 | if (tty) |
2575 | ts = tty->termios; | 2139 | ts = tty->termios; |
2576 | |||
2577 | bc = ch->brdchan; | 2140 | bc = ch->brdchan; |
2578 | 2141 | 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; | 2142 | wrapmask = ch->rxbufsize - 1; |
2586 | 2143 | ||
2587 | /* --------------------------------------------------------------------- | 2144 | /* --------------------------------------------------------------------- |
2588 | Get the head and tail pointers to the receiver queue. Wrap the | 2145 | Get the head and tail pointers to the receiver queue. Wrap the |
2589 | head pointer if it has reached the end of the buffer. | 2146 | head pointer if it has reached the end of the buffer. |
2590 | ------------------------------------------------------------------------ */ | 2147 | ------------------------------------------------------------------------ */ |
2591 | 2148 | head = readw(&bc->rin); | |
2592 | head = bc->rin; | ||
2593 | head &= wrapmask; | 2149 | head &= wrapmask; |
2594 | tail = bc->rout & wrapmask; | 2150 | tail = readw(&bc->rout) & wrapmask; |
2595 | 2151 | ||
2596 | bytesAvailable = (head - tail) & wrapmask; | 2152 | bytesAvailable = (head - tail) & wrapmask; |
2597 | |||
2598 | if (bytesAvailable == 0) | 2153 | if (bytesAvailable == 0) |
2599 | return; | 2154 | return; |
2600 | 2155 | ||
@@ -2602,73 +2157,53 @@ static void receive_data(struct channel *ch) | |||
2602 | If CREAD bit is off or device not open, set TX tail to head | 2157 | If CREAD bit is off or device not open, set TX tail to head |
2603 | --------------------------------------------------------------------- */ | 2158 | --------------------------------------------------------------------- */ |
2604 | 2159 | ||
2605 | if (!tty || !ts || !(ts->c_cflag & CREAD)) | 2160 | if (!tty || !ts || !(ts->c_cflag & CREAD)) { |
2606 | { | 2161 | writew(head, &bc->rout); |
2607 | bc->rout = head; | ||
2608 | return; | 2162 | return; |
2609 | } | 2163 | } |
2610 | 2164 | ||
2611 | if (tty->flip.count == TTY_FLIPBUF_SIZE) | 2165 | if (tty->flip.count == TTY_FLIPBUF_SIZE) |
2612 | return; | 2166 | return; |
2613 | 2167 | ||
2614 | if (bc->orun) | 2168 | if (readb(&bc->orun)) { |
2615 | { | 2169 | writeb(0, &bc->orun); |
2616 | bc->orun = 0; | 2170 | printk(KERN_WARNING "epca; overrun! DigiBoard device %s\n",tty->name); |
2617 | printk(KERN_WARNING "overrun! DigiBoard device %s\n",tty->name); | ||
2618 | } | 2171 | } |
2619 | |||
2620 | rxwinon(ch); | 2172 | rxwinon(ch); |
2621 | rptr = tty->flip.char_buf_ptr; | 2173 | rptr = tty->flip.char_buf_ptr; |
2622 | rc = tty->flip.count; | 2174 | rc = tty->flip.count; |
2623 | 2175 | 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; | 2176 | wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail; |
2628 | |||
2629 | /* --------------------------------------------------------------- | 2177 | /* --------------------------------------------------------------- |
2630 | Even if head has wrapped around only report the amount of | 2178 | Even if head has wrapped around only report the amount of |
2631 | data to be equal to the size - tail. Remember memcpy can't | 2179 | data to be equal to the size - tail. Remember memcpy can't |
2632 | automaticly wrap around the receive buffer. | 2180 | automaticly wrap around the receive buffer. |
2633 | ----------------------------------------------------------------- */ | 2181 | ----------------------------------------------------------------- */ |
2634 | |||
2635 | dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable; | 2182 | dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable; |
2636 | |||
2637 | /* -------------------------------------------------------------- | 2183 | /* -------------------------------------------------------------- |
2638 | Make sure we don't overflow the buffer | 2184 | Make sure we don't overflow the buffer |
2639 | ----------------------------------------------------------------- */ | 2185 | ----------------------------------------------------------------- */ |
2640 | |||
2641 | if ((rc + dataToRead) > TTY_FLIPBUF_SIZE) | 2186 | if ((rc + dataToRead) > TTY_FLIPBUF_SIZE) |
2642 | dataToRead = TTY_FLIPBUF_SIZE - rc; | 2187 | dataToRead = TTY_FLIPBUF_SIZE - rc; |
2643 | |||
2644 | if (dataToRead == 0) | 2188 | if (dataToRead == 0) |
2645 | break; | 2189 | break; |
2646 | |||
2647 | /* --------------------------------------------------------------- | 2190 | /* --------------------------------------------------------------- |
2648 | Move data read from our card into the line disciplines buffer | 2191 | Move data read from our card into the line disciplines buffer |
2649 | for translation if necessary. | 2192 | for translation if necessary. |
2650 | ------------------------------------------------------------------ */ | 2193 | ------------------------------------------------------------------ */ |
2651 | 2194 | 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; | 2195 | rc += dataToRead; |
2656 | rptr += dataToRead; | 2196 | rptr += dataToRead; |
2657 | tail = (tail + dataToRead) & wrapmask; | 2197 | tail = (tail + dataToRead) & wrapmask; |
2658 | bytesAvailable -= dataToRead; | 2198 | bytesAvailable -= dataToRead; |
2659 | |||
2660 | } /* End while there is data on the card */ | 2199 | } /* End while there is data on the card */ |
2661 | |||
2662 | |||
2663 | tty->flip.count = rc; | 2200 | tty->flip.count = rc; |
2664 | tty->flip.char_buf_ptr = rptr; | 2201 | tty->flip.char_buf_ptr = rptr; |
2665 | globalwinon(ch); | 2202 | globalwinon(ch); |
2666 | bc->rout = tail; | 2203 | writew(tail, &bc->rout); |
2667 | |||
2668 | /* Must be called with global data */ | 2204 | /* Must be called with global data */ |
2669 | tty_schedule_flip(ch->tty); | 2205 | tty_schedule_flip(ch->tty); |
2670 | return; | 2206 | return; |
2671 | |||
2672 | } /* End receive_data */ | 2207 | } /* End receive_data */ |
2673 | 2208 | ||
2674 | static int info_ioctl(struct tty_struct *tty, struct file * file, | 2209 | static int info_ioctl(struct tty_struct *tty, struct file * file, |
@@ -2676,17 +2211,15 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2676 | { | 2211 | { |
2677 | switch (cmd) | 2212 | switch (cmd) |
2678 | { /* Begin switch cmd */ | 2213 | { /* Begin switch cmd */ |
2679 | |||
2680 | case DIGI_GETINFO: | 2214 | case DIGI_GETINFO: |
2681 | { /* Begin case DIGI_GETINFO */ | 2215 | { /* Begin case DIGI_GETINFO */ |
2682 | |||
2683 | struct digi_info di ; | 2216 | struct digi_info di ; |
2684 | int brd; | 2217 | int brd; |
2685 | 2218 | ||
2686 | getUser(brd, (unsigned int __user *)arg); | 2219 | if(get_user(brd, (unsigned int __user *)arg)) |
2687 | 2220 | return -EFAULT; | |
2688 | if ((brd < 0) || (brd >= num_cards) || (num_cards == 0)) | 2221 | if (brd < 0 || brd >= num_cards || num_cards == 0) |
2689 | return (-ENODEV); | 2222 | return -ENODEV; |
2690 | 2223 | ||
2691 | memset(&di, 0, sizeof(di)); | 2224 | memset(&di, 0, sizeof(di)); |
2692 | 2225 | ||
@@ -2694,8 +2227,9 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2694 | di.status = boards[brd].status; | 2227 | di.status = boards[brd].status; |
2695 | di.type = boards[brd].type ; | 2228 | di.type = boards[brd].type ; |
2696 | di.numports = boards[brd].numports ; | 2229 | di.numports = boards[brd].numports ; |
2697 | di.port = boards[brd].port ; | 2230 | /* Legacy fixups - just move along nothing to see */ |
2698 | di.membase = boards[brd].membase ; | 2231 | di.port = (unsigned char *)boards[brd].port ; |
2232 | di.membase = (unsigned char *)boards[brd].membase ; | ||
2699 | 2233 | ||
2700 | if (copy_to_user((void __user *)arg, &di, sizeof (di))) | 2234 | if (copy_to_user((void __user *)arg, &di, sizeof (di))) |
2701 | return -EFAULT; | 2235 | return -EFAULT; |
@@ -2709,39 +2243,29 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2709 | int brd = arg & 0xff000000 >> 16 ; | 2243 | int brd = arg & 0xff000000 >> 16 ; |
2710 | unsigned char state = arg & 0xff ; | 2244 | unsigned char state = arg & 0xff ; |
2711 | 2245 | ||
2712 | if ((brd < 0) || (brd >= num_cards)) | 2246 | if (brd < 0 || brd >= num_cards) { |
2713 | { | 2247 | printk(KERN_ERR "epca: DIGI POLLER : brd not valid!\n"); |
2714 | printk(KERN_ERR "<Error> - DIGI POLLER : brd not valid!\n"); | ||
2715 | return (-ENODEV); | 2248 | return (-ENODEV); |
2716 | } | 2249 | } |
2717 | |||
2718 | digi_poller_inhibited = state ; | 2250 | digi_poller_inhibited = state ; |
2719 | break ; | 2251 | break ; |
2720 | |||
2721 | } /* End case DIGI_POLLER */ | 2252 | } /* End case DIGI_POLLER */ |
2722 | 2253 | ||
2723 | case DIGI_INIT: | 2254 | case DIGI_INIT: |
2724 | { /* Begin case DIGI_INIT */ | 2255 | { /* Begin case DIGI_INIT */ |
2725 | |||
2726 | /* ------------------------------------------------------------ | 2256 | /* ------------------------------------------------------------ |
2727 | This call is made by the apps to complete the initilization | 2257 | This call is made by the apps to complete the initilization |
2728 | of the board(s). This routine is responsible for setting | 2258 | of the board(s). This routine is responsible for setting |
2729 | the card to its initial state and setting the drivers control | 2259 | the card to its initial state and setting the drivers control |
2730 | fields to the sutianle settings for the card in question. | 2260 | fields to the sutianle settings for the card in question. |
2731 | ---------------------------------------------------------------- */ | 2261 | ---------------------------------------------------------------- */ |
2732 | |||
2733 | int crd ; | 2262 | int crd ; |
2734 | for (crd = 0; crd < num_cards; crd++) | 2263 | for (crd = 0; crd < num_cards; crd++) |
2735 | post_fep_init (crd); | 2264 | post_fep_init (crd); |
2736 | |||
2737 | break ; | 2265 | break ; |
2738 | |||
2739 | } /* End case DIGI_INIT */ | 2266 | } /* End case DIGI_INIT */ |
2740 | |||
2741 | |||
2742 | default: | 2267 | default: |
2743 | return -ENOIOCTLCMD; | 2268 | return -ENOTTY; |
2744 | |||
2745 | } /* End switch cmd */ | 2269 | } /* End switch cmd */ |
2746 | return (0) ; | 2270 | return (0) ; |
2747 | } | 2271 | } |
@@ -2750,43 +2274,33 @@ static int info_ioctl(struct tty_struct *tty, struct file * file, | |||
2750 | static int pc_tiocmget(struct tty_struct *tty, struct file *file) | 2274 | static int pc_tiocmget(struct tty_struct *tty, struct file *file) |
2751 | { | 2275 | { |
2752 | struct channel *ch = (struct channel *) tty->driver_data; | 2276 | struct channel *ch = (struct channel *) tty->driver_data; |
2753 | volatile struct board_chan *bc; | 2277 | struct board_chan __iomem *bc; |
2754 | unsigned int mstat, mflag = 0; | 2278 | unsigned int mstat, mflag = 0; |
2755 | unsigned long flags; | 2279 | unsigned long flags; |
2756 | 2280 | ||
2757 | if (ch) | 2281 | if (ch) |
2758 | bc = ch->brdchan; | 2282 | bc = ch->brdchan; |
2759 | else | 2283 | else |
2760 | { | 2284 | return -EINVAL; |
2761 | printk(KERN_ERR "<Error> - ch is NULL in pc_tiocmget!\n"); | ||
2762 | return(-EINVAL); | ||
2763 | } | ||
2764 | 2285 | ||
2765 | save_flags(flags); | 2286 | spin_lock_irqsave(&epca_lock, flags); |
2766 | cli(); | ||
2767 | globalwinon(ch); | 2287 | globalwinon(ch); |
2768 | mstat = bc->mstat; | 2288 | mstat = readb(&bc->mstat); |
2769 | memoff(ch); | 2289 | memoff(ch); |
2770 | restore_flags(flags); | 2290 | spin_unlock_irqrestore(&epca_lock, flags); |
2771 | 2291 | ||
2772 | if (mstat & ch->m_dtr) | 2292 | if (mstat & ch->m_dtr) |
2773 | mflag |= TIOCM_DTR; | 2293 | mflag |= TIOCM_DTR; |
2774 | |||
2775 | if (mstat & ch->m_rts) | 2294 | if (mstat & ch->m_rts) |
2776 | mflag |= TIOCM_RTS; | 2295 | mflag |= TIOCM_RTS; |
2777 | |||
2778 | if (mstat & ch->m_cts) | 2296 | if (mstat & ch->m_cts) |
2779 | mflag |= TIOCM_CTS; | 2297 | mflag |= TIOCM_CTS; |
2780 | |||
2781 | if (mstat & ch->dsr) | 2298 | if (mstat & ch->dsr) |
2782 | mflag |= TIOCM_DSR; | 2299 | mflag |= TIOCM_DSR; |
2783 | |||
2784 | if (mstat & ch->m_ri) | 2300 | if (mstat & ch->m_ri) |
2785 | mflag |= TIOCM_RI; | 2301 | mflag |= TIOCM_RI; |
2786 | |||
2787 | if (mstat & ch->dcd) | 2302 | if (mstat & ch->dcd) |
2788 | mflag |= TIOCM_CD; | 2303 | mflag |= TIOCM_CD; |
2789 | |||
2790 | return mflag; | 2304 | return mflag; |
2791 | } | 2305 | } |
2792 | 2306 | ||
@@ -2796,13 +2310,10 @@ static int pc_tiocmset(struct tty_struct *tty, struct file *file, | |||
2796 | struct channel *ch = (struct channel *) tty->driver_data; | 2310 | struct channel *ch = (struct channel *) tty->driver_data; |
2797 | unsigned long flags; | 2311 | unsigned long flags; |
2798 | 2312 | ||
2799 | if (!ch) { | 2313 | if (!ch) |
2800 | printk(KERN_ERR "<Error> - ch is NULL in pc_tiocmset!\n"); | 2314 | return -EINVAL; |
2801 | return(-EINVAL); | ||
2802 | } | ||
2803 | 2315 | ||
2804 | save_flags(flags); | 2316 | spin_lock_irqsave(&epca_lock, flags); |
2805 | cli(); | ||
2806 | /* | 2317 | /* |
2807 | * I think this modemfake stuff is broken. It doesn't | 2318 | * I think this modemfake stuff is broken. It doesn't |
2808 | * correctly reflect the behaviour desired by the TIOCM* | 2319 | * correctly reflect the behaviour desired by the TIOCM* |
@@ -2824,17 +2335,14 @@ static int pc_tiocmset(struct tty_struct *tty, struct file *file, | |||
2824 | ch->modemfake |= ch->m_dtr; | 2335 | ch->modemfake |= ch->m_dtr; |
2825 | ch->modem &= ~ch->m_dtr; | 2336 | ch->modem &= ~ch->m_dtr; |
2826 | } | 2337 | } |
2827 | |||
2828 | globalwinon(ch); | 2338 | globalwinon(ch); |
2829 | |||
2830 | /* -------------------------------------------------------------- | 2339 | /* -------------------------------------------------------------- |
2831 | The below routine generally sets up parity, baud, flow control | 2340 | The below routine generally sets up parity, baud, flow control |
2832 | issues, etc.... It effect both control flags and input flags. | 2341 | issues, etc.... It effect both control flags and input flags. |
2833 | ------------------------------------------------------------------ */ | 2342 | ------------------------------------------------------------------ */ |
2834 | |||
2835 | epcaparam(tty,ch); | 2343 | epcaparam(tty,ch); |
2836 | memoff(ch); | 2344 | memoff(ch); |
2837 | restore_flags(flags); | 2345 | spin_unlock_irqrestore(&epca_lock, flags); |
2838 | return 0; | 2346 | return 0; |
2839 | } | 2347 | } |
2840 | 2348 | ||
@@ -2847,19 +2355,14 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
2847 | unsigned long flags; | 2355 | unsigned long flags; |
2848 | unsigned int mflag, mstat; | 2356 | unsigned int mflag, mstat; |
2849 | unsigned char startc, stopc; | 2357 | unsigned char startc, stopc; |
2850 | volatile struct board_chan *bc; | 2358 | struct board_chan __iomem *bc; |
2851 | struct channel *ch = (struct channel *) tty->driver_data; | 2359 | struct channel *ch = (struct channel *) tty->driver_data; |
2852 | void __user *argp = (void __user *)arg; | 2360 | void __user *argp = (void __user *)arg; |
2853 | 2361 | ||
2854 | if (ch) | 2362 | if (ch) |
2855 | bc = ch->brdchan; | 2363 | bc = ch->brdchan; |
2856 | else | 2364 | else |
2857 | { | 2365 | return -EINVAL; |
2858 | printk(KERN_ERR "<Error> - ch is NULL in pc_ioctl!\n"); | ||
2859 | return(-EINVAL); | ||
2860 | } | ||
2861 | |||
2862 | save_flags(flags); | ||
2863 | 2366 | ||
2864 | /* ------------------------------------------------------------------- | 2367 | /* ------------------------------------------------------------------- |
2865 | For POSIX compliance we need to add more ioctls. See tty_ioctl.c | 2368 | For POSIX compliance we need to add more ioctls. See tty_ioctl.c |
@@ -2871,46 +2374,39 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
2871 | { /* Begin switch cmd */ | 2374 | { /* Begin switch cmd */ |
2872 | 2375 | ||
2873 | case TCGETS: | 2376 | case TCGETS: |
2874 | if (copy_to_user(argp, | 2377 | if (copy_to_user(argp, tty->termios, sizeof(struct termios))) |
2875 | tty->termios, sizeof(struct termios))) | ||
2876 | return -EFAULT; | 2378 | return -EFAULT; |
2877 | return(0); | 2379 | return 0; |
2878 | |||
2879 | case TCGETA: | 2380 | case TCGETA: |
2880 | return get_termio(tty, argp); | 2381 | return get_termio(tty, argp); |
2881 | |||
2882 | case TCSBRK: /* SVID version: non-zero arg --> no break */ | 2382 | case TCSBRK: /* SVID version: non-zero arg --> no break */ |
2883 | |||
2884 | retval = tty_check_change(tty); | 2383 | retval = tty_check_change(tty); |
2885 | if (retval) | 2384 | if (retval) |
2886 | return retval; | 2385 | return retval; |
2887 | |||
2888 | /* Setup an event to indicate when the transmit buffer empties */ | 2386 | /* Setup an event to indicate when the transmit buffer empties */ |
2889 | 2387 | spin_lock_irqsave(&epca_lock, flags); | |
2890 | setup_empty_event(tty,ch); | 2388 | setup_empty_event(tty,ch); |
2389 | spin_unlock_irqrestore(&epca_lock, flags); | ||
2891 | tty_wait_until_sent(tty, 0); | 2390 | tty_wait_until_sent(tty, 0); |
2892 | if (!arg) | 2391 | if (!arg) |
2893 | digi_send_break(ch, HZ/4); /* 1/4 second */ | 2392 | digi_send_break(ch, HZ/4); /* 1/4 second */ |
2894 | return 0; | 2393 | return 0; |
2895 | |||
2896 | case TCSBRKP: /* support for POSIX tcsendbreak() */ | 2394 | case TCSBRKP: /* support for POSIX tcsendbreak() */ |
2897 | |||
2898 | retval = tty_check_change(tty); | 2395 | retval = tty_check_change(tty); |
2899 | if (retval) | 2396 | if (retval) |
2900 | return retval; | 2397 | return retval; |
2901 | 2398 | ||
2902 | /* Setup an event to indicate when the transmit buffer empties */ | 2399 | /* Setup an event to indicate when the transmit buffer empties */ |
2903 | 2400 | spin_lock_irqsave(&epca_lock, flags); | |
2904 | setup_empty_event(tty,ch); | 2401 | setup_empty_event(tty,ch); |
2402 | spin_unlock_irqrestore(&epca_lock, flags); | ||
2905 | tty_wait_until_sent(tty, 0); | 2403 | tty_wait_until_sent(tty, 0); |
2906 | digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4); | 2404 | digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4); |
2907 | return 0; | 2405 | return 0; |
2908 | |||
2909 | case TIOCGSOFTCAR: | 2406 | case TIOCGSOFTCAR: |
2910 | if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)arg)) | 2407 | if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)arg)) |
2911 | return -EFAULT; | 2408 | return -EFAULT; |
2912 | return 0; | 2409 | return 0; |
2913 | |||
2914 | case TIOCSSOFTCAR: | 2410 | case TIOCSSOFTCAR: |
2915 | { | 2411 | { |
2916 | unsigned int value; | 2412 | unsigned int value; |
@@ -2922,75 +2418,63 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
2922 | (value ? CLOCAL : 0)); | 2418 | (value ? CLOCAL : 0)); |
2923 | return 0; | 2419 | return 0; |
2924 | } | 2420 | } |
2925 | |||
2926 | case TIOCMODG: | 2421 | case TIOCMODG: |
2927 | mflag = pc_tiocmget(tty, file); | 2422 | mflag = pc_tiocmget(tty, file); |
2928 | if (put_user(mflag, (unsigned long __user *)argp)) | 2423 | if (put_user(mflag, (unsigned long __user *)argp)) |
2929 | return -EFAULT; | 2424 | return -EFAULT; |
2930 | break; | 2425 | break; |
2931 | |||
2932 | case TIOCMODS: | 2426 | case TIOCMODS: |
2933 | if (get_user(mstat, (unsigned __user *)argp)) | 2427 | if (get_user(mstat, (unsigned __user *)argp)) |
2934 | return -EFAULT; | 2428 | return -EFAULT; |
2935 | return pc_tiocmset(tty, file, mstat, ~mstat); | 2429 | return pc_tiocmset(tty, file, mstat, ~mstat); |
2936 | |||
2937 | case TIOCSDTR: | 2430 | case TIOCSDTR: |
2431 | spin_lock_irqsave(&epca_lock, flags); | ||
2938 | ch->omodem |= ch->m_dtr; | 2432 | ch->omodem |= ch->m_dtr; |
2939 | cli(); | ||
2940 | globalwinon(ch); | 2433 | globalwinon(ch); |
2941 | fepcmd(ch, SETMODEM, ch->m_dtr, 0, 10, 1); | 2434 | fepcmd(ch, SETMODEM, ch->m_dtr, 0, 10, 1); |
2942 | memoff(ch); | 2435 | memoff(ch); |
2943 | restore_flags(flags); | 2436 | spin_unlock_irqrestore(&epca_lock, flags); |
2944 | break; | 2437 | break; |
2945 | 2438 | ||
2946 | case TIOCCDTR: | 2439 | case TIOCCDTR: |
2440 | spin_lock_irqsave(&epca_lock, flags); | ||
2947 | ch->omodem &= ~ch->m_dtr; | 2441 | ch->omodem &= ~ch->m_dtr; |
2948 | cli(); | ||
2949 | globalwinon(ch); | 2442 | globalwinon(ch); |
2950 | fepcmd(ch, SETMODEM, 0, ch->m_dtr, 10, 1); | 2443 | fepcmd(ch, SETMODEM, 0, ch->m_dtr, 10, 1); |
2951 | memoff(ch); | 2444 | memoff(ch); |
2952 | restore_flags(flags); | 2445 | spin_unlock_irqrestore(&epca_lock, flags); |
2953 | break; | 2446 | break; |
2954 | |||
2955 | case DIGI_GETA: | 2447 | case DIGI_GETA: |
2956 | if (copy_to_user(argp, &ch->digiext, sizeof(digi_t))) | 2448 | if (copy_to_user(argp, &ch->digiext, sizeof(digi_t))) |
2957 | return -EFAULT; | 2449 | return -EFAULT; |
2958 | break; | 2450 | break; |
2959 | |||
2960 | case DIGI_SETAW: | 2451 | case DIGI_SETAW: |
2961 | case DIGI_SETAF: | 2452 | case DIGI_SETAF: |
2962 | if ((cmd) == (DIGI_SETAW)) | 2453 | if (cmd == DIGI_SETAW) { |
2963 | { | ||
2964 | /* Setup an event to indicate when the transmit buffer empties */ | 2454 | /* Setup an event to indicate when the transmit buffer empties */ |
2965 | 2455 | spin_lock_irqsave(&epca_lock, flags); | |
2966 | setup_empty_event(tty,ch); | 2456 | setup_empty_event(tty,ch); |
2457 | spin_unlock_irqrestore(&epca_lock, flags); | ||
2967 | tty_wait_until_sent(tty, 0); | 2458 | tty_wait_until_sent(tty, 0); |
2968 | } | 2459 | } else { |
2969 | else | ||
2970 | { | ||
2971 | /* ldisc lock already held in ioctl */ | 2460 | /* ldisc lock already held in ioctl */ |
2972 | if (tty->ldisc.flush_buffer) | 2461 | if (tty->ldisc.flush_buffer) |
2973 | tty->ldisc.flush_buffer(tty); | 2462 | tty->ldisc.flush_buffer(tty); |
2974 | } | 2463 | } |
2975 | |||
2976 | /* Fall Thru */ | 2464 | /* Fall Thru */ |
2977 | |||
2978 | case DIGI_SETA: | 2465 | case DIGI_SETA: |
2979 | if (copy_from_user(&ch->digiext, argp, sizeof(digi_t))) | 2466 | if (copy_from_user(&ch->digiext, argp, sizeof(digi_t))) |
2980 | return -EFAULT; | 2467 | return -EFAULT; |
2981 | 2468 | ||
2982 | if (ch->digiext.digi_flags & DIGI_ALTPIN) | 2469 | if (ch->digiext.digi_flags & DIGI_ALTPIN) { |
2983 | { | ||
2984 | ch->dcd = ch->m_dsr; | 2470 | ch->dcd = ch->m_dsr; |
2985 | ch->dsr = ch->m_dcd; | 2471 | ch->dsr = ch->m_dcd; |
2986 | } | 2472 | } else { |
2987 | else | ||
2988 | { | ||
2989 | ch->dcd = ch->m_dcd; | 2473 | ch->dcd = ch->m_dcd; |
2990 | ch->dsr = ch->m_dsr; | 2474 | ch->dsr = ch->m_dsr; |
2991 | } | 2475 | } |
2992 | 2476 | ||
2993 | cli(); | 2477 | spin_lock_irqsave(&epca_lock, flags); |
2994 | globalwinon(ch); | 2478 | globalwinon(ch); |
2995 | 2479 | ||
2996 | /* ----------------------------------------------------------------- | 2480 | /* ----------------------------------------------------------------- |
@@ -3000,25 +2484,22 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
3000 | 2484 | ||
3001 | epcaparam(tty,ch); | 2485 | epcaparam(tty,ch); |
3002 | memoff(ch); | 2486 | memoff(ch); |
3003 | restore_flags(flags); | 2487 | spin_unlock_irqrestore(&epca_lock, flags); |
3004 | break; | 2488 | break; |
3005 | 2489 | ||
3006 | case DIGI_GETFLOW: | 2490 | case DIGI_GETFLOW: |
3007 | case DIGI_GETAFLOW: | 2491 | case DIGI_GETAFLOW: |
3008 | cli(); | 2492 | spin_lock_irqsave(&epca_lock, flags); |
3009 | globalwinon(ch); | 2493 | globalwinon(ch); |
3010 | if ((cmd) == (DIGI_GETFLOW)) | 2494 | if (cmd == DIGI_GETFLOW) { |
3011 | { | 2495 | dflow.startc = readb(&bc->startc); |
3012 | dflow.startc = bc->startc; | 2496 | dflow.stopc = readb(&bc->stopc); |
3013 | dflow.stopc = bc->stopc; | 2497 | } else { |
3014 | } | 2498 | dflow.startc = readb(&bc->startca); |
3015 | else | 2499 | dflow.stopc = readb(&bc->stopca); |
3016 | { | ||
3017 | dflow.startc = bc->startca; | ||
3018 | dflow.stopc = bc->stopca; | ||
3019 | } | 2500 | } |
3020 | memoff(ch); | 2501 | memoff(ch); |
3021 | restore_flags(flags); | 2502 | spin_unlock_irqrestore(&epca_lock, flags); |
3022 | 2503 | ||
3023 | if (copy_to_user(argp, &dflow, sizeof(dflow))) | 2504 | if (copy_to_user(argp, &dflow, sizeof(dflow))) |
3024 | return -EFAULT; | 2505 | return -EFAULT; |
@@ -3026,13 +2507,10 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
3026 | 2507 | ||
3027 | case DIGI_SETAFLOW: | 2508 | case DIGI_SETAFLOW: |
3028 | case DIGI_SETFLOW: | 2509 | case DIGI_SETFLOW: |
3029 | if ((cmd) == (DIGI_SETFLOW)) | 2510 | if (cmd == DIGI_SETFLOW) { |
3030 | { | ||
3031 | startc = ch->startc; | 2511 | startc = ch->startc; |
3032 | stopc = ch->stopc; | 2512 | stopc = ch->stopc; |
3033 | } | 2513 | } else { |
3034 | else | ||
3035 | { | ||
3036 | startc = ch->startca; | 2514 | startc = ch->startca; |
3037 | stopc = ch->stopca; | 2515 | stopc = ch->stopca; |
3038 | } | 2516 | } |
@@ -3040,40 +2518,31 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file, | |||
3040 | if (copy_from_user(&dflow, argp, sizeof(dflow))) | 2518 | if (copy_from_user(&dflow, argp, sizeof(dflow))) |
3041 | return -EFAULT; | 2519 | return -EFAULT; |
3042 | 2520 | ||
3043 | if (dflow.startc != startc || dflow.stopc != stopc) | 2521 | if (dflow.startc != startc || dflow.stopc != stopc) { /* Begin if setflow toggled */ |
3044 | { /* Begin if setflow toggled */ | 2522 | spin_lock_irqsave(&epca_lock, flags); |
3045 | cli(); | ||
3046 | globalwinon(ch); | 2523 | globalwinon(ch); |
3047 | 2524 | ||
3048 | if ((cmd) == (DIGI_SETFLOW)) | 2525 | if (cmd == DIGI_SETFLOW) { |
3049 | { | ||
3050 | ch->fepstartc = ch->startc = dflow.startc; | 2526 | ch->fepstartc = ch->startc = dflow.startc; |
3051 | ch->fepstopc = ch->stopc = dflow.stopc; | 2527 | ch->fepstopc = ch->stopc = dflow.stopc; |
3052 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); | 2528 | fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); |
3053 | } | 2529 | } else { |
3054 | else | ||
3055 | { | ||
3056 | ch->fepstartca = ch->startca = dflow.startc; | 2530 | ch->fepstartca = ch->startca = dflow.startc; |
3057 | ch->fepstopca = ch->stopca = dflow.stopc; | 2531 | ch->fepstopca = ch->stopca = dflow.stopc; |
3058 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); | 2532 | fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); |
3059 | } | 2533 | } |
3060 | 2534 | ||
3061 | if (ch->statusflags & TXSTOPPED) | 2535 | if (ch->statusflags & TXSTOPPED) |
3062 | pc_start(tty); | 2536 | pc_start(tty); |
3063 | 2537 | ||
3064 | memoff(ch); | 2538 | memoff(ch); |
3065 | restore_flags(flags); | 2539 | spin_unlock_irqrestore(&epca_lock, flags); |
3066 | |||
3067 | } /* End if setflow toggled */ | 2540 | } /* End if setflow toggled */ |
3068 | break; | 2541 | break; |
3069 | |||
3070 | default: | 2542 | default: |
3071 | return -ENOIOCTLCMD; | 2543 | return -ENOIOCTLCMD; |
3072 | |||
3073 | } /* End switch cmd */ | 2544 | } /* End switch cmd */ |
3074 | |||
3075 | return 0; | 2545 | return 0; |
3076 | |||
3077 | } /* End pc_ioctl */ | 2546 | } /* End pc_ioctl */ |
3078 | 2547 | ||
3079 | /* --------------------- Begin pc_set_termios ----------------------- */ | 2548 | /* --------------------- Begin pc_set_termios ----------------------- */ |
@@ -3083,20 +2552,16 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios) | |||
3083 | 2552 | ||
3084 | struct channel *ch; | 2553 | struct channel *ch; |
3085 | unsigned long flags; | 2554 | unsigned long flags; |
3086 | |||
3087 | /* --------------------------------------------------------- | 2555 | /* --------------------------------------------------------- |
3088 | verifyChannel returns the channel from the tty struct | 2556 | verifyChannel returns the channel from the tty struct |
3089 | if it is valid. This serves as a sanity check. | 2557 | if it is valid. This serves as a sanity check. |
3090 | ------------------------------------------------------------- */ | 2558 | ------------------------------------------------------------- */ |
3091 | 2559 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ | |
3092 | if ((ch = verifyChannel(tty)) != NULL) | 2560 | spin_lock_irqsave(&epca_lock, flags); |
3093 | { /* Begin if channel valid */ | ||
3094 | |||
3095 | save_flags(flags); | ||
3096 | cli(); | ||
3097 | globalwinon(ch); | 2561 | globalwinon(ch); |
3098 | epcaparam(tty, ch); | 2562 | epcaparam(tty, ch); |
3099 | memoff(ch); | 2563 | memoff(ch); |
2564 | spin_unlock_irqrestore(&epca_lock, flags); | ||
3100 | 2565 | ||
3101 | if ((old_termios->c_cflag & CRTSCTS) && | 2566 | if ((old_termios->c_cflag & CRTSCTS) && |
3102 | ((tty->termios->c_cflag & CRTSCTS) == 0)) | 2567 | ((tty->termios->c_cflag & CRTSCTS) == 0)) |
@@ -3106,8 +2571,6 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios) | |||
3106 | (tty->termios->c_cflag & CLOCAL)) | 2571 | (tty->termios->c_cflag & CLOCAL)) |
3107 | wake_up_interruptible(&ch->open_wait); | 2572 | wake_up_interruptible(&ch->open_wait); |
3108 | 2573 | ||
3109 | restore_flags(flags); | ||
3110 | |||
3111 | } /* End if channel valid */ | 2574 | } /* End if channel valid */ |
3112 | 2575 | ||
3113 | } /* End pc_set_termios */ | 2576 | } /* End pc_set_termios */ |
@@ -3116,29 +2579,18 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios) | |||
3116 | 2579 | ||
3117 | static void do_softint(void *private_) | 2580 | static void do_softint(void *private_) |
3118 | { /* Begin do_softint */ | 2581 | { /* Begin do_softint */ |
3119 | |||
3120 | struct channel *ch = (struct channel *) private_; | 2582 | struct channel *ch = (struct channel *) private_; |
3121 | |||
3122 | |||
3123 | /* Called in response to a modem change event */ | 2583 | /* Called in response to a modem change event */ |
3124 | 2584 | 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; | 2585 | struct tty_struct *tty = ch->tty; |
3129 | 2586 | ||
3130 | if (tty && tty->driver_data) | 2587 | if (tty && tty->driver_data) { |
3131 | { | 2588 | 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 */ | 2589 | tty_hangup(tty); /* FIXME: module removal race here - AKPM */ |
3136 | wake_up_interruptible(&ch->open_wait); | 2590 | wake_up_interruptible(&ch->open_wait); |
3137 | ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; | 2591 | ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; |
3138 | |||
3139 | } /* End if clear_bit */ | 2592 | } /* End if clear_bit */ |
3140 | } | 2593 | } |
3141 | |||
3142 | } /* End EPCA_MAGIC */ | 2594 | } /* End EPCA_MAGIC */ |
3143 | } /* End do_softint */ | 2595 | } /* End do_softint */ |
3144 | 2596 | ||
@@ -3154,82 +2606,49 @@ static void pc_stop(struct tty_struct *tty) | |||
3154 | 2606 | ||
3155 | struct channel *ch; | 2607 | struct channel *ch; |
3156 | unsigned long flags; | 2608 | unsigned long flags; |
3157 | |||
3158 | /* --------------------------------------------------------- | 2609 | /* --------------------------------------------------------- |
3159 | verifyChannel returns the channel from the tty struct | 2610 | verifyChannel returns the channel from the tty struct |
3160 | if it is valid. This serves as a sanity check. | 2611 | if it is valid. This serves as a sanity check. |
3161 | ------------------------------------------------------------- */ | 2612 | ------------------------------------------------------------- */ |
3162 | 2613 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if valid channel */ | |
3163 | if ((ch = verifyChannel(tty)) != NULL) | 2614 | spin_lock_irqsave(&epca_lock, flags); |
3164 | { /* Begin if valid channel */ | 2615 | 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); | 2616 | globalwinon(ch); |
3173 | |||
3174 | /* STOP transmitting now !! */ | 2617 | /* STOP transmitting now !! */ |
3175 | |||
3176 | fepcmd(ch, PAUSETX, 0, 0, 0, 0); | 2618 | fepcmd(ch, PAUSETX, 0, 0, 0, 0); |
3177 | |||
3178 | ch->statusflags |= TXSTOPPED; | 2619 | ch->statusflags |= TXSTOPPED; |
3179 | memoff(ch); | 2620 | memoff(ch); |
3180 | |||
3181 | } /* End if transmit stop requested */ | 2621 | } /* End if transmit stop requested */ |
3182 | 2622 | spin_unlock_irqrestore(&epca_lock, flags); | |
3183 | restore_flags(flags); | ||
3184 | |||
3185 | } /* End if valid channel */ | 2623 | } /* End if valid channel */ |
3186 | |||
3187 | } /* End pc_stop */ | 2624 | } /* End pc_stop */ |
3188 | 2625 | ||
3189 | /* --------------------- Begin pc_start ----------------------- */ | 2626 | /* --------------------- Begin pc_start ----------------------- */ |
3190 | 2627 | ||
3191 | static void pc_start(struct tty_struct *tty) | 2628 | static void pc_start(struct tty_struct *tty) |
3192 | { /* Begin pc_start */ | 2629 | { /* Begin pc_start */ |
3193 | |||
3194 | struct channel *ch; | 2630 | struct channel *ch; |
3195 | |||
3196 | /* --------------------------------------------------------- | 2631 | /* --------------------------------------------------------- |
3197 | verifyChannel returns the channel from the tty struct | 2632 | verifyChannel returns the channel from the tty struct |
3198 | if it is valid. This serves as a sanity check. | 2633 | if it is valid. This serves as a sanity check. |
3199 | ------------------------------------------------------------- */ | 2634 | ------------------------------------------------------------- */ |
3200 | 2635 | 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; | 2636 | unsigned long flags; |
3205 | 2637 | 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 */ | 2638 | /* Just in case output was resumed because of a change in Digi-flow */ |
3210 | if (ch->statusflags & TXSTOPPED) | 2639 | if (ch->statusflags & TXSTOPPED) { /* Begin transmit resume requested */ |
3211 | { /* Begin transmit resume requested */ | 2640 | struct board_chan __iomem *bc; |
3212 | |||
3213 | volatile struct board_chan *bc; | ||
3214 | |||
3215 | globalwinon(ch); | 2641 | globalwinon(ch); |
3216 | bc = ch->brdchan; | 2642 | bc = ch->brdchan; |
3217 | if (ch->statusflags & LOWWAIT) | 2643 | if (ch->statusflags & LOWWAIT) |
3218 | bc->ilow = 1; | 2644 | writeb(1, &bc->ilow); |
3219 | |||
3220 | /* Okay, you can start transmitting again... */ | 2645 | /* Okay, you can start transmitting again... */ |
3221 | |||
3222 | fepcmd(ch, RESUMETX, 0, 0, 0, 0); | 2646 | fepcmd(ch, RESUMETX, 0, 0, 0, 0); |
3223 | |||
3224 | ch->statusflags &= ~TXSTOPPED; | 2647 | ch->statusflags &= ~TXSTOPPED; |
3225 | memoff(ch); | 2648 | memoff(ch); |
3226 | |||
3227 | } /* End transmit resume requested */ | 2649 | } /* End transmit resume requested */ |
3228 | 2650 | spin_unlock_irqrestore(&epca_lock, flags); | |
3229 | restore_flags(flags); | ||
3230 | |||
3231 | } /* End if channel valid */ | 2651 | } /* End if channel valid */ |
3232 | |||
3233 | } /* End pc_start */ | 2652 | } /* End pc_start */ |
3234 | 2653 | ||
3235 | /* ------------------------------------------------------------------ | 2654 | /* ------------------------------------------------------------------ |
@@ -3244,86 +2663,55 @@ ______________________________________________________________________ */ | |||
3244 | 2663 | ||
3245 | static void pc_throttle(struct tty_struct * tty) | 2664 | static void pc_throttle(struct tty_struct * tty) |
3246 | { /* Begin pc_throttle */ | 2665 | { /* Begin pc_throttle */ |
3247 | |||
3248 | struct channel *ch; | 2666 | struct channel *ch; |
3249 | unsigned long flags; | 2667 | unsigned long flags; |
3250 | |||
3251 | /* --------------------------------------------------------- | 2668 | /* --------------------------------------------------------- |
3252 | verifyChannel returns the channel from the tty struct | 2669 | verifyChannel returns the channel from the tty struct |
3253 | if it is valid. This serves as a sanity check. | 2670 | if it is valid. This serves as a sanity check. |
3254 | ------------------------------------------------------------- */ | 2671 | ------------------------------------------------------------- */ |
3255 | 2672 | if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ | |
3256 | if ((ch = verifyChannel(tty)) != NULL) | 2673 | spin_lock_irqsave(&epca_lock, flags); |
3257 | { /* Begin if channel valid */ | 2674 | if ((ch->statusflags & RXSTOPPED) == 0) { |
3258 | |||
3259 | |||
3260 | save_flags(flags); | ||
3261 | cli(); | ||
3262 | |||
3263 | if ((ch->statusflags & RXSTOPPED) == 0) | ||
3264 | { | ||
3265 | globalwinon(ch); | 2675 | globalwinon(ch); |
3266 | fepcmd(ch, PAUSERX, 0, 0, 0, 0); | 2676 | fepcmd(ch, PAUSERX, 0, 0, 0, 0); |
3267 | |||
3268 | ch->statusflags |= RXSTOPPED; | 2677 | ch->statusflags |= RXSTOPPED; |
3269 | memoff(ch); | 2678 | memoff(ch); |
3270 | } | 2679 | } |
3271 | restore_flags(flags); | 2680 | spin_unlock_irqrestore(&epca_lock, flags); |
3272 | |||
3273 | } /* End if channel valid */ | 2681 | } /* End if channel valid */ |
3274 | |||
3275 | } /* End pc_throttle */ | 2682 | } /* End pc_throttle */ |
3276 | 2683 | ||
3277 | /* --------------------- Begin unthrottle ----------------------- */ | 2684 | /* --------------------- Begin unthrottle ----------------------- */ |
3278 | 2685 | ||
3279 | static void pc_unthrottle(struct tty_struct *tty) | 2686 | static void pc_unthrottle(struct tty_struct *tty) |
3280 | { /* Begin pc_unthrottle */ | 2687 | { /* Begin pc_unthrottle */ |
3281 | |||
3282 | struct channel *ch; | 2688 | struct channel *ch; |
3283 | unsigned long flags; | 2689 | unsigned long flags; |
3284 | volatile struct board_chan *bc; | ||
3285 | |||
3286 | |||
3287 | /* --------------------------------------------------------- | 2690 | /* --------------------------------------------------------- |
3288 | verifyChannel returns the channel from the tty struct | 2691 | verifyChannel returns the channel from the tty struct |
3289 | if it is valid. This serves as a sanity check. | 2692 | if it is valid. This serves as a sanity check. |
3290 | ------------------------------------------------------------- */ | 2693 | ------------------------------------------------------------- */ |
3291 | 2694 | 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 */ | 2695 | /* Just in case output was resumed because of a change in Digi-flow */ |
3297 | save_flags(flags); | 2696 | spin_lock_irqsave(&epca_lock, flags); |
3298 | cli(); | 2697 | if (ch->statusflags & RXSTOPPED) { |
3299 | |||
3300 | if (ch->statusflags & RXSTOPPED) | ||
3301 | { | ||
3302 | |||
3303 | globalwinon(ch); | 2698 | globalwinon(ch); |
3304 | bc = ch->brdchan; | ||
3305 | fepcmd(ch, RESUMERX, 0, 0, 0, 0); | 2699 | fepcmd(ch, RESUMERX, 0, 0, 0, 0); |
3306 | |||
3307 | ch->statusflags &= ~RXSTOPPED; | 2700 | ch->statusflags &= ~RXSTOPPED; |
3308 | memoff(ch); | 2701 | memoff(ch); |
3309 | } | 2702 | } |
3310 | restore_flags(flags); | 2703 | spin_unlock_irqrestore(&epca_lock, flags); |
3311 | |||
3312 | } /* End if channel valid */ | 2704 | } /* End if channel valid */ |
3313 | |||
3314 | } /* End pc_unthrottle */ | 2705 | } /* End pc_unthrottle */ |
3315 | 2706 | ||
3316 | /* --------------------- Begin digi_send_break ----------------------- */ | 2707 | /* --------------------- Begin digi_send_break ----------------------- */ |
3317 | 2708 | ||
3318 | void digi_send_break(struct channel *ch, int msec) | 2709 | void digi_send_break(struct channel *ch, int msec) |
3319 | { /* Begin digi_send_break */ | 2710 | { /* Begin digi_send_break */ |
3320 | |||
3321 | unsigned long flags; | 2711 | unsigned long flags; |
3322 | 2712 | ||
3323 | save_flags(flags); | 2713 | spin_lock_irqsave(&epca_lock, flags); |
3324 | cli(); | ||
3325 | globalwinon(ch); | 2714 | globalwinon(ch); |
3326 | |||
3327 | /* -------------------------------------------------------------------- | 2715 | /* -------------------------------------------------------------------- |
3328 | Maybe I should send an infinite break here, schedule() for | 2716 | Maybe I should send an infinite break here, schedule() for |
3329 | msec amount of time, and then stop the break. This way, | 2717 | msec amount of time, and then stop the break. This way, |
@@ -3331,36 +2719,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 | 2719 | to be called (i.e. via an ioctl()) more than once in msec amount |
3332 | of time. Try this for now... | 2720 | of time. Try this for now... |
3333 | ------------------------------------------------------------------------ */ | 2721 | ------------------------------------------------------------------------ */ |
3334 | |||
3335 | fepcmd(ch, SENDBREAK, msec, 0, 10, 0); | 2722 | fepcmd(ch, SENDBREAK, msec, 0, 10, 0); |
3336 | memoff(ch); | 2723 | memoff(ch); |
3337 | 2724 | spin_unlock_irqrestore(&epca_lock, flags); | |
3338 | restore_flags(flags); | ||
3339 | |||
3340 | } /* End digi_send_break */ | 2725 | } /* End digi_send_break */ |
3341 | 2726 | ||
3342 | /* --------------------- Begin setup_empty_event ----------------------- */ | 2727 | /* --------------------- Begin setup_empty_event ----------------------- */ |
3343 | 2728 | ||
2729 | /* Caller MUST hold the lock */ | ||
2730 | |||
3344 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch) | 2731 | static void setup_empty_event(struct tty_struct *tty, struct channel *ch) |
3345 | { /* Begin setup_empty_event */ | 2732 | { /* Begin setup_empty_event */ |
3346 | 2733 | ||
3347 | volatile struct board_chan *bc = ch->brdchan; | 2734 | struct board_chan __iomem *bc = ch->brdchan; |
3348 | unsigned long int flags; | ||
3349 | 2735 | ||
3350 | save_flags(flags); | ||
3351 | cli(); | ||
3352 | globalwinon(ch); | 2736 | globalwinon(ch); |
3353 | ch->statusflags |= EMPTYWAIT; | 2737 | ch->statusflags |= EMPTYWAIT; |
3354 | |||
3355 | /* ------------------------------------------------------------------ | 2738 | /* ------------------------------------------------------------------ |
3356 | When set the iempty flag request a event to be generated when the | 2739 | 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). | 2740 | transmit buffer is empty (If there is no BREAK in progress). |
3358 | --------------------------------------------------------------------- */ | 2741 | --------------------------------------------------------------------- */ |
3359 | 2742 | writeb(1, &bc->iempty); | |
3360 | bc->iempty = 1; | ||
3361 | memoff(ch); | 2743 | memoff(ch); |
3362 | restore_flags(flags); | ||
3363 | |||
3364 | } /* End setup_empty_event */ | 2744 | } /* End setup_empty_event */ |
3365 | 2745 | ||
3366 | /* --------------------- Begin get_termio ----------------------- */ | 2746 | /* --------------------- Begin get_termio ----------------------- */ |
@@ -3369,10 +2749,10 @@ static int get_termio(struct tty_struct * tty, struct termio __user * termio) | |||
3369 | { /* Begin get_termio */ | 2749 | { /* Begin get_termio */ |
3370 | return kernel_termios_to_user_termio(termio, tty->termios); | 2750 | return kernel_termios_to_user_termio(termio, tty->termios); |
3371 | } /* End get_termio */ | 2751 | } /* End get_termio */ |
2752 | |||
3372 | /* ---------------------- Begin epca_setup -------------------------- */ | 2753 | /* ---------------------- Begin epca_setup -------------------------- */ |
3373 | void epca_setup(char *str, int *ints) | 2754 | void epca_setup(char *str, int *ints) |
3374 | { /* Begin epca_setup */ | 2755 | { /* Begin epca_setup */ |
3375 | |||
3376 | struct board_info board; | 2756 | struct board_info board; |
3377 | int index, loop, last; | 2757 | int index, loop, last; |
3378 | char *temp, *t2; | 2758 | char *temp, *t2; |
@@ -3394,49 +2774,41 @@ void epca_setup(char *str, int *ints) | |||
3394 | for (last = 0, index = 1; index <= ints[0]; index++) | 2774 | for (last = 0, index = 1; index <= ints[0]; index++) |
3395 | switch(index) | 2775 | switch(index) |
3396 | { /* Begin parse switch */ | 2776 | { /* Begin parse switch */ |
3397 | |||
3398 | case 1: | 2777 | case 1: |
3399 | board.status = ints[index]; | 2778 | board.status = ints[index]; |
3400 | |||
3401 | /* --------------------------------------------------------- | 2779 | /* --------------------------------------------------------- |
3402 | We check for 2 (As opposed to 1; because 2 is a flag | 2780 | We check for 2 (As opposed to 1; because 2 is a flag |
3403 | instructing the driver to ignore epcaconfig.) For this | 2781 | instructing the driver to ignore epcaconfig.) For this |
3404 | reason we check for 2. | 2782 | reason we check for 2. |
3405 | ------------------------------------------------------------ */ | 2783 | ------------------------------------------------------------ */ |
3406 | if (board.status == 2) | 2784 | 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; | 2785 | nbdevs = 0; |
3409 | num_cards = 0; | 2786 | num_cards = 0; |
3410 | return; | 2787 | return; |
3411 | } /* End ignore epcaconfig as well as lilo cmd line */ | 2788 | } /* End ignore epcaconfig as well as lilo cmd line */ |
3412 | 2789 | ||
3413 | if (board.status > 2) | 2790 | if (board.status > 2) { |
3414 | { | 2791 | 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; | 2792 | invalid_lilo_config = 1; |
3417 | setup_error_code |= INVALID_BOARD_STATUS; | 2793 | setup_error_code |= INVALID_BOARD_STATUS; |
3418 | return; | 2794 | return; |
3419 | } | 2795 | } |
3420 | last = index; | 2796 | last = index; |
3421 | break; | 2797 | break; |
3422 | |||
3423 | case 2: | 2798 | case 2: |
3424 | board.type = ints[index]; | 2799 | board.type = ints[index]; |
3425 | if (board.type >= PCIXEM) | 2800 | if (board.type >= PCIXEM) { |
3426 | { | 2801 | 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; | 2802 | invalid_lilo_config = 1; |
3429 | setup_error_code |= INVALID_BOARD_TYPE; | 2803 | setup_error_code |= INVALID_BOARD_TYPE; |
3430 | return; | 2804 | return; |
3431 | } | 2805 | } |
3432 | last = index; | 2806 | last = index; |
3433 | break; | 2807 | break; |
3434 | |||
3435 | case 3: | 2808 | case 3: |
3436 | board.altpin = ints[index]; | 2809 | board.altpin = ints[index]; |
3437 | if (board.altpin > 1) | 2810 | if (board.altpin > 1) { |
3438 | { | 2811 | 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; | 2812 | invalid_lilo_config = 1; |
3441 | setup_error_code |= INVALID_ALTPIN; | 2813 | setup_error_code |= INVALID_ALTPIN; |
3442 | return; | 2814 | return; |
@@ -3446,9 +2818,8 @@ void epca_setup(char *str, int *ints) | |||
3446 | 2818 | ||
3447 | case 4: | 2819 | case 4: |
3448 | board.numports = ints[index]; | 2820 | board.numports = ints[index]; |
3449 | if ((board.numports < 2) || (board.numports > 256)) | 2821 | if (board.numports < 2 || board.numports > 256) { |
3450 | { | 2822 | 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; | 2823 | invalid_lilo_config = 1; |
3453 | setup_error_code |= INVALID_NUM_PORTS; | 2824 | setup_error_code |= INVALID_NUM_PORTS; |
3454 | return; | 2825 | return; |
@@ -3458,10 +2829,9 @@ void epca_setup(char *str, int *ints) | |||
3458 | break; | 2829 | break; |
3459 | 2830 | ||
3460 | case 5: | 2831 | case 5: |
3461 | board.port = (unsigned char *)ints[index]; | 2832 | board.port = ints[index]; |
3462 | if (ints[index] <= 0) | 2833 | if (ints[index] <= 0) { |
3463 | { | 2834 | 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; | 2835 | invalid_lilo_config = 1; |
3466 | setup_error_code |= INVALID_PORT_BASE; | 2836 | setup_error_code |= INVALID_PORT_BASE; |
3467 | return; | 2837 | return; |
@@ -3470,10 +2840,9 @@ void epca_setup(char *str, int *ints) | |||
3470 | break; | 2840 | break; |
3471 | 2841 | ||
3472 | case 6: | 2842 | case 6: |
3473 | board.membase = (unsigned char *)ints[index]; | 2843 | board.membase = ints[index]; |
3474 | if (ints[index] <= 0) | 2844 | if (ints[index] <= 0) { |
3475 | { | 2845 | 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; | 2846 | invalid_lilo_config = 1; |
3478 | setup_error_code |= INVALID_MEM_BASE; | 2847 | setup_error_code |= INVALID_MEM_BASE; |
3479 | return; | 2848 | return; |
@@ -3487,21 +2856,16 @@ void epca_setup(char *str, int *ints) | |||
3487 | 2856 | ||
3488 | } /* End parse switch */ | 2857 | } /* End parse switch */ |
3489 | 2858 | ||
3490 | while (str && *str) | 2859 | 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 */ | 2860 | /* find the next comma or terminator */ |
3494 | temp = str; | 2861 | temp = str; |
3495 | |||
3496 | /* While string is not null, and a comma hasn't been found */ | 2862 | /* While string is not null, and a comma hasn't been found */ |
3497 | while (*temp && (*temp != ',')) | 2863 | while (*temp && (*temp != ',')) |
3498 | temp++; | 2864 | temp++; |
3499 | |||
3500 | if (!*temp) | 2865 | if (!*temp) |
3501 | temp = NULL; | 2866 | temp = NULL; |
3502 | else | 2867 | else |
3503 | *temp++ = 0; | 2868 | *temp++ = 0; |
3504 | |||
3505 | /* Set index to the number of args + 1 */ | 2869 | /* Set index to the number of args + 1 */ |
3506 | index = last + 1; | 2870 | index = last + 1; |
3507 | 2871 | ||
@@ -3511,12 +2875,10 @@ void epca_setup(char *str, int *ints) | |||
3511 | len = strlen(str); | 2875 | len = strlen(str); |
3512 | if (strncmp("Disable", str, len) == 0) | 2876 | if (strncmp("Disable", str, len) == 0) |
3513 | board.status = 0; | 2877 | board.status = 0; |
3514 | else | 2878 | else if (strncmp("Enable", str, len) == 0) |
3515 | if (strncmp("Enable", str, len) == 0) | ||
3516 | board.status = 1; | 2879 | board.status = 1; |
3517 | else | 2880 | else { |
3518 | { | 2881 | 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; | 2882 | invalid_lilo_config = 1; |
3521 | setup_error_code |= INVALID_BOARD_STATUS; | 2883 | setup_error_code |= INVALID_BOARD_STATUS; |
3522 | return; | 2884 | return; |
@@ -3525,22 +2887,17 @@ void epca_setup(char *str, int *ints) | |||
3525 | break; | 2887 | break; |
3526 | 2888 | ||
3527 | case 2: | 2889 | case 2: |
3528 | |||
3529 | for(loop = 0; loop < EPCA_NUM_TYPES; loop++) | 2890 | for(loop = 0; loop < EPCA_NUM_TYPES; loop++) |
3530 | if (strcmp(board_desc[loop], str) == 0) | 2891 | if (strcmp(board_desc[loop], str) == 0) |
3531 | break; | 2892 | break; |
3532 | |||
3533 | |||
3534 | /* --------------------------------------------------------------- | 2893 | /* --------------------------------------------------------------- |
3535 | If the index incremented above refers to a legitamate board | 2894 | If the index incremented above refers to a legitamate board |
3536 | type set it here. | 2895 | type set it here. |
3537 | ------------------------------------------------------------------*/ | 2896 | ------------------------------------------------------------------*/ |
3538 | |||
3539 | if (index < EPCA_NUM_TYPES) | 2897 | if (index < EPCA_NUM_TYPES) |
3540 | board.type = loop; | 2898 | board.type = loop; |
3541 | else | 2899 | else { |
3542 | { | 2900 | 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; | 2901 | invalid_lilo_config = 1; |
3545 | setup_error_code |= INVALID_BOARD_TYPE; | 2902 | setup_error_code |= INVALID_BOARD_TYPE; |
3546 | return; | 2903 | return; |
@@ -3552,12 +2909,10 @@ void epca_setup(char *str, int *ints) | |||
3552 | len = strlen(str); | 2909 | len = strlen(str); |
3553 | if (strncmp("Disable", str, len) == 0) | 2910 | if (strncmp("Disable", str, len) == 0) |
3554 | board.altpin = 0; | 2911 | board.altpin = 0; |
3555 | else | 2912 | else if (strncmp("Enable", str, len) == 0) |
3556 | if (strncmp("Enable", str, len) == 0) | ||
3557 | board.altpin = 1; | 2913 | board.altpin = 1; |
3558 | else | 2914 | else { |
3559 | { | 2915 | 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; | 2916 | invalid_lilo_config = 1; |
3562 | setup_error_code |= INVALID_ALTPIN; | 2917 | setup_error_code |= INVALID_ALTPIN; |
3563 | return; | 2918 | return; |
@@ -3570,9 +2925,8 @@ void epca_setup(char *str, int *ints) | |||
3570 | while (isdigit(*t2)) | 2925 | while (isdigit(*t2)) |
3571 | t2++; | 2926 | t2++; |
3572 | 2927 | ||
3573 | if (*t2) | 2928 | if (*t2) { |
3574 | { | 2929 | 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; | 2930 | invalid_lilo_config = 1; |
3577 | setup_error_code |= INVALID_NUM_PORTS; | 2931 | setup_error_code |= INVALID_NUM_PORTS; |
3578 | return; | 2932 | return; |
@@ -3601,15 +2955,14 @@ void epca_setup(char *str, int *ints) | |||
3601 | while (isxdigit(*t2)) | 2955 | while (isxdigit(*t2)) |
3602 | t2++; | 2956 | t2++; |
3603 | 2957 | ||
3604 | if (*t2) | 2958 | if (*t2) { |
3605 | { | 2959 | 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; | 2960 | invalid_lilo_config = 1; |
3608 | setup_error_code |= INVALID_PORT_BASE; | 2961 | setup_error_code |= INVALID_PORT_BASE; |
3609 | return; | 2962 | return; |
3610 | } | 2963 | } |
3611 | 2964 | ||
3612 | board.port = (unsigned char *)simple_strtoul(str, NULL, 16); | 2965 | board.port = simple_strtoul(str, NULL, 16); |
3613 | last = index; | 2966 | last = index; |
3614 | break; | 2967 | break; |
3615 | 2968 | ||
@@ -3618,52 +2971,38 @@ void epca_setup(char *str, int *ints) | |||
3618 | while (isxdigit(*t2)) | 2971 | while (isxdigit(*t2)) |
3619 | t2++; | 2972 | t2++; |
3620 | 2973 | ||
3621 | if (*t2) | 2974 | if (*t2) { |
3622 | { | 2975 | 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; | 2976 | invalid_lilo_config = 1; |
3625 | setup_error_code |= INVALID_MEM_BASE; | 2977 | setup_error_code |= INVALID_MEM_BASE; |
3626 | return; | 2978 | return; |
3627 | } | 2979 | } |
3628 | 2980 | board.membase = simple_strtoul(str, NULL, 16); | |
3629 | board.membase = (unsigned char *)simple_strtoul(str, NULL, 16); | ||
3630 | last = index; | 2981 | last = index; |
3631 | break; | 2982 | break; |
3632 | |||
3633 | default: | 2983 | default: |
3634 | printk(KERN_ERR "PC/Xx: Too many string parms\n"); | 2984 | printk(KERN_ERR "epca: Too many string parms\n"); |
3635 | return; | 2985 | return; |
3636 | } | 2986 | } |
3637 | str = temp; | 2987 | str = temp; |
3638 | |||
3639 | } /* End while there is a string arg */ | 2988 | } /* End while there is a string arg */ |
3640 | 2989 | ||
3641 | 2990 | if (last < 6) { | |
3642 | if (last < 6) | 2991 | printk(KERN_ERR "epca: Insufficient parms specified\n"); |
3643 | { | ||
3644 | printk(KERN_ERR "PC/Xx: Insufficient parms specified\n"); | ||
3645 | return; | 2992 | return; |
3646 | } | 2993 | } |
3647 | 2994 | ||
3648 | /* I should REALLY validate the stuff here */ | 2995 | /* I should REALLY validate the stuff here */ |
3649 | |||
3650 | /* Copies our local copy of board into boards */ | 2996 | /* Copies our local copy of board into boards */ |
3651 | memcpy((void *)&boards[num_cards],(void *)&board, sizeof(board)); | 2997 | memcpy((void *)&boards[num_cards],(void *)&board, sizeof(board)); |
3652 | |||
3653 | |||
3654 | /* Does this get called once per lilo arg are what ? */ | 2998 | /* 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", | 2999 | 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], | 3000 | num_cards, board_desc[board.type], |
3658 | board.numports, (int)board.port, (unsigned int) board.membase); | 3001 | board.numports, (int)board.port, (unsigned int) board.membase); |
3659 | |||
3660 | num_cards++; | 3002 | num_cards++; |
3661 | |||
3662 | } /* End epca_setup */ | 3003 | } /* End epca_setup */ |
3663 | 3004 | ||
3664 | 3005 | ||
3665 | |||
3666 | #ifdef ENABLE_PCI | ||
3667 | /* ------------------------ Begin init_PCI --------------------------- */ | 3006 | /* ------------------------ Begin init_PCI --------------------------- */ |
3668 | 3007 | ||
3669 | enum epic_board_types { | 3008 | enum epic_board_types { |
@@ -3685,7 +3024,6 @@ static struct { | |||
3685 | { PCIXRJ, 2, }, | 3024 | { PCIXRJ, 2, }, |
3686 | }; | 3025 | }; |
3687 | 3026 | ||
3688 | |||
3689 | static int __devinit epca_init_one (struct pci_dev *pdev, | 3027 | static int __devinit epca_init_one (struct pci_dev *pdev, |
3690 | const struct pci_device_id *ent) | 3028 | const struct pci_device_id *ent) |
3691 | { | 3029 | { |
@@ -3711,10 +3049,8 @@ static int __devinit epca_init_one (struct pci_dev *pdev, | |||
3711 | boards[board_idx].status = ENABLED; | 3049 | boards[board_idx].status = ENABLED; |
3712 | boards[board_idx].type = epca_info_tbl[info_idx].board_type; | 3050 | boards[board_idx].type = epca_info_tbl[info_idx].board_type; |
3713 | boards[board_idx].numports = 0x0; | 3051 | boards[board_idx].numports = 0x0; |
3714 | boards[board_idx].port = | 3052 | boards[board_idx].port = addr + PCI_IO_OFFSET; |
3715 | (unsigned char *)((char *) addr + PCI_IO_OFFSET); | 3053 | boards[board_idx].membase = addr; |
3716 | boards[board_idx].membase = | ||
3717 | (unsigned char *)((char *) addr); | ||
3718 | 3054 | ||
3719 | if (!request_mem_region (addr + PCI_IO_OFFSET, 0x200000, "epca")) { | 3055 | if (!request_mem_region (addr + PCI_IO_OFFSET, 0x200000, "epca")) { |
3720 | printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", | 3056 | printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", |
@@ -3775,15 +3111,13 @@ static struct pci_device_id epca_pci_tbl[] = { | |||
3775 | MODULE_DEVICE_TABLE(pci, epca_pci_tbl); | 3111 | MODULE_DEVICE_TABLE(pci, epca_pci_tbl); |
3776 | 3112 | ||
3777 | int __init init_PCI (void) | 3113 | int __init init_PCI (void) |
3778 | { /* Begin init_PCI */ | 3114 | { /* Begin init_PCI */ |
3779 | memset (&epca_driver, 0, sizeof (epca_driver)); | 3115 | memset (&epca_driver, 0, sizeof (epca_driver)); |
3780 | epca_driver.name = "epca"; | 3116 | epca_driver.name = "epca"; |
3781 | epca_driver.id_table = epca_pci_tbl; | 3117 | epca_driver.id_table = epca_pci_tbl; |
3782 | epca_driver.probe = epca_init_one; | 3118 | epca_driver.probe = epca_init_one; |
3783 | 3119 | ||
3784 | return pci_register_driver(&epca_driver); | 3120 | return pci_register_driver(&epca_driver); |
3785 | } /* End init_PCI */ | 3121 | } |
3786 | |||
3787 | #endif /* ENABLE_PCI */ | ||
3788 | 3122 | ||
3789 | MODULE_LICENSE("GPL"); | 3123 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/char/epca.h b/drivers/char/epca.h index 52205ef71314..456d6c8f94a8 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 __iomem *txptr; |
132 | unchar *rxptr; | 132 | unsigned char __iomem *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 __iomem *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 __iomem *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 | void __iomem *re_map_port; |
153 | unchar *re_map_membase; | 153 | void __iomem *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/ftape/lowlevel/fdc-io.c b/drivers/char/ftape/lowlevel/fdc-io.c index 1704a2a57048..b2e0928e8428 100644 --- a/drivers/char/ftape/lowlevel/fdc-io.c +++ b/drivers/char/ftape/lowlevel/fdc-io.c | |||
@@ -387,10 +387,8 @@ int fdc_interrupt_wait(unsigned int time) | |||
387 | 387 | ||
388 | set_current_state(TASK_INTERRUPTIBLE); | 388 | set_current_state(TASK_INTERRUPTIBLE); |
389 | add_wait_queue(&ftape_wait_intr, &wait); | 389 | add_wait_queue(&ftape_wait_intr, &wait); |
390 | while (!ft_interrupt_seen && timeout) { | 390 | while (!ft_interrupt_seen && timeout) |
391 | set_current_state(TASK_INTERRUPTIBLE); | 391 | timeout = schedule_timeout_interruptible(timeout); |
392 | timeout = schedule_timeout(timeout); | ||
393 | } | ||
394 | 392 | ||
395 | spin_lock_irq(¤t->sighand->siglock); | 393 | spin_lock_irq(¤t->sighand->siglock); |
396 | current->blocked = old_sigmask; | 394 | current->blocked = old_sigmask; |
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..c055bb630ffc 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) |
@@ -100,14 +100,14 @@ static struct hpets *hpets; | |||
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | #ifndef readq | 102 | #ifndef readq |
103 | static unsigned long long __inline readq(void __iomem *addr) | 103 | static inline unsigned long long readq(void __iomem *addr) |
104 | { | 104 | { |
105 | return readl(addr) | (((unsigned long long)readl(addr + 4)) << 32LL); | 105 | return readl(addr) | (((unsigned long long)readl(addr + 4)) << 32LL); |
106 | } | 106 | } |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | #ifndef writeq | 109 | #ifndef writeq |
110 | static void __inline writeq(unsigned long long v, void __iomem *addr) | 110 | static inline void writeq(unsigned long long v, void __iomem *addr) |
111 | { | 111 | { |
112 | writel(v & 0xffffffff, addr); | 112 | writel(v & 0xffffffff, addr); |
113 | writel(v >> 32, addr + 4); | 113 | writel(v >> 32, addr + 4); |
@@ -273,7 +273,6 @@ static int hpet_mmap(struct file *file, struct vm_area_struct *vma) | |||
273 | 273 | ||
274 | vma->vm_flags |= VM_IO; | 274 | vma->vm_flags |= VM_IO; |
275 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); | 275 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); |
276 | addr = __pa(addr); | ||
277 | 276 | ||
278 | if (io_remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT, | 277 | if (io_remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT, |
279 | PAGE_SIZE, vma->vm_page_prot)) { | 278 | PAGE_SIZE, vma->vm_page_prot)) { |
@@ -712,7 +711,7 @@ static void hpet_register_interpolator(struct hpets *hpetp) | |||
712 | ti->shift = 10; | 711 | ti->shift = 10; |
713 | ti->addr = &hpetp->hp_hpet->hpet_mc; | 712 | ti->addr = &hpetp->hp_hpet->hpet_mc; |
714 | ti->frequency = hpet_time_div(hpets->hp_period); | 713 | ti->frequency = hpet_time_div(hpets->hp_period); |
715 | ti->drift = ti->frequency * HPET_DRIFT / 1000000; | 714 | ti->drift = HPET_DRIFT; |
716 | ti->mask = -1; | 715 | ti->mask = -1; |
717 | 716 | ||
718 | hpetp->hp_interpolator = ti; | 717 | hpetp->hp_interpolator = ti; |
@@ -906,11 +905,15 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data) | |||
906 | if (irqp->number_of_interrupts > 0) { | 905 | if (irqp->number_of_interrupts > 0) { |
907 | hdp->hd_nirqs = irqp->number_of_interrupts; | 906 | hdp->hd_nirqs = irqp->number_of_interrupts; |
908 | 907 | ||
909 | for (i = 0; i < hdp->hd_nirqs; i++) | 908 | for (i = 0; i < hdp->hd_nirqs; i++) { |
910 | hdp->hd_irq[i] = | 909 | int rc = |
911 | acpi_register_gsi(irqp->interrupts[i], | 910 | acpi_register_gsi(irqp->interrupts[i], |
912 | irqp->edge_level, | 911 | irqp->edge_level, |
913 | irqp->active_high_low); | 912 | irqp->active_high_low); |
913 | if (rc < 0) | ||
914 | return AE_ERROR; | ||
915 | hdp->hd_irq[i] = rc; | ||
916 | } | ||
914 | } | 917 | } |
915 | } | 918 | } |
916 | 919 | ||
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index cddb789902db..f92177634677 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c | |||
@@ -839,9 +839,6 @@ int __init hvc_init(void) | |||
839 | hvc_driver->flags = TTY_DRIVER_REAL_RAW; | 839 | hvc_driver->flags = TTY_DRIVER_REAL_RAW; |
840 | tty_set_operations(hvc_driver, &hvc_ops); | 840 | tty_set_operations(hvc_driver, &hvc_ops); |
841 | 841 | ||
842 | if (tty_register_driver(hvc_driver)) | ||
843 | panic("Couldn't register hvc console driver\n"); | ||
844 | |||
845 | /* Always start the kthread because there can be hotplug vty adapters | 842 | /* Always start the kthread because there can be hotplug vty adapters |
846 | * added later. */ | 843 | * added later. */ |
847 | hvc_task = kthread_run(khvcd, NULL, "khvcd"); | 844 | hvc_task = kthread_run(khvcd, NULL, "khvcd"); |
@@ -851,6 +848,9 @@ int __init hvc_init(void) | |||
851 | return -EIO; | 848 | return -EIO; |
852 | } | 849 | } |
853 | 850 | ||
851 | if (tty_register_driver(hvc_driver)) | ||
852 | panic("Couldn't register hvc console driver\n"); | ||
853 | |||
854 | return 0; | 854 | return 0; |
855 | } | 855 | } |
856 | module_init(hvc_init); | 856 | module_init(hvc_init); |
diff --git a/drivers/char/hw_random.c b/drivers/char/hw_random.c index 3480535a09c5..6f673d2de0b1 100644 --- a/drivers/char/hw_random.c +++ b/drivers/char/hw_random.c | |||
@@ -513,10 +513,7 @@ static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size, | |||
513 | return ret ? : -EAGAIN; | 513 | return ret ? : -EAGAIN; |
514 | 514 | ||
515 | if(need_resched()) | 515 | if(need_resched()) |
516 | { | 516 | schedule_timeout_interruptible(1); |
517 | current->state = TASK_INTERRUPTIBLE; | ||
518 | schedule_timeout(1); | ||
519 | } | ||
520 | else | 517 | else |
521 | udelay(200); /* FIXME: We could poll for 250uS ?? */ | 518 | udelay(200); /* FIXME: We could poll for 250uS ?? */ |
522 | 519 | ||
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c index 82c5f30375ac..ba85eb1b6ec7 100644 --- a/drivers/char/ip2/i2lib.c +++ b/drivers/char/ip2/i2lib.c | |||
@@ -655,8 +655,7 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands, | |||
655 | timeout--; // So negative values == forever | 655 | timeout--; // So negative values == forever |
656 | 656 | ||
657 | if (!in_interrupt()) { | 657 | if (!in_interrupt()) { |
658 | current->state = TASK_INTERRUPTIBLE; | 658 | schedule_timeout_interruptible(1); // short nap |
659 | schedule_timeout(1); // short nap | ||
660 | } else { | 659 | } else { |
661 | // we cannot sched/sleep in interrrupt silly | 660 | // we cannot sched/sleep in interrrupt silly |
662 | return 0; | 661 | return 0; |
@@ -1132,8 +1131,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user ) | |||
1132 | 1131 | ||
1133 | ip2trace (CHANN, ITRC_OUTPUT, 61, 0 ); | 1132 | ip2trace (CHANN, ITRC_OUTPUT, 61, 0 ); |
1134 | 1133 | ||
1135 | current->state = TASK_INTERRUPTIBLE; | 1134 | schedule_timeout_interruptible(2); |
1136 | schedule_timeout(2); | ||
1137 | if (signal_pending(current)) { | 1135 | if (signal_pending(current)) { |
1138 | break; | 1136 | break; |
1139 | } | 1137 | } |
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..32fa82c78c73 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 |
@@ -2563,7 +2620,7 @@ void ipmi_smi_msg_received(ipmi_smi_t intf, | |||
2563 | spin_lock_irqsave(&(intf->waiting_msgs_lock), flags); | 2620 | spin_lock_irqsave(&(intf->waiting_msgs_lock), flags); |
2564 | if (!list_empty(&(intf->waiting_msgs))) { | 2621 | if (!list_empty(&(intf->waiting_msgs))) { |
2565 | list_add_tail(&(msg->link), &(intf->waiting_msgs)); | 2622 | list_add_tail(&(msg->link), &(intf->waiting_msgs)); |
2566 | spin_unlock(&(intf->waiting_msgs_lock)); | 2623 | spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags); |
2567 | goto out_unlock; | 2624 | goto out_unlock; |
2568 | } | 2625 | } |
2569 | spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags); | 2626 | spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags); |
@@ -2572,9 +2629,9 @@ void ipmi_smi_msg_received(ipmi_smi_t intf, | |||
2572 | if (rv > 0) { | 2629 | if (rv > 0) { |
2573 | /* Could not handle the message now, just add it to a | 2630 | /* Could not handle the message now, just add it to a |
2574 | list to handle later. */ | 2631 | list to handle later. */ |
2575 | spin_lock(&(intf->waiting_msgs_lock)); | 2632 | spin_lock_irqsave(&(intf->waiting_msgs_lock), flags); |
2576 | list_add_tail(&(msg->link), &(intf->waiting_msgs)); | 2633 | list_add_tail(&(msg->link), &(intf->waiting_msgs)); |
2577 | spin_unlock(&(intf->waiting_msgs_lock)); | 2634 | spin_unlock_irqrestore(&(intf->waiting_msgs_lock), flags); |
2578 | } else if (rv == 0) { | 2635 | } else if (rv == 0) { |
2579 | ipmi_free_smi_msg(msg); | 2636 | ipmi_free_smi_msg(msg); |
2580 | } | 2637 | } |
@@ -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..b6e5cbfb09f8 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 |
@@ -1956,8 +1920,7 @@ static int try_get_dev_id(struct smi_info *smi_info) | |||
1956 | for (;;) | 1920 | for (;;) |
1957 | { | 1921 | { |
1958 | if (smi_result == SI_SM_CALL_WITH_DELAY) { | 1922 | if (smi_result == SI_SM_CALL_WITH_DELAY) { |
1959 | set_current_state(TASK_UNINTERRUPTIBLE); | 1923 | schedule_timeout_uninterruptible(1); |
1960 | schedule_timeout(1); | ||
1961 | smi_result = smi_info->handlers->event( | 1924 | smi_result = smi_info->handlers->event( |
1962 | smi_info->si_sm, 100); | 1925 | smi_info->si_sm, 100); |
1963 | } | 1926 | } |
@@ -1992,11 +1955,8 @@ static int try_get_dev_id(struct smi_info *smi_info) | |||
1992 | } | 1955 | } |
1993 | 1956 | ||
1994 | /* Record info from the get device id, in case we need it. */ | 1957 | /* Record info from the get device id, in case we need it. */ |
1995 | smi_info->ipmi_si_dev_rev = resp[4] & 0xf; | 1958 | memcpy(&smi_info->device_id, &resp[3], |
1996 | smi_info->ipmi_si_fw_rev_major = resp[5] & 0x7f; | 1959 | 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 | 1960 | ||
2001 | out: | 1961 | out: |
2002 | kfree(resp); | 1962 | kfree(resp); |
@@ -2028,7 +1988,7 @@ static int stat_file_read_proc(char *page, char **start, off_t off, | |||
2028 | struct smi_info *smi = data; | 1988 | struct smi_info *smi = data; |
2029 | 1989 | ||
2030 | out += sprintf(out, "interrupts_enabled: %d\n", | 1990 | out += sprintf(out, "interrupts_enabled: %d\n", |
2031 | smi->irq && !smi->interrupt_disabled); | 1991 | smi->irq && ! smi->interrupt_disabled); |
2032 | out += sprintf(out, "short_timeouts: %ld\n", | 1992 | out += sprintf(out, "short_timeouts: %ld\n", |
2033 | smi->short_timeouts); | 1993 | smi->short_timeouts); |
2034 | out += sprintf(out, "long_timeouts: %ld\n", | 1994 | out += sprintf(out, "long_timeouts: %ld\n", |
@@ -2057,6 +2017,73 @@ static int stat_file_read_proc(char *page, char **start, off_t off, | |||
2057 | return (out - ((char *) page)); | 2017 | return (out - ((char *) page)); |
2058 | } | 2018 | } |
2059 | 2019 | ||
2020 | /* | ||
2021 | * oem_data_avail_to_receive_msg_avail | ||
2022 | * @info - smi_info structure with msg_flags set | ||
2023 | * | ||
2024 | * Converts flags from OEM_DATA_AVAIL to RECEIVE_MSG_AVAIL | ||
2025 | * Returns 1 indicating need to re-run handle_flags(). | ||
2026 | */ | ||
2027 | static int oem_data_avail_to_receive_msg_avail(struct smi_info *smi_info) | ||
2028 | { | ||
2029 | smi_info->msg_flags = ((smi_info->msg_flags & ~OEM_DATA_AVAIL) | | ||
2030 | RECEIVE_MSG_AVAIL); | ||
2031 | return 1; | ||
2032 | } | ||
2033 | |||
2034 | /* | ||
2035 | * setup_dell_poweredge_oem_data_handler | ||
2036 | * @info - smi_info.device_id must be populated | ||
2037 | * | ||
2038 | * Systems that match, but have firmware version < 1.40 may assert | ||
2039 | * OEM0_DATA_AVAIL on their own, without being told via Set Flags that | ||
2040 | * it's safe to do so. Such systems will de-assert OEM1_DATA_AVAIL | ||
2041 | * upon receipt of IPMI_GET_MSG_CMD, so we should treat these flags | ||
2042 | * as RECEIVE_MSG_AVAIL instead. | ||
2043 | * | ||
2044 | * As Dell has no plans to release IPMI 1.5 firmware that *ever* | ||
2045 | * assert the OEM[012] bits, and if it did, the driver would have to | ||
2046 | * change to handle that properly, we don't actually check for the | ||
2047 | * firmware version. | ||
2048 | * Device ID = 0x20 BMC on PowerEdge 8G servers | ||
2049 | * Device Revision = 0x80 | ||
2050 | * Firmware Revision1 = 0x01 BMC version 1.40 | ||
2051 | * Firmware Revision2 = 0x40 BCD encoded | ||
2052 | * IPMI Version = 0x51 IPMI 1.5 | ||
2053 | * Manufacturer ID = A2 02 00 Dell IANA | ||
2054 | * | ||
2055 | */ | ||
2056 | #define DELL_POWEREDGE_8G_BMC_DEVICE_ID 0x20 | ||
2057 | #define DELL_POWEREDGE_8G_BMC_DEVICE_REV 0x80 | ||
2058 | #define DELL_POWEREDGE_8G_BMC_IPMI_VERSION 0x51 | ||
2059 | #define DELL_IANA_MFR_ID {0xA2, 0x02, 0x00} | ||
2060 | static void setup_dell_poweredge_oem_data_handler(struct smi_info *smi_info) | ||
2061 | { | ||
2062 | struct ipmi_device_id *id = &smi_info->device_id; | ||
2063 | const char mfr[3]=DELL_IANA_MFR_ID; | ||
2064 | if (! memcmp(mfr, id->manufacturer_id, sizeof(mfr)) | ||
2065 | && (id->device_id == DELL_POWEREDGE_8G_BMC_DEVICE_ID) | ||
2066 | && (id->device_revision == DELL_POWEREDGE_8G_BMC_DEVICE_REV) | ||
2067 | && (id->ipmi_version == DELL_POWEREDGE_8G_BMC_IPMI_VERSION)) | ||
2068 | { | ||
2069 | smi_info->oem_data_avail_handler = | ||
2070 | oem_data_avail_to_receive_msg_avail; | ||
2071 | } | ||
2072 | } | ||
2073 | |||
2074 | /* | ||
2075 | * setup_oem_data_handler | ||
2076 | * @info - smi_info.device_id must be filled in already | ||
2077 | * | ||
2078 | * Fills in smi_info.device_id.oem_data_available_handler | ||
2079 | * when we know what function to use there. | ||
2080 | */ | ||
2081 | |||
2082 | static void setup_oem_data_handler(struct smi_info *smi_info) | ||
2083 | { | ||
2084 | setup_dell_poweredge_oem_data_handler(smi_info); | ||
2085 | } | ||
2086 | |||
2060 | /* Returns 0 if initialized, or negative on an error. */ | 2087 | /* Returns 0 if initialized, or negative on an error. */ |
2061 | static int init_one_smi(int intf_num, struct smi_info **smi) | 2088 | static int init_one_smi(int intf_num, struct smi_info **smi) |
2062 | { | 2089 | { |
@@ -2067,20 +2094,16 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2067 | rv = try_init_mem(intf_num, &new_smi); | 2094 | rv = try_init_mem(intf_num, &new_smi); |
2068 | if (rv) | 2095 | if (rv) |
2069 | rv = try_init_port(intf_num, &new_smi); | 2096 | rv = try_init_port(intf_num, &new_smi); |
2070 | #ifdef CONFIG_ACPI_INTERPRETER | 2097 | #ifdef CONFIG_ACPI |
2071 | if ((rv) && (si_trydefaults)) { | 2098 | if (rv && si_trydefaults) |
2072 | rv = try_init_acpi(intf_num, &new_smi); | 2099 | rv = try_init_acpi(intf_num, &new_smi); |
2073 | } | ||
2074 | #endif | 2100 | #endif |
2075 | #ifdef CONFIG_X86 | 2101 | #ifdef CONFIG_X86 |
2076 | if ((rv) && (si_trydefaults)) { | 2102 | if (rv && si_trydefaults) |
2077 | rv = try_init_smbios(intf_num, &new_smi); | 2103 | rv = try_init_smbios(intf_num, &new_smi); |
2078 | } | ||
2079 | #endif | 2104 | #endif |
2080 | if ((rv) && (si_trydefaults)) { | 2105 | if (rv && si_trydefaults) |
2081 | rv = try_init_plug_and_play(intf_num, &new_smi); | 2106 | rv = try_init_plug_and_play(intf_num, &new_smi); |
2082 | } | ||
2083 | |||
2084 | 2107 | ||
2085 | if (rv) | 2108 | if (rv) |
2086 | return rv; | 2109 | return rv; |
@@ -2090,7 +2113,7 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2090 | new_smi->si_sm = NULL; | 2113 | new_smi->si_sm = NULL; |
2091 | new_smi->handlers = NULL; | 2114 | new_smi->handlers = NULL; |
2092 | 2115 | ||
2093 | if (!new_smi->irq_setup) { | 2116 | if (! new_smi->irq_setup) { |
2094 | new_smi->irq = irqs[intf_num]; | 2117 | new_smi->irq = irqs[intf_num]; |
2095 | new_smi->irq_setup = std_irq_setup; | 2118 | new_smi->irq_setup = std_irq_setup; |
2096 | new_smi->irq_cleanup = std_irq_cleanup; | 2119 | new_smi->irq_cleanup = std_irq_cleanup; |
@@ -2124,7 +2147,7 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2124 | 2147 | ||
2125 | /* Allocate the state machine's data and initialize it. */ | 2148 | /* Allocate the state machine's data and initialize it. */ |
2126 | new_smi->si_sm = kmalloc(new_smi->handlers->size(), GFP_KERNEL); | 2149 | new_smi->si_sm = kmalloc(new_smi->handlers->size(), GFP_KERNEL); |
2127 | if (!new_smi->si_sm) { | 2150 | if (! new_smi->si_sm) { |
2128 | printk(" Could not allocate state machine memory\n"); | 2151 | printk(" Could not allocate state machine memory\n"); |
2129 | rv = -ENOMEM; | 2152 | rv = -ENOMEM; |
2130 | goto out_err; | 2153 | goto out_err; |
@@ -2155,6 +2178,8 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2155 | if (rv) | 2178 | if (rv) |
2156 | goto out_err; | 2179 | goto out_err; |
2157 | 2180 | ||
2181 | setup_oem_data_handler(new_smi); | ||
2182 | |||
2158 | /* Try to claim any interrupts. */ | 2183 | /* Try to claim any interrupts. */ |
2159 | new_smi->irq_setup(new_smi); | 2184 | new_smi->irq_setup(new_smi); |
2160 | 2185 | ||
@@ -2188,8 +2213,8 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2188 | 2213 | ||
2189 | rv = ipmi_register_smi(&handlers, | 2214 | rv = ipmi_register_smi(&handlers, |
2190 | new_smi, | 2215 | new_smi, |
2191 | new_smi->ipmi_version_major, | 2216 | ipmi_version_major(&new_smi->device_id), |
2192 | new_smi->ipmi_version_minor, | 2217 | ipmi_version_minor(&new_smi->device_id), |
2193 | new_smi->slave_addr, | 2218 | new_smi->slave_addr, |
2194 | &(new_smi->intf)); | 2219 | &(new_smi->intf)); |
2195 | if (rv) { | 2220 | if (rv) { |
@@ -2230,10 +2255,8 @@ static int init_one_smi(int intf_num, struct smi_info **smi) | |||
2230 | 2255 | ||
2231 | /* Wait for the timer to stop. This avoids problems with race | 2256 | /* Wait for the timer to stop. This avoids problems with race |
2232 | conditions removing the timer here. */ | 2257 | conditions removing the timer here. */ |
2233 | while (!new_smi->timer_stopped) { | 2258 | while (!new_smi->timer_stopped) |
2234 | set_current_state(TASK_UNINTERRUPTIBLE); | 2259 | schedule_timeout_uninterruptible(1); |
2235 | schedule_timeout(1); | ||
2236 | } | ||
2237 | 2260 | ||
2238 | out_err: | 2261 | out_err: |
2239 | if (new_smi->intf) | 2262 | if (new_smi->intf) |
@@ -2270,7 +2293,7 @@ static __init int init_ipmi_si(void) | |||
2270 | /* Parse out the si_type string into its components. */ | 2293 | /* Parse out the si_type string into its components. */ |
2271 | str = si_type_str; | 2294 | str = si_type_str; |
2272 | if (*str != '\0') { | 2295 | if (*str != '\0') { |
2273 | for (i=0; (i<SI_MAX_PARMS) && (*str != '\0'); i++) { | 2296 | for (i = 0; (i < SI_MAX_PARMS) && (*str != '\0'); i++) { |
2274 | si_type[i] = str; | 2297 | si_type[i] = str; |
2275 | str = strchr(str, ','); | 2298 | str = strchr(str, ','); |
2276 | if (str) { | 2299 | if (str) { |
@@ -2282,22 +2305,14 @@ static __init int init_ipmi_si(void) | |||
2282 | } | 2305 | } |
2283 | } | 2306 | } |
2284 | 2307 | ||
2285 | printk(KERN_INFO "IPMI System Interface driver version " | 2308 | 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 | 2309 | ||
2295 | #ifdef CONFIG_X86 | 2310 | #ifdef CONFIG_X86 |
2296 | dmi_decode(); | 2311 | dmi_find_bmc(); |
2297 | #endif | 2312 | #endif |
2298 | 2313 | ||
2299 | rv = init_one_smi(0, &(smi_infos[pos])); | 2314 | rv = init_one_smi(0, &(smi_infos[pos])); |
2300 | if (rv && !ports[0] && si_trydefaults) { | 2315 | if (rv && ! ports[0] && si_trydefaults) { |
2301 | /* If we are trying defaults and the initial port is | 2316 | /* If we are trying defaults and the initial port is |
2302 | not set, then set it. */ | 2317 | not set, then set it. */ |
2303 | si_type[0] = "kcs"; | 2318 | si_type[0] = "kcs"; |
@@ -2319,7 +2334,7 @@ static __init int init_ipmi_si(void) | |||
2319 | if (rv == 0) | 2334 | if (rv == 0) |
2320 | pos++; | 2335 | pos++; |
2321 | 2336 | ||
2322 | for (i=1; i < SI_MAX_PARMS; i++) { | 2337 | for (i = 1; i < SI_MAX_PARMS; i++) { |
2323 | rv = init_one_smi(i, &(smi_infos[pos])); | 2338 | rv = init_one_smi(i, &(smi_infos[pos])); |
2324 | if (rv == 0) | 2339 | if (rv == 0) |
2325 | pos++; | 2340 | pos++; |
@@ -2361,17 +2376,14 @@ static void __exit cleanup_one_si(struct smi_info *to_clean) | |||
2361 | 2376 | ||
2362 | /* Wait for the timer to stop. This avoids problems with race | 2377 | /* Wait for the timer to stop. This avoids problems with race |
2363 | conditions removing the timer here. */ | 2378 | conditions removing the timer here. */ |
2364 | while (!to_clean->timer_stopped) { | 2379 | while (!to_clean->timer_stopped) |
2365 | set_current_state(TASK_UNINTERRUPTIBLE); | 2380 | schedule_timeout_uninterruptible(1); |
2366 | schedule_timeout(1); | ||
2367 | } | ||
2368 | 2381 | ||
2369 | /* Interrupts and timeouts are stopped, now make sure the | 2382 | /* Interrupts and timeouts are stopped, now make sure the |
2370 | interface is in a clean state. */ | 2383 | interface is in a clean state. */ |
2371 | while ((to_clean->curr_msg) || (to_clean->si_state != SI_NORMAL)) { | 2384 | while (to_clean->curr_msg || (to_clean->si_state != SI_NORMAL)) { |
2372 | poll(to_clean); | 2385 | poll(to_clean); |
2373 | set_current_state(TASK_UNINTERRUPTIBLE); | 2386 | schedule_timeout_uninterruptible(1); |
2374 | schedule_timeout(1); | ||
2375 | } | 2387 | } |
2376 | 2388 | ||
2377 | rv = ipmi_unregister_smi(to_clean->intf); | 2389 | rv = ipmi_unregister_smi(to_clean->intf); |
@@ -2392,13 +2404,15 @@ static __exit void cleanup_ipmi_si(void) | |||
2392 | { | 2404 | { |
2393 | int i; | 2405 | int i; |
2394 | 2406 | ||
2395 | if (!initialized) | 2407 | if (! initialized) |
2396 | return; | 2408 | return; |
2397 | 2409 | ||
2398 | for (i=0; i<SI_MAX_DRIVERS; i++) { | 2410 | for (i = 0; i < SI_MAX_DRIVERS; i++) { |
2399 | cleanup_one_si(smi_infos[i]); | 2411 | cleanup_one_si(smi_infos[i]); |
2400 | } | 2412 | } |
2401 | } | 2413 | } |
2402 | module_exit(cleanup_ipmi_si); | 2414 | module_exit(cleanup_ipmi_si); |
2403 | 2415 | ||
2404 | MODULE_LICENSE("GPL"); | 2416 | MODULE_LICENSE("GPL"); |
2417 | MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); | ||
2418 | 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..2da64bf7469c 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 | ||
@@ -1037,10 +1037,8 @@ static __exit void ipmi_unregister_watchdog(void) | |||
1037 | /* Wait to make sure the message makes it out. The lower layer has | 1037 | /* Wait to make sure the message makes it out. The lower layer has |
1038 | pointers to our buffers, we want to make sure they are done before | 1038 | pointers to our buffers, we want to make sure they are done before |
1039 | we release our memory. */ | 1039 | we release our memory. */ |
1040 | while (atomic_read(&set_timeout_tofree)) { | 1040 | while (atomic_read(&set_timeout_tofree)) |
1041 | set_current_state(TASK_UNINTERRUPTIBLE); | 1041 | schedule_timeout_uninterruptible(1); |
1042 | schedule_timeout(1); | ||
1043 | } | ||
1044 | 1042 | ||
1045 | /* Disconnect from IPMI. */ | 1043 | /* Disconnect from IPMI. */ |
1046 | rv = ipmi_destroy_user(watchdog_user); | 1044 | rv = ipmi_destroy_user(watchdog_user); |
@@ -1062,3 +1060,5 @@ static void __exit ipmi_wdog_exit(void) | |||
1062 | module_exit(ipmi_wdog_exit); | 1060 | module_exit(ipmi_wdog_exit); |
1063 | module_init(ipmi_wdog_init); | 1061 | module_init(ipmi_wdog_init); |
1064 | MODULE_LICENSE("GPL"); | 1062 | MODULE_LICENSE("GPL"); |
1063 | MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); | ||
1064 | 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 523fd3c8bbaa..449d029ad4f4 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c | |||
@@ -14,7 +14,7 @@ | |||
14 | * `Sticky' modifier keys, 951006. | 14 | * `Sticky' modifier keys, 951006. |
15 | * | 15 | * |
16 | * 11-11-96: SAK should now work in the raw mode (Martin Mares) | 16 | * 11-11-96: SAK should now work in the raw mode (Martin Mares) |
17 | * | 17 | * |
18 | * Modified to provide 'generic' keyboard support by Hamish Macdonald | 18 | * Modified to provide 'generic' keyboard support by Hamish Macdonald |
19 | * Merge with the m68k keyboard driver and split-off of the PC low-level | 19 | * Merge with the m68k keyboard driver and split-off of the PC low-level |
20 | * parts by Geert Uytterhoeven, May 1997 | 20 | * parts by Geert Uytterhoeven, May 1997 |
@@ -52,7 +52,7 @@ extern void ctrl_alt_del(void); | |||
52 | /* | 52 | /* |
53 | * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on. | 53 | * Some laptops take the 789uiojklm,. keys as number pad when NumLock is on. |
54 | * This seems a good reason to start with NumLock off. On HIL keyboards | 54 | * This seems a good reason to start with NumLock off. On HIL keyboards |
55 | * of PARISC machines however there is no NumLock key and everyone expects the keypad | 55 | * of PARISC machines however there is no NumLock key and everyone expects the keypad |
56 | * to be used for numbers. | 56 | * to be used for numbers. |
57 | */ | 57 | */ |
58 | 58 | ||
@@ -76,17 +76,17 @@ void compute_shiftstate(void); | |||
76 | k_meta, k_ascii, k_lock, k_lowercase,\ | 76 | k_meta, k_ascii, k_lock, k_lowercase,\ |
77 | k_slock, k_dead2, k_ignore, k_ignore | 77 | k_slock, k_dead2, k_ignore, k_ignore |
78 | 78 | ||
79 | typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value, | 79 | typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value, |
80 | char up_flag, struct pt_regs *regs); | 80 | char up_flag, struct pt_regs *regs); |
81 | static k_handler_fn K_HANDLERS; | 81 | static k_handler_fn K_HANDLERS; |
82 | static k_handler_fn *k_handler[16] = { K_HANDLERS }; | 82 | static k_handler_fn *k_handler[16] = { K_HANDLERS }; |
83 | 83 | ||
84 | #define FN_HANDLERS\ | 84 | #define FN_HANDLERS\ |
85 | fn_null, fn_enter, fn_show_ptregs, fn_show_mem,\ | 85 | fn_null, fn_enter, fn_show_ptregs, fn_show_mem,\ |
86 | fn_show_state, fn_send_intr, fn_lastcons, fn_caps_toggle,\ | 86 | fn_show_state, fn_send_intr, fn_lastcons, fn_caps_toggle,\ |
87 | fn_num, fn_hold, fn_scroll_forw, fn_scroll_back,\ | 87 | fn_num, fn_hold, fn_scroll_forw, fn_scroll_back,\ |
88 | fn_boot_it, fn_caps_on, fn_compose, fn_SAK,\ | 88 | fn_boot_it, fn_caps_on, fn_compose, fn_SAK,\ |
89 | fn_dec_console, fn_inc_console, fn_spawn_con, fn_bare_num | 89 | fn_dec_console, fn_inc_console, fn_spawn_con, fn_bare_num |
90 | 90 | ||
91 | typedef void (fn_handler_fn)(struct vc_data *vc, struct pt_regs *regs); | 91 | typedef void (fn_handler_fn)(struct vc_data *vc, struct pt_regs *regs); |
92 | static fn_handler_fn FN_HANDLERS; | 92 | static fn_handler_fn FN_HANDLERS; |
@@ -159,13 +159,13 @@ static int sysrq_alt; | |||
159 | */ | 159 | */ |
160 | int getkeycode(unsigned int scancode) | 160 | int getkeycode(unsigned int scancode) |
161 | { | 161 | { |
162 | struct list_head * node; | 162 | struct list_head *node; |
163 | struct input_dev *dev = NULL; | 163 | struct input_dev *dev = NULL; |
164 | 164 | ||
165 | list_for_each(node,&kbd_handler.h_list) { | 165 | list_for_each(node, &kbd_handler.h_list) { |
166 | struct input_handle * handle = to_handle_h(node); | 166 | struct input_handle *handle = to_handle_h(node); |
167 | if (handle->dev->keycodesize) { | 167 | if (handle->dev->keycodesize) { |
168 | dev = handle->dev; | 168 | dev = handle->dev; |
169 | break; | 169 | break; |
170 | } | 170 | } |
171 | } | 171 | } |
@@ -181,15 +181,15 @@ int getkeycode(unsigned int scancode) | |||
181 | 181 | ||
182 | int setkeycode(unsigned int scancode, unsigned int keycode) | 182 | int setkeycode(unsigned int scancode, unsigned int keycode) |
183 | { | 183 | { |
184 | struct list_head * node; | 184 | struct list_head *node; |
185 | struct input_dev *dev = NULL; | 185 | struct input_dev *dev = NULL; |
186 | unsigned int i, oldkey; | 186 | unsigned int i, oldkey; |
187 | 187 | ||
188 | list_for_each(node,&kbd_handler.h_list) { | 188 | list_for_each(node, &kbd_handler.h_list) { |
189 | struct input_handle *handle = to_handle_h(node); | 189 | struct input_handle *handle = to_handle_h(node); |
190 | if (handle->dev->keycodesize) { | 190 | if (handle->dev->keycodesize) { |
191 | dev = handle->dev; | 191 | dev = handle->dev; |
192 | break; | 192 | break; |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
@@ -200,7 +200,7 @@ int setkeycode(unsigned int scancode, unsigned int keycode) | |||
200 | return -EINVAL; | 200 | return -EINVAL; |
201 | if (keycode < 0 || keycode > KEY_MAX) | 201 | if (keycode < 0 || keycode > KEY_MAX) |
202 | return -EINVAL; | 202 | return -EINVAL; |
203 | if (keycode >> (dev->keycodesize * 8)) | 203 | if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8))) |
204 | return -EINVAL; | 204 | return -EINVAL; |
205 | 205 | ||
206 | oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode); | 206 | oldkey = SET_INPUT_KEYCODE(dev, scancode, keycode); |
@@ -216,11 +216,11 @@ int setkeycode(unsigned int scancode, unsigned int keycode) | |||
216 | } | 216 | } |
217 | 217 | ||
218 | /* | 218 | /* |
219 | * Making beeps and bells. | 219 | * Making beeps and bells. |
220 | */ | 220 | */ |
221 | static void kd_nosound(unsigned long ignored) | 221 | static void kd_nosound(unsigned long ignored) |
222 | { | 222 | { |
223 | struct list_head * node; | 223 | struct list_head *node; |
224 | 224 | ||
225 | list_for_each(node,&kbd_handler.h_list) { | 225 | list_for_each(node,&kbd_handler.h_list) { |
226 | struct input_handle *handle = to_handle_h(node); | 226 | struct input_handle *handle = to_handle_h(node); |
@@ -233,17 +233,16 @@ 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 | { |
241 | struct list_head * node; | 240 | struct list_head *node; |
242 | 241 | ||
243 | del_timer(&kd_mksound_timer); | 242 | del_timer(&kd_mksound_timer); |
244 | 243 | ||
245 | if (hz) { | 244 | if (hz) { |
246 | list_for_each_prev(node,&kbd_handler.h_list) { | 245 | list_for_each_prev(node, &kbd_handler.h_list) { |
247 | struct input_handle *handle = to_handle_h(node); | 246 | struct input_handle *handle = to_handle_h(node); |
248 | if (test_bit(EV_SND, handle->dev->evbit)) { | 247 | if (test_bit(EV_SND, handle->dev->evbit)) { |
249 | if (test_bit(SND_TONE, handle->dev->sndbit)) { | 248 | if (test_bit(SND_TONE, handle->dev->sndbit)) { |
@@ -338,19 +337,19 @@ static void to_utf8(struct vc_data *vc, ushort c) | |||
338 | if (c < 0x80) | 337 | if (c < 0x80) |
339 | /* 0******* */ | 338 | /* 0******* */ |
340 | put_queue(vc, c); | 339 | put_queue(vc, c); |
341 | else if (c < 0x800) { | 340 | else if (c < 0x800) { |
342 | /* 110***** 10****** */ | 341 | /* 110***** 10****** */ |
343 | put_queue(vc, 0xc0 | (c >> 6)); | 342 | put_queue(vc, 0xc0 | (c >> 6)); |
344 | put_queue(vc, 0x80 | (c & 0x3f)); | 343 | put_queue(vc, 0x80 | (c & 0x3f)); |
345 | } else { | 344 | } else { |
346 | /* 1110**** 10****** 10****** */ | 345 | /* 1110**** 10****** 10****** */ |
347 | put_queue(vc, 0xe0 | (c >> 12)); | 346 | put_queue(vc, 0xe0 | (c >> 12)); |
348 | put_queue(vc, 0x80 | ((c >> 6) & 0x3f)); | 347 | put_queue(vc, 0x80 | ((c >> 6) & 0x3f)); |
349 | put_queue(vc, 0x80 | (c & 0x3f)); | 348 | put_queue(vc, 0x80 | (c & 0x3f)); |
350 | } | 349 | } |
351 | } | 350 | } |
352 | 351 | ||
353 | /* | 352 | /* |
354 | * Called after returning from RAW mode or when changing consoles - recompute | 353 | * Called after returning from RAW mode or when changing consoles - recompute |
355 | * shift_down[] and shift_state from key_down[] maybe called when keymap is | 354 | * shift_down[] and shift_state from key_down[] maybe called when keymap is |
356 | * undefined, so that shiftkey release is seen | 355 | * undefined, so that shiftkey release is seen |
@@ -361,7 +360,7 @@ void compute_shiftstate(void) | |||
361 | 360 | ||
362 | shift_state = 0; | 361 | shift_state = 0; |
363 | memset(shift_down, 0, sizeof(shift_down)); | 362 | memset(shift_down, 0, sizeof(shift_down)); |
364 | 363 | ||
365 | for (i = 0; i < ARRAY_SIZE(key_down); i++) { | 364 | for (i = 0; i < ARRAY_SIZE(key_down); i++) { |
366 | 365 | ||
367 | if (!key_down[i]) | 366 | if (!key_down[i]) |
@@ -500,9 +499,9 @@ static void fn_dec_console(struct vc_data *vc, struct pt_regs *regs) | |||
500 | if (want_console != -1) | 499 | if (want_console != -1) |
501 | cur = want_console; | 500 | cur = want_console; |
502 | 501 | ||
503 | for (i = cur-1; i != cur; i--) { | 502 | for (i = cur - 1; i != cur; i--) { |
504 | if (i == -1) | 503 | if (i == -1) |
505 | i = MAX_NR_CONSOLES-1; | 504 | i = MAX_NR_CONSOLES - 1; |
506 | if (vc_cons_allocated(i)) | 505 | if (vc_cons_allocated(i)) |
507 | break; | 506 | break; |
508 | } | 507 | } |
@@ -568,9 +567,9 @@ static void fn_compose(struct vc_data *vc, struct pt_regs *regs) | |||
568 | 567 | ||
569 | static void fn_spawn_con(struct vc_data *vc, struct pt_regs *regs) | 568 | static void fn_spawn_con(struct vc_data *vc, struct pt_regs *regs) |
570 | { | 569 | { |
571 | if (spawnpid) | 570 | if (spawnpid) |
572 | if(kill_proc(spawnpid, spawnsig, 1)) | 571 | if (kill_proc(spawnpid, spawnsig, 1)) |
573 | spawnpid = 0; | 572 | spawnpid = 0; |
574 | } | 573 | } |
575 | 574 | ||
576 | static void fn_SAK(struct vc_data *vc, struct pt_regs *regs) | 575 | static void fn_SAK(struct vc_data *vc, struct pt_regs *regs) |
@@ -604,8 +603,8 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag, struct | |||
604 | return; | 603 | return; |
605 | if (value >= ARRAY_SIZE(fn_handler)) | 604 | if (value >= ARRAY_SIZE(fn_handler)) |
606 | return; | 605 | return; |
607 | if ((kbd->kbdmode == VC_RAW || | 606 | if ((kbd->kbdmode == VC_RAW || |
608 | kbd->kbdmode == VC_MEDIUMRAW) && | 607 | kbd->kbdmode == VC_MEDIUMRAW) && |
609 | value != KVAL(K_SAK)) | 608 | value != KVAL(K_SAK)) |
610 | return; /* SAK is allowed even in raw mode */ | 609 | return; /* SAK is allowed even in raw mode */ |
611 | fn_handler[value](vc, regs); | 610 | fn_handler[value](vc, regs); |
@@ -895,11 +894,11 @@ static inline unsigned char getleds(void) | |||
895 | 894 | ||
896 | static void kbd_bh(unsigned long dummy) | 895 | static void kbd_bh(unsigned long dummy) |
897 | { | 896 | { |
898 | struct list_head * node; | 897 | struct list_head *node; |
899 | unsigned char leds = getleds(); | 898 | unsigned char leds = getleds(); |
900 | 899 | ||
901 | if (leds != ledstate) { | 900 | if (leds != ledstate) { |
902 | list_for_each(node,&kbd_handler.h_list) { | 901 | list_for_each(node, &kbd_handler.h_list) { |
903 | struct input_handle * handle = to_handle_h(node); | 902 | struct input_handle * handle = to_handle_h(node); |
904 | input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01)); | 903 | input_event(handle->dev, EV_LED, LED_SCROLLL, !!(leds & 0x01)); |
905 | input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02)); | 904 | input_event(handle->dev, EV_LED, LED_NUML, !!(leds & 0x02)); |
@@ -964,11 +963,11 @@ static int sparc_l1_a_state = 0; | |||
964 | extern void sun_do_break(void); | 963 | extern void sun_do_break(void); |
965 | #endif | 964 | #endif |
966 | 965 | ||
967 | static int emulate_raw(struct vc_data *vc, unsigned int keycode, | 966 | static int emulate_raw(struct vc_data *vc, unsigned int keycode, |
968 | unsigned char up_flag) | 967 | unsigned char up_flag) |
969 | { | 968 | { |
970 | if (keycode > 255 || !x86_keycodes[keycode]) | 969 | if (keycode > 255 || !x86_keycodes[keycode]) |
971 | return -1; | 970 | return -1; |
972 | 971 | ||
973 | switch (keycode) { | 972 | switch (keycode) { |
974 | case KEY_PAUSE: | 973 | case KEY_PAUSE: |
@@ -982,7 +981,7 @@ static int emulate_raw(struct vc_data *vc, unsigned int keycode, | |||
982 | case KEY_HANJA: | 981 | case KEY_HANJA: |
983 | if (!up_flag) put_queue(vc, 0xf2); | 982 | if (!up_flag) put_queue(vc, 0xf2); |
984 | return 0; | 983 | return 0; |
985 | } | 984 | } |
986 | 985 | ||
987 | if (keycode == KEY_SYSRQ && sysrq_alt) { | 986 | if (keycode == KEY_SYSRQ && sysrq_alt) { |
988 | put_queue(vc, 0x54 | up_flag); | 987 | put_queue(vc, 0x54 | up_flag); |
@@ -1105,11 +1104,12 @@ static void kbd_keycode(unsigned int keycode, int down, | |||
1105 | else | 1104 | else |
1106 | clear_bit(keycode, key_down); | 1105 | clear_bit(keycode, key_down); |
1107 | 1106 | ||
1108 | if (rep && (!vc_kbd_mode(kbd, VC_REPEAT) || (tty && | 1107 | if (rep && |
1109 | (!L_ECHO(tty) && tty->driver->chars_in_buffer(tty))))) { | 1108 | (!vc_kbd_mode(kbd, VC_REPEAT) || |
1109 | (tty && !L_ECHO(tty) && tty->driver->chars_in_buffer(tty)))) { | ||
1110 | /* | 1110 | /* |
1111 | * Don't repeat a key if the input buffers are not empty and the | 1111 | * Don't repeat a key if the input buffers are not empty and the |
1112 | * characters get aren't echoed locally. This makes key repeat | 1112 | * characters get aren't echoed locally. This makes key repeat |
1113 | * usable with slow applications and under heavy loads. | 1113 | * usable with slow applications and under heavy loads. |
1114 | */ | 1114 | */ |
1115 | return; | 1115 | return; |
@@ -1131,7 +1131,8 @@ static void kbd_keycode(unsigned int keycode, int down, | |||
1131 | type = KTYP(keysym); | 1131 | type = KTYP(keysym); |
1132 | 1132 | ||
1133 | if (type < 0xf0) { | 1133 | if (type < 0xf0) { |
1134 | if (down && !raw_mode) to_utf8(vc, keysym); | 1134 | if (down && !raw_mode) |
1135 | to_utf8(vc, keysym); | ||
1135 | return; | 1136 | return; |
1136 | } | 1137 | } |
1137 | 1138 | ||
@@ -1155,7 +1156,7 @@ static void kbd_keycode(unsigned int keycode, int down, | |||
1155 | kbd->slockstate = 0; | 1156 | kbd->slockstate = 0; |
1156 | } | 1157 | } |
1157 | 1158 | ||
1158 | static void kbd_event(struct input_handle *handle, unsigned int event_type, | 1159 | static void kbd_event(struct input_handle *handle, unsigned int event_type, |
1159 | unsigned int event_code, int value) | 1160 | unsigned int event_code, int value) |
1160 | { | 1161 | { |
1161 | if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev)) | 1162 | if (event_type == EV_MSC && event_code == MSC_RAW && HW_RAW(handle->dev)) |
@@ -1167,15 +1168,13 @@ static void kbd_event(struct input_handle *handle, unsigned int event_type, | |||
1167 | schedule_console_callback(); | 1168 | schedule_console_callback(); |
1168 | } | 1169 | } |
1169 | 1170 | ||
1170 | static char kbd_name[] = "kbd"; | ||
1171 | |||
1172 | /* | 1171 | /* |
1173 | * When a keyboard (or other input device) is found, the kbd_connect | 1172 | * When a keyboard (or other input device) is found, the kbd_connect |
1174 | * function is called. The function then looks at the device, and if it | 1173 | * function is called. The function then looks at the device, and if it |
1175 | * likes it, it can open it and get events from it. In this (kbd_connect) | 1174 | * likes it, it can open it and get events from it. In this (kbd_connect) |
1176 | * function, we should decide which VT to bind that keyboard to initially. | 1175 | * function, we should decide which VT to bind that keyboard to initially. |
1177 | */ | 1176 | */ |
1178 | static struct input_handle *kbd_connect(struct input_handler *handler, | 1177 | static struct input_handle *kbd_connect(struct input_handler *handler, |
1179 | struct input_dev *dev, | 1178 | struct input_dev *dev, |
1180 | struct input_device_id *id) | 1179 | struct input_device_id *id) |
1181 | { | 1180 | { |
@@ -1183,18 +1182,19 @@ static struct input_handle *kbd_connect(struct input_handler *handler, | |||
1183 | int i; | 1182 | int i; |
1184 | 1183 | ||
1185 | for (i = KEY_RESERVED; i < BTN_MISC; i++) | 1184 | for (i = KEY_RESERVED; i < BTN_MISC; i++) |
1186 | if (test_bit(i, dev->keybit)) break; | 1185 | if (test_bit(i, dev->keybit)) |
1186 | break; | ||
1187 | 1187 | ||
1188 | if ((i == BTN_MISC) && !test_bit(EV_SND, dev->evbit)) | 1188 | if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit)) |
1189 | return NULL; | 1189 | return NULL; |
1190 | 1190 | ||
1191 | if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) | 1191 | if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) |
1192 | return NULL; | 1192 | return NULL; |
1193 | memset(handle, 0, sizeof(struct input_handle)); | 1193 | memset(handle, 0, sizeof(struct input_handle)); |
1194 | 1194 | ||
1195 | handle->dev = dev; | 1195 | handle->dev = dev; |
1196 | handle->handler = handler; | 1196 | handle->handler = handler; |
1197 | handle->name = kbd_name; | 1197 | handle->name = "kbd"; |
1198 | 1198 | ||
1199 | input_open_device(handle); | 1199 | input_open_device(handle); |
1200 | kbd_refresh_leds(handle); | 1200 | kbd_refresh_leds(handle); |
@@ -1213,11 +1213,11 @@ static struct input_device_id kbd_ids[] = { | |||
1213 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT, | 1213 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT, |
1214 | .evbit = { BIT(EV_KEY) }, | 1214 | .evbit = { BIT(EV_KEY) }, |
1215 | }, | 1215 | }, |
1216 | 1216 | ||
1217 | { | 1217 | { |
1218 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT, | 1218 | .flags = INPUT_DEVICE_ID_MATCH_EVBIT, |
1219 | .evbit = { BIT(EV_SND) }, | 1219 | .evbit = { BIT(EV_SND) }, |
1220 | }, | 1220 | }, |
1221 | 1221 | ||
1222 | { }, /* Terminating entry */ | 1222 | { }, /* Terminating entry */ |
1223 | }; | 1223 | }; |
diff --git a/drivers/char/lcd.c b/drivers/char/lcd.c index cf01a720eb2e..b77161146144 100644 --- a/drivers/char/lcd.c +++ b/drivers/char/lcd.c | |||
@@ -613,10 +613,15 @@ static struct miscdevice lcd_dev = { | |||
613 | 613 | ||
614 | static int lcd_init(void) | 614 | static int lcd_init(void) |
615 | { | 615 | { |
616 | int ret; | ||
616 | unsigned long data; | 617 | unsigned long data; |
617 | 618 | ||
618 | pr_info("%s\n", LCD_DRIVER); | 619 | pr_info("%s\n", LCD_DRIVER); |
619 | misc_register(&lcd_dev); | 620 | ret = misc_register(&lcd_dev); |
621 | if (ret) { | ||
622 | printk(KERN_WARNING LCD "Unable to register misc device.\n"); | ||
623 | return ret; | ||
624 | } | ||
620 | 625 | ||
621 | /* Check region? Naaah! Just snarf it up. */ | 626 | /* Check region? Naaah! Just snarf it up. */ |
622 | /* request_region(RTC_PORT(0), RTC_IO_EXTENT, "lcd");*/ | 627 | /* request_region(RTC_PORT(0), RTC_IO_EXTENT, "lcd");*/ |
diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 59eebe5a035f..2afb9038dbc5 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c | |||
@@ -128,6 +128,7 @@ | |||
128 | #include <linux/console.h> | 128 | #include <linux/console.h> |
129 | #include <linux/device.h> | 129 | #include <linux/device.h> |
130 | #include <linux/wait.h> | 130 | #include <linux/wait.h> |
131 | #include <linux/jiffies.h> | ||
131 | 132 | ||
132 | #include <linux/parport.h> | 133 | #include <linux/parport.h> |
133 | #undef LP_STATS | 134 | #undef LP_STATS |
@@ -307,7 +308,7 @@ static ssize_t lp_write(struct file * file, const char __user * buf, | |||
307 | (LP_F(minor) & LP_ABORT)); | 308 | (LP_F(minor) & LP_ABORT)); |
308 | 309 | ||
309 | #ifdef LP_STATS | 310 | #ifdef LP_STATS |
310 | if (jiffies-lp_table[minor].lastcall > LP_TIME(minor)) | 311 | if (time_after(jiffies, lp_table[minor].lastcall + LP_TIME(minor))) |
311 | lp_table[minor].runchars = 0; | 312 | lp_table[minor].runchars = 0; |
312 | 313 | ||
313 | lp_table[minor].lastcall = jiffies; | 314 | lp_table[minor].lastcall = jiffies; |
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..45d012d85e8c 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 | ||
@@ -1059,8 +1058,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) | |||
1059 | */ | 1058 | */ |
1060 | timeout = jiffies + HZ; | 1059 | timeout = jiffies + HZ; |
1061 | while (!(inb(info->base + UART_LSR) & UART_LSR_TEMT)) { | 1060 | while (!(inb(info->base + UART_LSR) & UART_LSR_TEMT)) { |
1062 | set_current_state(TASK_INTERRUPTIBLE); | 1061 | schedule_timeout_interruptible(5); |
1063 | schedule_timeout(5); | ||
1064 | if (time_after(jiffies, timeout)) | 1062 | if (time_after(jiffies, timeout)) |
1065 | break; | 1063 | break; |
1066 | } | 1064 | } |
@@ -1081,10 +1079,8 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) | |||
1081 | info->event = 0; | 1079 | info->event = 0; |
1082 | info->tty = NULL; | 1080 | info->tty = NULL; |
1083 | if (info->blocked_open) { | 1081 | if (info->blocked_open) { |
1084 | if (info->close_delay) { | 1082 | if (info->close_delay) |
1085 | set_current_state(TASK_INTERRUPTIBLE); | 1083 | schedule_timeout_interruptible(info->close_delay); |
1086 | schedule_timeout(info->close_delay); | ||
1087 | } | ||
1088 | wake_up_interruptible(&info->open_wait); | 1084 | wake_up_interruptible(&info->open_wait); |
1089 | } | 1085 | } |
1090 | 1086 | ||
@@ -1802,8 +1798,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout) | |||
1802 | #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT | 1798 | #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT |
1803 | printk("lsr = %d (jiff=%lu)...", lsr, jiffies); | 1799 | printk("lsr = %d (jiff=%lu)...", lsr, jiffies); |
1804 | #endif | 1800 | #endif |
1805 | set_current_state(TASK_INTERRUPTIBLE); | 1801 | schedule_timeout_interruptible(char_time); |
1806 | schedule_timeout(char_time); | ||
1807 | if (signal_pending(current)) | 1802 | if (signal_pending(current)) |
1808 | break; | 1803 | break; |
1809 | if (timeout && time_after(jiffies, orig_jiffies + timeout)) | 1804 | if (timeout && time_after(jiffies, orig_jiffies + timeout)) |
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index 09103b3d8f05..c9bdf544ed2c 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c | |||
@@ -62,7 +62,7 @@ | |||
62 | 62 | ||
63 | static inline unsigned char *alloc_buf(void) | 63 | static inline unsigned char *alloc_buf(void) |
64 | { | 64 | { |
65 | int prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; | 65 | unsigned int prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; |
66 | 66 | ||
67 | if (PAGE_SIZE != N_TTY_BUF_SIZE) | 67 | if (PAGE_SIZE != N_TTY_BUF_SIZE) |
68 | return kmalloc(N_TTY_BUF_SIZE, prio); | 68 | return kmalloc(N_TTY_BUF_SIZE, prio); |
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 7a0c74648124..02d7f046c10a 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/char/pcmcia/synclink_cs.c | 2 | * linux/drivers/char/pcmcia/synclink_cs.c |
3 | * | 3 | * |
4 | * $Id: synclink_cs.c,v 4.26 2004/08/11 19:30:02 paulkf Exp $ | 4 | * $Id: synclink_cs.c,v 4.34 2005/09/08 13:20:54 paulkf Exp $ |
5 | * | 5 | * |
6 | * Device driver for Microgate SyncLink PC Card | 6 | * Device driver for Microgate SyncLink PC Card |
7 | * multiprotocol serial adapter. | 7 | * multiprotocol serial adapter. |
@@ -472,7 +472,7 @@ module_param_array(dosyncppp, int, NULL, 0); | |||
472 | MODULE_LICENSE("GPL"); | 472 | MODULE_LICENSE("GPL"); |
473 | 473 | ||
474 | static char *driver_name = "SyncLink PC Card driver"; | 474 | static char *driver_name = "SyncLink PC Card driver"; |
475 | static char *driver_version = "$Revision: 4.26 $"; | 475 | static char *driver_version = "$Revision: 4.34 $"; |
476 | 476 | ||
477 | static struct tty_driver *serial_driver; | 477 | static struct tty_driver *serial_driver; |
478 | 478 | ||
@@ -1457,6 +1457,8 @@ static int startup(MGSLPC_INFO * info) | |||
1457 | 1457 | ||
1458 | info->pending_bh = 0; | 1458 | info->pending_bh = 0; |
1459 | 1459 | ||
1460 | memset(&info->icount, 0, sizeof(info->icount)); | ||
1461 | |||
1460 | init_timer(&info->tx_timer); | 1462 | init_timer(&info->tx_timer); |
1461 | info->tx_timer.data = (unsigned long)info; | 1463 | info->tx_timer.data = (unsigned long)info; |
1462 | info->tx_timer.function = tx_timeout; | 1464 | info->tx_timer.function = tx_timeout; |
@@ -1946,9 +1948,13 @@ static int get_stats(MGSLPC_INFO * info, struct mgsl_icount __user *user_icount) | |||
1946 | int err; | 1948 | int err; |
1947 | if (debug_level >= DEBUG_LEVEL_INFO) | 1949 | if (debug_level >= DEBUG_LEVEL_INFO) |
1948 | printk("get_params(%s)\n", info->device_name); | 1950 | printk("get_params(%s)\n", info->device_name); |
1949 | COPY_TO_USER(err,user_icount, &info->icount, sizeof(struct mgsl_icount)); | 1951 | if (!user_icount) { |
1950 | if (err) | 1952 | memset(&info->icount, 0, sizeof(info->icount)); |
1951 | return -EFAULT; | 1953 | } else { |
1954 | COPY_TO_USER(err, user_icount, &info->icount, sizeof(struct mgsl_icount)); | ||
1955 | if (err) | ||
1956 | return -EFAULT; | ||
1957 | } | ||
1952 | return 0; | 1958 | return 0; |
1953 | } | 1959 | } |
1954 | 1960 | ||
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..e91268e86833 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,45 @@ 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 + (old_row_size * new_rows); | ||
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 + | ||
820 | (old_row_size * new_rows) : | ||
821 | vc->vc_scr_end; | ||
794 | 822 | ||
795 | update_attr(vc); | 823 | update_attr(vc); |
796 | 824 | ||
797 | while (old_origin < vc->vc_scr_end) { | 825 | while (old_origin < end) { |
798 | scr_memcpyw((unsigned short *) new_origin, (unsigned short *) old_origin, rlth); | 826 | scr_memcpyw((unsigned short *) new_origin, |
827 | (unsigned short *) old_origin, rlth); | ||
799 | if (rrem) | 828 | if (rrem) |
800 | scr_memsetw((void *)(new_origin + rlth), vc->vc_video_erase_char, rrem); | 829 | scr_memsetw((void *)(new_origin + rlth), |
830 | vc->vc_video_erase_char, rrem); | ||
801 | old_origin += old_row_size; | 831 | old_origin += old_row_size; |
802 | new_origin += new_row_size; | 832 | new_origin += new_row_size; |
803 | } | 833 | } |
804 | if (new_scr_end > new_origin) | 834 | if (new_scr_end > new_origin) |
805 | scr_memsetw((void *)new_origin, vc->vc_video_erase_char, new_scr_end - new_origin); | 835 | scr_memsetw((void *)new_origin, vc->vc_video_erase_char, |
836 | new_scr_end - new_origin); | ||
806 | if (vc->vc_kmalloced) | 837 | if (vc->vc_kmalloced) |
807 | kfree(vc->vc_screenbuf); | 838 | kfree(vc->vc_screenbuf); |
808 | vc->vc_screenbuf = newscreen; | 839 | vc->vc_screenbuf = newscreen; |
@@ -2272,7 +2303,9 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) | |||
2272 | ret = paste_selection(tty); | 2303 | ret = paste_selection(tty); |
2273 | break; | 2304 | break; |
2274 | case TIOCL_UNBLANKSCREEN: | 2305 | case TIOCL_UNBLANKSCREEN: |
2306 | acquire_console_sem(); | ||
2275 | unblank_screen(); | 2307 | unblank_screen(); |
2308 | release_console_sem(); | ||
2276 | break; | 2309 | break; |
2277 | case TIOCL_SELLOADLUT: | 2310 | case TIOCL_SELLOADLUT: |
2278 | ret = sel_loadlut(p); | 2311 | ret = sel_loadlut(p); |
@@ -2317,8 +2350,10 @@ int tioclinux(struct tty_struct *tty, unsigned long arg) | |||
2317 | } | 2350 | } |
2318 | break; | 2351 | break; |
2319 | case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */ | 2352 | case TIOCL_BLANKSCREEN: /* until explicitly unblanked, not only poked */ |
2353 | acquire_console_sem(); | ||
2320 | ignore_poke = 1; | 2354 | ignore_poke = 1; |
2321 | do_blank_screen(0); | 2355 | do_blank_screen(0); |
2356 | release_console_sem(); | ||
2322 | break; | 2357 | break; |
2323 | case TIOCL_BLANKEDSCREEN: | 2358 | case TIOCL_BLANKEDSCREEN: |
2324 | ret = console_blanked; | 2359 | ret = console_blanked; |
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index b53e2e2b5aee..344001b45af9 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig | |||
@@ -84,6 +84,17 @@ config 977_WATCHDOG | |||
84 | 84 | ||
85 | Not sure? It's safe to say N. | 85 | Not sure? It's safe to say N. |
86 | 86 | ||
87 | config IXP2000_WATCHDOG | ||
88 | tristate "IXP2000 Watchdog" | ||
89 | depends on WATCHDOG && ARCH_IXP2000 | ||
90 | help | ||
91 | Say Y here if to include support for the watchdog timer | ||
92 | in the Intel IXP2000(2400, 2800, 2850) network processors. | ||
93 | This driver can be built as a module by choosing M. The module | ||
94 | will be called ixp2000_wdt. | ||
95 | |||
96 | Say N if you are unsure. | ||
97 | |||
87 | config IXP4XX_WATCHDOG | 98 | config IXP4XX_WATCHDOG |
88 | tristate "IXP4xx Watchdog" | 99 | tristate "IXP4xx Watchdog" |
89 | depends on WATCHDOG && ARCH_IXP4XX | 100 | depends on WATCHDOG && ARCH_IXP4XX |
@@ -100,17 +111,6 @@ config IXP4XX_WATCHDOG | |||
100 | 111 | ||
101 | Say N if you are unsure. | 112 | Say N if you are unsure. |
102 | 113 | ||
103 | config IXP2000_WATCHDOG | ||
104 | tristate "IXP2000 Watchdog" | ||
105 | depends on WATCHDOG && ARCH_IXP2000 | ||
106 | help | ||
107 | Say Y here if to include support for the watchdog timer | ||
108 | in the Intel IXP2000(2400, 2800, 2850) network processors. | ||
109 | This driver can be built as a module by choosing M. The module | ||
110 | will be called ixp2000_wdt. | ||
111 | |||
112 | Say N if you are unsure. | ||
113 | |||
114 | config S3C2410_WATCHDOG | 114 | config S3C2410_WATCHDOG |
115 | tristate "S3C2410 Watchdog" | 115 | tristate "S3C2410 Watchdog" |
116 | depends on WATCHDOG && ARCH_S3C2410 | 116 | depends on WATCHDOG && ARCH_S3C2410 |
@@ -139,6 +139,15 @@ config SA1100_WATCHDOG | |||
139 | To compile this driver as a module, choose M here: the | 139 | To compile this driver as a module, choose M here: the |
140 | module will be called sa1100_wdt. | 140 | module will be called sa1100_wdt. |
141 | 141 | ||
142 | config MPCORE_WATCHDOG | ||
143 | tristate "MPcore watchdog" | ||
144 | depends on WATCHDOG && ARM_MPCORE_PLATFORM && LOCAL_TIMERS | ||
145 | help | ||
146 | Watchdog timer embedded into the MPcore system. | ||
147 | |||
148 | To compile this driver as a module, choose M here: the | ||
149 | module will be called mpcore_wdt. | ||
150 | |||
142 | # X86 (i386 + ia64 + x86_64) Architecture | 151 | # X86 (i386 + ia64 + x86_64) Architecture |
143 | 152 | ||
144 | config ACQUIRE_WDT | 153 | config ACQUIRE_WDT |
@@ -224,6 +233,16 @@ config IB700_WDT | |||
224 | 233 | ||
225 | Most people will say N. | 234 | Most people will say N. |
226 | 235 | ||
236 | config IBMASR | ||
237 | tristate "IBM Automatic Server Restart" | ||
238 | depends on WATCHDOG && X86 | ||
239 | help | ||
240 | This is the driver for the IBM Automatic Server Restart watchdog | ||
241 | timer builtin into some eServer xSeries machines. | ||
242 | |||
243 | To compile this driver as a module, choose M here: the | ||
244 | module will be called ibmasr. | ||
245 | |||
227 | config WAFER_WDT | 246 | config WAFER_WDT |
228 | tristate "ICP Wafer 5823 Single Board Computer Watchdog" | 247 | tristate "ICP Wafer 5823 Single Board Computer Watchdog" |
229 | depends on WATCHDOG && X86 | 248 | depends on WATCHDOG && X86 |
@@ -234,6 +253,16 @@ config WAFER_WDT | |||
234 | To compile this driver as a module, choose M here: the | 253 | To compile this driver as a module, choose M here: the |
235 | module will be called wafer5823wdt. | 254 | module will be called wafer5823wdt. |
236 | 255 | ||
256 | config I6300ESB_WDT | ||
257 | tristate "Intel 6300ESB Timer/Watchdog" | ||
258 | depends on WATCHDOG && X86 && PCI | ||
259 | ---help--- | ||
260 | Hardware driver for the watchdog timer built into the Intel | ||
261 | 6300ESB controller hub. | ||
262 | |||
263 | To compile this driver as a module, choose M here: the | ||
264 | module will be called i6300esb. | ||
265 | |||
237 | config I8XX_TCO | 266 | config I8XX_TCO |
238 | tristate "Intel i8xx TCO Timer/Watchdog" | 267 | tristate "Intel i8xx TCO Timer/Watchdog" |
239 | depends on WATCHDOG && (X86 || IA64) && PCI | 268 | depends on WATCHDOG && (X86 || IA64) && PCI |
@@ -289,6 +318,19 @@ config 60XX_WDT | |||
289 | You can compile this driver directly into the kernel, or use | 318 | You can compile this driver directly into the kernel, or use |
290 | it as a module. The module will be called sbc60xxwdt. | 319 | it as a module. The module will be called sbc60xxwdt. |
291 | 320 | ||
321 | config SBC8360_WDT | ||
322 | tristate "SBC8360 Watchdog Timer" | ||
323 | depends on WATCHDOG && X86 | ||
324 | ---help--- | ||
325 | |||
326 | This is the driver for the hardware watchdog on the SBC8360 Single | ||
327 | Board Computer produced by Axiomtek Co., Ltd. (www.axiomtek.com). | ||
328 | |||
329 | To compile this driver as a module, choose M here: the | ||
330 | module will be called sbc8360.ko. | ||
331 | |||
332 | Most people will say N. | ||
333 | |||
292 | config CPU5_WDT | 334 | config CPU5_WDT |
293 | tristate "SMA CPU5 Watchdog" | 335 | tristate "SMA CPU5 Watchdog" |
294 | depends on WATCHDOG && X86 | 336 | depends on WATCHDOG && X86 |
@@ -327,6 +369,19 @@ config W83877F_WDT | |||
327 | 369 | ||
328 | Most people will say N. | 370 | Most people will say N. |
329 | 371 | ||
372 | config W83977F_WDT | ||
373 | tristate "W83977F (PCM-5335) Watchdog Timer" | ||
374 | depends on WATCHDOG && X86 | ||
375 | ---help--- | ||
376 | This is the driver for the hardware watchdog on the W83977F I/O chip | ||
377 | as used in AAEON's PCM-5335 SBC (and likely others). This | ||
378 | watchdog simply watches your kernel to make sure it doesn't freeze, | ||
379 | and if it does, it reboots your computer after a certain amount of | ||
380 | time. | ||
381 | |||
382 | To compile this driver as a module, choose M here: the | ||
383 | module will be called w83977f_wdt. | ||
384 | |||
330 | config MACHZ_WDT | 385 | config MACHZ_WDT |
331 | tristate "ZF MachZ Watchdog" | 386 | tristate "ZF MachZ Watchdog" |
332 | depends on WATCHDOG && X86 | 387 | depends on WATCHDOG && X86 |
@@ -346,6 +401,28 @@ config 8xx_WDT | |||
346 | tristate "MPC8xx Watchdog Timer" | 401 | tristate "MPC8xx Watchdog Timer" |
347 | depends on WATCHDOG && 8xx | 402 | depends on WATCHDOG && 8xx |
348 | 403 | ||
404 | config MV64X60_WDT | ||
405 | tristate "MV64X60 (Marvell Discovery) Watchdog Timer" | ||
406 | depends on WATCHDOG && MV64X60 | ||
407 | |||
408 | config BOOKE_WDT | ||
409 | tristate "PowerPC Book-E Watchdog Timer" | ||
410 | depends on WATCHDOG && (BOOKE || 4xx) | ||
411 | ---help--- | ||
412 | Please see Documentation/watchdog/watchdog-api.txt for | ||
413 | more information. | ||
414 | |||
415 | # PPC64 Architecture | ||
416 | |||
417 | config WATCHDOG_RTAS | ||
418 | tristate "RTAS watchdog" | ||
419 | depends on WATCHDOG && PPC_RTAS | ||
420 | help | ||
421 | This driver adds watchdog support for the RTAS watchdog. | ||
422 | |||
423 | To compile this driver as a module, choose M here. The module | ||
424 | will be called wdrtas. | ||
425 | |||
349 | # MIPS Architecture | 426 | # MIPS Architecture |
350 | 427 | ||
351 | config INDYDOG | 428 | config INDYDOG |
@@ -414,16 +491,6 @@ config WATCHDOG_RIO | |||
414 | machines. The watchdog timeout period is normally one minute but | 491 | machines. The watchdog timeout period is normally one minute but |
415 | can be changed with a boot-time parameter. | 492 | can be changed with a boot-time parameter. |
416 | 493 | ||
417 | # ppc64 RTAS watchdog | ||
418 | config WATCHDOG_RTAS | ||
419 | tristate "RTAS watchdog" | ||
420 | depends on WATCHDOG && PPC_RTAS | ||
421 | help | ||
422 | This driver adds watchdog support for the RTAS watchdog. | ||
423 | |||
424 | To compile this driver as a module, choose M here. The module | ||
425 | will be called wdrtas. | ||
426 | |||
427 | # | 494 | # |
428 | # ISA-based Watchdog Cards | 495 | # ISA-based Watchdog Cards |
429 | # | 496 | # |
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile index c1838834ea7f..cfd0a3987710 100644 --- a/drivers/char/watchdog/Makefile +++ b/drivers/char/watchdog/Makefile | |||
@@ -2,42 +2,74 @@ | |||
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 | obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o |
22 | obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o | 33 | |
23 | obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o | 34 | # X86 (i386 + ia64 + x86_64) Architecture |
24 | obj-$(CONFIG_SC520_WDT) += sc520_wdt.o | 35 | obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o |
25 | obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o | 36 | obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o |
26 | obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o | 37 | obj-$(CONFIG_ALIM1535_WDT) += alim1535_wdt.o |
27 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o | 38 | obj-$(CONFIG_ALIM7101_WDT) += alim7101_wdt.o |
39 | obj-$(CONFIG_SC520_WDT) += sc520_wdt.o | ||
40 | obj-$(CONFIG_EUROTECH_WDT) += eurotechwdt.o | ||
41 | obj-$(CONFIG_IB700_WDT) += ib700wdt.o | ||
42 | obj-$(CONFIG_IBMASR) += ibmasr.o | ||
28 | obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o | 43 | obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o |
44 | obj-$(CONFIG_I6300ESB_WDT) += i6300esb.o | ||
45 | obj-$(CONFIG_I8XX_TCO) += i8xx_tco.o | ||
46 | obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o | ||
47 | obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o | ||
48 | obj-$(CONFIG_60XX_WDT) += sbc60xxwdt.o | ||
49 | obj-$(CONFIG_SBC8360_WDT) += sbc8360.o | ||
29 | obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o | 50 | obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o |
30 | obj-$(CONFIG_INDYDOG) += indydog.o | 51 | obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o |
31 | obj-$(CONFIG_PCIPCWATCHDOG) += pcwd_pci.o | 52 | obj-$(CONFIG_W83877F_WDT) += w83877f_wdt.o |
32 | obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o | 53 | obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o |
33 | obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o | 54 | obj-$(CONFIG_MACHZ_WDT) += machzwd.o |
34 | obj-$(CONFIG_IXP2000_WATCHDOG) += ixp2000_wdt.o | 55 | |
56 | # PowerPC Architecture | ||
35 | obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o | 57 | obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o |
58 | obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o | ||
59 | obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o | ||
60 | |||
61 | # PPC64 Architecture | ||
36 | obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o | 62 | obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o |
37 | 63 | ||
38 | # Only one watchdog can succeed. We probe the hardware watchdog | 64 | # MIPS Architecture |
39 | # drivers first, then the softdog driver. This means if your hardware | 65 | obj-$(CONFIG_INDYDOG) += indydog.o |
40 | # watchdog dies or is 'borrowed' for some reason the software watchdog | 66 | |
41 | # still gives you some cover. | 67 | # S390 Architecture |
68 | |||
69 | # SUPERH Architecture | ||
70 | obj-$(CONFIG_SH_WDT) += shwdt.o | ||
71 | |||
72 | # SPARC64 Architecture | ||
42 | 73 | ||
74 | # Architecture Independant | ||
43 | obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o | 75 | 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/i6300esb.c b/drivers/char/watchdog/i6300esb.c new file mode 100644 index 000000000000..93785f13242e --- /dev/null +++ b/drivers/char/watchdog/i6300esb.c | |||
@@ -0,0 +1,527 @@ | |||
1 | /* | ||
2 | * i6300esb: Watchdog timer driver for Intel 6300ESB chipset | ||
3 | * | ||
4 | * (c) Copyright 2004 Google Inc. | ||
5 | * (c) Copyright 2005 David Härdeman <david@2gen.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * based on i810-tco.c which is in turn based on softdog.c | ||
13 | * | ||
14 | * The timer is implemented in the following I/O controller hubs: | ||
15 | * (See the intel documentation on http://developer.intel.com.) | ||
16 | * 6300ESB chip : document number 300641-003 | ||
17 | * | ||
18 | * 2004YYZZ Ross Biro | ||
19 | * Initial version 0.01 | ||
20 | * 2004YYZZ Ross Biro | ||
21 | * Version 0.02 | ||
22 | * 20050210 David Härdeman <david@2gen.com> | ||
23 | * Ported driver to kernel 2.6 | ||
24 | */ | ||
25 | |||
26 | /* | ||
27 | * Includes, defines, variables, module parameters, ... | ||
28 | */ | ||
29 | |||
30 | #include <linux/module.h> | ||
31 | #include <linux/types.h> | ||
32 | #include <linux/kernel.h> | ||
33 | #include <linux/fs.h> | ||
34 | #include <linux/mm.h> | ||
35 | #include <linux/miscdevice.h> | ||
36 | #include <linux/watchdog.h> | ||
37 | #include <linux/reboot.h> | ||
38 | #include <linux/init.h> | ||
39 | #include <linux/pci.h> | ||
40 | #include <linux/ioport.h> | ||
41 | |||
42 | #include <asm/uaccess.h> | ||
43 | #include <asm/io.h> | ||
44 | |||
45 | /* Module and version information */ | ||
46 | #define ESB_VERSION "0.03" | ||
47 | #define ESB_MODULE_NAME "i6300ESB timer" | ||
48 | #define ESB_DRIVER_NAME ESB_MODULE_NAME ", v" ESB_VERSION | ||
49 | #define PFX ESB_MODULE_NAME ": " | ||
50 | |||
51 | /* PCI configuration registers */ | ||
52 | #define ESB_CONFIG_REG 0x60 /* Config register */ | ||
53 | #define ESB_LOCK_REG 0x68 /* WDT lock register */ | ||
54 | |||
55 | /* Memory mapped registers */ | ||
56 | #define ESB_TIMER1_REG BASEADDR + 0x00 /* Timer1 value after each reset */ | ||
57 | #define ESB_TIMER2_REG BASEADDR + 0x04 /* Timer2 value after each reset */ | ||
58 | #define ESB_GINTSR_REG BASEADDR + 0x08 /* General Interrupt Status Register */ | ||
59 | #define ESB_RELOAD_REG BASEADDR + 0x0c /* Reload register */ | ||
60 | |||
61 | /* Lock register bits */ | ||
62 | #define ESB_WDT_FUNC ( 0x01 << 2 ) /* Watchdog functionality */ | ||
63 | #define ESB_WDT_ENABLE ( 0x01 << 1 ) /* Enable WDT */ | ||
64 | #define ESB_WDT_LOCK ( 0x01 << 0 ) /* Lock (nowayout) */ | ||
65 | |||
66 | /* Config register bits */ | ||
67 | #define ESB_WDT_REBOOT ( 0x01 << 5 ) /* Enable reboot on timeout */ | ||
68 | #define ESB_WDT_FREQ ( 0x01 << 2 ) /* Decrement frequency */ | ||
69 | #define ESB_WDT_INTTYPE ( 0x11 << 0 ) /* Interrupt type on timer1 timeout */ | ||
70 | |||
71 | /* Reload register bits */ | ||
72 | #define ESB_WDT_RELOAD ( 0x01 << 8 ) /* prevent timeout */ | ||
73 | |||
74 | /* Magic constants */ | ||
75 | #define ESB_UNLOCK1 0x80 /* Step 1 to unlock reset registers */ | ||
76 | #define ESB_UNLOCK2 0x86 /* Step 2 to unlock reset registers */ | ||
77 | |||
78 | /* internal variables */ | ||
79 | static void __iomem *BASEADDR; | ||
80 | static spinlock_t esb_lock; /* Guards the hardware */ | ||
81 | static unsigned long timer_alive; | ||
82 | static struct pci_dev *esb_pci; | ||
83 | static unsigned short triggered; /* The status of the watchdog upon boot */ | ||
84 | static char esb_expect_close; | ||
85 | |||
86 | /* module parameters */ | ||
87 | #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat (1<heartbeat<2*1023) */ | ||
88 | static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ | ||
89 | module_param(heartbeat, int, 0); | ||
90 | MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (1<heartbeat<2046, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); | ||
91 | |||
92 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
93 | module_param(nowayout, int, 0); | ||
94 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | ||
95 | |||
96 | /* | ||
97 | * Some i6300ESB specific functions | ||
98 | */ | ||
99 | |||
100 | /* | ||
101 | * Prepare for reloading the timer by unlocking the proper registers. | ||
102 | * This is performed by first writing 0x80 followed by 0x86 to the | ||
103 | * reload register. After this the appropriate registers can be written | ||
104 | * to once before they need to be unlocked again. | ||
105 | */ | ||
106 | static inline void esb_unlock_registers(void) { | ||
107 | writeb(ESB_UNLOCK1, ESB_RELOAD_REG); | ||
108 | writeb(ESB_UNLOCK2, ESB_RELOAD_REG); | ||
109 | } | ||
110 | |||
111 | static void esb_timer_start(void) | ||
112 | { | ||
113 | u8 val; | ||
114 | |||
115 | /* Enable or Enable + Lock? */ | ||
116 | val = 0x02 | (nowayout ? 0x01 : 0x00); | ||
117 | |||
118 | pci_write_config_byte(esb_pci, ESB_LOCK_REG, val); | ||
119 | } | ||
120 | |||
121 | static int esb_timer_stop(void) | ||
122 | { | ||
123 | u8 val; | ||
124 | |||
125 | spin_lock(&esb_lock); | ||
126 | /* First, reset timers as suggested by the docs */ | ||
127 | esb_unlock_registers(); | ||
128 | writew(ESB_WDT_RELOAD, ESB_RELOAD_REG); | ||
129 | /* Then disable the WDT */ | ||
130 | pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x0); | ||
131 | pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val); | ||
132 | spin_unlock(&esb_lock); | ||
133 | |||
134 | /* Returns 0 if the timer was disabled, non-zero otherwise */ | ||
135 | return (val & 0x01); | ||
136 | } | ||
137 | |||
138 | static void esb_timer_keepalive(void) | ||
139 | { | ||
140 | spin_lock(&esb_lock); | ||
141 | esb_unlock_registers(); | ||
142 | writew(ESB_WDT_RELOAD, ESB_RELOAD_REG); | ||
143 | /* FIXME: Do we need to flush anything here? */ | ||
144 | spin_unlock(&esb_lock); | ||
145 | } | ||
146 | |||
147 | static int esb_timer_set_heartbeat(int time) | ||
148 | { | ||
149 | u32 val; | ||
150 | |||
151 | if (time < 0x1 || time > (2 * 0x03ff)) | ||
152 | return -EINVAL; | ||
153 | |||
154 | spin_lock(&esb_lock); | ||
155 | |||
156 | /* We shift by 9, so if we are passed a value of 1 sec, | ||
157 | * val will be 1 << 9 = 512, then write that to two | ||
158 | * timers => 2 * 512 = 1024 (which is decremented at 1KHz) | ||
159 | */ | ||
160 | val = time << 9; | ||
161 | |||
162 | /* Write timer 1 */ | ||
163 | esb_unlock_registers(); | ||
164 | writel(val, ESB_TIMER1_REG); | ||
165 | |||
166 | /* Write timer 2 */ | ||
167 | esb_unlock_registers(); | ||
168 | writel(val, ESB_TIMER2_REG); | ||
169 | |||
170 | /* Reload */ | ||
171 | esb_unlock_registers(); | ||
172 | writew(ESB_WDT_RELOAD, ESB_RELOAD_REG); | ||
173 | |||
174 | /* FIXME: Do we need to flush everything out? */ | ||
175 | |||
176 | /* Done */ | ||
177 | heartbeat = time; | ||
178 | spin_unlock(&esb_lock); | ||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | static int esb_timer_read (void) | ||
183 | { | ||
184 | u32 count; | ||
185 | |||
186 | /* This isn't documented, and doesn't take into | ||
187 | * acount which stage is running, but it looks | ||
188 | * like a 20 bit count down, so we might as well report it. | ||
189 | */ | ||
190 | pci_read_config_dword(esb_pci, 0x64, &count); | ||
191 | return (int)count; | ||
192 | } | ||
193 | |||
194 | /* | ||
195 | * /dev/watchdog handling | ||
196 | */ | ||
197 | |||
198 | static int esb_open (struct inode *inode, struct file *file) | ||
199 | { | ||
200 | /* /dev/watchdog can only be opened once */ | ||
201 | if (test_and_set_bit(0, &timer_alive)) | ||
202 | return -EBUSY; | ||
203 | |||
204 | /* Reload and activate timer */ | ||
205 | esb_timer_keepalive (); | ||
206 | esb_timer_start (); | ||
207 | |||
208 | return nonseekable_open(inode, file); | ||
209 | } | ||
210 | |||
211 | static int esb_release (struct inode *inode, struct file *file) | ||
212 | { | ||
213 | /* Shut off the timer. */ | ||
214 | if (esb_expect_close == 42) { | ||
215 | esb_timer_stop (); | ||
216 | } else { | ||
217 | printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); | ||
218 | esb_timer_keepalive (); | ||
219 | } | ||
220 | clear_bit(0, &timer_alive); | ||
221 | esb_expect_close = 0; | ||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | static ssize_t esb_write (struct file *file, const char __user *data, | ||
226 | size_t len, loff_t * ppos) | ||
227 | { | ||
228 | /* See if we got the magic character 'V' and reload the timer */ | ||
229 | if (len) { | ||
230 | if (!nowayout) { | ||
231 | size_t i; | ||
232 | |||
233 | /* note: just in case someone wrote the magic character | ||
234 | * five months ago... */ | ||
235 | esb_expect_close = 0; | ||
236 | |||
237 | /* scan to see whether or not we got the magic character */ | ||
238 | for (i = 0; i != len; i++) { | ||
239 | char c; | ||
240 | if(get_user(c, data+i)) | ||
241 | return -EFAULT; | ||
242 | if (c == 'V') | ||
243 | esb_expect_close = 42; | ||
244 | } | ||
245 | } | ||
246 | |||
247 | /* someone wrote to us, we should reload the timer */ | ||
248 | esb_timer_keepalive (); | ||
249 | } | ||
250 | return len; | ||
251 | } | ||
252 | |||
253 | static int esb_ioctl (struct inode *inode, struct file *file, | ||
254 | unsigned int cmd, unsigned long arg) | ||
255 | { | ||
256 | int new_options, retval = -EINVAL; | ||
257 | int new_heartbeat; | ||
258 | void __user *argp = (void __user *)arg; | ||
259 | int __user *p = argp; | ||
260 | static struct watchdog_info ident = { | ||
261 | .options = WDIOF_SETTIMEOUT | | ||
262 | WDIOF_KEEPALIVEPING | | ||
263 | WDIOF_MAGICCLOSE, | ||
264 | .firmware_version = 0, | ||
265 | .identity = ESB_MODULE_NAME, | ||
266 | }; | ||
267 | |||
268 | switch (cmd) { | ||
269 | case WDIOC_GETSUPPORT: | ||
270 | return copy_to_user(argp, &ident, | ||
271 | sizeof (ident)) ? -EFAULT : 0; | ||
272 | |||
273 | case WDIOC_GETSTATUS: | ||
274 | return put_user (esb_timer_read(), p); | ||
275 | |||
276 | case WDIOC_GETBOOTSTATUS: | ||
277 | return put_user (triggered, p); | ||
278 | |||
279 | case WDIOC_KEEPALIVE: | ||
280 | esb_timer_keepalive (); | ||
281 | return 0; | ||
282 | |||
283 | case WDIOC_SETOPTIONS: | ||
284 | { | ||
285 | if (get_user (new_options, p)) | ||
286 | return -EFAULT; | ||
287 | |||
288 | if (new_options & WDIOS_DISABLECARD) { | ||
289 | esb_timer_stop (); | ||
290 | retval = 0; | ||
291 | } | ||
292 | |||
293 | if (new_options & WDIOS_ENABLECARD) { | ||
294 | esb_timer_keepalive (); | ||
295 | esb_timer_start (); | ||
296 | retval = 0; | ||
297 | } | ||
298 | |||
299 | return retval; | ||
300 | } | ||
301 | |||
302 | case WDIOC_SETTIMEOUT: | ||
303 | { | ||
304 | if (get_user(new_heartbeat, p)) | ||
305 | return -EFAULT; | ||
306 | |||
307 | if (esb_timer_set_heartbeat(new_heartbeat)) | ||
308 | return -EINVAL; | ||
309 | |||
310 | esb_timer_keepalive (); | ||
311 | /* Fall */ | ||
312 | } | ||
313 | |||
314 | case WDIOC_GETTIMEOUT: | ||
315 | return put_user(heartbeat, p); | ||
316 | |||
317 | default: | ||
318 | return -ENOIOCTLCMD; | ||
319 | } | ||
320 | } | ||
321 | |||
322 | /* | ||
323 | * Notify system | ||
324 | */ | ||
325 | |||
326 | static int esb_notify_sys (struct notifier_block *this, unsigned long code, void *unused) | ||
327 | { | ||
328 | if (code==SYS_DOWN || code==SYS_HALT) { | ||
329 | /* Turn the WDT off */ | ||
330 | esb_timer_stop (); | ||
331 | } | ||
332 | |||
333 | return NOTIFY_DONE; | ||
334 | } | ||
335 | |||
336 | /* | ||
337 | * Kernel Interfaces | ||
338 | */ | ||
339 | |||
340 | static struct file_operations esb_fops = { | ||
341 | .owner = THIS_MODULE, | ||
342 | .llseek = no_llseek, | ||
343 | .write = esb_write, | ||
344 | .ioctl = esb_ioctl, | ||
345 | .open = esb_open, | ||
346 | .release = esb_release, | ||
347 | }; | ||
348 | |||
349 | static struct miscdevice esb_miscdev = { | ||
350 | .minor = WATCHDOG_MINOR, | ||
351 | .name = "watchdog", | ||
352 | .fops = &esb_fops, | ||
353 | }; | ||
354 | |||
355 | static struct notifier_block esb_notifier = { | ||
356 | .notifier_call = esb_notify_sys, | ||
357 | }; | ||
358 | |||
359 | /* | ||
360 | * Data for PCI driver interface | ||
361 | * | ||
362 | * This data only exists for exporting the supported | ||
363 | * PCI ids via MODULE_DEVICE_TABLE. We do not actually | ||
364 | * register a pci_driver, because someone else might one day | ||
365 | * want to register another driver on the same PCI id. | ||
366 | */ | ||
367 | static struct pci_device_id esb_pci_tbl[] = { | ||
368 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_9), }, | ||
369 | { 0, }, /* End of list */ | ||
370 | }; | ||
371 | MODULE_DEVICE_TABLE (pci, esb_pci_tbl); | ||
372 | |||
373 | /* | ||
374 | * Init & exit routines | ||
375 | */ | ||
376 | |||
377 | static unsigned char __init esb_getdevice (void) | ||
378 | { | ||
379 | u8 val1; | ||
380 | unsigned short val2; | ||
381 | |||
382 | struct pci_dev *dev = NULL; | ||
383 | /* | ||
384 | * Find the PCI device | ||
385 | */ | ||
386 | |||
387 | for_each_pci_dev(dev) { | ||
388 | if (pci_match_id(esb_pci_tbl, dev)) { | ||
389 | esb_pci = dev; | ||
390 | break; | ||
391 | } | ||
392 | } | ||
393 | |||
394 | if (esb_pci) { | ||
395 | if (pci_enable_device(esb_pci)) { | ||
396 | printk (KERN_ERR PFX "failed to enable device\n"); | ||
397 | goto err_devput; | ||
398 | } | ||
399 | |||
400 | if (pci_request_region(esb_pci, 0, ESB_MODULE_NAME)) { | ||
401 | printk (KERN_ERR PFX "failed to request region\n"); | ||
402 | goto err_disable; | ||
403 | } | ||
404 | |||
405 | BASEADDR = ioremap(pci_resource_start(esb_pci, 0), | ||
406 | pci_resource_len(esb_pci, 0)); | ||
407 | if (BASEADDR == NULL) { | ||
408 | /* Something's wrong here, BASEADDR has to be set */ | ||
409 | printk (KERN_ERR PFX "failed to get BASEADDR\n"); | ||
410 | goto err_release; | ||
411 | } | ||
412 | |||
413 | /* | ||
414 | * The watchdog has two timers, it can be setup so that the | ||
415 | * expiry of timer1 results in an interrupt and the expiry of | ||
416 | * timer2 results in a reboot. We set it to not generate | ||
417 | * any interrupts as there is not much we can do with it | ||
418 | * right now. | ||
419 | * | ||
420 | * We also enable reboots and set the timer frequency to | ||
421 | * the PCI clock divided by 2^15 (approx 1KHz). | ||
422 | */ | ||
423 | pci_write_config_word(esb_pci, ESB_CONFIG_REG, 0x0003); | ||
424 | |||
425 | /* Check that the WDT isn't already locked */ | ||
426 | pci_read_config_byte(esb_pci, ESB_LOCK_REG, &val1); | ||
427 | if (val1 & ESB_WDT_LOCK) | ||
428 | printk (KERN_WARNING PFX "nowayout already set\n"); | ||
429 | |||
430 | /* Set the timer to watchdog mode and disable it for now */ | ||
431 | pci_write_config_byte(esb_pci, ESB_LOCK_REG, 0x00); | ||
432 | |||
433 | /* Check if the watchdog was previously triggered */ | ||
434 | esb_unlock_registers(); | ||
435 | val2 = readw(ESB_RELOAD_REG); | ||
436 | triggered = (val2 & (0x01 << 9) >> 9); | ||
437 | |||
438 | /* Reset trigger flag and timers */ | ||
439 | esb_unlock_registers(); | ||
440 | writew((0x11 << 8), ESB_RELOAD_REG); | ||
441 | |||
442 | /* Done */ | ||
443 | return 1; | ||
444 | |||
445 | err_release: | ||
446 | pci_release_region(esb_pci, 0); | ||
447 | err_disable: | ||
448 | pci_disable_device(esb_pci); | ||
449 | err_devput: | ||
450 | pci_dev_put(esb_pci); | ||
451 | } | ||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | static int __init watchdog_init (void) | ||
456 | { | ||
457 | int ret; | ||
458 | |||
459 | spin_lock_init(&esb_lock); | ||
460 | |||
461 | /* Check whether or not the hardware watchdog is there */ | ||
462 | if (!esb_getdevice () || esb_pci == NULL) | ||
463 | return -ENODEV; | ||
464 | |||
465 | /* Check that the heartbeat value is within it's range ; if not reset to the default */ | ||
466 | if (esb_timer_set_heartbeat (heartbeat)) { | ||
467 | esb_timer_set_heartbeat (WATCHDOG_HEARTBEAT); | ||
468 | printk(KERN_INFO PFX "heartbeat value must be 1<heartbeat<2046, using %d\n", | ||
469 | heartbeat); | ||
470 | } | ||
471 | |||
472 | ret = register_reboot_notifier(&esb_notifier); | ||
473 | if (ret != 0) { | ||
474 | printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", | ||
475 | ret); | ||
476 | goto err_unmap; | ||
477 | } | ||
478 | |||
479 | ret = misc_register(&esb_miscdev); | ||
480 | if (ret != 0) { | ||
481 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", | ||
482 | WATCHDOG_MINOR, ret); | ||
483 | goto err_notifier; | ||
484 | } | ||
485 | |||
486 | esb_timer_stop (); | ||
487 | |||
488 | printk (KERN_INFO PFX "initialized (0x%p). heartbeat=%d sec (nowayout=%d)\n", | ||
489 | BASEADDR, heartbeat, nowayout); | ||
490 | |||
491 | return 0; | ||
492 | |||
493 | err_notifier: | ||
494 | unregister_reboot_notifier(&esb_notifier); | ||
495 | err_unmap: | ||
496 | iounmap(BASEADDR); | ||
497 | /* err_release: */ | ||
498 | pci_release_region(esb_pci, 0); | ||
499 | /* err_disable: */ | ||
500 | pci_disable_device(esb_pci); | ||
501 | /* err_devput: */ | ||
502 | pci_dev_put(esb_pci); | ||
503 | return ret; | ||
504 | } | ||
505 | |||
506 | static void __exit watchdog_cleanup (void) | ||
507 | { | ||
508 | /* Stop the timer before we leave */ | ||
509 | if (!nowayout) | ||
510 | esb_timer_stop (); | ||
511 | |||
512 | /* Deregister */ | ||
513 | misc_deregister(&esb_miscdev); | ||
514 | unregister_reboot_notifier(&esb_notifier); | ||
515 | iounmap(BASEADDR); | ||
516 | pci_release_region(esb_pci, 0); | ||
517 | pci_disable_device(esb_pci); | ||
518 | pci_dev_put(esb_pci); | ||
519 | } | ||
520 | |||
521 | module_init(watchdog_init); | ||
522 | module_exit(watchdog_cleanup); | ||
523 | |||
524 | MODULE_AUTHOR("Ross Biro and David Härdeman"); | ||
525 | MODULE_DESCRIPTION("Watchdog driver for Intel 6300ESB chipsets"); | ||
526 | MODULE_LICENSE("GPL"); | ||
527 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/char/watchdog/ibmasr.c b/drivers/char/watchdog/ibmasr.c new file mode 100644 index 000000000000..294c474ae485 --- /dev/null +++ b/drivers/char/watchdog/ibmasr.c | |||
@@ -0,0 +1,405 @@ | |||
1 | /* | ||
2 | * IBM Automatic Server Restart driver. | ||
3 | * | ||
4 | * Copyright (c) 2005 Andrey Panin <pazke@donpac.ru> | ||
5 | * | ||
6 | * Based on driver written by Pete Reynolds. | ||
7 | * Copyright (c) IBM Corporation, 1998-2004. | ||
8 | * | ||
9 | * This software may be used and distributed according to the terms | ||
10 | * of the GNU Public License, incorporated herein by reference. | ||
11 | */ | ||
12 | |||
13 | #include <linux/config.h> | ||
14 | #include <linux/fs.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/pci.h> | ||
19 | #include <linux/timer.h> | ||
20 | #include <linux/miscdevice.h> | ||
21 | #include <linux/watchdog.h> | ||
22 | #include <linux/dmi.h> | ||
23 | |||
24 | #include <asm/io.h> | ||
25 | #include <asm/uaccess.h> | ||
26 | |||
27 | |||
28 | enum { | ||
29 | ASMTYPE_UNKNOWN, | ||
30 | ASMTYPE_TOPAZ, | ||
31 | ASMTYPE_JASPER, | ||
32 | ASMTYPE_PEARL, | ||
33 | ASMTYPE_JUNIPER, | ||
34 | ASMTYPE_SPRUCE, | ||
35 | }; | ||
36 | |||
37 | #define PFX "ibmasr: " | ||
38 | |||
39 | #define TOPAZ_ASR_REG_OFFSET 4 | ||
40 | #define TOPAZ_ASR_TOGGLE 0x40 | ||
41 | #define TOPAZ_ASR_DISABLE 0x80 | ||
42 | |||
43 | /* PEARL ASR S/W REGISTER SUPERIO PORT ADDRESSES */ | ||
44 | #define PEARL_BASE 0xe04 | ||
45 | #define PEARL_WRITE 0xe06 | ||
46 | #define PEARL_READ 0xe07 | ||
47 | |||
48 | #define PEARL_ASR_DISABLE_MASK 0x80 /* bit 7: disable = 1, enable = 0 */ | ||
49 | #define PEARL_ASR_TOGGLE_MASK 0x40 /* bit 6: 0, then 1, then 0 */ | ||
50 | |||
51 | /* JASPER OFFSET FROM SIO BASE ADDR TO ASR S/W REGISTERS. */ | ||
52 | #define JASPER_ASR_REG_OFFSET 0x38 | ||
53 | |||
54 | #define JASPER_ASR_DISABLE_MASK 0x01 /* bit 0: disable = 1, enable = 0 */ | ||
55 | #define JASPER_ASR_TOGGLE_MASK 0x02 /* bit 1: 0, then 1, then 0 */ | ||
56 | |||
57 | #define JUNIPER_BASE_ADDRESS 0x54b /* Base address of Juniper ASR */ | ||
58 | #define JUNIPER_ASR_DISABLE_MASK 0x01 /* bit 0: disable = 1 enable = 0 */ | ||
59 | #define JUNIPER_ASR_TOGGLE_MASK 0x02 /* bit 1: 0, then 1, then 0 */ | ||
60 | |||
61 | #define SPRUCE_BASE_ADDRESS 0x118e /* Base address of Spruce ASR */ | ||
62 | #define SPRUCE_ASR_DISABLE_MASK 0x01 /* bit 1: disable = 1 enable = 0 */ | ||
63 | #define SPRUCE_ASR_TOGGLE_MASK 0x02 /* bit 0: 0, then 1, then 0 */ | ||
64 | |||
65 | |||
66 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
67 | |||
68 | static unsigned long asr_is_open; | ||
69 | static char asr_expect_close; | ||
70 | |||
71 | static unsigned int asr_type, asr_base, asr_length; | ||
72 | static unsigned int asr_read_addr, asr_write_addr; | ||
73 | static unsigned char asr_toggle_mask, asr_disable_mask; | ||
74 | |||
75 | static void asr_toggle(void) | ||
76 | { | ||
77 | unsigned char reg = inb(asr_read_addr); | ||
78 | |||
79 | outb(reg & ~asr_toggle_mask, asr_write_addr); | ||
80 | reg = inb(asr_read_addr); | ||
81 | |||
82 | outb(reg | asr_toggle_mask, asr_write_addr); | ||
83 | reg = inb(asr_read_addr); | ||
84 | |||
85 | outb(reg & ~asr_toggle_mask, asr_write_addr); | ||
86 | reg = inb(asr_read_addr); | ||
87 | } | ||
88 | |||
89 | static void asr_enable(void) | ||
90 | { | ||
91 | unsigned char reg; | ||
92 | |||
93 | if (asr_type == ASMTYPE_TOPAZ) { | ||
94 | /* asr_write_addr == asr_read_addr */ | ||
95 | reg = inb(asr_read_addr); | ||
96 | outb(reg & ~(TOPAZ_ASR_TOGGLE | TOPAZ_ASR_DISABLE), | ||
97 | asr_read_addr); | ||
98 | } else { | ||
99 | /* | ||
100 | * First make sure the hardware timer is reset by toggling | ||
101 | * ASR hardware timer line. | ||
102 | */ | ||
103 | asr_toggle(); | ||
104 | |||
105 | reg = inb(asr_read_addr); | ||
106 | outb(reg & ~asr_disable_mask, asr_write_addr); | ||
107 | } | ||
108 | reg = inb(asr_read_addr); | ||
109 | } | ||
110 | |||
111 | static void asr_disable(void) | ||
112 | { | ||
113 | unsigned char reg = inb(asr_read_addr); | ||
114 | |||
115 | if (asr_type == ASMTYPE_TOPAZ) | ||
116 | /* asr_write_addr == asr_read_addr */ | ||
117 | outb(reg | TOPAZ_ASR_TOGGLE | TOPAZ_ASR_DISABLE, | ||
118 | asr_read_addr); | ||
119 | else { | ||
120 | outb(reg | asr_toggle_mask, asr_write_addr); | ||
121 | reg = inb(asr_read_addr); | ||
122 | |||
123 | outb(reg | asr_disable_mask, asr_write_addr); | ||
124 | } | ||
125 | reg = inb(asr_read_addr); | ||
126 | } | ||
127 | |||
128 | static int __init asr_get_base_address(void) | ||
129 | { | ||
130 | unsigned char low, high; | ||
131 | const char *type = ""; | ||
132 | |||
133 | asr_length = 1; | ||
134 | |||
135 | switch (asr_type) { | ||
136 | case ASMTYPE_TOPAZ: | ||
137 | /* SELECT SuperIO CHIP FOR QUERYING (WRITE 0x07 TO BOTH 0x2E and 0x2F) */ | ||
138 | outb(0x07, 0x2e); | ||
139 | outb(0x07, 0x2f); | ||
140 | |||
141 | /* SELECT AND READ THE HIGH-NIBBLE OF THE GPIO BASE ADDRESS */ | ||
142 | outb(0x60, 0x2e); | ||
143 | high = inb(0x2f); | ||
144 | |||
145 | /* SELECT AND READ THE LOW-NIBBLE OF THE GPIO BASE ADDRESS */ | ||
146 | outb(0x61, 0x2e); | ||
147 | low = inb(0x2f); | ||
148 | |||
149 | asr_base = (high << 16) | low; | ||
150 | asr_read_addr = asr_write_addr = | ||
151 | asr_base + TOPAZ_ASR_REG_OFFSET; | ||
152 | asr_length = 5; | ||
153 | |||
154 | break; | ||
155 | |||
156 | case ASMTYPE_JASPER: | ||
157 | type = "Jaspers "; | ||
158 | |||
159 | /* FIXME: need to use pci_config_lock here, but it's not exported */ | ||
160 | |||
161 | /* spin_lock_irqsave(&pci_config_lock, flags);*/ | ||
162 | |||
163 | /* Select the SuperIO chip in the PCI I/O port register */ | ||
164 | outl(0x8000f858, 0xcf8); | ||
165 | |||
166 | /* | ||
167 | * Read the base address for the SuperIO chip. | ||
168 | * Only the lower 16 bits are valid, but the address is word | ||
169 | * aligned so the last bit must be masked off. | ||
170 | */ | ||
171 | asr_base = inl(0xcfc) & 0xfffe; | ||
172 | |||
173 | /* spin_unlock_irqrestore(&pci_config_lock, flags);*/ | ||
174 | |||
175 | asr_read_addr = asr_write_addr = | ||
176 | asr_base + JASPER_ASR_REG_OFFSET; | ||
177 | asr_toggle_mask = JASPER_ASR_TOGGLE_MASK; | ||
178 | asr_disable_mask = JASPER_ASR_DISABLE_MASK; | ||
179 | asr_length = JASPER_ASR_REG_OFFSET + 1; | ||
180 | |||
181 | break; | ||
182 | |||
183 | case ASMTYPE_PEARL: | ||
184 | type = "Pearls "; | ||
185 | asr_base = PEARL_BASE; | ||
186 | asr_read_addr = PEARL_READ; | ||
187 | asr_write_addr = PEARL_WRITE; | ||
188 | asr_toggle_mask = PEARL_ASR_TOGGLE_MASK; | ||
189 | asr_disable_mask = PEARL_ASR_DISABLE_MASK; | ||
190 | asr_length = 4; | ||
191 | break; | ||
192 | |||
193 | case ASMTYPE_JUNIPER: | ||
194 | type = "Junipers "; | ||
195 | asr_base = JUNIPER_BASE_ADDRESS; | ||
196 | asr_read_addr = asr_write_addr = asr_base; | ||
197 | asr_toggle_mask = JUNIPER_ASR_TOGGLE_MASK; | ||
198 | asr_disable_mask = JUNIPER_ASR_DISABLE_MASK; | ||
199 | break; | ||
200 | |||
201 | case ASMTYPE_SPRUCE: | ||
202 | type = "Spruce's "; | ||
203 | asr_base = SPRUCE_BASE_ADDRESS; | ||
204 | asr_read_addr = asr_write_addr = asr_base; | ||
205 | asr_toggle_mask = SPRUCE_ASR_TOGGLE_MASK; | ||
206 | asr_disable_mask = SPRUCE_ASR_DISABLE_MASK; | ||
207 | break; | ||
208 | } | ||
209 | |||
210 | if (!request_region(asr_base, asr_length, "ibmasr")) { | ||
211 | printk(KERN_ERR PFX "address %#x already in use\n", | ||
212 | asr_base); | ||
213 | return -EBUSY; | ||
214 | } | ||
215 | |||
216 | printk(KERN_INFO PFX "found %sASR @ addr %#x\n", type, asr_base); | ||
217 | |||
218 | return 0; | ||
219 | } | ||
220 | |||
221 | |||
222 | static ssize_t asr_write(struct file *file, const char __user *buf, | ||
223 | size_t count, loff_t *ppos) | ||
224 | { | ||
225 | if (count) { | ||
226 | if (!nowayout) { | ||
227 | size_t i; | ||
228 | |||
229 | /* In case it was set long ago */ | ||
230 | asr_expect_close = 0; | ||
231 | |||
232 | for (i = 0; i != count; i++) { | ||
233 | char c; | ||
234 | if (get_user(c, buf + i)) | ||
235 | return -EFAULT; | ||
236 | if (c == 'V') | ||
237 | asr_expect_close = 42; | ||
238 | } | ||
239 | } | ||
240 | asr_toggle(); | ||
241 | } | ||
242 | return count; | ||
243 | } | ||
244 | |||
245 | static int asr_ioctl(struct inode *inode, struct file *file, | ||
246 | unsigned int cmd, unsigned long arg) | ||
247 | { | ||
248 | static const struct watchdog_info ident = { | ||
249 | .options = WDIOF_KEEPALIVEPING | | ||
250 | WDIOF_MAGICCLOSE, | ||
251 | .identity = "IBM ASR" | ||
252 | }; | ||
253 | void __user *argp = (void __user *)arg; | ||
254 | int __user *p = argp; | ||
255 | int heartbeat; | ||
256 | |||
257 | switch (cmd) { | ||
258 | case WDIOC_GETSUPPORT: | ||
259 | return copy_to_user(argp, &ident, sizeof(ident)) ? | ||
260 | -EFAULT : 0; | ||
261 | |||
262 | case WDIOC_GETSTATUS: | ||
263 | case WDIOC_GETBOOTSTATUS: | ||
264 | return put_user(0, p); | ||
265 | |||
266 | case WDIOC_KEEPALIVE: | ||
267 | asr_toggle(); | ||
268 | return 0; | ||
269 | |||
270 | /* | ||
271 | * The hardware has a fixed timeout value, so no WDIOC_SETTIMEOUT | ||
272 | * and WDIOC_GETTIMEOUT always returns 256. | ||
273 | */ | ||
274 | case WDIOC_GETTIMEOUT: | ||
275 | heartbeat = 256; | ||
276 | return put_user(heartbeat, p); | ||
277 | |||
278 | case WDIOC_SETOPTIONS: { | ||
279 | int new_options, retval = -EINVAL; | ||
280 | |||
281 | if (get_user(new_options, p)) | ||
282 | return -EFAULT; | ||
283 | |||
284 | if (new_options & WDIOS_DISABLECARD) { | ||
285 | asr_disable(); | ||
286 | retval = 0; | ||
287 | } | ||
288 | |||
289 | if (new_options & WDIOS_ENABLECARD) { | ||
290 | asr_enable(); | ||
291 | asr_toggle(); | ||
292 | retval = 0; | ||
293 | } | ||
294 | |||
295 | return retval; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | return -ENOIOCTLCMD; | ||
300 | } | ||
301 | |||
302 | static int asr_open(struct inode *inode, struct file *file) | ||
303 | { | ||
304 | if(test_and_set_bit(0, &asr_is_open)) | ||
305 | return -EBUSY; | ||
306 | |||
307 | asr_toggle(); | ||
308 | asr_enable(); | ||
309 | |||
310 | return nonseekable_open(inode, file); | ||
311 | } | ||
312 | |||
313 | static int asr_release(struct inode *inode, struct file *file) | ||
314 | { | ||
315 | if (asr_expect_close == 42) | ||
316 | asr_disable(); | ||
317 | else { | ||
318 | printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n"); | ||
319 | asr_toggle(); | ||
320 | } | ||
321 | clear_bit(0, &asr_is_open); | ||
322 | asr_expect_close = 0; | ||
323 | return 0; | ||
324 | } | ||
325 | |||
326 | static struct file_operations asr_fops = { | ||
327 | .owner = THIS_MODULE, | ||
328 | .llseek = no_llseek, | ||
329 | .write = asr_write, | ||
330 | .ioctl = asr_ioctl, | ||
331 | .open = asr_open, | ||
332 | .release = asr_release, | ||
333 | }; | ||
334 | |||
335 | static struct miscdevice asr_miscdev = { | ||
336 | .minor = WATCHDOG_MINOR, | ||
337 | .name = "watchdog", | ||
338 | .fops = &asr_fops, | ||
339 | }; | ||
340 | |||
341 | |||
342 | struct ibmasr_id { | ||
343 | const char *desc; | ||
344 | int type; | ||
345 | }; | ||
346 | |||
347 | static struct ibmasr_id __initdata ibmasr_id_table[] = { | ||
348 | { "IBM Automatic Server Restart - eserver xSeries 220", ASMTYPE_TOPAZ }, | ||
349 | { "IBM Automatic Server Restart - Machine Type 8673", ASMTYPE_PEARL }, | ||
350 | { "IBM Automatic Server Restart - Machine Type 8480", ASMTYPE_JASPER }, | ||
351 | { "IBM Automatic Server Restart - Machine Type 8482", ASMTYPE_JUNIPER }, | ||
352 | { "IBM Automatic Server Restart - Machine Type 8648", ASMTYPE_SPRUCE }, | ||
353 | { NULL } | ||
354 | }; | ||
355 | |||
356 | static int __init ibmasr_init(void) | ||
357 | { | ||
358 | struct ibmasr_id *id; | ||
359 | int rc; | ||
360 | |||
361 | for (id = ibmasr_id_table; id->desc; id++) { | ||
362 | if (dmi_find_device(DMI_DEV_TYPE_OTHER, id->desc, NULL)) { | ||
363 | asr_type = id->type; | ||
364 | break; | ||
365 | } | ||
366 | } | ||
367 | |||
368 | if (!asr_type) | ||
369 | return -ENODEV; | ||
370 | |||
371 | rc = misc_register(&asr_miscdev); | ||
372 | if (rc < 0) { | ||
373 | printk(KERN_ERR PFX "failed to register misc device\n"); | ||
374 | return rc; | ||
375 | } | ||
376 | |||
377 | rc = asr_get_base_address(); | ||
378 | if (rc) { | ||
379 | misc_deregister(&asr_miscdev); | ||
380 | return rc; | ||
381 | } | ||
382 | |||
383 | return 0; | ||
384 | } | ||
385 | |||
386 | static void __exit ibmasr_exit(void) | ||
387 | { | ||
388 | if (!nowayout) | ||
389 | asr_disable(); | ||
390 | |||
391 | misc_deregister(&asr_miscdev); | ||
392 | |||
393 | release_region(asr_base, asr_length); | ||
394 | } | ||
395 | |||
396 | module_init(ibmasr_init); | ||
397 | module_exit(ibmasr_exit); | ||
398 | |||
399 | module_param(nowayout, int, 0); | ||
400 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | ||
401 | |||
402 | MODULE_DESCRIPTION("IBM Automatic Server Restart driver"); | ||
403 | MODULE_AUTHOR("Andrey Panin"); | ||
404 | MODULE_LICENSE("GPL"); | ||
405 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
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/mpcore_wdt.c b/drivers/char/watchdog/mpcore_wdt.c new file mode 100644 index 000000000000..75ca84ed4adf --- /dev/null +++ b/drivers/char/watchdog/mpcore_wdt.c | |||
@@ -0,0 +1,436 @@ | |||
1 | /* | ||
2 | * Watchdog driver for the mpcore watchdog timer | ||
3 | * | ||
4 | * (c) Copyright 2004 ARM Limited | ||
5 | * | ||
6 | * Based on the SoftDog driver: | ||
7 | * (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved. | ||
8 | * http://www.redhat.com | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * as published by the Free Software Foundation; either version | ||
13 | * 2 of the License, or (at your option) any later version. | ||
14 | * | ||
15 | * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide | ||
16 | * warranty for any of this software. This material is provided | ||
17 | * "AS-IS" and at no charge. | ||
18 | * | ||
19 | * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk> | ||
20 | * | ||
21 | */ | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/moduleparam.h> | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/types.h> | ||
26 | #include <linux/miscdevice.h> | ||
27 | #include <linux/watchdog.h> | ||
28 | #include <linux/fs.h> | ||
29 | #include <linux/reboot.h> | ||
30 | #include <linux/init.h> | ||
31 | #include <linux/interrupt.h> | ||
32 | #include <linux/device.h> | ||
33 | |||
34 | #include <asm/hardware/arm_twd.h> | ||
35 | #include <asm/uaccess.h> | ||
36 | |||
37 | struct mpcore_wdt { | ||
38 | unsigned long timer_alive; | ||
39 | struct device *dev; | ||
40 | void __iomem *base; | ||
41 | int irq; | ||
42 | unsigned int perturb; | ||
43 | char expect_close; | ||
44 | }; | ||
45 | |||
46 | static struct platform_device *mpcore_wdt_dev; | ||
47 | |||
48 | extern unsigned int mpcore_timer_rate; | ||
49 | |||
50 | #define TIMER_MARGIN 60 | ||
51 | static int mpcore_margin = TIMER_MARGIN; | ||
52 | module_param(mpcore_margin, int, 0); | ||
53 | MODULE_PARM_DESC(mpcore_margin, "MPcore timer margin in seconds. (0<mpcore_margin<65536, default=" __MODULE_STRING(TIMER_MARGIN) ")"); | ||
54 | |||
55 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
56 | module_param(nowayout, int, 0); | ||
57 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); | ||
58 | |||
59 | #define ONLY_TESTING 0 | ||
60 | static int mpcore_noboot = ONLY_TESTING; | ||
61 | module_param(mpcore_noboot, int, 0); | ||
62 | MODULE_PARM_DESC(mpcore_noboot, "MPcore watchdog action, set to 1 to ignore reboots, 0 to reboot (default=" __MODULE_STRING(ONLY_TESTING) ")"); | ||
63 | |||
64 | /* | ||
65 | * This is the interrupt handler. Note that we only use this | ||
66 | * in testing mode, so don't actually do a reboot here. | ||
67 | */ | ||
68 | static irqreturn_t mpcore_wdt_fire(int irq, void *arg, struct pt_regs *regs) | ||
69 | { | ||
70 | struct mpcore_wdt *wdt = arg; | ||
71 | |||
72 | /* Check it really was our interrupt */ | ||
73 | if (readl(wdt->base + TWD_WDOG_INTSTAT)) { | ||
74 | dev_printk(KERN_CRIT, wdt->dev, "Triggered - Reboot ignored.\n"); | ||
75 | |||
76 | /* Clear the interrupt on the watchdog */ | ||
77 | writel(1, wdt->base + TWD_WDOG_INTSTAT); | ||
78 | |||
79 | return IRQ_HANDLED; | ||
80 | } | ||
81 | |||
82 | return IRQ_NONE; | ||
83 | } | ||
84 | |||
85 | /* | ||
86 | * mpcore_wdt_keepalive - reload the timer | ||
87 | * | ||
88 | * Note that the spec says a DIFFERENT value must be written to the reload | ||
89 | * register each time. The "perturb" variable deals with this by adding 1 | ||
90 | * to the count every other time the function is called. | ||
91 | */ | ||
92 | static void mpcore_wdt_keepalive(struct mpcore_wdt *wdt) | ||
93 | { | ||
94 | unsigned int count; | ||
95 | |||
96 | /* Assume prescale is set to 256 */ | ||
97 | count = (mpcore_timer_rate / 256) * mpcore_margin; | ||
98 | |||
99 | /* Reload the counter */ | ||
100 | writel(count + wdt->perturb, wdt->base + TWD_WDOG_LOAD); | ||
101 | |||
102 | wdt->perturb = wdt->perturb ? 0 : 1; | ||
103 | } | ||
104 | |||
105 | static void mpcore_wdt_stop(struct mpcore_wdt *wdt) | ||
106 | { | ||
107 | writel(0x12345678, wdt->base + TWD_WDOG_DISABLE); | ||
108 | writel(0x87654321, wdt->base + TWD_WDOG_DISABLE); | ||
109 | writel(0x0, wdt->base + TWD_WDOG_CONTROL); | ||
110 | } | ||
111 | |||
112 | static void mpcore_wdt_start(struct mpcore_wdt *wdt) | ||
113 | { | ||
114 | dev_printk(KERN_INFO, wdt->dev, "enabling watchdog.\n"); | ||
115 | |||
116 | /* This loads the count register but does NOT start the count yet */ | ||
117 | mpcore_wdt_keepalive(wdt); | ||
118 | |||
119 | if (mpcore_noboot) { | ||
120 | /* Enable watchdog - prescale=256, watchdog mode=0, enable=1 */ | ||
121 | writel(0x0000FF01, wdt->base + TWD_WDOG_CONTROL); | ||
122 | } else { | ||
123 | /* Enable watchdog - prescale=256, watchdog mode=1, enable=1 */ | ||
124 | writel(0x0000FF09, wdt->base + TWD_WDOG_CONTROL); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | static int mpcore_wdt_set_heartbeat(int t) | ||
129 | { | ||
130 | if (t < 0x0001 || t > 0xFFFF) | ||
131 | return -EINVAL; | ||
132 | |||
133 | mpcore_margin = t; | ||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | /* | ||
138 | * /dev/watchdog handling | ||
139 | */ | ||
140 | static int mpcore_wdt_open(struct inode *inode, struct file *file) | ||
141 | { | ||
142 | struct mpcore_wdt *wdt = dev_get_drvdata(&mpcore_wdt_dev->dev); | ||
143 | |||
144 | if (test_and_set_bit(0, &wdt->timer_alive)) | ||
145 | return -EBUSY; | ||
146 | |||
147 | if (nowayout) | ||
148 | __module_get(THIS_MODULE); | ||
149 | |||
150 | file->private_data = wdt; | ||
151 | |||
152 | /* | ||
153 | * Activate timer | ||
154 | */ | ||
155 | mpcore_wdt_start(wdt); | ||
156 | |||
157 | return nonseekable_open(inode, file); | ||
158 | } | ||
159 | |||
160 | static int mpcore_wdt_release(struct inode *inode, struct file *file) | ||
161 | { | ||
162 | struct mpcore_wdt *wdt = file->private_data; | ||
163 | |||
164 | /* | ||
165 | * Shut off the timer. | ||
166 | * Lock it in if it's a module and we set nowayout | ||
167 | */ | ||
168 | if (wdt->expect_close == 42) { | ||
169 | mpcore_wdt_stop(wdt); | ||
170 | } else { | ||
171 | dev_printk(KERN_CRIT, wdt->dev, "unexpected close, not stopping watchdog!\n"); | ||
172 | mpcore_wdt_keepalive(wdt); | ||
173 | } | ||
174 | clear_bit(0, &wdt->timer_alive); | ||
175 | wdt->expect_close = 0; | ||
176 | return 0; | ||
177 | } | ||
178 | |||
179 | static ssize_t mpcore_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos) | ||
180 | { | ||
181 | struct mpcore_wdt *wdt = file->private_data; | ||
182 | |||
183 | /* Can't seek (pwrite) on this device */ | ||
184 | if (ppos != &file->f_pos) | ||
185 | return -ESPIPE; | ||
186 | |||
187 | /* | ||
188 | * Refresh the timer. | ||
189 | */ | ||
190 | if (len) { | ||
191 | if (!nowayout) { | ||
192 | size_t i; | ||
193 | |||
194 | /* In case it was set long ago */ | ||
195 | wdt->expect_close = 0; | ||
196 | |||
197 | for (i = 0; i != len; i++) { | ||
198 | char c; | ||
199 | |||
200 | if (get_user(c, data + i)) | ||
201 | return -EFAULT; | ||
202 | if (c == 'V') | ||
203 | wdt->expect_close = 42; | ||
204 | } | ||
205 | } | ||
206 | mpcore_wdt_keepalive(wdt); | ||
207 | } | ||
208 | return len; | ||
209 | } | ||
210 | |||
211 | static struct watchdog_info ident = { | ||
212 | .options = WDIOF_SETTIMEOUT | | ||
213 | WDIOF_KEEPALIVEPING | | ||
214 | WDIOF_MAGICCLOSE, | ||
215 | .identity = "MPcore Watchdog", | ||
216 | }; | ||
217 | |||
218 | static int mpcore_wdt_ioctl(struct inode *inode, struct file *file, | ||
219 | unsigned int cmd, unsigned long arg) | ||
220 | { | ||
221 | struct mpcore_wdt *wdt = file->private_data; | ||
222 | int ret; | ||
223 | union { | ||
224 | struct watchdog_info ident; | ||
225 | int i; | ||
226 | } uarg; | ||
227 | |||
228 | if (_IOC_DIR(cmd) && _IOC_SIZE(cmd) > sizeof(uarg)) | ||
229 | return -ENOIOCTLCMD; | ||
230 | |||
231 | if (_IOC_DIR(cmd) & _IOC_WRITE) { | ||
232 | ret = copy_from_user(&uarg, (void __user *)arg, _IOC_SIZE(cmd)); | ||
233 | if (ret) | ||
234 | return -EFAULT; | ||
235 | } | ||
236 | |||
237 | switch (cmd) { | ||
238 | case WDIOC_GETSUPPORT: | ||
239 | uarg.ident = ident; | ||
240 | ret = 0; | ||
241 | break; | ||
242 | |||
243 | case WDIOC_SETOPTIONS: | ||
244 | ret = -EINVAL; | ||
245 | if (uarg.i & WDIOS_DISABLECARD) { | ||
246 | mpcore_wdt_stop(wdt); | ||
247 | ret = 0; | ||
248 | } | ||
249 | if (uarg.i & WDIOS_ENABLECARD) { | ||
250 | mpcore_wdt_start(wdt); | ||
251 | ret = 0; | ||
252 | } | ||
253 | break; | ||
254 | |||
255 | case WDIOC_GETSTATUS: | ||
256 | case WDIOC_GETBOOTSTATUS: | ||
257 | uarg.i = 0; | ||
258 | ret = 0; | ||
259 | break; | ||
260 | |||
261 | case WDIOC_KEEPALIVE: | ||
262 | mpcore_wdt_keepalive(wdt); | ||
263 | ret = 0; | ||
264 | break; | ||
265 | |||
266 | case WDIOC_SETTIMEOUT: | ||
267 | ret = mpcore_wdt_set_heartbeat(uarg.i); | ||
268 | if (ret) | ||
269 | break; | ||
270 | |||
271 | mpcore_wdt_keepalive(wdt); | ||
272 | /* Fall */ | ||
273 | case WDIOC_GETTIMEOUT: | ||
274 | uarg.i = mpcore_margin; | ||
275 | ret = 0; | ||
276 | break; | ||
277 | |||
278 | default: | ||
279 | return -ENOIOCTLCMD; | ||
280 | } | ||
281 | |||
282 | if (ret == 0 && _IOC_DIR(cmd) & _IOC_READ) { | ||
283 | ret = copy_to_user((void __user *)arg, &uarg, _IOC_SIZE(cmd)); | ||
284 | if (ret) | ||
285 | ret = -EFAULT; | ||
286 | } | ||
287 | return ret; | ||
288 | } | ||
289 | |||
290 | /* | ||
291 | * System shutdown handler. Turn off the watchdog if we're | ||
292 | * restarting or halting the system. | ||
293 | */ | ||
294 | static void mpcore_wdt_shutdown(struct device *_dev) | ||
295 | { | ||
296 | struct mpcore_wdt *wdt = dev_get_drvdata(_dev); | ||
297 | |||
298 | if (system_state == SYSTEM_RESTART || system_state == SYSTEM_HALT) | ||
299 | mpcore_wdt_stop(wdt); | ||
300 | } | ||
301 | |||
302 | /* | ||
303 | * Kernel Interfaces | ||
304 | */ | ||
305 | static struct file_operations mpcore_wdt_fops = { | ||
306 | .owner = THIS_MODULE, | ||
307 | .llseek = no_llseek, | ||
308 | .write = mpcore_wdt_write, | ||
309 | .ioctl = mpcore_wdt_ioctl, | ||
310 | .open = mpcore_wdt_open, | ||
311 | .release = mpcore_wdt_release, | ||
312 | }; | ||
313 | |||
314 | static struct miscdevice mpcore_wdt_miscdev = { | ||
315 | .minor = WATCHDOG_MINOR, | ||
316 | .name = "watchdog", | ||
317 | .fops = &mpcore_wdt_fops, | ||
318 | }; | ||
319 | |||
320 | static int __devinit mpcore_wdt_probe(struct device *_dev) | ||
321 | { | ||
322 | struct platform_device *dev = to_platform_device(_dev); | ||
323 | struct mpcore_wdt *wdt; | ||
324 | struct resource *res; | ||
325 | int ret; | ||
326 | |||
327 | /* We only accept one device, and it must have an id of -1 */ | ||
328 | if (dev->id != -1) | ||
329 | return -ENODEV; | ||
330 | |||
331 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
332 | if (!res) { | ||
333 | ret = -ENODEV; | ||
334 | goto err_out; | ||
335 | } | ||
336 | |||
337 | wdt = kmalloc(sizeof(struct mpcore_wdt), GFP_KERNEL); | ||
338 | if (!wdt) { | ||
339 | ret = -ENOMEM; | ||
340 | goto err_out; | ||
341 | } | ||
342 | memset(wdt, 0, sizeof(struct mpcore_wdt)); | ||
343 | |||
344 | wdt->dev = &dev->dev; | ||
345 | wdt->irq = platform_get_irq(dev, 0); | ||
346 | wdt->base = ioremap(res->start, res->end - res->start + 1); | ||
347 | if (!wdt->base) { | ||
348 | ret = -ENOMEM; | ||
349 | goto err_free; | ||
350 | } | ||
351 | |||
352 | mpcore_wdt_miscdev.dev = &dev->dev; | ||
353 | ret = misc_register(&mpcore_wdt_miscdev); | ||
354 | if (ret) { | ||
355 | dev_printk(KERN_ERR, _dev, "cannot register miscdev on minor=%d (err=%d)\n", | ||
356 | WATCHDOG_MINOR, ret); | ||
357 | goto err_misc; | ||
358 | } | ||
359 | |||
360 | ret = request_irq(wdt->irq, mpcore_wdt_fire, SA_INTERRUPT, "mpcore_wdt", wdt); | ||
361 | if (ret) { | ||
362 | dev_printk(KERN_ERR, _dev, "cannot register IRQ%d for watchdog\n", wdt->irq); | ||
363 | goto err_irq; | ||
364 | } | ||
365 | |||
366 | mpcore_wdt_stop(wdt); | ||
367 | dev_set_drvdata(&dev->dev, wdt); | ||
368 | mpcore_wdt_dev = dev; | ||
369 | |||
370 | return 0; | ||
371 | |||
372 | err_irq: | ||
373 | misc_deregister(&mpcore_wdt_miscdev); | ||
374 | err_misc: | ||
375 | iounmap(wdt->base); | ||
376 | err_free: | ||
377 | kfree(wdt); | ||
378 | err_out: | ||
379 | return ret; | ||
380 | } | ||
381 | |||
382 | static int __devexit mpcore_wdt_remove(struct device *dev) | ||
383 | { | ||
384 | struct mpcore_wdt *wdt = dev_get_drvdata(dev); | ||
385 | |||
386 | dev_set_drvdata(dev, NULL); | ||
387 | |||
388 | misc_deregister(&mpcore_wdt_miscdev); | ||
389 | |||
390 | mpcore_wdt_dev = NULL; | ||
391 | |||
392 | free_irq(wdt->irq, wdt); | ||
393 | iounmap(wdt->base); | ||
394 | kfree(wdt); | ||
395 | return 0; | ||
396 | } | ||
397 | |||
398 | static struct device_driver mpcore_wdt_driver = { | ||
399 | .name = "mpcore_wdt", | ||
400 | .bus = &platform_bus_type, | ||
401 | .probe = mpcore_wdt_probe, | ||
402 | .remove = __devexit_p(mpcore_wdt_remove), | ||
403 | .shutdown = mpcore_wdt_shutdown, | ||
404 | }; | ||
405 | |||
406 | static char banner[] __initdata = KERN_INFO "MPcore Watchdog Timer: 0.1. mpcore_noboot=%d mpcore_margin=%d sec (nowayout= %d)\n"; | ||
407 | |||
408 | static int __init mpcore_wdt_init(void) | ||
409 | { | ||
410 | /* | ||
411 | * Check that the margin value is within it's range; | ||
412 | * if not reset to the default | ||
413 | */ | ||
414 | if (mpcore_wdt_set_heartbeat(mpcore_margin)) { | ||
415 | mpcore_wdt_set_heartbeat(TIMER_MARGIN); | ||
416 | printk(KERN_INFO "mpcore_margin value must be 0<mpcore_margin<65536, using %d\n", | ||
417 | TIMER_MARGIN); | ||
418 | } | ||
419 | |||
420 | printk(banner, mpcore_noboot, mpcore_margin, nowayout); | ||
421 | |||
422 | return driver_register(&mpcore_wdt_driver); | ||
423 | } | ||
424 | |||
425 | static void __exit mpcore_wdt_exit(void) | ||
426 | { | ||
427 | driver_unregister(&mpcore_wdt_driver); | ||
428 | } | ||
429 | |||
430 | module_init(mpcore_wdt_init); | ||
431 | module_exit(mpcore_wdt_exit); | ||
432 | |||
433 | MODULE_AUTHOR("ARM Limited"); | ||
434 | MODULE_DESCRIPTION("MPcore Watchdog Device Driver"); | ||
435 | MODULE_LICENSE("GPL"); | ||
436 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/char/watchdog/mv64x60_wdt.c b/drivers/char/watchdog/mv64x60_wdt.c new file mode 100644 index 000000000000..1436aea3b28f --- /dev/null +++ b/drivers/char/watchdog/mv64x60_wdt.c | |||
@@ -0,0 +1,252 @@ | |||
1 | /* | ||
2 | * mv64x60_wdt.c - MV64X60 (Marvell Discovery) watchdog userspace interface | ||
3 | * | ||
4 | * Author: James Chapman <jchapman@katalix.com> | ||
5 | * | ||
6 | * Platform-specific setup code should configure the dog to generate | ||
7 | * interrupt or reset as required. This code only enables/disables | ||
8 | * and services the watchdog. | ||
9 | * | ||
10 | * Derived from mpc8xx_wdt.c, with the following copyright. | ||
11 | * | ||
12 | * 2002 (c) Florian Schirmer <jolt@tuxbox.org> This file is licensed under | ||
13 | * the terms of the GNU General Public License version 2. This program | ||
14 | * is licensed "as is" without any warranty of any kind, whether express | ||
15 | * or implied. | ||
16 | */ | ||
17 | |||
18 | #include <linux/config.h> | ||
19 | #include <linux/fs.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/miscdevice.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/watchdog.h> | ||
25 | #include <asm/mv64x60.h> | ||
26 | #include <asm/uaccess.h> | ||
27 | #include <asm/io.h> | ||
28 | |||
29 | /* MV64x60 WDC (config) register access definitions */ | ||
30 | #define MV64x60_WDC_CTL1_MASK (3 << 24) | ||
31 | #define MV64x60_WDC_CTL1(val) ((val & 3) << 24) | ||
32 | #define MV64x60_WDC_CTL2_MASK (3 << 26) | ||
33 | #define MV64x60_WDC_CTL2(val) ((val & 3) << 26) | ||
34 | |||
35 | /* Flags bits */ | ||
36 | #define MV64x60_WDOG_FLAG_OPENED 0 | ||
37 | #define MV64x60_WDOG_FLAG_ENABLED 1 | ||
38 | |||
39 | static unsigned long wdt_flags; | ||
40 | static int wdt_status; | ||
41 | static void __iomem *mv64x60_regs; | ||
42 | static int mv64x60_wdt_timeout; | ||
43 | |||
44 | static void mv64x60_wdt_reg_write(u32 val) | ||
45 | { | ||
46 | /* Allow write only to CTL1 / CTL2 fields, retaining values in | ||
47 | * other fields. | ||
48 | */ | ||
49 | u32 data = readl(mv64x60_regs + MV64x60_WDT_WDC); | ||
50 | data &= ~(MV64x60_WDC_CTL1_MASK | MV64x60_WDC_CTL2_MASK); | ||
51 | data |= val; | ||
52 | writel(data, mv64x60_regs + MV64x60_WDT_WDC); | ||
53 | } | ||
54 | |||
55 | static void mv64x60_wdt_service(void) | ||
56 | { | ||
57 | /* Write 01 followed by 10 to CTL2 */ | ||
58 | mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x01)); | ||
59 | mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x02)); | ||
60 | } | ||
61 | |||
62 | static void mv64x60_wdt_handler_disable(void) | ||
63 | { | ||
64 | if (test_and_clear_bit(MV64x60_WDOG_FLAG_ENABLED, &wdt_flags)) { | ||
65 | /* Write 01 followed by 10 to CTL1 */ | ||
66 | mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x01)); | ||
67 | mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x02)); | ||
68 | printk(KERN_NOTICE "mv64x60_wdt: watchdog deactivated\n"); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | static void mv64x60_wdt_handler_enable(void) | ||
73 | { | ||
74 | if (!test_and_set_bit(MV64x60_WDOG_FLAG_ENABLED, &wdt_flags)) { | ||
75 | /* Write 01 followed by 10 to CTL1 */ | ||
76 | mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x01)); | ||
77 | mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x02)); | ||
78 | printk(KERN_NOTICE "mv64x60_wdt: watchdog activated\n"); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | static int mv64x60_wdt_open(struct inode *inode, struct file *file) | ||
83 | { | ||
84 | if (test_and_set_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags)) | ||
85 | return -EBUSY; | ||
86 | |||
87 | mv64x60_wdt_service(); | ||
88 | mv64x60_wdt_handler_enable(); | ||
89 | |||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | static int mv64x60_wdt_release(struct inode *inode, struct file *file) | ||
94 | { | ||
95 | mv64x60_wdt_service(); | ||
96 | |||
97 | #if !defined(CONFIG_WATCHDOG_NOWAYOUT) | ||
98 | mv64x60_wdt_handler_disable(); | ||
99 | #endif | ||
100 | |||
101 | clear_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags); | ||
102 | |||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | static ssize_t mv64x60_wdt_write(struct file *file, const char *data, | ||
107 | size_t len, loff_t * ppos) | ||
108 | { | ||
109 | if (*ppos != file->f_pos) | ||
110 | return -ESPIPE; | ||
111 | |||
112 | if (len) | ||
113 | mv64x60_wdt_service(); | ||
114 | |||
115 | return len; | ||
116 | } | ||
117 | |||
118 | static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file, | ||
119 | unsigned int cmd, unsigned long arg) | ||
120 | { | ||
121 | int timeout; | ||
122 | static struct watchdog_info info = { | ||
123 | .options = WDIOF_KEEPALIVEPING, | ||
124 | .firmware_version = 0, | ||
125 | .identity = "MV64x60 watchdog", | ||
126 | }; | ||
127 | |||
128 | switch (cmd) { | ||
129 | case WDIOC_GETSUPPORT: | ||
130 | if (copy_to_user((void *)arg, &info, sizeof(info))) | ||
131 | return -EFAULT; | ||
132 | break; | ||
133 | |||
134 | case WDIOC_GETSTATUS: | ||
135 | case WDIOC_GETBOOTSTATUS: | ||
136 | if (put_user(wdt_status, (int *)arg)) | ||
137 | return -EFAULT; | ||
138 | wdt_status &= ~WDIOF_KEEPALIVEPING; | ||
139 | break; | ||
140 | |||
141 | case WDIOC_GETTEMP: | ||
142 | return -EOPNOTSUPP; | ||
143 | |||
144 | case WDIOC_SETOPTIONS: | ||
145 | return -EOPNOTSUPP; | ||
146 | |||
147 | case WDIOC_KEEPALIVE: | ||
148 | mv64x60_wdt_service(); | ||
149 | wdt_status |= WDIOF_KEEPALIVEPING; | ||
150 | break; | ||
151 | |||
152 | case WDIOC_SETTIMEOUT: | ||
153 | return -EOPNOTSUPP; | ||
154 | |||
155 | case WDIOC_GETTIMEOUT: | ||
156 | timeout = mv64x60_wdt_timeout * HZ; | ||
157 | if (put_user(timeout, (int *)arg)) | ||
158 | return -EFAULT; | ||
159 | break; | ||
160 | |||
161 | default: | ||
162 | return -ENOIOCTLCMD; | ||
163 | } | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | static struct file_operations mv64x60_wdt_fops = { | ||
169 | .owner = THIS_MODULE, | ||
170 | .llseek = no_llseek, | ||
171 | .write = mv64x60_wdt_write, | ||
172 | .ioctl = mv64x60_wdt_ioctl, | ||
173 | .open = mv64x60_wdt_open, | ||
174 | .release = mv64x60_wdt_release, | ||
175 | }; | ||
176 | |||
177 | static struct miscdevice mv64x60_wdt_miscdev = { | ||
178 | .minor = WATCHDOG_MINOR, | ||
179 | .name = "watchdog", | ||
180 | .fops = &mv64x60_wdt_fops, | ||
181 | }; | ||
182 | |||
183 | static int __devinit mv64x60_wdt_probe(struct device *dev) | ||
184 | { | ||
185 | struct platform_device *pd = to_platform_device(dev); | ||
186 | struct mv64x60_wdt_pdata *pdata = pd->dev.platform_data; | ||
187 | int bus_clk = 133; | ||
188 | |||
189 | mv64x60_wdt_timeout = 10; | ||
190 | if (pdata) { | ||
191 | mv64x60_wdt_timeout = pdata->timeout; | ||
192 | bus_clk = pdata->bus_clk; | ||
193 | } | ||
194 | |||
195 | mv64x60_regs = mv64x60_get_bridge_vbase(); | ||
196 | |||
197 | writel((mv64x60_wdt_timeout * (bus_clk * 1000000)) >> 8, | ||
198 | mv64x60_regs + MV64x60_WDT_WDC); | ||
199 | |||
200 | return misc_register(&mv64x60_wdt_miscdev); | ||
201 | } | ||
202 | |||
203 | static int __devexit mv64x60_wdt_remove(struct device *dev) | ||
204 | { | ||
205 | misc_deregister(&mv64x60_wdt_miscdev); | ||
206 | |||
207 | mv64x60_wdt_service(); | ||
208 | mv64x60_wdt_handler_disable(); | ||
209 | |||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | static struct device_driver mv64x60_wdt_driver = { | ||
214 | .name = MV64x60_WDT_NAME, | ||
215 | .bus = &platform_bus_type, | ||
216 | .probe = mv64x60_wdt_probe, | ||
217 | .remove = __devexit_p(mv64x60_wdt_remove), | ||
218 | }; | ||
219 | |||
220 | static struct platform_device *mv64x60_wdt_dev; | ||
221 | |||
222 | static int __init mv64x60_wdt_init(void) | ||
223 | { | ||
224 | int ret; | ||
225 | |||
226 | printk(KERN_INFO "MV64x60 watchdog driver\n"); | ||
227 | |||
228 | mv64x60_wdt_dev = platform_device_register_simple(MV64x60_WDT_NAME, | ||
229 | -1, NULL, 0); | ||
230 | if (IS_ERR(mv64x60_wdt_dev)) { | ||
231 | ret = PTR_ERR(mv64x60_wdt_dev); | ||
232 | goto out; | ||
233 | } | ||
234 | |||
235 | ret = driver_register(&mv64x60_wdt_driver); | ||
236 | out: | ||
237 | return ret; | ||
238 | } | ||
239 | |||
240 | static void __exit mv64x60_wdt_exit(void) | ||
241 | { | ||
242 | driver_unregister(&mv64x60_wdt_driver); | ||
243 | platform_device_unregister(mv64x60_wdt_dev); | ||
244 | } | ||
245 | |||
246 | module_init(mv64x60_wdt_init); | ||
247 | module_exit(mv64x60_wdt_exit); | ||
248 | |||
249 | MODULE_AUTHOR("James Chapman <jchapman@katalix.com>"); | ||
250 | MODULE_DESCRIPTION("MV64x60 watchdog driver"); | ||
251 | MODULE_LICENSE("GPL"); | ||
252 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
diff --git a/drivers/char/watchdog/pcwd_pci.c b/drivers/char/watchdog/pcwd_pci.c index 2b13afb09c5d..5a80adbf8032 100644 --- a/drivers/char/watchdog/pcwd_pci.c +++ b/drivers/char/watchdog/pcwd_pci.c | |||
@@ -29,27 +29,29 @@ | |||
29 | * Includes, defines, variables, module parameters, ... | 29 | * Includes, defines, variables, module parameters, ... |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <linux/config.h> | 32 | #include <linux/config.h> /* For CONFIG_WATCHDOG_NOWAYOUT/... */ |
33 | #include <linux/module.h> | 33 | #include <linux/module.h> /* For module specific items */ |
34 | #include <linux/moduleparam.h> | 34 | #include <linux/moduleparam.h> /* For new moduleparam's */ |
35 | #include <linux/types.h> | 35 | #include <linux/types.h> /* For standard types (like size_t) */ |
36 | #include <linux/delay.h> | 36 | #include <linux/errno.h> /* For the -ENODEV/... values */ |
37 | #include <linux/miscdevice.h> | 37 | #include <linux/kernel.h> /* For printk/panic/... */ |
38 | #include <linux/watchdog.h> | 38 | #include <linux/delay.h> /* For mdelay function */ |
39 | #include <linux/notifier.h> | 39 | #include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ |
40 | #include <linux/reboot.h> | 40 | #include <linux/watchdog.h> /* For the watchdog specific items */ |
41 | #include <linux/init.h> | 41 | #include <linux/notifier.h> /* For notifier support */ |
42 | #include <linux/fs.h> | 42 | #include <linux/reboot.h> /* For reboot_notifier stuff */ |
43 | #include <linux/pci.h> | 43 | #include <linux/init.h> /* For __init/__exit/... */ |
44 | #include <linux/ioport.h> | 44 | #include <linux/fs.h> /* For file operations */ |
45 | #include <linux/spinlock.h> | 45 | #include <linux/pci.h> /* For pci functions */ |
46 | 46 | #include <linux/ioport.h> /* For io-port access */ | |
47 | #include <asm/uaccess.h> | 47 | #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ |
48 | #include <asm/io.h> | 48 | |
49 | #include <asm/uaccess.h> /* For copy_to_user/put_user/... */ | ||
50 | #include <asm/io.h> /* For inb/outb/... */ | ||
49 | 51 | ||
50 | /* Module and version information */ | 52 | /* Module and version information */ |
51 | #define WATCHDOG_VERSION "1.01" | 53 | #define WATCHDOG_VERSION "1.01" |
52 | #define WATCHDOG_DATE "15 Mar 2005" | 54 | #define WATCHDOG_DATE "02 Sep 2005" |
53 | #define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" | 55 | #define WATCHDOG_DRIVER_NAME "PCI-PC Watchdog" |
54 | #define WATCHDOG_NAME "pcwd_pci" | 56 | #define WATCHDOG_NAME "pcwd_pci" |
55 | #define PFX WATCHDOG_NAME ": " | 57 | #define PFX WATCHDOG_NAME ": " |
@@ -335,12 +337,14 @@ static int pcipcwd_ioctl(struct inode *inode, struct file *file, | |||
335 | return -EFAULT; | 337 | return -EFAULT; |
336 | 338 | ||
337 | if (new_options & WDIOS_DISABLECARD) { | 339 | if (new_options & WDIOS_DISABLECARD) { |
338 | pcipcwd_stop(); | 340 | if (pcipcwd_stop()) |
341 | return -EIO; | ||
339 | retval = 0; | 342 | retval = 0; |
340 | } | 343 | } |
341 | 344 | ||
342 | if (new_options & WDIOS_ENABLECARD) { | 345 | if (new_options & WDIOS_ENABLECARD) { |
343 | pcipcwd_start(); | 346 | if (pcipcwd_start()) |
347 | return -EIO; | ||
344 | retval = 0; | 348 | retval = 0; |
345 | } | 349 | } |
346 | 350 | ||
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index f85ac898a49a..3625b2601b42 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, pm_message_t 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/sbc8360.c b/drivers/char/watchdog/sbc8360.c new file mode 100644 index 000000000000..c6cbf808d8c2 --- /dev/null +++ b/drivers/char/watchdog/sbc8360.c | |||
@@ -0,0 +1,414 @@ | |||
1 | /* | ||
2 | * SBC8360 Watchdog driver | ||
3 | * | ||
4 | * (c) Copyright 2005 Webcon, Inc. | ||
5 | * | ||
6 | * Based on ib700wdt.c, which is based on advantechwdt.c which is based | ||
7 | * on acquirewdt.c which is based on wdt.c. | ||
8 | * | ||
9 | * (c) Copyright 2001 Charles Howes <chowes@vsol.net> | ||
10 | * | ||
11 | * Based on advantechwdt.c which is based on acquirewdt.c which | ||
12 | * is based on wdt.c. | ||
13 | * | ||
14 | * (c) Copyright 2000-2001 Marek Michalkiewicz <marekm@linux.org.pl> | ||
15 | * | ||
16 | * Based on acquirewdt.c which is based on wdt.c. | ||
17 | * Original copyright messages: | ||
18 | * | ||
19 | * (c) Copyright 1996 Alan Cox <alan@redhat.com>, All Rights Reserved. | ||
20 | * http://www.redhat.com | ||
21 | * | ||
22 | * This program is free software; you can redistribute it and/or | ||
23 | * modify it under the terms of the GNU General Public License | ||
24 | * as published by the Free Software Foundation; either version | ||
25 | * 2 of the License, or (at your option) any later version. | ||
26 | * | ||
27 | * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide | ||
28 | * warranty for any of this software. This material is provided | ||
29 | * "AS-IS" and at no charge. | ||
30 | * | ||
31 | * (c) Copyright 1995 Alan Cox <alan@redhat.com> | ||
32 | * | ||
33 | * 14-Dec-2001 Matt Domsch <Matt_Domsch@dell.com> | ||
34 | * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT | ||
35 | * Added timeout module option to override default | ||
36 | * | ||
37 | */ | ||
38 | |||
39 | #include <linux/config.h> | ||
40 | #include <linux/module.h> | ||
41 | #include <linux/types.h> | ||
42 | #include <linux/miscdevice.h> | ||
43 | #include <linux/watchdog.h> | ||
44 | #include <linux/ioport.h> | ||
45 | #include <linux/delay.h> | ||
46 | #include <linux/notifier.h> | ||
47 | #include <linux/fs.h> | ||
48 | #include <linux/reboot.h> | ||
49 | #include <linux/init.h> | ||
50 | #include <linux/spinlock.h> | ||
51 | #include <linux/moduleparam.h> | ||
52 | |||
53 | #include <asm/io.h> | ||
54 | #include <asm/uaccess.h> | ||
55 | #include <asm/system.h> | ||
56 | |||
57 | static unsigned long sbc8360_is_open; | ||
58 | static spinlock_t sbc8360_lock; | ||
59 | static char expect_close; | ||
60 | |||
61 | #define PFX "sbc8360: " | ||
62 | |||
63 | /* | ||
64 | * | ||
65 | * Watchdog Timer Configuration | ||
66 | * | ||
67 | * The function of the watchdog timer is to reset the system automatically | ||
68 | * and is defined at I/O port 0120H and 0121H. To enable the watchdog timer | ||
69 | * and allow the system to reset, write appropriate values from the table | ||
70 | * below to I/O port 0120H and 0121H. To disable the timer, write a zero | ||
71 | * value to I/O port 0121H for the system to stop the watchdog function. | ||
72 | * | ||
73 | * The following describes how the timer should be programmed (according to | ||
74 | * the vendor documentation) | ||
75 | * | ||
76 | * Enabling Watchdog: | ||
77 | * MOV AX,000AH (enable, phase I) | ||
78 | * MOV DX,0120H | ||
79 | * OUT DX,AX | ||
80 | * MOV AX,000BH (enable, phase II) | ||
81 | * MOV DX,0120H | ||
82 | * OUT DX,AX | ||
83 | * MOV AX,000nH (set multiplier n, from 1-4) | ||
84 | * MOV DX,0120H | ||
85 | * OUT DX,AX | ||
86 | * MOV AX,000mH (set base timer m, from 0-F) | ||
87 | * MOV DX,0121H | ||
88 | * OUT DX,AX | ||
89 | * | ||
90 | * Reset timer: | ||
91 | * MOV AX,000mH (same as set base timer, above) | ||
92 | * MOV DX,0121H | ||
93 | * OUT DX,AX | ||
94 | * | ||
95 | * Disabling Watchdog: | ||
96 | * MOV AX,0000H (a zero value) | ||
97 | * MOV DX,0120H | ||
98 | * OUT DX,AX | ||
99 | * | ||
100 | * Watchdog timeout configuration values: | ||
101 | * N | ||
102 | * M | 1 2 3 4 | ||
103 | * --|---------------------------------- | ||
104 | * 0 | 0.5s 5s 50s 100s | ||
105 | * 1 | 1s 10s 100s 200s | ||
106 | * 2 | 1.5s 15s 150s 300s | ||
107 | * 3 | 2s 20s 200s 400s | ||
108 | * 4 | 2.5s 25s 250s 500s | ||
109 | * 5 | 3s 30s 300s 600s | ||
110 | * 6 | 3.5s 35s 350s 700s | ||
111 | * 7 | 4s 40s 400s 800s | ||
112 | * 8 | 4.5s 45s 450s 900s | ||
113 | * 9 | 5s 50s 500s 1000s | ||
114 | * A | 5.5s 55s 550s 1100s | ||
115 | * B | 6s 60s 600s 1200s | ||
116 | * C | 6.5s 65s 650s 1300s | ||
117 | * D | 7s 70s 700s 1400s | ||
118 | * E | 7.5s 75s 750s 1500s | ||
119 | * F | 8s 80s 800s 1600s | ||
120 | * | ||
121 | * Another way to say the same things is: | ||
122 | * For N=1, Timeout = (M+1) * 0.5s | ||
123 | * For N=2, Timeout = (M+1) * 5s | ||
124 | * For N=3, Timeout = (M+1) * 50s | ||
125 | * For N=4, Timeout = (M+1) * 100s | ||
126 | * | ||
127 | */ | ||
128 | |||
129 | static int wd_times[64][2] = { | ||
130 | {0, 1}, /* 0 = 0.5s */ | ||
131 | {1, 1}, /* 1 = 1s */ | ||
132 | {2, 1}, /* 2 = 1.5s */ | ||
133 | {3, 1}, /* 3 = 2s */ | ||
134 | {4, 1}, /* 4 = 2.5s */ | ||
135 | {5, 1}, /* 5 = 3s */ | ||
136 | {6, 1}, /* 6 = 3.5s */ | ||
137 | {7, 1}, /* 7 = 4s */ | ||
138 | {8, 1}, /* 8 = 4.5s */ | ||
139 | {9, 1}, /* 9 = 5s */ | ||
140 | {0xA, 1}, /* 10 = 5.5s */ | ||
141 | {0xB, 1}, /* 11 = 6s */ | ||
142 | {0xC, 1}, /* 12 = 6.5s */ | ||
143 | {0xD, 1}, /* 13 = 7s */ | ||
144 | {0xE, 1}, /* 14 = 7.5s */ | ||
145 | {0xF, 1}, /* 15 = 8s */ | ||
146 | {0, 2}, /* 16 = 5s */ | ||
147 | {1, 2}, /* 17 = 10s */ | ||
148 | {2, 2}, /* 18 = 15s */ | ||
149 | {3, 2}, /* 19 = 20s */ | ||
150 | {4, 2}, /* 20 = 25s */ | ||
151 | {5, 2}, /* 21 = 30s */ | ||
152 | {6, 2}, /* 22 = 35s */ | ||
153 | {7, 2}, /* 23 = 40s */ | ||
154 | {8, 2}, /* 24 = 45s */ | ||
155 | {9, 2}, /* 25 = 50s */ | ||
156 | {0xA, 2}, /* 26 = 55s */ | ||
157 | {0xB, 2}, /* 27 = 60s */ | ||
158 | {0xC, 2}, /* 28 = 65s */ | ||
159 | {0xD, 2}, /* 29 = 70s */ | ||
160 | {0xE, 2}, /* 30 = 75s */ | ||
161 | {0xF, 2}, /* 31 = 80s */ | ||
162 | {0, 3}, /* 32 = 50s */ | ||
163 | {1, 3}, /* 33 = 100s */ | ||
164 | {2, 3}, /* 34 = 150s */ | ||
165 | {3, 3}, /* 35 = 200s */ | ||
166 | {4, 3}, /* 36 = 250s */ | ||
167 | {5, 3}, /* 37 = 300s */ | ||
168 | {6, 3}, /* 38 = 350s */ | ||
169 | {7, 3}, /* 39 = 400s */ | ||
170 | {8, 3}, /* 40 = 450s */ | ||
171 | {9, 3}, /* 41 = 500s */ | ||
172 | {0xA, 3}, /* 42 = 550s */ | ||
173 | {0xB, 3}, /* 43 = 600s */ | ||
174 | {0xC, 3}, /* 44 = 650s */ | ||
175 | {0xD, 3}, /* 45 = 700s */ | ||
176 | {0xE, 3}, /* 46 = 750s */ | ||
177 | {0xF, 3}, /* 47 = 800s */ | ||
178 | {0, 4}, /* 48 = 100s */ | ||
179 | {1, 4}, /* 49 = 200s */ | ||
180 | {2, 4}, /* 50 = 300s */ | ||
181 | {3, 4}, /* 51 = 400s */ | ||
182 | {4, 4}, /* 52 = 500s */ | ||
183 | {5, 4}, /* 53 = 600s */ | ||
184 | {6, 4}, /* 54 = 700s */ | ||
185 | {7, 4}, /* 55 = 800s */ | ||
186 | {8, 4}, /* 56 = 900s */ | ||
187 | {9, 4}, /* 57 = 1000s */ | ||
188 | {0xA, 4}, /* 58 = 1100s */ | ||
189 | {0xB, 4}, /* 59 = 1200s */ | ||
190 | {0xC, 4}, /* 60 = 1300s */ | ||
191 | {0xD, 4}, /* 61 = 1400s */ | ||
192 | {0xE, 4}, /* 62 = 1500s */ | ||
193 | {0xF, 4} /* 63 = 1600s */ | ||
194 | }; | ||
195 | |||
196 | #define SBC8360_ENABLE 0x120 | ||
197 | #define SBC8360_BASETIME 0x121 | ||
198 | |||
199 | static int timeout = 27; | ||
200 | static int wd_margin = 0xB; | ||
201 | static int wd_multiplier = 2; | ||
202 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
203 | |||
204 | module_param(timeout, int, 27); | ||
205 | MODULE_PARM_DESC(timeout, "Index into timeout table (0-63) (default=27 (60s))"); | ||
206 | module_param(nowayout, int, 0); | ||
207 | MODULE_PARM_DESC(nowayout, | ||
208 | "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | ||
209 | |||
210 | /* | ||
211 | * Kernel methods. | ||
212 | */ | ||
213 | |||
214 | /* Activate and pre-configure watchdog */ | ||
215 | static void sbc8360_activate(void) | ||
216 | { | ||
217 | /* Enable the watchdog */ | ||
218 | outb(0x0A, SBC8360_ENABLE); | ||
219 | msleep_interruptible(100); | ||
220 | outb(0x0B, SBC8360_ENABLE); | ||
221 | msleep_interruptible(100); | ||
222 | /* Set timeout multiplier */ | ||
223 | outb(wd_multiplier, SBC8360_ENABLE); | ||
224 | msleep_interruptible(100); | ||
225 | /* Nothing happens until first sbc8360_ping() */ | ||
226 | } | ||
227 | |||
228 | /* Kernel pings watchdog */ | ||
229 | static void sbc8360_ping(void) | ||
230 | { | ||
231 | /* Write the base timer register */ | ||
232 | outb(wd_margin, SBC8360_BASETIME); | ||
233 | } | ||
234 | |||
235 | /* Userspace pings kernel driver, or requests clean close */ | ||
236 | static ssize_t sbc8360_write(struct file *file, const char __user * buf, | ||
237 | size_t count, loff_t * ppos) | ||
238 | { | ||
239 | if (count) { | ||
240 | if (!nowayout) { | ||
241 | size_t i; | ||
242 | |||
243 | /* In case it was set long ago */ | ||
244 | expect_close = 0; | ||
245 | |||
246 | for (i = 0; i != count; i++) { | ||
247 | char c; | ||
248 | if (get_user(c, buf + i)) | ||
249 | return -EFAULT; | ||
250 | if (c == 'V') | ||
251 | expect_close = 42; | ||
252 | } | ||
253 | } | ||
254 | sbc8360_ping(); | ||
255 | } | ||
256 | return count; | ||
257 | } | ||
258 | |||
259 | static int sbc8360_open(struct inode *inode, struct file *file) | ||
260 | { | ||
261 | spin_lock(&sbc8360_lock); | ||
262 | if (test_and_set_bit(0, &sbc8360_is_open)) { | ||
263 | spin_unlock(&sbc8360_lock); | ||
264 | return -EBUSY; | ||
265 | } | ||
266 | if (nowayout) | ||
267 | __module_get(THIS_MODULE); | ||
268 | |||
269 | /* Activate and ping once to start the countdown */ | ||
270 | spin_unlock(&sbc8360_lock); | ||
271 | sbc8360_activate(); | ||
272 | sbc8360_ping(); | ||
273 | return nonseekable_open(inode, file); | ||
274 | } | ||
275 | |||
276 | static int sbc8360_close(struct inode *inode, struct file *file) | ||
277 | { | ||
278 | spin_lock(&sbc8360_lock); | ||
279 | if (expect_close == 42) | ||
280 | outb(0, SBC8360_ENABLE); | ||
281 | else | ||
282 | printk(KERN_CRIT PFX | ||
283 | "SBC8360 device closed unexpectedly. SBC8360 will not stop!\n"); | ||
284 | |||
285 | clear_bit(0, &sbc8360_is_open); | ||
286 | expect_close = 0; | ||
287 | spin_unlock(&sbc8360_lock); | ||
288 | return 0; | ||
289 | } | ||
290 | |||
291 | /* | ||
292 | * Notifier for system down | ||
293 | */ | ||
294 | |||
295 | static int sbc8360_notify_sys(struct notifier_block *this, unsigned long code, | ||
296 | void *unused) | ||
297 | { | ||
298 | if (code == SYS_DOWN || code == SYS_HALT) { | ||
299 | /* Disable the SBC8360 Watchdog */ | ||
300 | outb(0, SBC8360_ENABLE); | ||
301 | } | ||
302 | return NOTIFY_DONE; | ||
303 | } | ||
304 | |||
305 | /* | ||
306 | * Kernel Interfaces | ||
307 | */ | ||
308 | |||
309 | static struct file_operations sbc8360_fops = { | ||
310 | .owner = THIS_MODULE, | ||
311 | .llseek = no_llseek, | ||
312 | .write = sbc8360_write, | ||
313 | .open = sbc8360_open, | ||
314 | .release = sbc8360_close, | ||
315 | }; | ||
316 | |||
317 | static struct miscdevice sbc8360_miscdev = { | ||
318 | .minor = WATCHDOG_MINOR, | ||
319 | .name = "watchdog", | ||
320 | .fops = &sbc8360_fops, | ||
321 | }; | ||
322 | |||
323 | /* | ||
324 | * The SBC8360 needs to learn about soft shutdowns in order to | ||
325 | * turn the timebomb registers off. | ||
326 | */ | ||
327 | |||
328 | static struct notifier_block sbc8360_notifier = { | ||
329 | .notifier_call = sbc8360_notify_sys, | ||
330 | }; | ||
331 | |||
332 | static int __init sbc8360_init(void) | ||
333 | { | ||
334 | int res; | ||
335 | unsigned long int mseconds = 60000; | ||
336 | |||
337 | spin_lock_init(&sbc8360_lock); | ||
338 | res = misc_register(&sbc8360_miscdev); | ||
339 | if (res) { | ||
340 | printk(KERN_ERR PFX "failed to register misc device\n"); | ||
341 | goto out_nomisc; | ||
342 | } | ||
343 | |||
344 | if (!request_region(SBC8360_ENABLE, 1, "SBC8360")) { | ||
345 | printk(KERN_ERR PFX "ENABLE method I/O %X is not available.\n", | ||
346 | SBC8360_ENABLE); | ||
347 | res = -EIO; | ||
348 | goto out_noenablereg; | ||
349 | } | ||
350 | if (!request_region(SBC8360_BASETIME, 1, "SBC8360")) { | ||
351 | printk(KERN_ERR PFX | ||
352 | "BASETIME method I/O %X is not available.\n", | ||
353 | SBC8360_BASETIME); | ||
354 | res = -EIO; | ||
355 | goto out_nobasetimereg; | ||
356 | } | ||
357 | |||
358 | res = register_reboot_notifier(&sbc8360_notifier); | ||
359 | if (res) { | ||
360 | printk(KERN_ERR PFX "Failed to register reboot notifier.\n"); | ||
361 | goto out_noreboot; | ||
362 | } | ||
363 | |||
364 | if (timeout < 0 || timeout > 63) { | ||
365 | printk(KERN_ERR PFX "Invalid timeout index (must be 0-63).\n"); | ||
366 | res = -EINVAL; | ||
367 | goto out_noreboot; | ||
368 | } | ||
369 | |||
370 | wd_margin = wd_times[timeout][0]; | ||
371 | wd_multiplier = wd_times[timeout][1]; | ||
372 | |||
373 | if (wd_multiplier == 1) | ||
374 | mseconds = (wd_margin + 1) * 500; | ||
375 | else if (wd_multiplier == 2) | ||
376 | mseconds = (wd_margin + 1) * 5000; | ||
377 | else if (wd_multiplier == 3) | ||
378 | mseconds = (wd_margin + 1) * 50000; | ||
379 | else if (wd_multiplier == 4) | ||
380 | mseconds = (wd_margin + 1) * 100000; | ||
381 | |||
382 | /* My kingdom for the ability to print "0.5 seconds" in the kernel! */ | ||
383 | printk(KERN_INFO PFX "Timeout set at %ld ms.\n", mseconds); | ||
384 | |||
385 | return 0; | ||
386 | |||
387 | out_noreboot: | ||
388 | release_region(SBC8360_ENABLE, 1); | ||
389 | release_region(SBC8360_BASETIME, 1); | ||
390 | out_noenablereg: | ||
391 | out_nobasetimereg: | ||
392 | misc_deregister(&sbc8360_miscdev); | ||
393 | out_nomisc: | ||
394 | return res; | ||
395 | } | ||
396 | |||
397 | static void __exit sbc8360_exit(void) | ||
398 | { | ||
399 | misc_deregister(&sbc8360_miscdev); | ||
400 | unregister_reboot_notifier(&sbc8360_notifier); | ||
401 | release_region(SBC8360_ENABLE, 1); | ||
402 | release_region(SBC8360_BASETIME, 1); | ||
403 | } | ||
404 | |||
405 | module_init(sbc8360_init); | ||
406 | module_exit(sbc8360_exit); | ||
407 | |||
408 | MODULE_AUTHOR("Ian E. Morgan <imorgan@webcon.ca>"); | ||
409 | MODULE_DESCRIPTION("SBC8360 watchdog driver"); | ||
410 | MODULE_LICENSE("GPL"); | ||
411 | MODULE_VERSION("1.0"); | ||
412 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||
413 | |||
414 | /* end of sbc8360.c */ | ||
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 */ |
diff --git a/drivers/char/watchdog/w83977f_wdt.c b/drivers/char/watchdog/w83977f_wdt.c new file mode 100644 index 000000000000..a7ff64c8921f --- /dev/null +++ b/drivers/char/watchdog/w83977f_wdt.c | |||
@@ -0,0 +1,543 @@ | |||
1 | /* | ||
2 | * W83977F Watchdog Timer Driver for Winbond W83977F I/O Chip | ||
3 | * | ||
4 | * (c) Copyright 2005 Jose Goncalves <jose.goncalves@inov.pt> | ||
5 | * | ||
6 | * Based on w83877f_wdt.c by Scott Jennings, | ||
7 | * and wdt977.c by Woody Suwalski | ||
8 | * | ||
9 | * ----------------------- | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License | ||
13 | * as published by the Free Software Foundation; either version | ||
14 | * 2 of the License, or (at your option) any later version. | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/moduleparam.h> | ||
20 | #include <linux/config.h> | ||
21 | #include <linux/types.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/fs.h> | ||
24 | #include <linux/miscdevice.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/ioport.h> | ||
27 | #include <linux/watchdog.h> | ||
28 | #include <linux/notifier.h> | ||
29 | #include <linux/reboot.h> | ||
30 | |||
31 | #include <asm/io.h> | ||
32 | #include <asm/system.h> | ||
33 | #include <asm/uaccess.h> | ||
34 | |||
35 | #define WATCHDOG_VERSION "1.00" | ||
36 | #define WATCHDOG_NAME "W83977F WDT" | ||
37 | #define PFX WATCHDOG_NAME ": " | ||
38 | #define DRIVER_VERSION WATCHDOG_NAME " driver, v" WATCHDOG_VERSION "\n" | ||
39 | |||
40 | #define IO_INDEX_PORT 0x3F0 | ||
41 | #define IO_DATA_PORT (IO_INDEX_PORT+1) | ||
42 | |||
43 | #define UNLOCK_DATA 0x87 | ||
44 | #define LOCK_DATA 0xAA | ||
45 | #define DEVICE_REGISTER 0x07 | ||
46 | |||
47 | #define DEFAULT_TIMEOUT 45 /* default timeout in seconds */ | ||
48 | |||
49 | static int timeout = DEFAULT_TIMEOUT; | ||
50 | static int timeoutW; /* timeout in watchdog counter units */ | ||
51 | static unsigned long timer_alive; | ||
52 | static int testmode; | ||
53 | static char expect_close; | ||
54 | static spinlock_t spinlock; | ||
55 | |||
56 | module_param(timeout, int, 0); | ||
57 | MODULE_PARM_DESC(timeout,"Watchdog timeout in seconds (15..7635), default=" __MODULE_STRING(DEFAULT_TIMEOUT) ")"); | ||
58 | module_param(testmode, int, 0); | ||
59 | MODULE_PARM_DESC(testmode,"Watchdog testmode (1 = no reboot), default=0"); | ||
60 | |||
61 | static int nowayout = WATCHDOG_NOWAYOUT; | ||
62 | module_param(nowayout, int, 0); | ||
63 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); | ||
64 | |||
65 | /* | ||
66 | * Start the watchdog | ||
67 | */ | ||
68 | |||
69 | static int wdt_start(void) | ||
70 | { | ||
71 | unsigned long flags; | ||
72 | |||
73 | spin_lock_irqsave(&spinlock, flags); | ||
74 | |||
75 | /* Unlock the SuperIO chip */ | ||
76 | outb_p(UNLOCK_DATA,IO_INDEX_PORT); | ||
77 | outb_p(UNLOCK_DATA,IO_INDEX_PORT); | ||
78 | |||
79 | /* | ||
80 | * Select device Aux2 (device=8) to set watchdog regs F2, F3 and F4. | ||
81 | * F2 has the timeout in watchdog counter units. | ||
82 | * F3 is set to enable watchdog LED blink at timeout. | ||
83 | * F4 is used to just clear the TIMEOUT'ed state (bit 0). | ||
84 | */ | ||
85 | outb_p(DEVICE_REGISTER,IO_INDEX_PORT); | ||
86 | outb_p(0x08,IO_DATA_PORT); | ||
87 | outb_p(0xF2,IO_INDEX_PORT); | ||
88 | outb_p(timeoutW,IO_DATA_PORT); | ||
89 | outb_p(0xF3,IO_INDEX_PORT); | ||
90 | outb_p(0x08,IO_DATA_PORT); | ||
91 | outb_p(0xF4,IO_INDEX_PORT); | ||
92 | outb_p(0x00,IO_DATA_PORT); | ||
93 | |||
94 | /* Set device Aux2 active */ | ||
95 | outb_p(0x30,IO_INDEX_PORT); | ||
96 | outb_p(0x01,IO_DATA_PORT); | ||
97 | |||
98 | /* | ||
99 | * Select device Aux1 (dev=7) to set GP16 as the watchdog output | ||
100 | * (in reg E6) and GP13 as the watchdog LED output (in reg E3). | ||
101 | * Map GP16 at pin 119. | ||
102 | * In test mode watch the bit 0 on F4 to indicate "triggered" or | ||
103 | * check watchdog LED on SBC. | ||
104 | */ | ||
105 | outb_p(DEVICE_REGISTER,IO_INDEX_PORT); | ||
106 | outb_p(0x07,IO_DATA_PORT); | ||
107 | if (!testmode) | ||
108 | { | ||
109 | unsigned pin_map; | ||
110 | |||
111 | outb_p(0xE6,IO_INDEX_PORT); | ||
112 | outb_p(0x0A,IO_DATA_PORT); | ||
113 | outb_p(0x2C,IO_INDEX_PORT); | ||
114 | pin_map = inb_p(IO_DATA_PORT); | ||
115 | pin_map |= 0x10; | ||
116 | pin_map &= ~(0x20); | ||
117 | outb_p(0x2C,IO_INDEX_PORT); | ||
118 | outb_p(pin_map,IO_DATA_PORT); | ||
119 | } | ||
120 | outb_p(0xE3,IO_INDEX_PORT); | ||
121 | outb_p(0x08,IO_DATA_PORT); | ||
122 | |||
123 | /* Set device Aux1 active */ | ||
124 | outb_p(0x30,IO_INDEX_PORT); | ||
125 | outb_p(0x01,IO_DATA_PORT); | ||
126 | |||
127 | /* Lock the SuperIO chip */ | ||
128 | outb_p(LOCK_DATA,IO_INDEX_PORT); | ||
129 | |||
130 | spin_unlock_irqrestore(&spinlock, flags); | ||
131 | |||
132 | printk(KERN_INFO PFX "activated.\n"); | ||
133 | |||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | /* | ||
138 | * Stop the watchdog | ||
139 | */ | ||
140 | |||
141 | static int wdt_stop(void) | ||
142 | { | ||
143 | unsigned long flags; | ||
144 | |||
145 | spin_lock_irqsave(&spinlock, flags); | ||
146 | |||
147 | /* Unlock the SuperIO chip */ | ||
148 | outb_p(UNLOCK_DATA,IO_INDEX_PORT); | ||
149 | outb_p(UNLOCK_DATA,IO_INDEX_PORT); | ||
150 | |||
151 | /* | ||
152 | * Select device Aux2 (device=8) to set watchdog regs F2, F3 and F4. | ||
153 | * F2 is reset to its default value (watchdog timer disabled). | ||
154 | * F3 is reset to its default state. | ||
155 | * F4 clears the TIMEOUT'ed state (bit 0) - back to default. | ||
156 | */ | ||
157 | outb_p(DEVICE_REGISTER,IO_INDEX_PORT); | ||
158 | outb_p(0x08,IO_DATA_PORT); | ||
159 | outb_p(0xF2,IO_INDEX_PORT); | ||
160 | outb_p(0xFF,IO_DATA_PORT); | ||
161 | outb_p(0xF3,IO_INDEX_PORT); | ||
162 | outb_p(0x00,IO_DATA_PORT); | ||
163 | outb_p(0xF4,IO_INDEX_PORT); | ||
164 | outb_p(0x00,IO_DATA_PORT); | ||
165 | outb_p(0xF2,IO_INDEX_PORT); | ||
166 | outb_p(0x00,IO_DATA_PORT); | ||
167 | |||
168 | /* | ||
169 | * Select device Aux1 (dev=7) to set GP16 (in reg E6) and | ||
170 | * Gp13 (in reg E3) as inputs. | ||
171 | */ | ||
172 | outb_p(DEVICE_REGISTER,IO_INDEX_PORT); | ||
173 | outb_p(0x07,IO_DATA_PORT); | ||
174 | if (!testmode) | ||
175 | { | ||
176 | outb_p(0xE6,IO_INDEX_PORT); | ||
177 | outb_p(0x01,IO_DATA_PORT); | ||
178 | } | ||
179 | outb_p(0xE3,IO_INDEX_PORT); | ||
180 | outb_p(0x01,IO_DATA_PORT); | ||
181 | |||
182 | /* Lock the SuperIO chip */ | ||
183 | outb_p(LOCK_DATA,IO_INDEX_PORT); | ||
184 | |||
185 | spin_unlock_irqrestore(&spinlock, flags); | ||
186 | |||
187 | printk(KERN_INFO PFX "shutdown.\n"); | ||
188 | |||
189 | return 0; | ||
190 | } | ||
191 | |||
192 | /* | ||
193 | * Send a keepalive ping to the watchdog | ||
194 | * This is done by simply re-writing the timeout to reg. 0xF2 | ||
195 | */ | ||
196 | |||
197 | static int wdt_keepalive(void) | ||
198 | { | ||
199 | unsigned long flags; | ||
200 | |||
201 | spin_lock_irqsave(&spinlock, flags); | ||
202 | |||
203 | /* Unlock the SuperIO chip */ | ||
204 | outb_p(UNLOCK_DATA,IO_INDEX_PORT); | ||
205 | outb_p(UNLOCK_DATA,IO_INDEX_PORT); | ||
206 | |||
207 | /* Select device Aux2 (device=8) to kick watchdog reg F2 */ | ||
208 | outb_p(DEVICE_REGISTER,IO_INDEX_PORT); | ||
209 | outb_p(0x08,IO_DATA_PORT); | ||
210 | outb_p(0xF2,IO_INDEX_PORT); | ||
211 | outb_p(timeoutW,IO_DATA_PORT); | ||
212 | |||
213 | /* Lock the SuperIO chip */ | ||
214 | outb_p(LOCK_DATA,IO_INDEX_PORT); | ||
215 | |||
216 | spin_unlock_irqrestore(&spinlock, flags); | ||
217 | |||
218 | return 0; | ||
219 | } | ||
220 | |||
221 | /* | ||
222 | * Set the watchdog timeout value | ||
223 | */ | ||
224 | |||
225 | static int wdt_set_timeout(int t) | ||
226 | { | ||
227 | int tmrval; | ||
228 | |||
229 | /* | ||
230 | * Convert seconds to watchdog counter time units, rounding up. | ||
231 | * On PCM-5335 watchdog units are 30 seconds/step with 15 sec startup | ||
232 | * value. This information is supplied in the PCM-5335 manual and was | ||
233 | * checked by me on a real board. This is a bit strange because W83977f | ||
234 | * datasheet says counter unit is in minutes! | ||
235 | */ | ||
236 | if (t < 15) | ||
237 | return -EINVAL; | ||
238 | |||
239 | tmrval = ((t + 15) + 29) / 30; | ||
240 | |||
241 | if (tmrval > 255) | ||
242 | return -EINVAL; | ||
243 | |||
244 | /* | ||
245 | * timeout is the timeout in seconds, | ||
246 | * timeoutW is the timeout in watchdog counter units. | ||
247 | */ | ||
248 | timeoutW = tmrval; | ||
249 | timeout = (timeoutW * 30) - 15; | ||
250 | return 0; | ||
251 | } | ||
252 | |||
253 | /* | ||
254 | * Get the watchdog status | ||
255 | */ | ||
256 | |||
257 | static int wdt_get_status(int *status) | ||
258 | { | ||
259 | int new_status; | ||
260 | unsigned long flags; | ||
261 | |||
262 | spin_lock_irqsave(&spinlock, flags); | ||
263 | |||
264 | /* Unlock the SuperIO chip */ | ||
265 | outb_p(UNLOCK_DATA,IO_INDEX_PORT); | ||
266 | outb_p(UNLOCK_DATA,IO_INDEX_PORT); | ||
267 | |||
268 | /* Select device Aux2 (device=8) to read watchdog reg F4 */ | ||
269 | outb_p(DEVICE_REGISTER,IO_INDEX_PORT); | ||
270 | outb_p(0x08,IO_DATA_PORT); | ||
271 | outb_p(0xF4,IO_INDEX_PORT); | ||
272 | new_status = inb_p(IO_DATA_PORT); | ||
273 | |||
274 | /* Lock the SuperIO chip */ | ||
275 | outb_p(LOCK_DATA,IO_INDEX_PORT); | ||
276 | |||
277 | spin_unlock_irqrestore(&spinlock, flags); | ||
278 | |||
279 | *status = 0; | ||
280 | if (new_status & 1) | ||
281 | *status |= WDIOF_CARDRESET; | ||
282 | |||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | |||
287 | /* | ||
288 | * /dev/watchdog handling | ||
289 | */ | ||
290 | |||
291 | static int wdt_open(struct inode *inode, struct file *file) | ||
292 | { | ||
293 | /* If the watchdog is alive we don't need to start it again */ | ||
294 | if( test_and_set_bit(0, &timer_alive) ) | ||
295 | return -EBUSY; | ||
296 | |||
297 | if (nowayout) | ||
298 | __module_get(THIS_MODULE); | ||
299 | |||
300 | wdt_start(); | ||
301 | return nonseekable_open(inode, file); | ||
302 | } | ||
303 | |||
304 | static int wdt_release(struct inode *inode, struct file *file) | ||
305 | { | ||
306 | /* | ||
307 | * Shut off the timer. | ||
308 | * Lock it in if it's a module and we set nowayout | ||
309 | */ | ||
310 | if (expect_close == 42) | ||
311 | { | ||
312 | wdt_stop(); | ||
313 | clear_bit(0, &timer_alive); | ||
314 | } else { | ||
315 | wdt_keepalive(); | ||
316 | printk(KERN_CRIT PFX "unexpected close, not stopping watchdog!\n"); | ||
317 | } | ||
318 | expect_close = 0; | ||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | /* | ||
323 | * wdt_write: | ||
324 | * @file: file handle to the watchdog | ||
325 | * @buf: buffer to write (unused as data does not matter here | ||
326 | * @count: count of bytes | ||
327 | * @ppos: pointer to the position to write. No seeks allowed | ||
328 | * | ||
329 | * A write to a watchdog device is defined as a keepalive signal. Any | ||
330 | * write of data will do, as we we don't define content meaning. | ||
331 | */ | ||
332 | |||
333 | static ssize_t wdt_write(struct file *file, const char __user *buf, | ||
334 | size_t count, loff_t *ppos) | ||
335 | { | ||
336 | /* See if we got the magic character 'V' and reload the timer */ | ||
337 | if(count) | ||
338 | { | ||
339 | if (!nowayout) | ||
340 | { | ||
341 | size_t ofs; | ||
342 | |||
343 | /* note: just in case someone wrote the magic character long ago */ | ||
344 | expect_close = 0; | ||
345 | |||
346 | /* scan to see whether or not we got the magic character */ | ||
347 | for(ofs = 0; ofs != count; ofs++) | ||
348 | { | ||
349 | char c; | ||
350 | if (get_user(c, buf + ofs)) | ||
351 | return -EFAULT; | ||
352 | if (c == 'V') { | ||
353 | expect_close = 42; | ||
354 | } | ||
355 | } | ||
356 | } | ||
357 | |||
358 | /* someone wrote to us, we should restart timer */ | ||
359 | wdt_keepalive(); | ||
360 | } | ||
361 | return count; | ||
362 | } | ||
363 | |||
364 | /* | ||
365 | * wdt_ioctl: | ||
366 | * @inode: inode of the device | ||
367 | * @file: file handle to the device | ||
368 | * @cmd: watchdog command | ||
369 | * @arg: argument pointer | ||
370 | * | ||
371 | * The watchdog API defines a common set of functions for all watchdogs | ||
372 | * according to their available features. | ||
373 | */ | ||
374 | |||
375 | static struct watchdog_info ident = { | ||
376 | .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, | ||
377 | .firmware_version = 1, | ||
378 | .identity = WATCHDOG_NAME, | ||
379 | }; | ||
380 | |||
381 | static int wdt_ioctl(struct inode *inode, struct file *file, | ||
382 | unsigned int cmd, unsigned long arg) | ||
383 | { | ||
384 | int status; | ||
385 | int new_options, retval = -EINVAL; | ||
386 | int new_timeout; | ||
387 | union { | ||
388 | struct watchdog_info __user *ident; | ||
389 | int __user *i; | ||
390 | } uarg; | ||
391 | |||
392 | uarg.i = (int __user *)arg; | ||
393 | |||
394 | switch(cmd) | ||
395 | { | ||
396 | default: | ||
397 | return -ENOIOCTLCMD; | ||
398 | |||
399 | case WDIOC_GETSUPPORT: | ||
400 | return copy_to_user(uarg.ident, &ident, sizeof(ident)) ? -EFAULT : 0; | ||
401 | |||
402 | case WDIOC_GETSTATUS: | ||
403 | wdt_get_status(&status); | ||
404 | return put_user(status, uarg.i); | ||
405 | |||
406 | case WDIOC_GETBOOTSTATUS: | ||
407 | return put_user(0, uarg.i); | ||
408 | |||
409 | case WDIOC_KEEPALIVE: | ||
410 | wdt_keepalive(); | ||
411 | return 0; | ||
412 | |||
413 | case WDIOC_SETOPTIONS: | ||
414 | if (get_user (new_options, uarg.i)) | ||
415 | return -EFAULT; | ||
416 | |||
417 | if (new_options & WDIOS_DISABLECARD) { | ||
418 | wdt_stop(); | ||
419 | retval = 0; | ||
420 | } | ||
421 | |||
422 | if (new_options & WDIOS_ENABLECARD) { | ||
423 | wdt_start(); | ||
424 | retval = 0; | ||
425 | } | ||
426 | |||
427 | return retval; | ||
428 | |||
429 | case WDIOC_SETTIMEOUT: | ||
430 | if (get_user(new_timeout, uarg.i)) | ||
431 | return -EFAULT; | ||
432 | |||
433 | if (wdt_set_timeout(new_timeout)) | ||
434 | return -EINVAL; | ||
435 | |||
436 | wdt_keepalive(); | ||
437 | /* Fall */ | ||
438 | |||
439 | case WDIOC_GETTIMEOUT: | ||
440 | return put_user(timeout, uarg.i); | ||
441 | |||
442 | } | ||
443 | } | ||
444 | |||
445 | static int wdt_notify_sys(struct notifier_block *this, unsigned long code, | ||
446 | void *unused) | ||
447 | { | ||
448 | if (code==SYS_DOWN || code==SYS_HALT) | ||
449 | wdt_stop(); | ||
450 | return NOTIFY_DONE; | ||
451 | } | ||
452 | |||
453 | static struct file_operations wdt_fops= | ||
454 | { | ||
455 | .owner = THIS_MODULE, | ||
456 | .llseek = no_llseek, | ||
457 | .write = wdt_write, | ||
458 | .ioctl = wdt_ioctl, | ||
459 | .open = wdt_open, | ||
460 | .release = wdt_release, | ||
461 | }; | ||
462 | |||
463 | static struct miscdevice wdt_miscdev= | ||
464 | { | ||
465 | .minor = WATCHDOG_MINOR, | ||
466 | .name = "watchdog", | ||
467 | .fops = &wdt_fops, | ||
468 | }; | ||
469 | |||
470 | static struct notifier_block wdt_notifier = { | ||
471 | .notifier_call = wdt_notify_sys, | ||
472 | }; | ||
473 | |||
474 | static int __init w83977f_wdt_init(void) | ||
475 | { | ||
476 | int rc; | ||
477 | |||
478 | printk(KERN_INFO PFX DRIVER_VERSION); | ||
479 | |||
480 | spin_lock_init(&spinlock); | ||
481 | |||
482 | /* | ||
483 | * Check that the timeout value is within it's range ; | ||
484 | * if not reset to the default | ||
485 | */ | ||
486 | if (wdt_set_timeout(timeout)) { | ||
487 | wdt_set_timeout(DEFAULT_TIMEOUT); | ||
488 | printk(KERN_INFO PFX "timeout value must be 15<=timeout<=7635, using %d\n", | ||
489 | DEFAULT_TIMEOUT); | ||
490 | } | ||
491 | |||
492 | if (!request_region(IO_INDEX_PORT, 2, WATCHDOG_NAME)) | ||
493 | { | ||
494 | printk(KERN_ERR PFX "I/O address 0x%04x already in use\n", | ||
495 | IO_INDEX_PORT); | ||
496 | rc = -EIO; | ||
497 | goto err_out; | ||
498 | } | ||
499 | |||
500 | rc = misc_register(&wdt_miscdev); | ||
501 | if (rc) | ||
502 | { | ||
503 | printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n", | ||
504 | wdt_miscdev.minor, rc); | ||
505 | goto err_out_region; | ||
506 | } | ||
507 | |||
508 | rc = register_reboot_notifier(&wdt_notifier); | ||
509 | if (rc) | ||
510 | { | ||
511 | printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", | ||
512 | rc); | ||
513 | goto err_out_miscdev; | ||
514 | } | ||
515 | |||
516 | printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d testmode=%d)\n", | ||
517 | timeout, nowayout, testmode); | ||
518 | |||
519 | return 0; | ||
520 | |||
521 | err_out_miscdev: | ||
522 | misc_deregister(&wdt_miscdev); | ||
523 | err_out_region: | ||
524 | release_region(IO_INDEX_PORT,2); | ||
525 | err_out: | ||
526 | return rc; | ||
527 | } | ||
528 | |||
529 | static void __exit w83977f_wdt_exit(void) | ||
530 | { | ||
531 | wdt_stop(); | ||
532 | misc_deregister(&wdt_miscdev); | ||
533 | unregister_reboot_notifier(&wdt_notifier); | ||
534 | release_region(IO_INDEX_PORT,2); | ||
535 | } | ||
536 | |||
537 | module_init(w83977f_wdt_init); | ||
538 | module_exit(w83977f_wdt_exit); | ||
539 | |||
540 | MODULE_AUTHOR("Jose Goncalves <jose.goncalves@inov.pt>"); | ||
541 | MODULE_DESCRIPTION("Driver for watchdog timer in W83977F I/O chip"); | ||
542 | MODULE_LICENSE("GPL"); | ||
543 | MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); | ||