diff options
Diffstat (limited to 'drivers')
170 files changed, 4397 insertions, 3311 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 0e71dff327cd..b1ea4df85c7d 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -456,6 +456,35 @@ static void class_device_remove_attrs(struct class_device * cd) | |||
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | static int class_device_add_groups(struct class_device * cd) | ||
460 | { | ||
461 | int i; | ||
462 | int error = 0; | ||
463 | |||
464 | if (cd->groups) { | ||
465 | for (i = 0; cd->groups[i]; i++) { | ||
466 | error = sysfs_create_group(&cd->kobj, cd->groups[i]); | ||
467 | if (error) { | ||
468 | while (--i >= 0) | ||
469 | sysfs_remove_group(&cd->kobj, cd->groups[i]); | ||
470 | goto out; | ||
471 | } | ||
472 | } | ||
473 | } | ||
474 | out: | ||
475 | return error; | ||
476 | } | ||
477 | |||
478 | static void class_device_remove_groups(struct class_device * cd) | ||
479 | { | ||
480 | int i; | ||
481 | if (cd->groups) { | ||
482 | for (i = 0; cd->groups[i]; i++) { | ||
483 | sysfs_remove_group(&cd->kobj, cd->groups[i]); | ||
484 | } | ||
485 | } | ||
486 | } | ||
487 | |||
459 | static ssize_t show_dev(struct class_device *class_dev, char *buf) | 488 | static ssize_t show_dev(struct class_device *class_dev, char *buf) |
460 | { | 489 | { |
461 | return print_dev_t(buf, class_dev->devt); | 490 | return print_dev_t(buf, class_dev->devt); |
@@ -559,6 +588,8 @@ int class_device_add(struct class_device *class_dev) | |||
559 | class_name); | 588 | class_name); |
560 | } | 589 | } |
561 | 590 | ||
591 | class_device_add_groups(class_dev); | ||
592 | |||
562 | kobject_uevent(&class_dev->kobj, KOBJ_ADD); | 593 | kobject_uevent(&class_dev->kobj, KOBJ_ADD); |
563 | 594 | ||
564 | /* notify any interfaces this device is now here */ | 595 | /* notify any interfaces this device is now here */ |
@@ -672,6 +703,7 @@ void class_device_del(struct class_device *class_dev) | |||
672 | if (class_dev->devt_attr) | 703 | if (class_dev->devt_attr) |
673 | class_device_remove_file(class_dev, class_dev->devt_attr); | 704 | class_device_remove_file(class_dev, class_dev->devt_attr); |
674 | class_device_remove_attrs(class_dev); | 705 | class_device_remove_attrs(class_dev); |
706 | class_device_remove_groups(class_dev); | ||
675 | 707 | ||
676 | kobject_uevent(&class_dev->kobj, KOBJ_REMOVE); | 708 | kobject_uevent(&class_dev->kobj, KOBJ_REMOVE); |
677 | kobject_del(&class_dev->kobj); | 709 | kobject_del(&class_dev->kobj); |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index f73446f580df..c688c25992e4 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -536,6 +536,9 @@ static void ub_cleanup(struct ub_dev *sc) | |||
536 | kfree(lun); | 536 | kfree(lun); |
537 | } | 537 | } |
538 | 538 | ||
539 | usb_set_intfdata(sc->intf, NULL); | ||
540 | usb_put_intf(sc->intf); | ||
541 | usb_put_dev(sc->dev); | ||
539 | kfree(sc); | 542 | kfree(sc); |
540 | } | 543 | } |
541 | 544 | ||
@@ -2221,7 +2224,12 @@ static int ub_probe(struct usb_interface *intf, | |||
2221 | // sc->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; | 2224 | // sc->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; |
2222 | usb_set_intfdata(intf, sc); | 2225 | usb_set_intfdata(intf, sc); |
2223 | usb_get_dev(sc->dev); | 2226 | usb_get_dev(sc->dev); |
2224 | // usb_get_intf(sc->intf); /* Do we need this? */ | 2227 | /* |
2228 | * Since we give the interface struct to the block level through | ||
2229 | * disk->driverfs_dev, we have to pin it. Otherwise, block_uevent | ||
2230 | * oopses on close after a disconnect (kernels 2.6.16 and up). | ||
2231 | */ | ||
2232 | usb_get_intf(sc->intf); | ||
2225 | 2233 | ||
2226 | snprintf(sc->name, 12, DRV_NAME "(%d.%d)", | 2234 | snprintf(sc->name, 12, DRV_NAME "(%d.%d)", |
2227 | sc->dev->bus->busnum, sc->dev->devnum); | 2235 | sc->dev->bus->busnum, sc->dev->devnum); |
@@ -2286,7 +2294,7 @@ static int ub_probe(struct usb_interface *intf, | |||
2286 | 2294 | ||
2287 | err_dev_desc: | 2295 | err_dev_desc: |
2288 | usb_set_intfdata(intf, NULL); | 2296 | usb_set_intfdata(intf, NULL); |
2289 | // usb_put_intf(sc->intf); | 2297 | usb_put_intf(sc->intf); |
2290 | usb_put_dev(sc->dev); | 2298 | usb_put_dev(sc->dev); |
2291 | kfree(sc); | 2299 | kfree(sc); |
2292 | err_core: | 2300 | err_core: |
@@ -2461,12 +2469,6 @@ static void ub_disconnect(struct usb_interface *intf) | |||
2461 | * and no URBs left in transit. | 2469 | * and no URBs left in transit. |
2462 | */ | 2470 | */ |
2463 | 2471 | ||
2464 | usb_set_intfdata(intf, NULL); | ||
2465 | // usb_put_intf(sc->intf); | ||
2466 | sc->intf = NULL; | ||
2467 | usb_put_dev(sc->dev); | ||
2468 | sc->dev = NULL; | ||
2469 | |||
2470 | ub_put(sc); | 2472 | ub_put(sc); |
2471 | } | 2473 | } |
2472 | 2474 | ||
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 402296670d3a..78d928f9d9f1 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -291,7 +291,7 @@ config SX | |||
291 | 291 | ||
292 | config RIO | 292 | config RIO |
293 | tristate "Specialix RIO system support" | 293 | tristate "Specialix RIO system support" |
294 | depends on SERIAL_NONSTANDARD && !64BIT | 294 | depends on SERIAL_NONSTANDARD |
295 | help | 295 | help |
296 | This is a driver for the Specialix RIO, a smart serial card which | 296 | This is a driver for the Specialix RIO, a smart serial card which |
297 | drives an outboard box that can support up to 128 ports. Product | 297 | drives an outboard box that can support up to 128 ports. Product |
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 02114a0bd0d9..128b2632512d 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c | |||
@@ -1981,10 +1981,6 @@ static int __init cmm_init(void) | |||
1981 | if (!cmm_class) | 1981 | if (!cmm_class) |
1982 | return -1; | 1982 | return -1; |
1983 | 1983 | ||
1984 | rc = pcmcia_register_driver(&cm4000_driver); | ||
1985 | if (rc < 0) | ||
1986 | return rc; | ||
1987 | |||
1988 | major = register_chrdev(0, DEVICE_NAME, &cm4000_fops); | 1984 | major = register_chrdev(0, DEVICE_NAME, &cm4000_fops); |
1989 | if (major < 0) { | 1985 | if (major < 0) { |
1990 | printk(KERN_WARNING MODULE_NAME | 1986 | printk(KERN_WARNING MODULE_NAME |
@@ -1992,6 +1988,12 @@ static int __init cmm_init(void) | |||
1992 | return -1; | 1988 | return -1; |
1993 | } | 1989 | } |
1994 | 1990 | ||
1991 | rc = pcmcia_register_driver(&cm4000_driver); | ||
1992 | if (rc < 0) { | ||
1993 | unregister_chrdev(major, DEVICE_NAME); | ||
1994 | return rc; | ||
1995 | } | ||
1996 | |||
1995 | return 0; | 1997 | return 0; |
1996 | } | 1998 | } |
1997 | 1999 | ||
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index 29efa64580a8..47a8465bf95b 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c | |||
@@ -724,16 +724,19 @@ static int __init cm4040_init(void) | |||
724 | if (!cmx_class) | 724 | if (!cmx_class) |
725 | return -1; | 725 | return -1; |
726 | 726 | ||
727 | rc = pcmcia_register_driver(&reader_driver); | ||
728 | if (rc < 0) | ||
729 | return rc; | ||
730 | |||
731 | major = register_chrdev(0, DEVICE_NAME, &reader_fops); | 727 | major = register_chrdev(0, DEVICE_NAME, &reader_fops); |
732 | if (major < 0) { | 728 | if (major < 0) { |
733 | printk(KERN_WARNING MODULE_NAME | 729 | printk(KERN_WARNING MODULE_NAME |
734 | ": could not get major number\n"); | 730 | ": could not get major number\n"); |
735 | return -1; | 731 | return -1; |
736 | } | 732 | } |
733 | |||
734 | rc = pcmcia_register_driver(&reader_driver); | ||
735 | if (rc < 0) { | ||
736 | unregister_chrdev(major, DEVICE_NAME); | ||
737 | return rc; | ||
738 | } | ||
739 | |||
737 | return 0; | 740 | return 0; |
738 | } | 741 | } |
739 | 742 | ||
diff --git a/drivers/char/rio/host.h b/drivers/char/rio/host.h index 3ec73d1a279a..179cdbea712b 100644 --- a/drivers/char/rio/host.h +++ b/drivers/char/rio/host.h | |||
@@ -33,12 +33,6 @@ | |||
33 | #ifndef __rio_host_h__ | 33 | #ifndef __rio_host_h__ |
34 | #define __rio_host_h__ | 34 | #define __rio_host_h__ |
35 | 35 | ||
36 | #ifdef SCCS_LABELS | ||
37 | #ifndef lint | ||
38 | static char *_host_h_sccs_ = "@(#)host.h 1.2"; | ||
39 | #endif | ||
40 | #endif | ||
41 | |||
42 | /* | 36 | /* |
43 | ** the host structure - one per host card in the system. | 37 | ** the host structure - one per host card in the system. |
44 | */ | 38 | */ |
@@ -77,9 +71,6 @@ struct Host { | |||
77 | #define RC_STARTUP 1 | 71 | #define RC_STARTUP 1 |
78 | #define RC_RUNNING 2 | 72 | #define RC_RUNNING 2 |
79 | #define RC_STUFFED 3 | 73 | #define RC_STUFFED 3 |
80 | #define RC_SOMETHING 4 | ||
81 | #define RC_SOMETHING_NEW 5 | ||
82 | #define RC_SOMETHING_ELSE 6 | ||
83 | #define RC_READY 7 | 74 | #define RC_READY 7 |
84 | #define RUN_STATE 7 | 75 | #define RUN_STATE 7 |
85 | /* | 76 | /* |
diff --git a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c index acda9326c2ef..290143addd34 100644 --- a/drivers/char/rio/rioboot.c +++ b/drivers/char/rio/rioboot.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/termios.h> | 35 | #include <linux/termios.h> |
36 | #include <linux/serial.h> | 36 | #include <linux/serial.h> |
37 | #include <linux/vmalloc.h> | ||
37 | #include <asm/semaphore.h> | 38 | #include <asm/semaphore.h> |
38 | #include <linux/generic_serial.h> | 39 | #include <linux/generic_serial.h> |
39 | #include <linux/errno.h> | 40 | #include <linux/errno.h> |
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c index d31aba62bb7f..75b2557c37ec 100644 --- a/drivers/char/rio/rioctrl.c +++ b/drivers/char/rio/rioctrl.c | |||
@@ -1394,14 +1394,17 @@ int RIOPreemptiveCmd(struct rio_info *p, struct Port *PortP, u8 Cmd) | |||
1394 | return RIO_FAIL; | 1394 | return RIO_FAIL; |
1395 | } | 1395 | } |
1396 | 1396 | ||
1397 | if (((int) ((char) PortP->InUse) == -1) || !(CmdBlkP = RIOGetCmdBlk())) { | 1397 | if ((PortP->InUse == (typeof(PortP->InUse))-1) || |
1398 | rio_dprintk(RIO_DEBUG_CTRL, "Cannot allocate command block for command %d on port %d\n", Cmd, PortP->PortNum); | 1398 | !(CmdBlkP = RIOGetCmdBlk())) { |
1399 | rio_dprintk(RIO_DEBUG_CTRL, "Cannot allocate command block " | ||
1400 | "for command %d on port %d\n", Cmd, PortP->PortNum); | ||
1399 | return RIO_FAIL; | 1401 | return RIO_FAIL; |
1400 | } | 1402 | } |
1401 | 1403 | ||
1402 | rio_dprintk(RIO_DEBUG_CTRL, "Command blk %p - InUse now %d\n", CmdBlkP, PortP->InUse); | 1404 | rio_dprintk(RIO_DEBUG_CTRL, "Command blk %p - InUse now %d\n", |
1405 | CmdBlkP, PortP->InUse); | ||
1403 | 1406 | ||
1404 | PktCmdP = (struct PktCmd_M *) &CmdBlkP->Packet.data[0]; | 1407 | PktCmdP = (struct PktCmd_M *)&CmdBlkP->Packet.data[0]; |
1405 | 1408 | ||
1406 | CmdBlkP->Packet.src_unit = 0; | 1409 | CmdBlkP->Packet.src_unit = 0; |
1407 | if (PortP->SecondBlock) | 1410 | if (PortP->SecondBlock) |
@@ -1425,38 +1428,46 @@ int RIOPreemptiveCmd(struct rio_info *p, struct Port *PortP, u8 Cmd) | |||
1425 | 1428 | ||
1426 | switch (Cmd) { | 1429 | switch (Cmd) { |
1427 | case MEMDUMP: | 1430 | case MEMDUMP: |
1428 | rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk %p (addr 0x%x)\n", CmdBlkP, (int) SubCmd.Addr); | 1431 | rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk %p " |
1432 | "(addr 0x%x)\n", CmdBlkP, (int) SubCmd.Addr); | ||
1429 | PktCmdP->SubCommand = MEMDUMP; | 1433 | PktCmdP->SubCommand = MEMDUMP; |
1430 | PktCmdP->SubAddr = SubCmd.Addr; | 1434 | PktCmdP->SubAddr = SubCmd.Addr; |
1431 | break; | 1435 | break; |
1432 | case FCLOSE: | 1436 | case FCLOSE: |
1433 | rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk %p\n", CmdBlkP); | 1437 | rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk %p\n", |
1438 | CmdBlkP); | ||
1434 | break; | 1439 | break; |
1435 | case READ_REGISTER: | 1440 | case READ_REGISTER: |
1436 | rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk %p\n", (int) SubCmd.Addr, CmdBlkP); | 1441 | rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) " |
1442 | "command blk %p\n", (int) SubCmd.Addr, CmdBlkP); | ||
1437 | PktCmdP->SubCommand = READ_REGISTER; | 1443 | PktCmdP->SubCommand = READ_REGISTER; |
1438 | PktCmdP->SubAddr = SubCmd.Addr; | 1444 | PktCmdP->SubAddr = SubCmd.Addr; |
1439 | break; | 1445 | break; |
1440 | case RESUME: | 1446 | case RESUME: |
1441 | rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk %p\n", CmdBlkP); | 1447 | rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk %p\n", |
1448 | CmdBlkP); | ||
1442 | break; | 1449 | break; |
1443 | case RFLUSH: | 1450 | case RFLUSH: |
1444 | rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk %p\n", CmdBlkP); | 1451 | rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk %p\n", |
1452 | CmdBlkP); | ||
1445 | CmdBlkP->PostFuncP = RIORFlushEnable; | 1453 | CmdBlkP->PostFuncP = RIORFlushEnable; |
1446 | break; | 1454 | break; |
1447 | case SUSPEND: | 1455 | case SUSPEND: |
1448 | rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk %p\n", CmdBlkP); | 1456 | rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk %p\n", |
1457 | CmdBlkP); | ||
1449 | break; | 1458 | break; |
1450 | 1459 | ||
1451 | case MGET: | 1460 | case MGET: |
1452 | rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk %p\n", CmdBlkP); | 1461 | rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk %p\n", |
1462 | CmdBlkP); | ||
1453 | break; | 1463 | break; |
1454 | 1464 | ||
1455 | case MSET: | 1465 | case MSET: |
1456 | case MBIC: | 1466 | case MBIC: |
1457 | case MBIS: | 1467 | case MBIS: |
1458 | CmdBlkP->Packet.data[4] = (char) PortP->ModemLines; | 1468 | CmdBlkP->Packet.data[4] = (char) PortP->ModemLines; |
1459 | rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk %p\n", CmdBlkP); | 1469 | rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command " |
1470 | "blk %p\n", CmdBlkP); | ||
1460 | break; | 1471 | break; |
1461 | 1472 | ||
1462 | case WFLUSH: | 1473 | case WFLUSH: |
@@ -1465,12 +1476,14 @@ int RIOPreemptiveCmd(struct rio_info *p, struct Port *PortP, u8 Cmd) | |||
1465 | ** allowed then we should not bother sending any more to the | 1476 | ** allowed then we should not bother sending any more to the |
1466 | ** RTA. | 1477 | ** RTA. |
1467 | */ | 1478 | */ |
1468 | if ((int) ((char) PortP->WflushFlag) == (int) -1) { | 1479 | if (PortP->WflushFlag == (typeof(PortP->WflushFlag))-1) { |
1469 | rio_dprintk(RIO_DEBUG_CTRL, "Trashed WFLUSH, WflushFlag about to wrap!"); | 1480 | rio_dprintk(RIO_DEBUG_CTRL, "Trashed WFLUSH, " |
1481 | "WflushFlag about to wrap!"); | ||
1470 | RIOFreeCmdBlk(CmdBlkP); | 1482 | RIOFreeCmdBlk(CmdBlkP); |
1471 | return (RIO_FAIL); | 1483 | return (RIO_FAIL); |
1472 | } else { | 1484 | } else { |
1473 | rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command blk %p\n", CmdBlkP); | 1485 | rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command " |
1486 | "blk %p\n", CmdBlkP); | ||
1474 | CmdBlkP->PostFuncP = RIOWFlushMark; | 1487 | CmdBlkP->PostFuncP = RIOWFlushMark; |
1475 | } | 1488 | } |
1476 | break; | 1489 | break; |
diff --git a/drivers/char/rio/rioioctl.h b/drivers/char/rio/rioioctl.h index 14b83fae75c8..e8af5b30519e 100644 --- a/drivers/char/rio/rioioctl.h +++ b/drivers/char/rio/rioioctl.h | |||
@@ -33,10 +33,6 @@ | |||
33 | #ifndef __rioioctl_h__ | 33 | #ifndef __rioioctl_h__ |
34 | #define __rioioctl_h__ | 34 | #define __rioioctl_h__ |
35 | 35 | ||
36 | #ifdef SCCS_LABELS | ||
37 | static char *_rioioctl_h_sccs_ = "@(#)rioioctl.h 1.2"; | ||
38 | #endif | ||
39 | |||
40 | /* | 36 | /* |
41 | ** RIO device driver - user ioctls and associated structures. | 37 | ** RIO device driver - user ioctls and associated structures. |
42 | */ | 38 | */ |
@@ -44,55 +40,13 @@ static char *_rioioctl_h_sccs_ = "@(#)rioioctl.h 1.2"; | |||
44 | struct portStats { | 40 | struct portStats { |
45 | int port; | 41 | int port; |
46 | int gather; | 42 | int gather; |
47 | ulong txchars; | 43 | unsigned long txchars; |
48 | ulong rxchars; | 44 | unsigned long rxchars; |
49 | ulong opens; | 45 | unsigned long opens; |
50 | ulong closes; | 46 | unsigned long closes; |
51 | ulong ioctls; | 47 | unsigned long ioctls; |
52 | }; | 48 | }; |
53 | 49 | ||
54 | |||
55 | #define rIOC ('r'<<8) | ||
56 | #define TCRIOSTATE (rIOC | 1) | ||
57 | #define TCRIOXPON (rIOC | 2) | ||
58 | #define TCRIOXPOFF (rIOC | 3) | ||
59 | #define TCRIOXPCPS (rIOC | 4) | ||
60 | #define TCRIOXPRINT (rIOC | 5) | ||
61 | #define TCRIOIXANYON (rIOC | 6) | ||
62 | #define TCRIOIXANYOFF (rIOC | 7) | ||
63 | #define TCRIOIXONON (rIOC | 8) | ||
64 | #define TCRIOIXONOFF (rIOC | 9) | ||
65 | #define TCRIOMBIS (rIOC | 10) | ||
66 | #define TCRIOMBIC (rIOC | 11) | ||
67 | #define TCRIOTRIAD (rIOC | 12) | ||
68 | #define TCRIOTSTATE (rIOC | 13) | ||
69 | |||
70 | /* | ||
71 | ** 15.10.1998 ARG - ESIL 0761 part fix | ||
72 | ** Add RIO ioctls for manipulating RTS and CTS flow control, (as LynxOS | ||
73 | ** appears to not support hardware flow control). | ||
74 | */ | ||
75 | #define TCRIOCTSFLOWEN (rIOC | 14) /* enable CTS flow control */ | ||
76 | #define TCRIOCTSFLOWDIS (rIOC | 15) /* disable CTS flow control */ | ||
77 | #define TCRIORTSFLOWEN (rIOC | 16) /* enable RTS flow control */ | ||
78 | #define TCRIORTSFLOWDIS (rIOC | 17) /* disable RTS flow control */ | ||
79 | |||
80 | /* | ||
81 | ** 09.12.1998 ARG - ESIL 0776 part fix | ||
82 | ** Definition for 'RIOC' also appears in daemon.h, so we'd better do a | ||
83 | ** #ifndef here first. | ||
84 | ** 'RIO_QUICK_CHECK' also #define'd here as this ioctl is now | ||
85 | ** allowed to be used by customers. | ||
86 | ** | ||
87 | ** 05.02.1999 ARG - | ||
88 | ** This is what I've decied to do with ioctls etc., which are intended to be | ||
89 | ** invoked from users applications : | ||
90 | ** Anything that needs to be defined here will be removed from daemon.h, that | ||
91 | ** way it won't end up having to be defined/maintained in two places. The only | ||
92 | ** consequence of this is that this file should now be #include'd by daemon.h | ||
93 | ** | ||
94 | ** 'stats' ioctls now #define'd here as they are to be used by customers. | ||
95 | */ | ||
96 | #define RIOC ('R'<<8)|('i'<<16)|('o'<<24) | 50 | #define RIOC ('R'<<8)|('i'<<16)|('o'<<24) |
97 | 51 | ||
98 | #define RIO_QUICK_CHECK (RIOC | 105) | 52 | #define RIO_QUICK_CHECK (RIOC | 105) |
diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig index 1efde3b27619..fe00c7dfb649 100644 --- a/drivers/char/tpm/Kconfig +++ b/drivers/char/tpm/Kconfig | |||
@@ -22,7 +22,7 @@ config TCG_TPM | |||
22 | 22 | ||
23 | config TCG_TIS | 23 | config TCG_TIS |
24 | tristate "TPM Interface Specification 1.2 Interface" | 24 | tristate "TPM Interface Specification 1.2 Interface" |
25 | depends on TCG_TPM | 25 | depends on TCG_TPM && PNPACPI |
26 | ---help--- | 26 | ---help--- |
27 | If you have a TPM security chip that is compliant with the | 27 | If you have a TPM security chip that is compliant with the |
28 | TCG TIS 1.2 TPM specification say Yes and it will be accessible | 28 | TCG TIS 1.2 TPM specification say Yes and it will be accessible |
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 54a4c804e25f..050ced247f68 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h | |||
@@ -140,7 +140,7 @@ extern int tpm_pm_resume(struct device *); | |||
140 | extern struct dentry ** tpm_bios_log_setup(char *); | 140 | extern struct dentry ** tpm_bios_log_setup(char *); |
141 | extern void tpm_bios_log_teardown(struct dentry **); | 141 | extern void tpm_bios_log_teardown(struct dentry **); |
142 | #else | 142 | #else |
143 | static inline struct dentry* tpm_bios_log_setup(char *name) | 143 | static inline struct dentry ** tpm_bios_log_setup(char *name) |
144 | { | 144 | { |
145 | return NULL; | 145 | return NULL; |
146 | } | 146 | } |
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index b9cae9a238bb..f621168f38ae 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c | |||
@@ -55,7 +55,7 @@ enum tis_int_flags { | |||
55 | }; | 55 | }; |
56 | 56 | ||
57 | enum tis_defaults { | 57 | enum tis_defaults { |
58 | TIS_MEM_BASE = 0xFED4000, | 58 | TIS_MEM_BASE = 0xFED40000, |
59 | TIS_MEM_LEN = 0x5000, | 59 | TIS_MEM_LEN = 0x5000, |
60 | TIS_SHORT_TIMEOUT = 750, /* ms */ | 60 | TIS_SHORT_TIMEOUT = 750, /* ms */ |
61 | TIS_LONG_TIMEOUT = 2000, /* 2 sec */ | 61 | TIS_LONG_TIMEOUT = 2000, /* 2 sec */ |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 956d121cb161..3e6ffcaa5af4 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -74,6 +74,8 @@ static unsigned int dbs_enable; /* number of CPUs using this policy */ | |||
74 | static DEFINE_MUTEX (dbs_mutex); | 74 | static DEFINE_MUTEX (dbs_mutex); |
75 | static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); | 75 | static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); |
76 | 76 | ||
77 | static struct workqueue_struct *dbs_workq; | ||
78 | |||
77 | struct dbs_tuners { | 79 | struct dbs_tuners { |
78 | unsigned int sampling_rate; | 80 | unsigned int sampling_rate; |
79 | unsigned int sampling_down_factor; | 81 | unsigned int sampling_down_factor; |
@@ -364,23 +366,29 @@ static void do_dbs_timer(void *data) | |||
364 | mutex_lock(&dbs_mutex); | 366 | mutex_lock(&dbs_mutex); |
365 | for_each_online_cpu(i) | 367 | for_each_online_cpu(i) |
366 | dbs_check_cpu(i); | 368 | dbs_check_cpu(i); |
367 | schedule_delayed_work(&dbs_work, | 369 | queue_delayed_work(dbs_workq, &dbs_work, |
368 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); | 370 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); |
369 | mutex_unlock(&dbs_mutex); | 371 | mutex_unlock(&dbs_mutex); |
370 | } | 372 | } |
371 | 373 | ||
372 | static inline void dbs_timer_init(void) | 374 | static inline void dbs_timer_init(void) |
373 | { | 375 | { |
374 | INIT_WORK(&dbs_work, do_dbs_timer, NULL); | 376 | INIT_WORK(&dbs_work, do_dbs_timer, NULL); |
375 | schedule_delayed_work(&dbs_work, | 377 | if (!dbs_workq) |
376 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); | 378 | dbs_workq = create_singlethread_workqueue("ondemand"); |
379 | if (!dbs_workq) { | ||
380 | printk(KERN_ERR "ondemand: Cannot initialize kernel thread\n"); | ||
381 | return; | ||
382 | } | ||
383 | queue_delayed_work(dbs_workq, &dbs_work, | ||
384 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); | ||
377 | return; | 385 | return; |
378 | } | 386 | } |
379 | 387 | ||
380 | static inline void dbs_timer_exit(void) | 388 | static inline void dbs_timer_exit(void) |
381 | { | 389 | { |
382 | cancel_delayed_work(&dbs_work); | 390 | if (dbs_workq) |
383 | return; | 391 | cancel_rearming_delayed_workqueue(dbs_workq, &dbs_work); |
384 | } | 392 | } |
385 | 393 | ||
386 | static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | 394 | static int cpufreq_governor_dbs(struct cpufreq_policy *policy, |
@@ -489,8 +497,12 @@ static int __init cpufreq_gov_dbs_init(void) | |||
489 | 497 | ||
490 | static void __exit cpufreq_gov_dbs_exit(void) | 498 | static void __exit cpufreq_gov_dbs_exit(void) |
491 | { | 499 | { |
492 | /* Make sure that the scheduled work is indeed not running */ | 500 | /* Make sure that the scheduled work is indeed not running. |
493 | flush_scheduled_work(); | 501 | Assumes the timer has been cancelled first. */ |
502 | if (dbs_workq) { | ||
503 | flush_workqueue(dbs_workq); | ||
504 | destroy_workqueue(dbs_workq); | ||
505 | } | ||
494 | 506 | ||
495 | cpufreq_unregister_governor(&cpufreq_gov_dbs); | 507 | cpufreq_unregister_governor(&cpufreq_gov_dbs); |
496 | } | 508 | } |
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c index 66572c5323ad..fce31936e6d7 100644 --- a/drivers/edac/e752x_edac.c +++ b/drivers/edac/e752x_edac.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include "edac_mc.h" | 26 | #include "edac_mc.h" |
27 | 27 | ||
28 | static int force_function_unhide; | ||
29 | |||
28 | #define e752x_printk(level, fmt, arg...) \ | 30 | #define e752x_printk(level, fmt, arg...) \ |
29 | edac_printk(level, "e752x", fmt, ##arg) | 31 | edac_printk(level, "e752x", fmt, ##arg) |
30 | 32 | ||
@@ -782,8 +784,16 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx) | |||
782 | debugf0("%s(): mci\n", __func__); | 784 | debugf0("%s(): mci\n", __func__); |
783 | debugf0("Starting Probe1\n"); | 785 | debugf0("Starting Probe1\n"); |
784 | 786 | ||
785 | /* enable device 0 function 1 */ | 787 | /* check to see if device 0 function 1 is enabled; if it isn't, we |
788 | * assume the BIOS has reserved it for a reason and is expecting | ||
789 | * exclusive access, we take care not to violate that assumption and | ||
790 | * fail the probe. */ | ||
786 | pci_read_config_byte(pdev, E752X_DEVPRES1, &stat8); | 791 | pci_read_config_byte(pdev, E752X_DEVPRES1, &stat8); |
792 | if (!force_function_unhide && !(stat8 & (1 << 5))) { | ||
793 | printk(KERN_INFO "Contact your BIOS vendor to see if the " | ||
794 | "E752x error registers can be safely un-hidden\n"); | ||
795 | goto fail; | ||
796 | } | ||
787 | stat8 |= (1 << 5); | 797 | stat8 |= (1 << 5); |
788 | pci_write_config_byte(pdev, E752X_DEVPRES1, stat8); | 798 | pci_write_config_byte(pdev, E752X_DEVPRES1, stat8); |
789 | 799 | ||
@@ -1063,3 +1073,8 @@ module_exit(e752x_exit); | |||
1063 | MODULE_LICENSE("GPL"); | 1073 | MODULE_LICENSE("GPL"); |
1064 | MODULE_AUTHOR("Linux Networx (http://lnxi.com) Tom Zimmerman\n"); | 1074 | MODULE_AUTHOR("Linux Networx (http://lnxi.com) Tom Zimmerman\n"); |
1065 | MODULE_DESCRIPTION("MC support for Intel e752x memory controllers"); | 1075 | MODULE_DESCRIPTION("MC support for Intel e752x memory controllers"); |
1076 | |||
1077 | module_param(force_function_unhide, int, 0444); | ||
1078 | MODULE_PARM_DESC(force_function_unhide, "if BIOS sets Dev0:Fun1 up as hidden:" | ||
1079 | " 1=force unhide and hope BIOS doesn't fight driver for Dev0:Fun1 access"); | ||
1080 | |||
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index 8bd305e47f0d..a140e4536a4e 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c | |||
@@ -133,6 +133,9 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status) | |||
133 | 133 | ||
134 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); | 134 | outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1); |
135 | outb(ACBST_STASTR | ACBST_NEGACK, ACBST); | 135 | outb(ACBST_STASTR | ACBST_NEGACK, ACBST); |
136 | |||
137 | /* Reset the status register */ | ||
138 | outb(0, ACBST); | ||
136 | return; | 139 | return; |
137 | } | 140 | } |
138 | 141 | ||
@@ -228,6 +231,10 @@ static void scx200_acb_poll(struct scx200_acb_iface *iface) | |||
228 | timeout = jiffies + POLL_TIMEOUT; | 231 | timeout = jiffies + POLL_TIMEOUT; |
229 | while (time_before(jiffies, timeout)) { | 232 | while (time_before(jiffies, timeout)) { |
230 | status = inb(ACBST); | 233 | status = inb(ACBST); |
234 | |||
235 | /* Reset the status register to avoid the hang */ | ||
236 | outb(0, ACBST); | ||
237 | |||
231 | if ((status & (ACBST_SDAST|ACBST_BER|ACBST_NEGACK)) != 0) { | 238 | if ((status & (ACBST_SDAST|ACBST_BER|ACBST_NEGACK)) != 0) { |
232 | scx200_acb_machine(iface, status); | 239 | scx200_acb_machine(iface, status); |
233 | return; | 240 | return; |
@@ -415,7 +422,6 @@ static int __init scx200_acb_create(const char *text, int base, int index) | |||
415 | struct scx200_acb_iface *iface; | 422 | struct scx200_acb_iface *iface; |
416 | struct i2c_adapter *adapter; | 423 | struct i2c_adapter *adapter; |
417 | int rc; | 424 | int rc; |
418 | char description[64]; | ||
419 | 425 | ||
420 | iface = kzalloc(sizeof(*iface), GFP_KERNEL); | 426 | iface = kzalloc(sizeof(*iface), GFP_KERNEL); |
421 | if (!iface) { | 427 | if (!iface) { |
@@ -434,10 +440,7 @@ static int __init scx200_acb_create(const char *text, int base, int index) | |||
434 | 440 | ||
435 | mutex_init(&iface->mutex); | 441 | mutex_init(&iface->mutex); |
436 | 442 | ||
437 | snprintf(description, sizeof(description), "%s ACCESS.bus [%s]", | 443 | if (!request_region(base, 8, adapter->name)) { |
438 | text, adapter->name); | ||
439 | |||
440 | if (request_region(base, 8, description) == 0) { | ||
441 | printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n", | 444 | printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n", |
442 | base, base + 8-1); | 445 | base, base + 8-1); |
443 | rc = -EBUSY; | 446 | rc = -EBUSY; |
@@ -524,6 +527,9 @@ static int __init scx200_acb_init(void) | |||
524 | } else if (pci_dev_present(divil_pci)) | 527 | } else if (pci_dev_present(divil_pci)) |
525 | rc = scx200_add_cs553x(); | 528 | rc = scx200_add_cs553x(); |
526 | 529 | ||
530 | /* If at least one bus was created, init must succeed */ | ||
531 | if (scx200_acb_list) | ||
532 | return 0; | ||
527 | return rc; | 533 | return rc; |
528 | } | 534 | } |
529 | 535 | ||
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index 4961f1e764a7..602797a44208 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c | |||
@@ -392,6 +392,7 @@ static struct pcmcia_device_id ide_ids[] = { | |||
392 | PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e), | 392 | PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e), |
393 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae), | 393 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae), |
394 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178), | 394 | PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178), |
395 | PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178), | ||
395 | PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), | 396 | PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), |
396 | PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b), | 397 | PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b), |
397 | PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149), | 398 | PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149), |
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 7cfedb8d9bcd..86fee43502cd 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c | |||
@@ -34,6 +34,8 @@ | |||
34 | * | 34 | * |
35 | * $Id: cm.c 2821 2005-07-08 17:07:28Z sean.hefty $ | 35 | * $Id: cm.c 2821 2005-07-08 17:07:28Z sean.hefty $ |
36 | */ | 36 | */ |
37 | |||
38 | #include <linux/completion.h> | ||
37 | #include <linux/dma-mapping.h> | 39 | #include <linux/dma-mapping.h> |
38 | #include <linux/err.h> | 40 | #include <linux/err.h> |
39 | #include <linux/idr.h> | 41 | #include <linux/idr.h> |
@@ -122,7 +124,7 @@ struct cm_id_private { | |||
122 | struct rb_node service_node; | 124 | struct rb_node service_node; |
123 | struct rb_node sidr_id_node; | 125 | struct rb_node sidr_id_node; |
124 | spinlock_t lock; /* Do not acquire inside cm.lock */ | 126 | spinlock_t lock; /* Do not acquire inside cm.lock */ |
125 | wait_queue_head_t wait; | 127 | struct completion comp; |
126 | atomic_t refcount; | 128 | atomic_t refcount; |
127 | 129 | ||
128 | struct ib_mad_send_buf *msg; | 130 | struct ib_mad_send_buf *msg; |
@@ -159,7 +161,7 @@ static void cm_work_handler(void *data); | |||
159 | static inline void cm_deref_id(struct cm_id_private *cm_id_priv) | 161 | static inline void cm_deref_id(struct cm_id_private *cm_id_priv) |
160 | { | 162 | { |
161 | if (atomic_dec_and_test(&cm_id_priv->refcount)) | 163 | if (atomic_dec_and_test(&cm_id_priv->refcount)) |
162 | wake_up(&cm_id_priv->wait); | 164 | complete(&cm_id_priv->comp); |
163 | } | 165 | } |
164 | 166 | ||
165 | static int cm_alloc_msg(struct cm_id_private *cm_id_priv, | 167 | static int cm_alloc_msg(struct cm_id_private *cm_id_priv, |
@@ -559,7 +561,7 @@ struct ib_cm_id *ib_create_cm_id(struct ib_device *device, | |||
559 | goto error; | 561 | goto error; |
560 | 562 | ||
561 | spin_lock_init(&cm_id_priv->lock); | 563 | spin_lock_init(&cm_id_priv->lock); |
562 | init_waitqueue_head(&cm_id_priv->wait); | 564 | init_completion(&cm_id_priv->comp); |
563 | INIT_LIST_HEAD(&cm_id_priv->work_list); | 565 | INIT_LIST_HEAD(&cm_id_priv->work_list); |
564 | atomic_set(&cm_id_priv->work_count, -1); | 566 | atomic_set(&cm_id_priv->work_count, -1); |
565 | atomic_set(&cm_id_priv->refcount, 1); | 567 | atomic_set(&cm_id_priv->refcount, 1); |
@@ -724,8 +726,8 @@ retest: | |||
724 | } | 726 | } |
725 | 727 | ||
726 | cm_free_id(cm_id->local_id); | 728 | cm_free_id(cm_id->local_id); |
727 | atomic_dec(&cm_id_priv->refcount); | 729 | cm_deref_id(cm_id_priv); |
728 | wait_event(cm_id_priv->wait, !atomic_read(&cm_id_priv->refcount)); | 730 | wait_for_completion(&cm_id_priv->comp); |
729 | while ((work = cm_dequeue_work(cm_id_priv)) != NULL) | 731 | while ((work = cm_dequeue_work(cm_id_priv)) != NULL) |
730 | cm_free_work(work); | 732 | cm_free_work(work); |
731 | if (cm_id_priv->private_data && cm_id_priv->private_data_len) | 733 | if (cm_id_priv->private_data && cm_id_priv->private_data_len) |
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index 469b6923a2e2..5ad41a64314c 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c | |||
@@ -352,7 +352,7 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, | |||
352 | INIT_WORK(&mad_agent_priv->local_work, local_completions, | 352 | INIT_WORK(&mad_agent_priv->local_work, local_completions, |
353 | mad_agent_priv); | 353 | mad_agent_priv); |
354 | atomic_set(&mad_agent_priv->refcount, 1); | 354 | atomic_set(&mad_agent_priv->refcount, 1); |
355 | init_waitqueue_head(&mad_agent_priv->wait); | 355 | init_completion(&mad_agent_priv->comp); |
356 | 356 | ||
357 | return &mad_agent_priv->agent; | 357 | return &mad_agent_priv->agent; |
358 | 358 | ||
@@ -467,7 +467,7 @@ struct ib_mad_agent *ib_register_mad_snoop(struct ib_device *device, | |||
467 | mad_snoop_priv->agent.qp = port_priv->qp_info[qpn].qp; | 467 | mad_snoop_priv->agent.qp = port_priv->qp_info[qpn].qp; |
468 | mad_snoop_priv->agent.port_num = port_num; | 468 | mad_snoop_priv->agent.port_num = port_num; |
469 | mad_snoop_priv->mad_snoop_flags = mad_snoop_flags; | 469 | mad_snoop_priv->mad_snoop_flags = mad_snoop_flags; |
470 | init_waitqueue_head(&mad_snoop_priv->wait); | 470 | init_completion(&mad_snoop_priv->comp); |
471 | mad_snoop_priv->snoop_index = register_snoop_agent( | 471 | mad_snoop_priv->snoop_index = register_snoop_agent( |
472 | &port_priv->qp_info[qpn], | 472 | &port_priv->qp_info[qpn], |
473 | mad_snoop_priv); | 473 | mad_snoop_priv); |
@@ -486,6 +486,18 @@ error1: | |||
486 | } | 486 | } |
487 | EXPORT_SYMBOL(ib_register_mad_snoop); | 487 | EXPORT_SYMBOL(ib_register_mad_snoop); |
488 | 488 | ||
489 | static inline void deref_mad_agent(struct ib_mad_agent_private *mad_agent_priv) | ||
490 | { | ||
491 | if (atomic_dec_and_test(&mad_agent_priv->refcount)) | ||
492 | complete(&mad_agent_priv->comp); | ||
493 | } | ||
494 | |||
495 | static inline void deref_snoop_agent(struct ib_mad_snoop_private *mad_snoop_priv) | ||
496 | { | ||
497 | if (atomic_dec_and_test(&mad_snoop_priv->refcount)) | ||
498 | complete(&mad_snoop_priv->comp); | ||
499 | } | ||
500 | |||
489 | static void unregister_mad_agent(struct ib_mad_agent_private *mad_agent_priv) | 501 | static void unregister_mad_agent(struct ib_mad_agent_private *mad_agent_priv) |
490 | { | 502 | { |
491 | struct ib_mad_port_private *port_priv; | 503 | struct ib_mad_port_private *port_priv; |
@@ -509,9 +521,8 @@ static void unregister_mad_agent(struct ib_mad_agent_private *mad_agent_priv) | |||
509 | flush_workqueue(port_priv->wq); | 521 | flush_workqueue(port_priv->wq); |
510 | ib_cancel_rmpp_recvs(mad_agent_priv); | 522 | ib_cancel_rmpp_recvs(mad_agent_priv); |
511 | 523 | ||
512 | atomic_dec(&mad_agent_priv->refcount); | 524 | deref_mad_agent(mad_agent_priv); |
513 | wait_event(mad_agent_priv->wait, | 525 | wait_for_completion(&mad_agent_priv->comp); |
514 | !atomic_read(&mad_agent_priv->refcount)); | ||
515 | 526 | ||
516 | kfree(mad_agent_priv->reg_req); | 527 | kfree(mad_agent_priv->reg_req); |
517 | ib_dereg_mr(mad_agent_priv->agent.mr); | 528 | ib_dereg_mr(mad_agent_priv->agent.mr); |
@@ -529,9 +540,8 @@ static void unregister_mad_snoop(struct ib_mad_snoop_private *mad_snoop_priv) | |||
529 | atomic_dec(&qp_info->snoop_count); | 540 | atomic_dec(&qp_info->snoop_count); |
530 | spin_unlock_irqrestore(&qp_info->snoop_lock, flags); | 541 | spin_unlock_irqrestore(&qp_info->snoop_lock, flags); |
531 | 542 | ||
532 | atomic_dec(&mad_snoop_priv->refcount); | 543 | deref_snoop_agent(mad_snoop_priv); |
533 | wait_event(mad_snoop_priv->wait, | 544 | wait_for_completion(&mad_snoop_priv->comp); |
534 | !atomic_read(&mad_snoop_priv->refcount)); | ||
535 | 545 | ||
536 | kfree(mad_snoop_priv); | 546 | kfree(mad_snoop_priv); |
537 | } | 547 | } |
@@ -600,8 +610,7 @@ static void snoop_send(struct ib_mad_qp_info *qp_info, | |||
600 | spin_unlock_irqrestore(&qp_info->snoop_lock, flags); | 610 | spin_unlock_irqrestore(&qp_info->snoop_lock, flags); |
601 | mad_snoop_priv->agent.snoop_handler(&mad_snoop_priv->agent, | 611 | mad_snoop_priv->agent.snoop_handler(&mad_snoop_priv->agent, |
602 | send_buf, mad_send_wc); | 612 | send_buf, mad_send_wc); |
603 | if (atomic_dec_and_test(&mad_snoop_priv->refcount)) | 613 | deref_snoop_agent(mad_snoop_priv); |
604 | wake_up(&mad_snoop_priv->wait); | ||
605 | spin_lock_irqsave(&qp_info->snoop_lock, flags); | 614 | spin_lock_irqsave(&qp_info->snoop_lock, flags); |
606 | } | 615 | } |
607 | spin_unlock_irqrestore(&qp_info->snoop_lock, flags); | 616 | spin_unlock_irqrestore(&qp_info->snoop_lock, flags); |
@@ -626,8 +635,7 @@ static void snoop_recv(struct ib_mad_qp_info *qp_info, | |||
626 | spin_unlock_irqrestore(&qp_info->snoop_lock, flags); | 635 | spin_unlock_irqrestore(&qp_info->snoop_lock, flags); |
627 | mad_snoop_priv->agent.recv_handler(&mad_snoop_priv->agent, | 636 | mad_snoop_priv->agent.recv_handler(&mad_snoop_priv->agent, |
628 | mad_recv_wc); | 637 | mad_recv_wc); |
629 | if (atomic_dec_and_test(&mad_snoop_priv->refcount)) | 638 | deref_snoop_agent(mad_snoop_priv); |
630 | wake_up(&mad_snoop_priv->wait); | ||
631 | spin_lock_irqsave(&qp_info->snoop_lock, flags); | 639 | spin_lock_irqsave(&qp_info->snoop_lock, flags); |
632 | } | 640 | } |
633 | spin_unlock_irqrestore(&qp_info->snoop_lock, flags); | 641 | spin_unlock_irqrestore(&qp_info->snoop_lock, flags); |
@@ -968,8 +976,7 @@ void ib_free_send_mad(struct ib_mad_send_buf *send_buf) | |||
968 | 976 | ||
969 | free_send_rmpp_list(mad_send_wr); | 977 | free_send_rmpp_list(mad_send_wr); |
970 | kfree(send_buf->mad); | 978 | kfree(send_buf->mad); |
971 | if (atomic_dec_and_test(&mad_agent_priv->refcount)) | 979 | deref_mad_agent(mad_agent_priv); |
972 | wake_up(&mad_agent_priv->wait); | ||
973 | } | 980 | } |
974 | EXPORT_SYMBOL(ib_free_send_mad); | 981 | EXPORT_SYMBOL(ib_free_send_mad); |
975 | 982 | ||
@@ -1757,8 +1764,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, | |||
1757 | mad_recv_wc = ib_process_rmpp_recv_wc(mad_agent_priv, | 1764 | mad_recv_wc = ib_process_rmpp_recv_wc(mad_agent_priv, |
1758 | mad_recv_wc); | 1765 | mad_recv_wc); |
1759 | if (!mad_recv_wc) { | 1766 | if (!mad_recv_wc) { |
1760 | if (atomic_dec_and_test(&mad_agent_priv->refcount)) | 1767 | deref_mad_agent(mad_agent_priv); |
1761 | wake_up(&mad_agent_priv->wait); | ||
1762 | return; | 1768 | return; |
1763 | } | 1769 | } |
1764 | } | 1770 | } |
@@ -1770,8 +1776,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, | |||
1770 | if (!mad_send_wr) { | 1776 | if (!mad_send_wr) { |
1771 | spin_unlock_irqrestore(&mad_agent_priv->lock, flags); | 1777 | spin_unlock_irqrestore(&mad_agent_priv->lock, flags); |
1772 | ib_free_recv_mad(mad_recv_wc); | 1778 | ib_free_recv_mad(mad_recv_wc); |
1773 | if (atomic_dec_and_test(&mad_agent_priv->refcount)) | 1779 | deref_mad_agent(mad_agent_priv); |
1774 | wake_up(&mad_agent_priv->wait); | ||
1775 | return; | 1780 | return; |
1776 | } | 1781 | } |
1777 | ib_mark_mad_done(mad_send_wr); | 1782 | ib_mark_mad_done(mad_send_wr); |
@@ -1790,8 +1795,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, | |||
1790 | } else { | 1795 | } else { |
1791 | mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent, | 1796 | mad_agent_priv->agent.recv_handler(&mad_agent_priv->agent, |
1792 | mad_recv_wc); | 1797 | mad_recv_wc); |
1793 | if (atomic_dec_and_test(&mad_agent_priv->refcount)) | 1798 | deref_mad_agent(mad_agent_priv); |
1794 | wake_up(&mad_agent_priv->wait); | ||
1795 | } | 1799 | } |
1796 | } | 1800 | } |
1797 | 1801 | ||
@@ -2021,8 +2025,7 @@ void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr, | |||
2021 | mad_send_wc); | 2025 | mad_send_wc); |
2022 | 2026 | ||
2023 | /* Release reference on agent taken when sending */ | 2027 | /* Release reference on agent taken when sending */ |
2024 | if (atomic_dec_and_test(&mad_agent_priv->refcount)) | 2028 | deref_mad_agent(mad_agent_priv); |
2025 | wake_up(&mad_agent_priv->wait); | ||
2026 | return; | 2029 | return; |
2027 | done: | 2030 | done: |
2028 | spin_unlock_irqrestore(&mad_agent_priv->lock, flags); | 2031 | spin_unlock_irqrestore(&mad_agent_priv->lock, flags); |
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h index 6c9c133d71ef..b4fa28d3160f 100644 --- a/drivers/infiniband/core/mad_priv.h +++ b/drivers/infiniband/core/mad_priv.h | |||
@@ -37,6 +37,7 @@ | |||
37 | #ifndef __IB_MAD_PRIV_H__ | 37 | #ifndef __IB_MAD_PRIV_H__ |
38 | #define __IB_MAD_PRIV_H__ | 38 | #define __IB_MAD_PRIV_H__ |
39 | 39 | ||
40 | #include <linux/completion.h> | ||
40 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
41 | #include <linux/kthread.h> | 42 | #include <linux/kthread.h> |
42 | #include <linux/workqueue.h> | 43 | #include <linux/workqueue.h> |
@@ -108,7 +109,7 @@ struct ib_mad_agent_private { | |||
108 | struct list_head rmpp_list; | 109 | struct list_head rmpp_list; |
109 | 110 | ||
110 | atomic_t refcount; | 111 | atomic_t refcount; |
111 | wait_queue_head_t wait; | 112 | struct completion comp; |
112 | }; | 113 | }; |
113 | 114 | ||
114 | struct ib_mad_snoop_private { | 115 | struct ib_mad_snoop_private { |
@@ -117,7 +118,7 @@ struct ib_mad_snoop_private { | |||
117 | int snoop_index; | 118 | int snoop_index; |
118 | int mad_snoop_flags; | 119 | int mad_snoop_flags; |
119 | atomic_t refcount; | 120 | atomic_t refcount; |
120 | wait_queue_head_t wait; | 121 | struct completion comp; |
121 | }; | 122 | }; |
122 | 123 | ||
123 | struct ib_mad_send_wr_private { | 124 | struct ib_mad_send_wr_private { |
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c index dfd4e588ce03..d4704e054e30 100644 --- a/drivers/infiniband/core/mad_rmpp.c +++ b/drivers/infiniband/core/mad_rmpp.c | |||
@@ -49,7 +49,7 @@ struct mad_rmpp_recv { | |||
49 | struct list_head list; | 49 | struct list_head list; |
50 | struct work_struct timeout_work; | 50 | struct work_struct timeout_work; |
51 | struct work_struct cleanup_work; | 51 | struct work_struct cleanup_work; |
52 | wait_queue_head_t wait; | 52 | struct completion comp; |
53 | enum rmpp_state state; | 53 | enum rmpp_state state; |
54 | spinlock_t lock; | 54 | spinlock_t lock; |
55 | atomic_t refcount; | 55 | atomic_t refcount; |
@@ -69,10 +69,16 @@ struct mad_rmpp_recv { | |||
69 | u8 method; | 69 | u8 method; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static inline void deref_rmpp_recv(struct mad_rmpp_recv *rmpp_recv) | ||
73 | { | ||
74 | if (atomic_dec_and_test(&rmpp_recv->refcount)) | ||
75 | complete(&rmpp_recv->comp); | ||
76 | } | ||
77 | |||
72 | static void destroy_rmpp_recv(struct mad_rmpp_recv *rmpp_recv) | 78 | static void destroy_rmpp_recv(struct mad_rmpp_recv *rmpp_recv) |
73 | { | 79 | { |
74 | atomic_dec(&rmpp_recv->refcount); | 80 | deref_rmpp_recv(rmpp_recv); |
75 | wait_event(rmpp_recv->wait, !atomic_read(&rmpp_recv->refcount)); | 81 | wait_for_completion(&rmpp_recv->comp); |
76 | ib_destroy_ah(rmpp_recv->ah); | 82 | ib_destroy_ah(rmpp_recv->ah); |
77 | kfree(rmpp_recv); | 83 | kfree(rmpp_recv); |
78 | } | 84 | } |
@@ -253,7 +259,7 @@ create_rmpp_recv(struct ib_mad_agent_private *agent, | |||
253 | goto error; | 259 | goto error; |
254 | 260 | ||
255 | rmpp_recv->agent = agent; | 261 | rmpp_recv->agent = agent; |
256 | init_waitqueue_head(&rmpp_recv->wait); | 262 | init_completion(&rmpp_recv->comp); |
257 | INIT_WORK(&rmpp_recv->timeout_work, recv_timeout_handler, rmpp_recv); | 263 | INIT_WORK(&rmpp_recv->timeout_work, recv_timeout_handler, rmpp_recv); |
258 | INIT_WORK(&rmpp_recv->cleanup_work, recv_cleanup_handler, rmpp_recv); | 264 | INIT_WORK(&rmpp_recv->cleanup_work, recv_cleanup_handler, rmpp_recv); |
259 | spin_lock_init(&rmpp_recv->lock); | 265 | spin_lock_init(&rmpp_recv->lock); |
@@ -279,12 +285,6 @@ error: kfree(rmpp_recv); | |||
279 | return NULL; | 285 | return NULL; |
280 | } | 286 | } |
281 | 287 | ||
282 | static inline void deref_rmpp_recv(struct mad_rmpp_recv *rmpp_recv) | ||
283 | { | ||
284 | if (atomic_dec_and_test(&rmpp_recv->refcount)) | ||
285 | wake_up(&rmpp_recv->wait); | ||
286 | } | ||
287 | |||
288 | static struct mad_rmpp_recv * | 288 | static struct mad_rmpp_recv * |
289 | find_rmpp_recv(struct ib_mad_agent_private *agent, | 289 | find_rmpp_recv(struct ib_mad_agent_private *agent, |
290 | struct ib_mad_recv_wc *mad_recv_wc) | 290 | struct ib_mad_recv_wc *mad_recv_wc) |
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 15121cb5a1f6..21f9282c1b25 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c | |||
@@ -336,7 +336,7 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr, | |||
336 | switch (width) { | 336 | switch (width) { |
337 | case 4: | 337 | case 4: |
338 | ret = sprintf(buf, "%u\n", (out_mad->data[40 + offset / 8] >> | 338 | ret = sprintf(buf, "%u\n", (out_mad->data[40 + offset / 8] >> |
339 | (offset % 4)) & 0xf); | 339 | (4 - (offset % 8))) & 0xf); |
340 | break; | 340 | break; |
341 | case 8: | 341 | case 8: |
342 | ret = sprintf(buf, "%u\n", out_mad->data[40 + offset / 8]); | 342 | ret = sprintf(buf, "%u\n", out_mad->data[40 + offset / 8]); |
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index f6a05965a4e8..9164a09b6ccd 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c | |||
@@ -32,6 +32,8 @@ | |||
32 | * | 32 | * |
33 | * $Id: ucm.c 2594 2005-06-13 19:46:02Z libor $ | 33 | * $Id: ucm.c 2594 2005-06-13 19:46:02Z libor $ |
34 | */ | 34 | */ |
35 | |||
36 | #include <linux/completion.h> | ||
35 | #include <linux/init.h> | 37 | #include <linux/init.h> |
36 | #include <linux/fs.h> | 38 | #include <linux/fs.h> |
37 | #include <linux/module.h> | 39 | #include <linux/module.h> |
@@ -72,7 +74,7 @@ struct ib_ucm_file { | |||
72 | 74 | ||
73 | struct ib_ucm_context { | 75 | struct ib_ucm_context { |
74 | int id; | 76 | int id; |
75 | wait_queue_head_t wait; | 77 | struct completion comp; |
76 | atomic_t ref; | 78 | atomic_t ref; |
77 | int events_reported; | 79 | int events_reported; |
78 | 80 | ||
@@ -138,7 +140,7 @@ static struct ib_ucm_context *ib_ucm_ctx_get(struct ib_ucm_file *file, int id) | |||
138 | static void ib_ucm_ctx_put(struct ib_ucm_context *ctx) | 140 | static void ib_ucm_ctx_put(struct ib_ucm_context *ctx) |
139 | { | 141 | { |
140 | if (atomic_dec_and_test(&ctx->ref)) | 142 | if (atomic_dec_and_test(&ctx->ref)) |
141 | wake_up(&ctx->wait); | 143 | complete(&ctx->comp); |
142 | } | 144 | } |
143 | 145 | ||
144 | static inline int ib_ucm_new_cm_id(int event) | 146 | static inline int ib_ucm_new_cm_id(int event) |
@@ -178,7 +180,7 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file) | |||
178 | return NULL; | 180 | return NULL; |
179 | 181 | ||
180 | atomic_set(&ctx->ref, 1); | 182 | atomic_set(&ctx->ref, 1); |
181 | init_waitqueue_head(&ctx->wait); | 183 | init_completion(&ctx->comp); |
182 | ctx->file = file; | 184 | ctx->file = file; |
183 | INIT_LIST_HEAD(&ctx->events); | 185 | INIT_LIST_HEAD(&ctx->events); |
184 | 186 | ||
@@ -586,8 +588,8 @@ static ssize_t ib_ucm_destroy_id(struct ib_ucm_file *file, | |||
586 | if (IS_ERR(ctx)) | 588 | if (IS_ERR(ctx)) |
587 | return PTR_ERR(ctx); | 589 | return PTR_ERR(ctx); |
588 | 590 | ||
589 | atomic_dec(&ctx->ref); | 591 | ib_ucm_ctx_put(ctx); |
590 | wait_event(ctx->wait, !atomic_read(&ctx->ref)); | 592 | wait_for_completion(&ctx->comp); |
591 | 593 | ||
592 | /* No new events will be generated after destroying the cm_id. */ | 594 | /* No new events will be generated after destroying the cm_id. */ |
593 | ib_destroy_cm_id(ctx->cm_id); | 595 | ib_destroy_cm_id(ctx->cm_id); |
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c index 398add4d4cb1..3697edafd6d2 100644 --- a/drivers/infiniband/hw/ipath/ipath_driver.c +++ b/drivers/infiniband/hw/ipath/ipath_driver.c | |||
@@ -116,10 +116,9 @@ static int __devinit ipath_init_one(struct pci_dev *, | |||
116 | #define PCI_DEVICE_ID_INFINIPATH_PE800 0x10 | 116 | #define PCI_DEVICE_ID_INFINIPATH_PE800 0x10 |
117 | 117 | ||
118 | static const struct pci_device_id ipath_pci_tbl[] = { | 118 | static const struct pci_device_id ipath_pci_tbl[] = { |
119 | {PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE, | 119 | { PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE, PCI_DEVICE_ID_INFINIPATH_HT) }, |
120 | PCI_DEVICE_ID_INFINIPATH_HT)}, | 120 | { PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE, PCI_DEVICE_ID_INFINIPATH_PE800) }, |
121 | {PCI_DEVICE(PCI_VENDOR_ID_PATHSCALE, | 121 | { 0, } |
122 | PCI_DEVICE_ID_INFINIPATH_PE800)}, | ||
123 | }; | 122 | }; |
124 | 123 | ||
125 | MODULE_DEVICE_TABLE(pci, ipath_pci_tbl); | 124 | MODULE_DEVICE_TABLE(pci, ipath_pci_tbl); |
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c index 312cf90731ea..205854e9c662 100644 --- a/drivers/infiniband/hw/mthca/mthca_cq.c +++ b/drivers/infiniband/hw/mthca/mthca_cq.c | |||
@@ -238,9 +238,9 @@ void mthca_cq_event(struct mthca_dev *dev, u32 cqn, | |||
238 | spin_lock(&dev->cq_table.lock); | 238 | spin_lock(&dev->cq_table.lock); |
239 | 239 | ||
240 | cq = mthca_array_get(&dev->cq_table.cq, cqn & (dev->limits.num_cqs - 1)); | 240 | cq = mthca_array_get(&dev->cq_table.cq, cqn & (dev->limits.num_cqs - 1)); |
241 | |||
242 | if (cq) | 241 | if (cq) |
243 | atomic_inc(&cq->refcount); | 242 | ++cq->refcount; |
243 | |||
244 | spin_unlock(&dev->cq_table.lock); | 244 | spin_unlock(&dev->cq_table.lock); |
245 | 245 | ||
246 | if (!cq) { | 246 | if (!cq) { |
@@ -254,8 +254,10 @@ void mthca_cq_event(struct mthca_dev *dev, u32 cqn, | |||
254 | if (cq->ibcq.event_handler) | 254 | if (cq->ibcq.event_handler) |
255 | cq->ibcq.event_handler(&event, cq->ibcq.cq_context); | 255 | cq->ibcq.event_handler(&event, cq->ibcq.cq_context); |
256 | 256 | ||
257 | if (atomic_dec_and_test(&cq->refcount)) | 257 | spin_lock(&dev->cq_table.lock); |
258 | if (!--cq->refcount) | ||
258 | wake_up(&cq->wait); | 259 | wake_up(&cq->wait); |
260 | spin_unlock(&dev->cq_table.lock); | ||
259 | } | 261 | } |
260 | 262 | ||
261 | static inline int is_recv_cqe(struct mthca_cqe *cqe) | 263 | static inline int is_recv_cqe(struct mthca_cqe *cqe) |
@@ -267,23 +269,13 @@ static inline int is_recv_cqe(struct mthca_cqe *cqe) | |||
267 | return !(cqe->is_send & 0x80); | 269 | return !(cqe->is_send & 0x80); |
268 | } | 270 | } |
269 | 271 | ||
270 | void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn, | 272 | void mthca_cq_clean(struct mthca_dev *dev, struct mthca_cq *cq, u32 qpn, |
271 | struct mthca_srq *srq) | 273 | struct mthca_srq *srq) |
272 | { | 274 | { |
273 | struct mthca_cq *cq; | ||
274 | struct mthca_cqe *cqe; | 275 | struct mthca_cqe *cqe; |
275 | u32 prod_index; | 276 | u32 prod_index; |
276 | int nfreed = 0; | 277 | int nfreed = 0; |
277 | 278 | ||
278 | spin_lock_irq(&dev->cq_table.lock); | ||
279 | cq = mthca_array_get(&dev->cq_table.cq, cqn & (dev->limits.num_cqs - 1)); | ||
280 | if (cq) | ||
281 | atomic_inc(&cq->refcount); | ||
282 | spin_unlock_irq(&dev->cq_table.lock); | ||
283 | |||
284 | if (!cq) | ||
285 | return; | ||
286 | |||
287 | spin_lock_irq(&cq->lock); | 279 | spin_lock_irq(&cq->lock); |
288 | 280 | ||
289 | /* | 281 | /* |
@@ -301,7 +293,7 @@ void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn, | |||
301 | 293 | ||
302 | if (0) | 294 | if (0) |
303 | mthca_dbg(dev, "Cleaning QPN %06x from CQN %06x; ci %d, pi %d\n", | 295 | mthca_dbg(dev, "Cleaning QPN %06x from CQN %06x; ci %d, pi %d\n", |
304 | qpn, cqn, cq->cons_index, prod_index); | 296 | qpn, cq->cqn, cq->cons_index, prod_index); |
305 | 297 | ||
306 | /* | 298 | /* |
307 | * Now sweep backwards through the CQ, removing CQ entries | 299 | * Now sweep backwards through the CQ, removing CQ entries |
@@ -325,8 +317,6 @@ void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn, | |||
325 | } | 317 | } |
326 | 318 | ||
327 | spin_unlock_irq(&cq->lock); | 319 | spin_unlock_irq(&cq->lock); |
328 | if (atomic_dec_and_test(&cq->refcount)) | ||
329 | wake_up(&cq->wait); | ||
330 | } | 320 | } |
331 | 321 | ||
332 | void mthca_cq_resize_copy_cqes(struct mthca_cq *cq) | 322 | void mthca_cq_resize_copy_cqes(struct mthca_cq *cq) |
@@ -821,7 +811,7 @@ int mthca_init_cq(struct mthca_dev *dev, int nent, | |||
821 | } | 811 | } |
822 | 812 | ||
823 | spin_lock_init(&cq->lock); | 813 | spin_lock_init(&cq->lock); |
824 | atomic_set(&cq->refcount, 1); | 814 | cq->refcount = 1; |
825 | init_waitqueue_head(&cq->wait); | 815 | init_waitqueue_head(&cq->wait); |
826 | 816 | ||
827 | memset(cq_context, 0, sizeof *cq_context); | 817 | memset(cq_context, 0, sizeof *cq_context); |
@@ -896,6 +886,17 @@ err_out: | |||
896 | return err; | 886 | return err; |
897 | } | 887 | } |
898 | 888 | ||
889 | static inline int get_cq_refcount(struct mthca_dev *dev, struct mthca_cq *cq) | ||
890 | { | ||
891 | int c; | ||
892 | |||
893 | spin_lock_irq(&dev->cq_table.lock); | ||
894 | c = cq->refcount; | ||
895 | spin_unlock_irq(&dev->cq_table.lock); | ||
896 | |||
897 | return c; | ||
898 | } | ||
899 | |||
899 | void mthca_free_cq(struct mthca_dev *dev, | 900 | void mthca_free_cq(struct mthca_dev *dev, |
900 | struct mthca_cq *cq) | 901 | struct mthca_cq *cq) |
901 | { | 902 | { |
@@ -929,6 +930,7 @@ void mthca_free_cq(struct mthca_dev *dev, | |||
929 | spin_lock_irq(&dev->cq_table.lock); | 930 | spin_lock_irq(&dev->cq_table.lock); |
930 | mthca_array_clear(&dev->cq_table.cq, | 931 | mthca_array_clear(&dev->cq_table.cq, |
931 | cq->cqn & (dev->limits.num_cqs - 1)); | 932 | cq->cqn & (dev->limits.num_cqs - 1)); |
933 | --cq->refcount; | ||
932 | spin_unlock_irq(&dev->cq_table.lock); | 934 | spin_unlock_irq(&dev->cq_table.lock); |
933 | 935 | ||
934 | if (dev->mthca_flags & MTHCA_FLAG_MSI_X) | 936 | if (dev->mthca_flags & MTHCA_FLAG_MSI_X) |
@@ -936,8 +938,7 @@ void mthca_free_cq(struct mthca_dev *dev, | |||
936 | else | 938 | else |
937 | synchronize_irq(dev->pdev->irq); | 939 | synchronize_irq(dev->pdev->irq); |
938 | 940 | ||
939 | atomic_dec(&cq->refcount); | 941 | wait_event(cq->wait, !get_cq_refcount(dev, cq)); |
940 | wait_event(cq->wait, !atomic_read(&cq->refcount)); | ||
941 | 942 | ||
942 | if (cq->is_kernel) { | 943 | if (cq->is_kernel) { |
943 | mthca_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe); | 944 | mthca_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe); |
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h index 4c1dcb4c1822..f8160b8de090 100644 --- a/drivers/infiniband/hw/mthca/mthca_dev.h +++ b/drivers/infiniband/hw/mthca/mthca_dev.h | |||
@@ -496,7 +496,7 @@ void mthca_free_cq(struct mthca_dev *dev, | |||
496 | void mthca_cq_completion(struct mthca_dev *dev, u32 cqn); | 496 | void mthca_cq_completion(struct mthca_dev *dev, u32 cqn); |
497 | void mthca_cq_event(struct mthca_dev *dev, u32 cqn, | 497 | void mthca_cq_event(struct mthca_dev *dev, u32 cqn, |
498 | enum ib_event_type event_type); | 498 | enum ib_event_type event_type); |
499 | void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn, | 499 | void mthca_cq_clean(struct mthca_dev *dev, struct mthca_cq *cq, u32 qpn, |
500 | struct mthca_srq *srq); | 500 | struct mthca_srq *srq); |
501 | void mthca_cq_resize_copy_cqes(struct mthca_cq *cq); | 501 | void mthca_cq_resize_copy_cqes(struct mthca_cq *cq); |
502 | int mthca_alloc_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int nent); | 502 | int mthca_alloc_cq_buf(struct mthca_dev *dev, struct mthca_cq_buf *buf, int nent); |
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c index 25e1c1db9a40..a486dec1707e 100644 --- a/drivers/infiniband/hw/mthca/mthca_mr.c +++ b/drivers/infiniband/hw/mthca/mthca_mr.c | |||
@@ -761,6 +761,7 @@ void mthca_arbel_fmr_unmap(struct mthca_dev *dev, struct mthca_fmr *fmr) | |||
761 | 761 | ||
762 | int __devinit mthca_init_mr_table(struct mthca_dev *dev) | 762 | int __devinit mthca_init_mr_table(struct mthca_dev *dev) |
763 | { | 763 | { |
764 | unsigned long addr; | ||
764 | int err, i; | 765 | int err, i; |
765 | 766 | ||
766 | err = mthca_alloc_init(&dev->mr_table.mpt_alloc, | 767 | err = mthca_alloc_init(&dev->mr_table.mpt_alloc, |
@@ -796,9 +797,12 @@ int __devinit mthca_init_mr_table(struct mthca_dev *dev) | |||
796 | goto err_fmr_mpt; | 797 | goto err_fmr_mpt; |
797 | } | 798 | } |
798 | 799 | ||
800 | addr = pci_resource_start(dev->pdev, 4) + | ||
801 | ((pci_resource_len(dev->pdev, 4) - 1) & | ||
802 | dev->mr_table.mpt_base); | ||
803 | |||
799 | dev->mr_table.tavor_fmr.mpt_base = | 804 | dev->mr_table.tavor_fmr.mpt_base = |
800 | ioremap(dev->mr_table.mpt_base, | 805 | ioremap(addr, (1 << i) * sizeof(struct mthca_mpt_entry)); |
801 | (1 << i) * sizeof (struct mthca_mpt_entry)); | ||
802 | 806 | ||
803 | if (!dev->mr_table.tavor_fmr.mpt_base) { | 807 | if (!dev->mr_table.tavor_fmr.mpt_base) { |
804 | mthca_warn(dev, "MPT ioremap for FMR failed.\n"); | 808 | mthca_warn(dev, "MPT ioremap for FMR failed.\n"); |
@@ -806,9 +810,12 @@ int __devinit mthca_init_mr_table(struct mthca_dev *dev) | |||
806 | goto err_fmr_mpt; | 810 | goto err_fmr_mpt; |
807 | } | 811 | } |
808 | 812 | ||
813 | addr = pci_resource_start(dev->pdev, 4) + | ||
814 | ((pci_resource_len(dev->pdev, 4) - 1) & | ||
815 | dev->mr_table.mtt_base); | ||
816 | |||
809 | dev->mr_table.tavor_fmr.mtt_base = | 817 | dev->mr_table.tavor_fmr.mtt_base = |
810 | ioremap(dev->mr_table.mtt_base, | 818 | ioremap(addr, (1 << i) * MTHCA_MTT_SEG_SIZE); |
811 | (1 << i) * MTHCA_MTT_SEG_SIZE); | ||
812 | if (!dev->mr_table.tavor_fmr.mtt_base) { | 819 | if (!dev->mr_table.tavor_fmr.mtt_base) { |
813 | mthca_warn(dev, "MTT ioremap for FMR failed.\n"); | 820 | mthca_warn(dev, "MTT ioremap for FMR failed.\n"); |
814 | err = -ENOMEM; | 821 | err = -ENOMEM; |
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.h b/drivers/infiniband/hw/mthca/mthca_provider.h index 6676a786d690..179a8f610d0f 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.h +++ b/drivers/infiniband/hw/mthca/mthca_provider.h | |||
@@ -139,11 +139,12 @@ struct mthca_ah { | |||
139 | * a qp may be locked, with the send cq locked first. No other | 139 | * a qp may be locked, with the send cq locked first. No other |
140 | * nesting should be done. | 140 | * nesting should be done. |
141 | * | 141 | * |
142 | * Each struct mthca_cq/qp also has an atomic_t ref count. The | 142 | * Each struct mthca_cq/qp also has an ref count, protected by the |
143 | * pointer from the cq/qp_table to the struct counts as one reference. | 143 | * corresponding table lock. The pointer from the cq/qp_table to the |
144 | * This reference also is good for access through the consumer API, so | 144 | * struct counts as one reference. This reference also is good for |
145 | * modifying the CQ/QP etc doesn't need to take another reference. | 145 | * access through the consumer API, so modifying the CQ/QP etc doesn't |
146 | * Access because of a completion being polled does need a reference. | 146 | * need to take another reference. Access to a QP because of a |
147 | * completion being polled does not need a reference either. | ||
147 | * | 148 | * |
148 | * Finally, each struct mthca_cq/qp has a wait_queue_head_t for the | 149 | * Finally, each struct mthca_cq/qp has a wait_queue_head_t for the |
149 | * destroy function to sleep on. | 150 | * destroy function to sleep on. |
@@ -159,8 +160,9 @@ struct mthca_ah { | |||
159 | * - decrement ref count; if zero, wake up waiters | 160 | * - decrement ref count; if zero, wake up waiters |
160 | * | 161 | * |
161 | * To destroy a CQ/QP, we can do the following: | 162 | * To destroy a CQ/QP, we can do the following: |
162 | * - lock cq/qp_table, remove pointer, unlock cq/qp_table lock | 163 | * - lock cq/qp_table |
163 | * - decrement ref count | 164 | * - remove pointer and decrement ref count |
165 | * - unlock cq/qp_table lock | ||
164 | * - wait_event until ref count is zero | 166 | * - wait_event until ref count is zero |
165 | * | 167 | * |
166 | * It is the consumer's responsibilty to make sure that no QP | 168 | * It is the consumer's responsibilty to make sure that no QP |
@@ -197,7 +199,7 @@ struct mthca_cq_resize { | |||
197 | struct mthca_cq { | 199 | struct mthca_cq { |
198 | struct ib_cq ibcq; | 200 | struct ib_cq ibcq; |
199 | spinlock_t lock; | 201 | spinlock_t lock; |
200 | atomic_t refcount; | 202 | int refcount; |
201 | int cqn; | 203 | int cqn; |
202 | u32 cons_index; | 204 | u32 cons_index; |
203 | struct mthca_cq_buf buf; | 205 | struct mthca_cq_buf buf; |
@@ -217,7 +219,7 @@ struct mthca_cq { | |||
217 | struct mthca_srq { | 219 | struct mthca_srq { |
218 | struct ib_srq ibsrq; | 220 | struct ib_srq ibsrq; |
219 | spinlock_t lock; | 221 | spinlock_t lock; |
220 | atomic_t refcount; | 222 | int refcount; |
221 | int srqn; | 223 | int srqn; |
222 | int max; | 224 | int max; |
223 | int max_gs; | 225 | int max_gs; |
@@ -254,7 +256,7 @@ struct mthca_wq { | |||
254 | 256 | ||
255 | struct mthca_qp { | 257 | struct mthca_qp { |
256 | struct ib_qp ibqp; | 258 | struct ib_qp ibqp; |
257 | atomic_t refcount; | 259 | int refcount; |
258 | u32 qpn; | 260 | u32 qpn; |
259 | int is_direct; | 261 | int is_direct; |
260 | u8 port; /* for SQP and memfree use only */ | 262 | u8 port; /* for SQP and memfree use only */ |
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index f37b0e367323..19765f6f8d58 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c | |||
@@ -240,7 +240,7 @@ void mthca_qp_event(struct mthca_dev *dev, u32 qpn, | |||
240 | spin_lock(&dev->qp_table.lock); | 240 | spin_lock(&dev->qp_table.lock); |
241 | qp = mthca_array_get(&dev->qp_table.qp, qpn & (dev->limits.num_qps - 1)); | 241 | qp = mthca_array_get(&dev->qp_table.qp, qpn & (dev->limits.num_qps - 1)); |
242 | if (qp) | 242 | if (qp) |
243 | atomic_inc(&qp->refcount); | 243 | ++qp->refcount; |
244 | spin_unlock(&dev->qp_table.lock); | 244 | spin_unlock(&dev->qp_table.lock); |
245 | 245 | ||
246 | if (!qp) { | 246 | if (!qp) { |
@@ -257,8 +257,10 @@ void mthca_qp_event(struct mthca_dev *dev, u32 qpn, | |||
257 | if (qp->ibqp.event_handler) | 257 | if (qp->ibqp.event_handler) |
258 | qp->ibqp.event_handler(&event, qp->ibqp.qp_context); | 258 | qp->ibqp.event_handler(&event, qp->ibqp.qp_context); |
259 | 259 | ||
260 | if (atomic_dec_and_test(&qp->refcount)) | 260 | spin_lock(&dev->qp_table.lock); |
261 | if (!--qp->refcount) | ||
261 | wake_up(&qp->wait); | 262 | wake_up(&qp->wait); |
263 | spin_unlock(&dev->qp_table.lock); | ||
262 | } | 264 | } |
263 | 265 | ||
264 | static int to_mthca_state(enum ib_qp_state ib_state) | 266 | static int to_mthca_state(enum ib_qp_state ib_state) |
@@ -833,10 +835,10 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask) | |||
833 | * entries and reinitialize the QP. | 835 | * entries and reinitialize the QP. |
834 | */ | 836 | */ |
835 | if (new_state == IB_QPS_RESET && !qp->ibqp.uobject) { | 837 | if (new_state == IB_QPS_RESET && !qp->ibqp.uobject) { |
836 | mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq)->cqn, qp->qpn, | 838 | mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq), qp->qpn, |
837 | qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); | 839 | qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); |
838 | if (qp->ibqp.send_cq != qp->ibqp.recv_cq) | 840 | if (qp->ibqp.send_cq != qp->ibqp.recv_cq) |
839 | mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq)->cqn, qp->qpn, | 841 | mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq), qp->qpn, |
840 | qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); | 842 | qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); |
841 | 843 | ||
842 | mthca_wq_init(&qp->sq); | 844 | mthca_wq_init(&qp->sq); |
@@ -1096,7 +1098,7 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev, | |||
1096 | int ret; | 1098 | int ret; |
1097 | int i; | 1099 | int i; |
1098 | 1100 | ||
1099 | atomic_set(&qp->refcount, 1); | 1101 | qp->refcount = 1; |
1100 | init_waitqueue_head(&qp->wait); | 1102 | init_waitqueue_head(&qp->wait); |
1101 | qp->state = IB_QPS_RESET; | 1103 | qp->state = IB_QPS_RESET; |
1102 | qp->atomic_rd_en = 0; | 1104 | qp->atomic_rd_en = 0; |
@@ -1318,6 +1320,17 @@ int mthca_alloc_sqp(struct mthca_dev *dev, | |||
1318 | return err; | 1320 | return err; |
1319 | } | 1321 | } |
1320 | 1322 | ||
1323 | static inline int get_qp_refcount(struct mthca_dev *dev, struct mthca_qp *qp) | ||
1324 | { | ||
1325 | int c; | ||
1326 | |||
1327 | spin_lock_irq(&dev->qp_table.lock); | ||
1328 | c = qp->refcount; | ||
1329 | spin_unlock_irq(&dev->qp_table.lock); | ||
1330 | |||
1331 | return c; | ||
1332 | } | ||
1333 | |||
1321 | void mthca_free_qp(struct mthca_dev *dev, | 1334 | void mthca_free_qp(struct mthca_dev *dev, |
1322 | struct mthca_qp *qp) | 1335 | struct mthca_qp *qp) |
1323 | { | 1336 | { |
@@ -1339,14 +1352,14 @@ void mthca_free_qp(struct mthca_dev *dev, | |||
1339 | spin_lock(&dev->qp_table.lock); | 1352 | spin_lock(&dev->qp_table.lock); |
1340 | mthca_array_clear(&dev->qp_table.qp, | 1353 | mthca_array_clear(&dev->qp_table.qp, |
1341 | qp->qpn & (dev->limits.num_qps - 1)); | 1354 | qp->qpn & (dev->limits.num_qps - 1)); |
1355 | --qp->refcount; | ||
1342 | spin_unlock(&dev->qp_table.lock); | 1356 | spin_unlock(&dev->qp_table.lock); |
1343 | 1357 | ||
1344 | if (send_cq != recv_cq) | 1358 | if (send_cq != recv_cq) |
1345 | spin_unlock(&recv_cq->lock); | 1359 | spin_unlock(&recv_cq->lock); |
1346 | spin_unlock_irq(&send_cq->lock); | 1360 | spin_unlock_irq(&send_cq->lock); |
1347 | 1361 | ||
1348 | atomic_dec(&qp->refcount); | 1362 | wait_event(qp->wait, !get_qp_refcount(dev, qp)); |
1349 | wait_event(qp->wait, !atomic_read(&qp->refcount)); | ||
1350 | 1363 | ||
1351 | if (qp->state != IB_QPS_RESET) | 1364 | if (qp->state != IB_QPS_RESET) |
1352 | mthca_MODIFY_QP(dev, qp->state, IB_QPS_RESET, qp->qpn, 0, | 1365 | mthca_MODIFY_QP(dev, qp->state, IB_QPS_RESET, qp->qpn, 0, |
@@ -1358,10 +1371,10 @@ void mthca_free_qp(struct mthca_dev *dev, | |||
1358 | * unref the mem-free tables and free the QPN in our table. | 1371 | * unref the mem-free tables and free the QPN in our table. |
1359 | */ | 1372 | */ |
1360 | if (!qp->ibqp.uobject) { | 1373 | if (!qp->ibqp.uobject) { |
1361 | mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq)->cqn, qp->qpn, | 1374 | mthca_cq_clean(dev, to_mcq(qp->ibqp.send_cq), qp->qpn, |
1362 | qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); | 1375 | qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); |
1363 | if (qp->ibqp.send_cq != qp->ibqp.recv_cq) | 1376 | if (qp->ibqp.send_cq != qp->ibqp.recv_cq) |
1364 | mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq)->cqn, qp->qpn, | 1377 | mthca_cq_clean(dev, to_mcq(qp->ibqp.recv_cq), qp->qpn, |
1365 | qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); | 1378 | qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); |
1366 | 1379 | ||
1367 | mthca_free_memfree(dev, qp); | 1380 | mthca_free_memfree(dev, qp); |
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c index adcaf85355ae..1ea433291fa7 100644 --- a/drivers/infiniband/hw/mthca/mthca_srq.c +++ b/drivers/infiniband/hw/mthca/mthca_srq.c | |||
@@ -241,7 +241,7 @@ int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd, | |||
241 | goto err_out_mailbox; | 241 | goto err_out_mailbox; |
242 | 242 | ||
243 | spin_lock_init(&srq->lock); | 243 | spin_lock_init(&srq->lock); |
244 | atomic_set(&srq->refcount, 1); | 244 | srq->refcount = 1; |
245 | init_waitqueue_head(&srq->wait); | 245 | init_waitqueue_head(&srq->wait); |
246 | 246 | ||
247 | if (mthca_is_memfree(dev)) | 247 | if (mthca_is_memfree(dev)) |
@@ -308,6 +308,17 @@ err_out: | |||
308 | return err; | 308 | return err; |
309 | } | 309 | } |
310 | 310 | ||
311 | static inline int get_srq_refcount(struct mthca_dev *dev, struct mthca_srq *srq) | ||
312 | { | ||
313 | int c; | ||
314 | |||
315 | spin_lock_irq(&dev->srq_table.lock); | ||
316 | c = srq->refcount; | ||
317 | spin_unlock_irq(&dev->srq_table.lock); | ||
318 | |||
319 | return c; | ||
320 | } | ||
321 | |||
311 | void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq) | 322 | void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq) |
312 | { | 323 | { |
313 | struct mthca_mailbox *mailbox; | 324 | struct mthca_mailbox *mailbox; |
@@ -329,10 +340,10 @@ void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq) | |||
329 | spin_lock_irq(&dev->srq_table.lock); | 340 | spin_lock_irq(&dev->srq_table.lock); |
330 | mthca_array_clear(&dev->srq_table.srq, | 341 | mthca_array_clear(&dev->srq_table.srq, |
331 | srq->srqn & (dev->limits.num_srqs - 1)); | 342 | srq->srqn & (dev->limits.num_srqs - 1)); |
343 | --srq->refcount; | ||
332 | spin_unlock_irq(&dev->srq_table.lock); | 344 | spin_unlock_irq(&dev->srq_table.lock); |
333 | 345 | ||
334 | atomic_dec(&srq->refcount); | 346 | wait_event(srq->wait, !get_srq_refcount(dev, srq)); |
335 | wait_event(srq->wait, !atomic_read(&srq->refcount)); | ||
336 | 347 | ||
337 | if (!srq->ibsrq.uobject) { | 348 | if (!srq->ibsrq.uobject) { |
338 | mthca_free_srq_buf(dev, srq); | 349 | mthca_free_srq_buf(dev, srq); |
@@ -414,7 +425,7 @@ void mthca_srq_event(struct mthca_dev *dev, u32 srqn, | |||
414 | spin_lock(&dev->srq_table.lock); | 425 | spin_lock(&dev->srq_table.lock); |
415 | srq = mthca_array_get(&dev->srq_table.srq, srqn & (dev->limits.num_srqs - 1)); | 426 | srq = mthca_array_get(&dev->srq_table.srq, srqn & (dev->limits.num_srqs - 1)); |
416 | if (srq) | 427 | if (srq) |
417 | atomic_inc(&srq->refcount); | 428 | ++srq->refcount; |
418 | spin_unlock(&dev->srq_table.lock); | 429 | spin_unlock(&dev->srq_table.lock); |
419 | 430 | ||
420 | if (!srq) { | 431 | if (!srq) { |
@@ -431,8 +442,10 @@ void mthca_srq_event(struct mthca_dev *dev, u32 srqn, | |||
431 | srq->ibsrq.event_handler(&event, srq->ibsrq.srq_context); | 442 | srq->ibsrq.event_handler(&event, srq->ibsrq.srq_context); |
432 | 443 | ||
433 | out: | 444 | out: |
434 | if (atomic_dec_and_test(&srq->refcount)) | 445 | spin_lock(&dev->srq_table.lock); |
446 | if (!--srq->refcount) | ||
435 | wake_up(&srq->wait); | 447 | wake_up(&srq->wait); |
448 | spin_unlock(&dev->srq_table.lock); | ||
436 | } | 449 | } |
437 | 450 | ||
438 | /* | 451 | /* |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c index 4ca175553f9f..f887780e8093 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c | |||
@@ -158,10 +158,8 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey) | |||
158 | if (priv->pkey == pkey) { | 158 | if (priv->pkey == pkey) { |
159 | unregister_netdev(priv->dev); | 159 | unregister_netdev(priv->dev); |
160 | ipoib_dev_cleanup(priv->dev); | 160 | ipoib_dev_cleanup(priv->dev); |
161 | |||
162 | list_del(&priv->list); | 161 | list_del(&priv->list); |
163 | 162 | free_netdev(priv->dev); | |
164 | kfree(priv); | ||
165 | 163 | ||
166 | ret = 0; | 164 | ret = 0; |
167 | break; | 165 | break; |
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 5bb55742ada6..c32ce4348e1b 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -409,6 +409,34 @@ static int srp_connect_target(struct srp_target_port *target) | |||
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
412 | static void srp_unmap_data(struct scsi_cmnd *scmnd, | ||
413 | struct srp_target_port *target, | ||
414 | struct srp_request *req) | ||
415 | { | ||
416 | struct scatterlist *scat; | ||
417 | int nents; | ||
418 | |||
419 | if (!scmnd->request_buffer || | ||
420 | (scmnd->sc_data_direction != DMA_TO_DEVICE && | ||
421 | scmnd->sc_data_direction != DMA_FROM_DEVICE)) | ||
422 | return; | ||
423 | |||
424 | /* | ||
425 | * This handling of non-SG commands can be killed when the | ||
426 | * SCSI midlayer no longer generates non-SG commands. | ||
427 | */ | ||
428 | if (likely(scmnd->use_sg)) { | ||
429 | nents = scmnd->use_sg; | ||
430 | scat = scmnd->request_buffer; | ||
431 | } else { | ||
432 | nents = 1; | ||
433 | scat = &req->fake_sg; | ||
434 | } | ||
435 | |||
436 | dma_unmap_sg(target->srp_host->dev->dma_device, scat, nents, | ||
437 | scmnd->sc_data_direction); | ||
438 | } | ||
439 | |||
412 | static int srp_reconnect_target(struct srp_target_port *target) | 440 | static int srp_reconnect_target(struct srp_target_port *target) |
413 | { | 441 | { |
414 | struct ib_cm_id *new_cm_id; | 442 | struct ib_cm_id *new_cm_id; |
@@ -455,16 +483,16 @@ static int srp_reconnect_target(struct srp_target_port *target) | |||
455 | list_for_each_entry(req, &target->req_queue, list) { | 483 | list_for_each_entry(req, &target->req_queue, list) { |
456 | req->scmnd->result = DID_RESET << 16; | 484 | req->scmnd->result = DID_RESET << 16; |
457 | req->scmnd->scsi_done(req->scmnd); | 485 | req->scmnd->scsi_done(req->scmnd); |
486 | srp_unmap_data(req->scmnd, target, req); | ||
458 | } | 487 | } |
459 | 488 | ||
460 | target->rx_head = 0; | 489 | target->rx_head = 0; |
461 | target->tx_head = 0; | 490 | target->tx_head = 0; |
462 | target->tx_tail = 0; | 491 | target->tx_tail = 0; |
463 | target->req_head = 0; | 492 | INIT_LIST_HEAD(&target->free_reqs); |
464 | for (i = 0; i < SRP_SQ_SIZE - 1; ++i) | ||
465 | target->req_ring[i].next = i + 1; | ||
466 | target->req_ring[SRP_SQ_SIZE - 1].next = -1; | ||
467 | INIT_LIST_HEAD(&target->req_queue); | 493 | INIT_LIST_HEAD(&target->req_queue); |
494 | for (i = 0; i < SRP_SQ_SIZE; ++i) | ||
495 | list_add_tail(&target->req_ring[i].list, &target->free_reqs); | ||
468 | 496 | ||
469 | ret = srp_connect_target(target); | 497 | ret = srp_connect_target(target); |
470 | if (ret) | 498 | if (ret) |
@@ -589,40 +617,10 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target, | |||
589 | return len; | 617 | return len; |
590 | } | 618 | } |
591 | 619 | ||
592 | static void srp_unmap_data(struct scsi_cmnd *scmnd, | 620 | static void srp_remove_req(struct srp_target_port *target, struct srp_request *req) |
593 | struct srp_target_port *target, | ||
594 | struct srp_request *req) | ||
595 | { | ||
596 | struct scatterlist *scat; | ||
597 | int nents; | ||
598 | |||
599 | if (!scmnd->request_buffer || | ||
600 | (scmnd->sc_data_direction != DMA_TO_DEVICE && | ||
601 | scmnd->sc_data_direction != DMA_FROM_DEVICE)) | ||
602 | return; | ||
603 | |||
604 | /* | ||
605 | * This handling of non-SG commands can be killed when the | ||
606 | * SCSI midlayer no longer generates non-SG commands. | ||
607 | */ | ||
608 | if (likely(scmnd->use_sg)) { | ||
609 | nents = scmnd->use_sg; | ||
610 | scat = scmnd->request_buffer; | ||
611 | } else { | ||
612 | nents = 1; | ||
613 | scat = &req->fake_sg; | ||
614 | } | ||
615 | |||
616 | dma_unmap_sg(target->srp_host->dev->dma_device, scat, nents, | ||
617 | scmnd->sc_data_direction); | ||
618 | } | ||
619 | |||
620 | static void srp_remove_req(struct srp_target_port *target, struct srp_request *req, | ||
621 | int index) | ||
622 | { | 621 | { |
623 | list_del(&req->list); | 622 | srp_unmap_data(req->scmnd, target, req); |
624 | req->next = target->req_head; | 623 | list_move_tail(&req->list, &target->free_reqs); |
625 | target->req_head = index; | ||
626 | } | 624 | } |
627 | 625 | ||
628 | static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) | 626 | static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) |
@@ -647,7 +645,7 @@ static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) | |||
647 | req->tsk_status = rsp->data[3]; | 645 | req->tsk_status = rsp->data[3]; |
648 | complete(&req->done); | 646 | complete(&req->done); |
649 | } else { | 647 | } else { |
650 | scmnd = req->scmnd; | 648 | scmnd = req->scmnd; |
651 | if (!scmnd) | 649 | if (!scmnd) |
652 | printk(KERN_ERR "Null scmnd for RSP w/tag %016llx\n", | 650 | printk(KERN_ERR "Null scmnd for RSP w/tag %016llx\n", |
653 | (unsigned long long) rsp->tag); | 651 | (unsigned long long) rsp->tag); |
@@ -665,14 +663,11 @@ static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) | |||
665 | else if (rsp->flags & (SRP_RSP_FLAG_DIOVER | SRP_RSP_FLAG_DIUNDER)) | 663 | else if (rsp->flags & (SRP_RSP_FLAG_DIOVER | SRP_RSP_FLAG_DIUNDER)) |
666 | scmnd->resid = be32_to_cpu(rsp->data_in_res_cnt); | 664 | scmnd->resid = be32_to_cpu(rsp->data_in_res_cnt); |
667 | 665 | ||
668 | srp_unmap_data(scmnd, target, req); | ||
669 | |||
670 | if (!req->tsk_mgmt) { | 666 | if (!req->tsk_mgmt) { |
671 | req->scmnd = NULL; | ||
672 | scmnd->host_scribble = (void *) -1L; | 667 | scmnd->host_scribble = (void *) -1L; |
673 | scmnd->scsi_done(scmnd); | 668 | scmnd->scsi_done(scmnd); |
674 | 669 | ||
675 | srp_remove_req(target, req, rsp->tag & ~SRP_TAG_TSK_MGMT); | 670 | srp_remove_req(target, req); |
676 | } else | 671 | } else |
677 | req->cmd_done = 1; | 672 | req->cmd_done = 1; |
678 | } | 673 | } |
@@ -859,7 +854,6 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd, | |||
859 | struct srp_request *req; | 854 | struct srp_request *req; |
860 | struct srp_iu *iu; | 855 | struct srp_iu *iu; |
861 | struct srp_cmd *cmd; | 856 | struct srp_cmd *cmd; |
862 | long req_index; | ||
863 | int len; | 857 | int len; |
864 | 858 | ||
865 | if (target->state == SRP_TARGET_CONNECTING) | 859 | if (target->state == SRP_TARGET_CONNECTING) |
@@ -879,22 +873,20 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd, | |||
879 | dma_sync_single_for_cpu(target->srp_host->dev->dma_device, iu->dma, | 873 | dma_sync_single_for_cpu(target->srp_host->dev->dma_device, iu->dma, |
880 | SRP_MAX_IU_LEN, DMA_TO_DEVICE); | 874 | SRP_MAX_IU_LEN, DMA_TO_DEVICE); |
881 | 875 | ||
882 | req_index = target->req_head; | 876 | req = list_entry(target->free_reqs.next, struct srp_request, list); |
883 | 877 | ||
884 | scmnd->scsi_done = done; | 878 | scmnd->scsi_done = done; |
885 | scmnd->result = 0; | 879 | scmnd->result = 0; |
886 | scmnd->host_scribble = (void *) req_index; | 880 | scmnd->host_scribble = (void *) (long) req->index; |
887 | 881 | ||
888 | cmd = iu->buf; | 882 | cmd = iu->buf; |
889 | memset(cmd, 0, sizeof *cmd); | 883 | memset(cmd, 0, sizeof *cmd); |
890 | 884 | ||
891 | cmd->opcode = SRP_CMD; | 885 | cmd->opcode = SRP_CMD; |
892 | cmd->lun = cpu_to_be64((u64) scmnd->device->lun << 48); | 886 | cmd->lun = cpu_to_be64((u64) scmnd->device->lun << 48); |
893 | cmd->tag = req_index; | 887 | cmd->tag = req->index; |
894 | memcpy(cmd->cdb, scmnd->cmnd, scmnd->cmd_len); | 888 | memcpy(cmd->cdb, scmnd->cmnd, scmnd->cmd_len); |
895 | 889 | ||
896 | req = &target->req_ring[req_index]; | ||
897 | |||
898 | req->scmnd = scmnd; | 890 | req->scmnd = scmnd; |
899 | req->cmd = iu; | 891 | req->cmd = iu; |
900 | req->cmd_done = 0; | 892 | req->cmd_done = 0; |
@@ -919,8 +911,7 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd, | |||
919 | goto err_unmap; | 911 | goto err_unmap; |
920 | } | 912 | } |
921 | 913 | ||
922 | target->req_head = req->next; | 914 | list_move_tail(&req->list, &target->req_queue); |
923 | list_add_tail(&req->list, &target->req_queue); | ||
924 | 915 | ||
925 | return 0; | 916 | return 0; |
926 | 917 | ||
@@ -1143,30 +1134,20 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) | |||
1143 | return 0; | 1134 | return 0; |
1144 | } | 1135 | } |
1145 | 1136 | ||
1146 | static int srp_send_tsk_mgmt(struct scsi_cmnd *scmnd, u8 func) | 1137 | static int srp_send_tsk_mgmt(struct srp_target_port *target, |
1138 | struct srp_request *req, u8 func) | ||
1147 | { | 1139 | { |
1148 | struct srp_target_port *target = host_to_target(scmnd->device->host); | ||
1149 | struct srp_request *req; | ||
1150 | struct srp_iu *iu; | 1140 | struct srp_iu *iu; |
1151 | struct srp_tsk_mgmt *tsk_mgmt; | 1141 | struct srp_tsk_mgmt *tsk_mgmt; |
1152 | int req_index; | ||
1153 | int ret = FAILED; | ||
1154 | 1142 | ||
1155 | spin_lock_irq(target->scsi_host->host_lock); | 1143 | spin_lock_irq(target->scsi_host->host_lock); |
1156 | 1144 | ||
1157 | if (target->state == SRP_TARGET_DEAD || | 1145 | if (target->state == SRP_TARGET_DEAD || |
1158 | target->state == SRP_TARGET_REMOVED) { | 1146 | target->state == SRP_TARGET_REMOVED) { |
1159 | scmnd->result = DID_BAD_TARGET << 16; | 1147 | req->scmnd->result = DID_BAD_TARGET << 16; |
1160 | goto out; | 1148 | goto out; |
1161 | } | 1149 | } |
1162 | 1150 | ||
1163 | if (scmnd->host_scribble == (void *) -1L) | ||
1164 | goto out; | ||
1165 | |||
1166 | req_index = (long) scmnd->host_scribble; | ||
1167 | printk(KERN_ERR "Abort for req_index %d\n", req_index); | ||
1168 | |||
1169 | req = &target->req_ring[req_index]; | ||
1170 | init_completion(&req->done); | 1151 | init_completion(&req->done); |
1171 | 1152 | ||
1172 | iu = __srp_get_tx_iu(target); | 1153 | iu = __srp_get_tx_iu(target); |
@@ -1177,10 +1158,10 @@ static int srp_send_tsk_mgmt(struct scsi_cmnd *scmnd, u8 func) | |||
1177 | memset(tsk_mgmt, 0, sizeof *tsk_mgmt); | 1158 | memset(tsk_mgmt, 0, sizeof *tsk_mgmt); |
1178 | 1159 | ||
1179 | tsk_mgmt->opcode = SRP_TSK_MGMT; | 1160 | tsk_mgmt->opcode = SRP_TSK_MGMT; |
1180 | tsk_mgmt->lun = cpu_to_be64((u64) scmnd->device->lun << 48); | 1161 | tsk_mgmt->lun = cpu_to_be64((u64) req->scmnd->device->lun << 48); |
1181 | tsk_mgmt->tag = req_index | SRP_TAG_TSK_MGMT; | 1162 | tsk_mgmt->tag = req->index | SRP_TAG_TSK_MGMT; |
1182 | tsk_mgmt->tsk_mgmt_func = func; | 1163 | tsk_mgmt->tsk_mgmt_func = func; |
1183 | tsk_mgmt->task_tag = req_index; | 1164 | tsk_mgmt->task_tag = req->index; |
1184 | 1165 | ||
1185 | if (__srp_post_send(target, iu, sizeof *tsk_mgmt)) | 1166 | if (__srp_post_send(target, iu, sizeof *tsk_mgmt)) |
1186 | goto out; | 1167 | goto out; |
@@ -1188,37 +1169,85 @@ static int srp_send_tsk_mgmt(struct scsi_cmnd *scmnd, u8 func) | |||
1188 | req->tsk_mgmt = iu; | 1169 | req->tsk_mgmt = iu; |
1189 | 1170 | ||
1190 | spin_unlock_irq(target->scsi_host->host_lock); | 1171 | spin_unlock_irq(target->scsi_host->host_lock); |
1172 | |||
1191 | if (!wait_for_completion_timeout(&req->done, | 1173 | if (!wait_for_completion_timeout(&req->done, |
1192 | msecs_to_jiffies(SRP_ABORT_TIMEOUT_MS))) | 1174 | msecs_to_jiffies(SRP_ABORT_TIMEOUT_MS))) |
1193 | return FAILED; | 1175 | return -1; |
1194 | spin_lock_irq(target->scsi_host->host_lock); | ||
1195 | 1176 | ||
1196 | if (req->cmd_done) { | 1177 | return 0; |
1197 | srp_remove_req(target, req, req_index); | ||
1198 | scmnd->scsi_done(scmnd); | ||
1199 | } else if (!req->tsk_status) { | ||
1200 | srp_remove_req(target, req, req_index); | ||
1201 | scmnd->result = DID_ABORT << 16; | ||
1202 | ret = SUCCESS; | ||
1203 | } | ||
1204 | 1178 | ||
1205 | out: | 1179 | out: |
1206 | spin_unlock_irq(target->scsi_host->host_lock); | 1180 | spin_unlock_irq(target->scsi_host->host_lock); |
1207 | return ret; | 1181 | return -1; |
1182 | } | ||
1183 | |||
1184 | static int srp_find_req(struct srp_target_port *target, | ||
1185 | struct scsi_cmnd *scmnd, | ||
1186 | struct srp_request **req) | ||
1187 | { | ||
1188 | if (scmnd->host_scribble == (void *) -1L) | ||
1189 | return -1; | ||
1190 | |||
1191 | *req = &target->req_ring[(long) scmnd->host_scribble]; | ||
1192 | |||
1193 | return 0; | ||
1208 | } | 1194 | } |
1209 | 1195 | ||
1210 | static int srp_abort(struct scsi_cmnd *scmnd) | 1196 | static int srp_abort(struct scsi_cmnd *scmnd) |
1211 | { | 1197 | { |
1198 | struct srp_target_port *target = host_to_target(scmnd->device->host); | ||
1199 | struct srp_request *req; | ||
1200 | int ret = SUCCESS; | ||
1201 | |||
1212 | printk(KERN_ERR "SRP abort called\n"); | 1202 | printk(KERN_ERR "SRP abort called\n"); |
1213 | 1203 | ||
1214 | return srp_send_tsk_mgmt(scmnd, SRP_TSK_ABORT_TASK); | 1204 | if (srp_find_req(target, scmnd, &req)) |
1205 | return FAILED; | ||
1206 | if (srp_send_tsk_mgmt(target, req, SRP_TSK_ABORT_TASK)) | ||
1207 | return FAILED; | ||
1208 | |||
1209 | spin_lock_irq(target->scsi_host->host_lock); | ||
1210 | |||
1211 | if (req->cmd_done) { | ||
1212 | srp_remove_req(target, req); | ||
1213 | scmnd->scsi_done(scmnd); | ||
1214 | } else if (!req->tsk_status) { | ||
1215 | srp_remove_req(target, req); | ||
1216 | scmnd->result = DID_ABORT << 16; | ||
1217 | } else | ||
1218 | ret = FAILED; | ||
1219 | |||
1220 | spin_unlock_irq(target->scsi_host->host_lock); | ||
1221 | |||
1222 | return ret; | ||
1215 | } | 1223 | } |
1216 | 1224 | ||
1217 | static int srp_reset_device(struct scsi_cmnd *scmnd) | 1225 | static int srp_reset_device(struct scsi_cmnd *scmnd) |
1218 | { | 1226 | { |
1227 | struct srp_target_port *target = host_to_target(scmnd->device->host); | ||
1228 | struct srp_request *req, *tmp; | ||
1229 | |||
1219 | printk(KERN_ERR "SRP reset_device called\n"); | 1230 | printk(KERN_ERR "SRP reset_device called\n"); |
1220 | 1231 | ||
1221 | return srp_send_tsk_mgmt(scmnd, SRP_TSK_LUN_RESET); | 1232 | if (srp_find_req(target, scmnd, &req)) |
1233 | return FAILED; | ||
1234 | if (srp_send_tsk_mgmt(target, req, SRP_TSK_LUN_RESET)) | ||
1235 | return FAILED; | ||
1236 | if (req->tsk_status) | ||
1237 | return FAILED; | ||
1238 | |||
1239 | spin_lock_irq(target->scsi_host->host_lock); | ||
1240 | |||
1241 | list_for_each_entry_safe(req, tmp, &target->req_queue, list) | ||
1242 | if (req->scmnd->device == scmnd->device) { | ||
1243 | req->scmnd->result = DID_RESET << 16; | ||
1244 | scmnd->scsi_done(scmnd); | ||
1245 | srp_remove_req(target, req); | ||
1246 | } | ||
1247 | |||
1248 | spin_unlock_irq(target->scsi_host->host_lock); | ||
1249 | |||
1250 | return SUCCESS; | ||
1222 | } | 1251 | } |
1223 | 1252 | ||
1224 | static int srp_reset_host(struct scsi_cmnd *scmnd) | 1253 | static int srp_reset_host(struct scsi_cmnd *scmnd) |
@@ -1518,10 +1547,12 @@ static ssize_t srp_create_target(struct class_device *class_dev, | |||
1518 | 1547 | ||
1519 | INIT_WORK(&target->work, srp_reconnect_work, target); | 1548 | INIT_WORK(&target->work, srp_reconnect_work, target); |
1520 | 1549 | ||
1521 | for (i = 0; i < SRP_SQ_SIZE - 1; ++i) | 1550 | INIT_LIST_HEAD(&target->free_reqs); |
1522 | target->req_ring[i].next = i + 1; | ||
1523 | target->req_ring[SRP_SQ_SIZE - 1].next = -1; | ||
1524 | INIT_LIST_HEAD(&target->req_queue); | 1551 | INIT_LIST_HEAD(&target->req_queue); |
1552 | for (i = 0; i < SRP_SQ_SIZE; ++i) { | ||
1553 | target->req_ring[i].index = i; | ||
1554 | list_add_tail(&target->req_ring[i].list, &target->free_reqs); | ||
1555 | } | ||
1525 | 1556 | ||
1526 | ret = srp_parse_options(buf, target); | 1557 | ret = srp_parse_options(buf, target); |
1527 | if (ret) | 1558 | if (ret) |
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h index bd7f7c3115de..c5cd43aae860 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.h +++ b/drivers/infiniband/ulp/srp/ib_srp.h | |||
@@ -101,7 +101,7 @@ struct srp_request { | |||
101 | */ | 101 | */ |
102 | struct scatterlist fake_sg; | 102 | struct scatterlist fake_sg; |
103 | struct completion done; | 103 | struct completion done; |
104 | short next; | 104 | short index; |
105 | u8 cmd_done; | 105 | u8 cmd_done; |
106 | u8 tsk_status; | 106 | u8 tsk_status; |
107 | }; | 107 | }; |
@@ -133,7 +133,7 @@ struct srp_target_port { | |||
133 | unsigned tx_tail; | 133 | unsigned tx_tail; |
134 | struct srp_iu *tx_ring[SRP_SQ_SIZE + 1]; | 134 | struct srp_iu *tx_ring[SRP_SQ_SIZE + 1]; |
135 | 135 | ||
136 | int req_head; | 136 | struct list_head free_reqs; |
137 | struct list_head req_queue; | 137 | struct list_head req_queue; |
138 | struct srp_request req_ring[SRP_SQ_SIZE]; | 138 | struct srp_request req_ring[SRP_SQ_SIZE]; |
139 | 139 | ||
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c index 1042987856f7..5013703db0e6 100644 --- a/drivers/input/touchscreen/corgi_ts.c +++ b/drivers/input/touchscreen/corgi_ts.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <asm/irq.h> | 20 | //#include <asm/irq.h> |
21 | 21 | ||
22 | #include <asm/arch/sharpsl.h> | 22 | #include <asm/arch/sharpsl.h> |
23 | #include <asm/arch/hardware.h> | 23 | #include <asm/arch/hardware.h> |
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 9b493f0becc4..173c899a1fb4 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c | |||
@@ -1499,7 +1499,6 @@ static int __init capi_init(void) | |||
1499 | printk(KERN_ERR "capi20: unable to get major %d\n", capi_major); | 1499 | printk(KERN_ERR "capi20: unable to get major %d\n", capi_major); |
1500 | return major_ret; | 1500 | return major_ret; |
1501 | } | 1501 | } |
1502 | capi_major = major_ret; | ||
1503 | capi_class = class_create(THIS_MODULE, "capi"); | 1502 | capi_class = class_create(THIS_MODULE, "capi"); |
1504 | if (IS_ERR(capi_class)) { | 1503 | if (IS_ERR(capi_class)) { |
1505 | unregister_chrdev(capi_major, "capi20"); | 1504 | unregister_chrdev(capi_major, "capi20"); |
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c index bfb73fd5077e..d86ab68114b0 100644 --- a/drivers/isdn/gigaset/usb-gigaset.c +++ b/drivers/isdn/gigaset/usb-gigaset.c | |||
@@ -710,8 +710,8 @@ static int gigaset_probe(struct usb_interface *interface, | |||
710 | retval = -ENODEV; //FIXME | 710 | retval = -ENODEV; //FIXME |
711 | 711 | ||
712 | /* See if the device offered us matches what we can accept */ | 712 | /* See if the device offered us matches what we can accept */ |
713 | if ((le16_to_cpu(udev->descriptor.idVendor != USB_M105_VENDOR_ID)) || | 713 | if ((le16_to_cpu(udev->descriptor.idVendor) != USB_M105_VENDOR_ID) || |
714 | (le16_to_cpu(udev->descriptor.idProduct != USB_M105_PRODUCT_ID))) | 714 | (le16_to_cpu(udev->descriptor.idProduct) != USB_M105_PRODUCT_ID)) |
715 | return -ENODEV; | 715 | return -ENODEV; |
716 | 716 | ||
717 | /* this starts to become ascii art... */ | 717 | /* this starts to become ascii art... */ |
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 3f5b64794542..626506234b76 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -4,8 +4,11 @@ menu "LED devices" | |||
4 | config NEW_LEDS | 4 | config NEW_LEDS |
5 | bool "LED Support" | 5 | bool "LED Support" |
6 | help | 6 | help |
7 | Say Y to enable Linux LED support. This is not related to standard | 7 | Say Y to enable Linux LED support. This allows control of supported |
8 | keyboard LEDs which are controlled via the input system. | 8 | LEDs from both userspace and optionally, by kernel events (triggers). |
9 | |||
10 | This is not related to standard keyboard LEDs which are controlled | ||
11 | via the input system. | ||
9 | 12 | ||
10 | config LEDS_CLASS | 13 | config LEDS_CLASS |
11 | tristate "LED Class Support" | 14 | tristate "LED Class Support" |
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index b0b5d05fadd6..c75d0ef1609c 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/sysdev.h> | 19 | #include <linux/sysdev.h> |
20 | #include <linux/timer.h> | 20 | #include <linux/timer.h> |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/ctype.h> | ||
22 | #include <linux/leds.h> | 23 | #include <linux/leds.h> |
23 | #include "leds.h" | 24 | #include "leds.h" |
24 | 25 | ||
@@ -43,9 +44,13 @@ static ssize_t led_brightness_store(struct class_device *dev, | |||
43 | ssize_t ret = -EINVAL; | 44 | ssize_t ret = -EINVAL; |
44 | char *after; | 45 | char *after; |
45 | unsigned long state = simple_strtoul(buf, &after, 10); | 46 | unsigned long state = simple_strtoul(buf, &after, 10); |
47 | size_t count = after - buf; | ||
46 | 48 | ||
47 | if (after - buf > 0) { | 49 | if (*after && isspace(*after)) |
48 | ret = after - buf; | 50 | count++; |
51 | |||
52 | if (count == size) { | ||
53 | ret = count; | ||
49 | led_set_brightness(led_cdev, state); | 54 | led_set_brightness(led_cdev, state); |
50 | } | 55 | } |
51 | 56 | ||
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c index f484b5d6dbf8..fbf141ef46ec 100644 --- a/drivers/leds/ledtrig-timer.c +++ b/drivers/leds/ledtrig-timer.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | #include <linux/sysdev.h> | 21 | #include <linux/sysdev.h> |
22 | #include <linux/timer.h> | 22 | #include <linux/timer.h> |
23 | #include <linux/ctype.h> | ||
23 | #include <linux/leds.h> | 24 | #include <linux/leds.h> |
24 | #include "leds.h" | 25 | #include "leds.h" |
25 | 26 | ||
@@ -69,11 +70,15 @@ static ssize_t led_delay_on_store(struct class_device *dev, const char *buf, | |||
69 | int ret = -EINVAL; | 70 | int ret = -EINVAL; |
70 | char *after; | 71 | char *after; |
71 | unsigned long state = simple_strtoul(buf, &after, 10); | 72 | unsigned long state = simple_strtoul(buf, &after, 10); |
73 | size_t count = after - buf; | ||
72 | 74 | ||
73 | if (after - buf > 0) { | 75 | if (*after && isspace(*after)) |
76 | count++; | ||
77 | |||
78 | if (count == size) { | ||
74 | timer_data->delay_on = state; | 79 | timer_data->delay_on = state; |
75 | mod_timer(&timer_data->timer, jiffies + 1); | 80 | mod_timer(&timer_data->timer, jiffies + 1); |
76 | ret = after - buf; | 81 | ret = count; |
77 | } | 82 | } |
78 | 83 | ||
79 | return ret; | 84 | return ret; |
@@ -97,11 +102,15 @@ static ssize_t led_delay_off_store(struct class_device *dev, const char *buf, | |||
97 | int ret = -EINVAL; | 102 | int ret = -EINVAL; |
98 | char *after; | 103 | char *after; |
99 | unsigned long state = simple_strtoul(buf, &after, 10); | 104 | unsigned long state = simple_strtoul(buf, &after, 10); |
105 | size_t count = after - buf; | ||
106 | |||
107 | if (*after && isspace(*after)) | ||
108 | count++; | ||
100 | 109 | ||
101 | if (after - buf > 0) { | 110 | if (count == size) { |
102 | timer_data->delay_off = state; | 111 | timer_data->delay_off = state; |
103 | mod_timer(&timer_data->timer, jiffies + 1); | 112 | mod_timer(&timer_data->timer, jiffies + 1); |
104 | ret = after - buf; | 113 | ret = count; |
105 | } | 114 | } |
106 | 115 | ||
107 | return ret; | 116 | return ret; |
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 266414ca2814..9080853fe283 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c | |||
@@ -1189,7 +1189,6 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) | |||
1189 | ioc->diagPending = 0; | 1189 | ioc->diagPending = 0; |
1190 | spin_lock_init(&ioc->diagLock); | 1190 | spin_lock_init(&ioc->diagLock); |
1191 | spin_lock_init(&ioc->fc_rescan_work_lock); | 1191 | spin_lock_init(&ioc->fc_rescan_work_lock); |
1192 | spin_lock_init(&ioc->fc_rport_lock); | ||
1193 | spin_lock_init(&ioc->initializing_hba_lock); | 1192 | spin_lock_init(&ioc->initializing_hba_lock); |
1194 | 1193 | ||
1195 | /* Initialize the event logging. | 1194 | /* Initialize the event logging. |
@@ -5736,11 +5735,13 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag) | |||
5736 | return rc; | 5735 | return rc; |
5737 | } | 5736 | } |
5738 | 5737 | ||
5738 | # define EVENT_DESCR_STR_SZ 100 | ||
5739 | |||
5739 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 5740 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
5740 | static void | 5741 | static void |
5741 | EventDescriptionStr(u8 event, u32 evData0, char *evStr) | 5742 | EventDescriptionStr(u8 event, u32 evData0, char *evStr) |
5742 | { | 5743 | { |
5743 | char *ds; | 5744 | char *ds = NULL; |
5744 | 5745 | ||
5745 | switch(event) { | 5746 | switch(event) { |
5746 | case MPI_EVENT_NONE: | 5747 | case MPI_EVENT_NONE: |
@@ -5777,9 +5778,9 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr) | |||
5777 | if (evData0 == MPI_EVENT_LOOP_STATE_CHANGE_LIP) | 5778 | if (evData0 == MPI_EVENT_LOOP_STATE_CHANGE_LIP) |
5778 | ds = "Loop State(LIP) Change"; | 5779 | ds = "Loop State(LIP) Change"; |
5779 | else if (evData0 == MPI_EVENT_LOOP_STATE_CHANGE_LPE) | 5780 | else if (evData0 == MPI_EVENT_LOOP_STATE_CHANGE_LPE) |
5780 | ds = "Loop State(LPE) Change"; /* ??? */ | 5781 | ds = "Loop State(LPE) Change"; /* ??? */ |
5781 | else | 5782 | else |
5782 | ds = "Loop State(LPB) Change"; /* ??? */ | 5783 | ds = "Loop State(LPB) Change"; /* ??? */ |
5783 | break; | 5784 | break; |
5784 | case MPI_EVENT_LOGOUT: | 5785 | case MPI_EVENT_LOGOUT: |
5785 | ds = "Logout"; | 5786 | ds = "Logout"; |
@@ -5841,27 +5842,32 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr) | |||
5841 | break; | 5842 | break; |
5842 | case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE: | 5843 | case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE: |
5843 | { | 5844 | { |
5844 | char buf[50]; | ||
5845 | u8 id = (u8)(evData0); | 5845 | u8 id = (u8)(evData0); |
5846 | u8 ReasonCode = (u8)(evData0 >> 16); | 5846 | u8 ReasonCode = (u8)(evData0 >> 16); |
5847 | switch (ReasonCode) { | 5847 | switch (ReasonCode) { |
5848 | case MPI_EVENT_SAS_DEV_STAT_RC_ADDED: | 5848 | case MPI_EVENT_SAS_DEV_STAT_RC_ADDED: |
5849 | sprintf(buf,"SAS Device Status Change: Added: id=%d", id); | 5849 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5850 | "SAS Device Status Change: Added: id=%d", id); | ||
5850 | break; | 5851 | break; |
5851 | case MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING: | 5852 | case MPI_EVENT_SAS_DEV_STAT_RC_NOT_RESPONDING: |
5852 | sprintf(buf,"SAS Device Status Change: Deleted: id=%d", id); | 5853 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5854 | "SAS Device Status Change: Deleted: id=%d", id); | ||
5853 | break; | 5855 | break; |
5854 | case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA: | 5856 | case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA: |
5855 | sprintf(buf,"SAS Device Status Change: SMART Data: id=%d", id); | 5857 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5858 | "SAS Device Status Change: SMART Data: id=%d", | ||
5859 | id); | ||
5856 | break; | 5860 | break; |
5857 | case MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED: | 5861 | case MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED: |
5858 | sprintf(buf,"SAS Device Status Change: No Persistancy Added: id=%d", id); | 5862 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5863 | "SAS Device Status Change: No Persistancy " | ||
5864 | "Added: id=%d", id); | ||
5859 | break; | 5865 | break; |
5860 | default: | 5866 | default: |
5861 | sprintf(buf,"SAS Device Status Change: Unknown: id=%d", id); | 5867 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5862 | break; | 5868 | "SAS Device Status Change: Unknown: id=%d", id); |
5869 | break; | ||
5863 | } | 5870 | } |
5864 | ds = buf; | ||
5865 | break; | 5871 | break; |
5866 | } | 5872 | } |
5867 | case MPI_EVENT_ON_BUS_TIMER_EXPIRED: | 5873 | case MPI_EVENT_ON_BUS_TIMER_EXPIRED: |
@@ -5878,41 +5884,46 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr) | |||
5878 | break; | 5884 | break; |
5879 | case MPI_EVENT_SAS_PHY_LINK_STATUS: | 5885 | case MPI_EVENT_SAS_PHY_LINK_STATUS: |
5880 | { | 5886 | { |
5881 | char buf[50]; | ||
5882 | u8 LinkRates = (u8)(evData0 >> 8); | 5887 | u8 LinkRates = (u8)(evData0 >> 8); |
5883 | u8 PhyNumber = (u8)(evData0); | 5888 | u8 PhyNumber = (u8)(evData0); |
5884 | LinkRates = (LinkRates & MPI_EVENT_SAS_PLS_LR_CURRENT_MASK) >> | 5889 | LinkRates = (LinkRates & MPI_EVENT_SAS_PLS_LR_CURRENT_MASK) >> |
5885 | MPI_EVENT_SAS_PLS_LR_CURRENT_SHIFT; | 5890 | MPI_EVENT_SAS_PLS_LR_CURRENT_SHIFT; |
5886 | switch (LinkRates) { | 5891 | switch (LinkRates) { |
5887 | case MPI_EVENT_SAS_PLS_LR_RATE_UNKNOWN: | 5892 | case MPI_EVENT_SAS_PLS_LR_RATE_UNKNOWN: |
5888 | sprintf(buf,"SAS PHY Link Status: Phy=%d:" | 5893 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5894 | "SAS PHY Link Status: Phy=%d:" | ||
5889 | " Rate Unknown",PhyNumber); | 5895 | " Rate Unknown",PhyNumber); |
5890 | break; | 5896 | break; |
5891 | case MPI_EVENT_SAS_PLS_LR_RATE_PHY_DISABLED: | 5897 | case MPI_EVENT_SAS_PLS_LR_RATE_PHY_DISABLED: |
5892 | sprintf(buf,"SAS PHY Link Status: Phy=%d:" | 5898 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5899 | "SAS PHY Link Status: Phy=%d:" | ||
5893 | " Phy Disabled",PhyNumber); | 5900 | " Phy Disabled",PhyNumber); |
5894 | break; | 5901 | break; |
5895 | case MPI_EVENT_SAS_PLS_LR_RATE_FAILED_SPEED_NEGOTIATION: | 5902 | case MPI_EVENT_SAS_PLS_LR_RATE_FAILED_SPEED_NEGOTIATION: |
5896 | sprintf(buf,"SAS PHY Link Status: Phy=%d:" | 5903 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5904 | "SAS PHY Link Status: Phy=%d:" | ||
5897 | " Failed Speed Nego",PhyNumber); | 5905 | " Failed Speed Nego",PhyNumber); |
5898 | break; | 5906 | break; |
5899 | case MPI_EVENT_SAS_PLS_LR_RATE_SATA_OOB_COMPLETE: | 5907 | case MPI_EVENT_SAS_PLS_LR_RATE_SATA_OOB_COMPLETE: |
5900 | sprintf(buf,"SAS PHY Link Status: Phy=%d:" | 5908 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5909 | "SAS PHY Link Status: Phy=%d:" | ||
5901 | " Sata OOB Completed",PhyNumber); | 5910 | " Sata OOB Completed",PhyNumber); |
5902 | break; | 5911 | break; |
5903 | case MPI_EVENT_SAS_PLS_LR_RATE_1_5: | 5912 | case MPI_EVENT_SAS_PLS_LR_RATE_1_5: |
5904 | sprintf(buf,"SAS PHY Link Status: Phy=%d:" | 5913 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5914 | "SAS PHY Link Status: Phy=%d:" | ||
5905 | " Rate 1.5 Gbps",PhyNumber); | 5915 | " Rate 1.5 Gbps",PhyNumber); |
5906 | break; | 5916 | break; |
5907 | case MPI_EVENT_SAS_PLS_LR_RATE_3_0: | 5917 | case MPI_EVENT_SAS_PLS_LR_RATE_3_0: |
5908 | sprintf(buf,"SAS PHY Link Status: Phy=%d:" | 5918 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5919 | "SAS PHY Link Status: Phy=%d:" | ||
5909 | " Rate 3.0 Gpbs",PhyNumber); | 5920 | " Rate 3.0 Gpbs",PhyNumber); |
5910 | break; | 5921 | break; |
5911 | default: | 5922 | default: |
5912 | sprintf(buf,"SAS PHY Link Status: Phy=%d", PhyNumber); | 5923 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5924 | "SAS PHY Link Status: Phy=%d", PhyNumber); | ||
5913 | break; | 5925 | break; |
5914 | } | 5926 | } |
5915 | ds = buf; | ||
5916 | break; | 5927 | break; |
5917 | } | 5928 | } |
5918 | case MPI_EVENT_SAS_DISCOVERY_ERROR: | 5929 | case MPI_EVENT_SAS_DISCOVERY_ERROR: |
@@ -5921,9 +5932,8 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr) | |||
5921 | case MPI_EVENT_IR_RESYNC_UPDATE: | 5932 | case MPI_EVENT_IR_RESYNC_UPDATE: |
5922 | { | 5933 | { |
5923 | u8 resync_complete = (u8)(evData0 >> 16); | 5934 | u8 resync_complete = (u8)(evData0 >> 16); |
5924 | char buf[40]; | 5935 | snprintf(evStr, EVENT_DESCR_STR_SZ, |
5925 | sprintf(buf,"IR Resync Update: Complete = %d:",resync_complete); | 5936 | "IR Resync Update: Complete = %d:",resync_complete); |
5926 | ds = buf; | ||
5927 | break; | 5937 | break; |
5928 | } | 5938 | } |
5929 | case MPI_EVENT_IR2: | 5939 | case MPI_EVENT_IR2: |
@@ -5976,7 +5986,8 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr) | |||
5976 | ds = "Unknown"; | 5986 | ds = "Unknown"; |
5977 | break; | 5987 | break; |
5978 | } | 5988 | } |
5979 | strcpy(evStr,ds); | 5989 | if (ds) |
5990 | strncpy(evStr, ds, EVENT_DESCR_STR_SZ); | ||
5980 | } | 5991 | } |
5981 | 5992 | ||
5982 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 5993 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
@@ -5998,7 +6009,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply | |||
5998 | int ii; | 6009 | int ii; |
5999 | int r = 0; | 6010 | int r = 0; |
6000 | int handlers = 0; | 6011 | int handlers = 0; |
6001 | char evStr[100]; | 6012 | char evStr[EVENT_DESCR_STR_SZ]; |
6002 | u8 event; | 6013 | u8 event; |
6003 | 6014 | ||
6004 | /* | 6015 | /* |
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h index be7e8501b53c..f673cca507e1 100644 --- a/drivers/message/fusion/mptbase.h +++ b/drivers/message/fusion/mptbase.h | |||
@@ -76,8 +76,8 @@ | |||
76 | #define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR | 76 | #define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR |
77 | #endif | 77 | #endif |
78 | 78 | ||
79 | #define MPT_LINUX_VERSION_COMMON "3.03.08" | 79 | #define MPT_LINUX_VERSION_COMMON "3.03.09" |
80 | #define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.08" | 80 | #define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.09" |
81 | #define WHAT_MAGIC_STRING "@" "(" "#" ")" | 81 | #define WHAT_MAGIC_STRING "@" "(" "#" ")" |
82 | 82 | ||
83 | #define show_mptmod_ver(s,ver) \ | 83 | #define show_mptmod_ver(s,ver) \ |
@@ -489,7 +489,6 @@ typedef struct _RaidCfgData { | |||
489 | 489 | ||
490 | #define MPT_RPORT_INFO_FLAGS_REGISTERED 0x01 /* rport registered */ | 490 | #define MPT_RPORT_INFO_FLAGS_REGISTERED 0x01 /* rport registered */ |
491 | #define MPT_RPORT_INFO_FLAGS_MISSING 0x02 /* missing from DevPage0 scan */ | 491 | #define MPT_RPORT_INFO_FLAGS_MISSING 0x02 /* missing from DevPage0 scan */ |
492 | #define MPT_RPORT_INFO_FLAGS_MAPPED_VDEV 0x04 /* target mapped in vdev */ | ||
493 | 492 | ||
494 | /* | 493 | /* |
495 | * data allocated for each fc rport device | 494 | * data allocated for each fc rport device |
@@ -501,7 +500,6 @@ struct mptfc_rport_info | |||
501 | struct scsi_target *starget; | 500 | struct scsi_target *starget; |
502 | FCDevicePage0_t pg0; | 501 | FCDevicePage0_t pg0; |
503 | u8 flags; | 502 | u8 flags; |
504 | u8 remap_needed; | ||
505 | }; | 503 | }; |
506 | 504 | ||
507 | /* | 505 | /* |
@@ -628,11 +626,11 @@ typedef struct _MPT_ADAPTER | |||
628 | struct work_struct mptscsih_persistTask; | 626 | struct work_struct mptscsih_persistTask; |
629 | 627 | ||
630 | struct list_head fc_rports; | 628 | struct list_head fc_rports; |
631 | spinlock_t fc_rport_lock; /* list and ri flags */ | ||
632 | spinlock_t fc_rescan_work_lock; | 629 | spinlock_t fc_rescan_work_lock; |
633 | int fc_rescan_work_count; | 630 | int fc_rescan_work_count; |
634 | struct work_struct fc_rescan_work; | 631 | struct work_struct fc_rescan_work; |
635 | 632 | char fc_rescan_work_q_name[KOBJ_NAME_LEN]; | |
633 | struct workqueue_struct *fc_rescan_work_q; | ||
636 | } MPT_ADAPTER; | 634 | } MPT_ADAPTER; |
637 | 635 | ||
638 | /* | 636 | /* |
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index b343f2a68b1c..856487741ef4 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c | |||
@@ -341,9 +341,6 @@ mptfc_generate_rport_ids(FCDevicePage0_t *pg0, struct fc_rport_identifiers *rid) | |||
341 | rid->port_name = ((u64)pg0->WWPN.High) << 32 | (u64)pg0->WWPN.Low; | 341 | rid->port_name = ((u64)pg0->WWPN.High) << 32 | (u64)pg0->WWPN.Low; |
342 | rid->port_id = pg0->PortIdentifier; | 342 | rid->port_id = pg0->PortIdentifier; |
343 | rid->roles = FC_RPORT_ROLE_UNKNOWN; | 343 | rid->roles = FC_RPORT_ROLE_UNKNOWN; |
344 | rid->roles |= FC_RPORT_ROLE_FCP_TARGET; | ||
345 | if (pg0->Protocol & MPI_FC_DEVICE_PAGE0_PROT_FCP_INITIATOR) | ||
346 | rid->roles |= FC_RPORT_ROLE_FCP_INITIATOR; | ||
347 | 344 | ||
348 | return 0; | 345 | return 0; |
349 | } | 346 | } |
@@ -355,15 +352,18 @@ mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0) | |||
355 | struct fc_rport *rport; | 352 | struct fc_rport *rport; |
356 | struct mptfc_rport_info *ri; | 353 | struct mptfc_rport_info *ri; |
357 | int new_ri = 1; | 354 | int new_ri = 1; |
358 | u64 pn; | 355 | u64 pn, nn; |
359 | unsigned long flags; | ||
360 | VirtTarget *vtarget; | 356 | VirtTarget *vtarget; |
357 | u32 roles = FC_RPORT_ROLE_UNKNOWN; | ||
361 | 358 | ||
362 | if (mptfc_generate_rport_ids(pg0, &rport_ids) < 0) | 359 | if (mptfc_generate_rport_ids(pg0, &rport_ids) < 0) |
363 | return; | 360 | return; |
364 | 361 | ||
362 | roles |= FC_RPORT_ROLE_FCP_TARGET; | ||
363 | if (pg0->Protocol & MPI_FC_DEVICE_PAGE0_PROT_FCP_INITIATOR) | ||
364 | roles |= FC_RPORT_ROLE_FCP_INITIATOR; | ||
365 | |||
365 | /* scan list looking for a match */ | 366 | /* scan list looking for a match */ |
366 | spin_lock_irqsave(&ioc->fc_rport_lock, flags); | ||
367 | list_for_each_entry(ri, &ioc->fc_rports, list) { | 367 | list_for_each_entry(ri, &ioc->fc_rports, list) { |
368 | pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; | 368 | pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; |
369 | if (pn == rport_ids.port_name) { /* match */ | 369 | if (pn == rport_ids.port_name) { /* match */ |
@@ -373,11 +373,9 @@ mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0) | |||
373 | } | 373 | } |
374 | } | 374 | } |
375 | if (new_ri) { /* allocate one */ | 375 | if (new_ri) { /* allocate one */ |
376 | spin_unlock_irqrestore(&ioc->fc_rport_lock, flags); | ||
377 | ri = kzalloc(sizeof(struct mptfc_rport_info), GFP_KERNEL); | 376 | ri = kzalloc(sizeof(struct mptfc_rport_info), GFP_KERNEL); |
378 | if (!ri) | 377 | if (!ri) |
379 | return; | 378 | return; |
380 | spin_lock_irqsave(&ioc->fc_rport_lock, flags); | ||
381 | list_add_tail(&ri->list, &ioc->fc_rports); | 379 | list_add_tail(&ri->list, &ioc->fc_rports); |
382 | } | 380 | } |
383 | 381 | ||
@@ -387,14 +385,11 @@ mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0) | |||
387 | /* MPT_RPORT_INFO_FLAGS_REGISTERED - rport not previously deleted */ | 385 | /* MPT_RPORT_INFO_FLAGS_REGISTERED - rport not previously deleted */ |
388 | if (!(ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED)) { | 386 | if (!(ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED)) { |
389 | ri->flags |= MPT_RPORT_INFO_FLAGS_REGISTERED; | 387 | ri->flags |= MPT_RPORT_INFO_FLAGS_REGISTERED; |
390 | spin_unlock_irqrestore(&ioc->fc_rport_lock, flags); | ||
391 | rport = fc_remote_port_add(ioc->sh, channel, &rport_ids); | 388 | rport = fc_remote_port_add(ioc->sh, channel, &rport_ids); |
392 | spin_lock_irqsave(&ioc->fc_rport_lock, flags); | ||
393 | if (rport) { | 389 | if (rport) { |
394 | ri->rport = rport; | 390 | ri->rport = rport; |
395 | if (new_ri) /* may have been reset by user */ | 391 | if (new_ri) /* may have been reset by user */ |
396 | rport->dev_loss_tmo = mptfc_dev_loss_tmo; | 392 | rport->dev_loss_tmo = mptfc_dev_loss_tmo; |
397 | *((struct mptfc_rport_info **)rport->dd_data) = ri; | ||
398 | /* | 393 | /* |
399 | * if already mapped, remap here. If not mapped, | 394 | * if already mapped, remap here. If not mapped, |
400 | * target_alloc will allocate vtarget and map, | 395 | * target_alloc will allocate vtarget and map, |
@@ -406,16 +401,21 @@ mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0) | |||
406 | vtarget->target_id = pg0->CurrentTargetID; | 401 | vtarget->target_id = pg0->CurrentTargetID; |
407 | vtarget->bus_id = pg0->CurrentBus; | 402 | vtarget->bus_id = pg0->CurrentBus; |
408 | } | 403 | } |
409 | ri->remap_needed = 0; | ||
410 | } | 404 | } |
405 | *((struct mptfc_rport_info **)rport->dd_data) = ri; | ||
406 | /* scan will be scheduled once rport becomes a target */ | ||
407 | fc_remote_port_rolechg(rport,roles); | ||
408 | |||
409 | pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; | ||
410 | nn = (u64)ri->pg0.WWNN.High << 32 | (u64)ri->pg0.WWNN.Low; | ||
411 | dfcprintk ((MYIOC_s_INFO_FMT | 411 | dfcprintk ((MYIOC_s_INFO_FMT |
412 | "mptfc_reg_dev.%d: %x, %llx / %llx, tid %d, " | 412 | "mptfc_reg_dev.%d: %x, %llx / %llx, tid %d, " |
413 | "rport tid %d, tmo %d\n", | 413 | "rport tid %d, tmo %d\n", |
414 | ioc->name, | 414 | ioc->name, |
415 | ioc->sh->host_no, | 415 | ioc->sh->host_no, |
416 | pg0->PortIdentifier, | 416 | pg0->PortIdentifier, |
417 | pg0->WWNN, | 417 | (unsigned long long)nn, |
418 | pg0->WWPN, | 418 | (unsigned long long)pn, |
419 | pg0->CurrentTargetID, | 419 | pg0->CurrentTargetID, |
420 | ri->rport->scsi_target_id, | 420 | ri->rport->scsi_target_id, |
421 | ri->rport->dev_loss_tmo)); | 421 | ri->rport->dev_loss_tmo)); |
@@ -425,8 +425,6 @@ mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0) | |||
425 | ri = NULL; | 425 | ri = NULL; |
426 | } | 426 | } |
427 | } | 427 | } |
428 | spin_unlock_irqrestore(&ioc->fc_rport_lock,flags); | ||
429 | |||
430 | } | 428 | } |
431 | 429 | ||
432 | /* | 430 | /* |
@@ -476,7 +474,6 @@ mptfc_target_alloc(struct scsi_target *starget) | |||
476 | vtarget->target_id = ri->pg0.CurrentTargetID; | 474 | vtarget->target_id = ri->pg0.CurrentTargetID; |
477 | vtarget->bus_id = ri->pg0.CurrentBus; | 475 | vtarget->bus_id = ri->pg0.CurrentBus; |
478 | ri->starget = starget; | 476 | ri->starget = starget; |
479 | ri->remap_needed = 0; | ||
480 | rc = 0; | 477 | rc = 0; |
481 | } | 478 | } |
482 | } | 479 | } |
@@ -502,10 +499,10 @@ mptfc_slave_alloc(struct scsi_device *sdev) | |||
502 | VirtDevice *vdev; | 499 | VirtDevice *vdev; |
503 | struct scsi_target *starget; | 500 | struct scsi_target *starget; |
504 | struct fc_rport *rport; | 501 | struct fc_rport *rport; |
505 | unsigned long flags; | ||
506 | 502 | ||
507 | 503 | ||
508 | rport = starget_to_rport(scsi_target(sdev)); | 504 | starget = scsi_target(sdev); |
505 | rport = starget_to_rport(starget); | ||
509 | 506 | ||
510 | if (!rport || fc_remote_port_chkready(rport)) | 507 | if (!rport || fc_remote_port_chkready(rport)) |
511 | return -ENXIO; | 508 | return -ENXIO; |
@@ -519,10 +516,8 @@ mptfc_slave_alloc(struct scsi_device *sdev) | |||
519 | return -ENOMEM; | 516 | return -ENOMEM; |
520 | } | 517 | } |
521 | 518 | ||
522 | spin_lock_irqsave(&hd->ioc->fc_rport_lock,flags); | ||
523 | 519 | ||
524 | sdev->hostdata = vdev; | 520 | sdev->hostdata = vdev; |
525 | starget = scsi_target(sdev); | ||
526 | vtarget = starget->hostdata; | 521 | vtarget = starget->hostdata; |
527 | 522 | ||
528 | if (vtarget->num_luns == 0) { | 523 | if (vtarget->num_luns == 0) { |
@@ -535,14 +530,16 @@ mptfc_slave_alloc(struct scsi_device *sdev) | |||
535 | vdev->vtarget = vtarget; | 530 | vdev->vtarget = vtarget; |
536 | vdev->lun = sdev->lun; | 531 | vdev->lun = sdev->lun; |
537 | 532 | ||
538 | spin_unlock_irqrestore(&hd->ioc->fc_rport_lock,flags); | ||
539 | |||
540 | vtarget->num_luns++; | 533 | vtarget->num_luns++; |
541 | 534 | ||
535 | |||
542 | #ifdef DMPT_DEBUG_FC | 536 | #ifdef DMPT_DEBUG_FC |
543 | { | 537 | { |
538 | u64 nn, pn; | ||
544 | struct mptfc_rport_info *ri; | 539 | struct mptfc_rport_info *ri; |
545 | ri = *((struct mptfc_rport_info **)rport->dd_data); | 540 | ri = *((struct mptfc_rport_info **)rport->dd_data); |
541 | pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; | ||
542 | nn = (u64)ri->pg0.WWNN.High << 32 | (u64)ri->pg0.WWNN.Low; | ||
546 | dfcprintk ((MYIOC_s_INFO_FMT | 543 | dfcprintk ((MYIOC_s_INFO_FMT |
547 | "mptfc_slv_alloc.%d: num_luns %d, sdev.id %d, " | 544 | "mptfc_slv_alloc.%d: num_luns %d, sdev.id %d, " |
548 | "CurrentTargetID %d, %x %llx %llx\n", | 545 | "CurrentTargetID %d, %x %llx %llx\n", |
@@ -550,7 +547,9 @@ mptfc_slave_alloc(struct scsi_device *sdev) | |||
550 | sdev->host->host_no, | 547 | sdev->host->host_no, |
551 | vtarget->num_luns, | 548 | vtarget->num_luns, |
552 | sdev->id, ri->pg0.CurrentTargetID, | 549 | sdev->id, ri->pg0.CurrentTargetID, |
553 | ri->pg0.PortIdentifier, ri->pg0.WWPN, ri->pg0.WWNN)); | 550 | ri->pg0.PortIdentifier, |
551 | (unsigned long long)pn, | ||
552 | (unsigned long long)nn)); | ||
554 | } | 553 | } |
555 | #endif | 554 | #endif |
556 | 555 | ||
@@ -570,11 +569,31 @@ mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) | |||
570 | done(SCpnt); | 569 | done(SCpnt); |
571 | return 0; | 570 | return 0; |
572 | } | 571 | } |
572 | |||
573 | /* dd_data is null until finished adding target */ | ||
573 | ri = *((struct mptfc_rport_info **)rport->dd_data); | 574 | ri = *((struct mptfc_rport_info **)rport->dd_data); |
574 | if (unlikely(ri->remap_needed)) | 575 | if (unlikely(!ri)) { |
575 | return SCSI_MLQUEUE_HOST_BUSY; | 576 | dfcprintk ((MYIOC_s_INFO_FMT |
577 | "mptfc_qcmd.%d: %d:%d, dd_data is null.\n", | ||
578 | ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->name, | ||
579 | ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->sh->host_no, | ||
580 | SCpnt->device->id,SCpnt->device->lun)); | ||
581 | SCpnt->result = DID_IMM_RETRY << 16; | ||
582 | done(SCpnt); | ||
583 | return 0; | ||
584 | } | ||
576 | 585 | ||
577 | return mptscsih_qcmd(SCpnt,done); | 586 | err = mptscsih_qcmd(SCpnt,done); |
587 | #ifdef DMPT_DEBUG_FC | ||
588 | if (unlikely(err)) { | ||
589 | dfcprintk ((MYIOC_s_INFO_FMT | ||
590 | "mptfc_qcmd.%d: %d:%d, mptscsih_qcmd returns non-zero.\n", | ||
591 | ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->name, | ||
592 | ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->sh->host_no, | ||
593 | SCpnt->device->id,SCpnt->device->lun)); | ||
594 | } | ||
595 | #endif | ||
596 | return err; | ||
578 | } | 597 | } |
579 | 598 | ||
580 | static void | 599 | static void |
@@ -615,18 +634,17 @@ mptfc_rescan_devices(void *arg) | |||
615 | MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; | 634 | MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; |
616 | int ii; | 635 | int ii; |
617 | int work_to_do; | 636 | int work_to_do; |
637 | u64 pn; | ||
618 | unsigned long flags; | 638 | unsigned long flags; |
619 | struct mptfc_rport_info *ri; | 639 | struct mptfc_rport_info *ri; |
620 | 640 | ||
621 | do { | 641 | do { |
622 | /* start by tagging all ports as missing */ | 642 | /* start by tagging all ports as missing */ |
623 | spin_lock_irqsave(&ioc->fc_rport_lock,flags); | ||
624 | list_for_each_entry(ri, &ioc->fc_rports, list) { | 643 | list_for_each_entry(ri, &ioc->fc_rports, list) { |
625 | if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) { | 644 | if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) { |
626 | ri->flags |= MPT_RPORT_INFO_FLAGS_MISSING; | 645 | ri->flags |= MPT_RPORT_INFO_FLAGS_MISSING; |
627 | } | 646 | } |
628 | } | 647 | } |
629 | spin_unlock_irqrestore(&ioc->fc_rport_lock,flags); | ||
630 | 648 | ||
631 | /* | 649 | /* |
632 | * now rescan devices known to adapter, | 650 | * now rescan devices known to adapter, |
@@ -639,33 +657,24 @@ mptfc_rescan_devices(void *arg) | |||
639 | } | 657 | } |
640 | 658 | ||
641 | /* delete devices still missing */ | 659 | /* delete devices still missing */ |
642 | spin_lock_irqsave(&ioc->fc_rport_lock, flags); | ||
643 | list_for_each_entry(ri, &ioc->fc_rports, list) { | 660 | list_for_each_entry(ri, &ioc->fc_rports, list) { |
644 | /* if newly missing, delete it */ | 661 | /* if newly missing, delete it */ |
645 | if ((ri->flags & (MPT_RPORT_INFO_FLAGS_REGISTERED | | 662 | if (ri->flags & MPT_RPORT_INFO_FLAGS_MISSING) { |
646 | MPT_RPORT_INFO_FLAGS_MISSING)) | ||
647 | == (MPT_RPORT_INFO_FLAGS_REGISTERED | | ||
648 | MPT_RPORT_INFO_FLAGS_MISSING)) { | ||
649 | 663 | ||
650 | ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED| | 664 | ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED| |
651 | MPT_RPORT_INFO_FLAGS_MISSING); | 665 | MPT_RPORT_INFO_FLAGS_MISSING); |
652 | ri->remap_needed = 1; | 666 | fc_remote_port_delete(ri->rport); /* won't sleep */ |
653 | fc_remote_port_delete(ri->rport); | ||
654 | /* | ||
655 | * remote port not really deleted 'cause | ||
656 | * binding is by WWPN and driver only | ||
657 | * registers FCP_TARGETs but cannot trust | ||
658 | * data structures. | ||
659 | */ | ||
660 | ri->rport = NULL; | 667 | ri->rport = NULL; |
668 | |||
669 | pn = (u64)ri->pg0.WWPN.High << 32 | | ||
670 | (u64)ri->pg0.WWPN.Low; | ||
661 | dfcprintk ((MYIOC_s_INFO_FMT | 671 | dfcprintk ((MYIOC_s_INFO_FMT |
662 | "mptfc_rescan.%d: %llx deleted\n", | 672 | "mptfc_rescan.%d: %llx deleted\n", |
663 | ioc->name, | 673 | ioc->name, |
664 | ioc->sh->host_no, | 674 | ioc->sh->host_no, |
665 | ri->pg0.WWPN)); | 675 | (unsigned long long)pn)); |
666 | } | 676 | } |
667 | } | 677 | } |
668 | spin_unlock_irqrestore(&ioc->fc_rport_lock,flags); | ||
669 | 678 | ||
670 | /* | 679 | /* |
671 | * allow multiple passes as target state | 680 | * allow multiple passes as target state |
@@ -870,10 +879,23 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
870 | goto out_mptfc_probe; | 879 | goto out_mptfc_probe; |
871 | } | 880 | } |
872 | 881 | ||
873 | for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) { | 882 | /* initialize workqueue */ |
874 | mptfc_init_host_attr(ioc,ii); | 883 | |
875 | mptfc_GetFcDevPage0(ioc,ii,mptfc_register_dev); | 884 | snprintf(ioc->fc_rescan_work_q_name, KOBJ_NAME_LEN, "mptfc_wq_%d", |
876 | } | 885 | sh->host_no); |
886 | ioc->fc_rescan_work_q = | ||
887 | create_singlethread_workqueue(ioc->fc_rescan_work_q_name); | ||
888 | if (!ioc->fc_rescan_work_q) | ||
889 | goto out_mptfc_probe; | ||
890 | |||
891 | /* | ||
892 | * scan for rports - | ||
893 | * by doing it via the workqueue, some locking is eliminated | ||
894 | */ | ||
895 | |||
896 | ioc->fc_rescan_work_count = 1; | ||
897 | queue_work(ioc->fc_rescan_work_q, &ioc->fc_rescan_work); | ||
898 | flush_workqueue(ioc->fc_rescan_work_q); | ||
877 | 899 | ||
878 | return 0; | 900 | return 0; |
879 | 901 | ||
@@ -949,8 +971,18 @@ mptfc_init(void) | |||
949 | static void __devexit | 971 | static void __devexit |
950 | mptfc_remove(struct pci_dev *pdev) | 972 | mptfc_remove(struct pci_dev *pdev) |
951 | { | 973 | { |
952 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | 974 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); |
953 | struct mptfc_rport_info *p, *n; | 975 | struct mptfc_rport_info *p, *n; |
976 | struct workqueue_struct *work_q; | ||
977 | unsigned long flags; | ||
978 | |||
979 | /* destroy workqueue */ | ||
980 | if ((work_q=ioc->fc_rescan_work_q)) { | ||
981 | spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); | ||
982 | ioc->fc_rescan_work_q = NULL; | ||
983 | spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); | ||
984 | destroy_workqueue(work_q); | ||
985 | } | ||
954 | 986 | ||
955 | fc_remove_host(ioc->sh); | 987 | fc_remove_host(ioc->sh); |
956 | 988 | ||
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index e9716b10acea..af6ec553ff7c 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c | |||
@@ -91,6 +91,7 @@ enum mptsas_hotplug_action { | |||
91 | MPTSAS_DEL_DEVICE, | 91 | MPTSAS_DEL_DEVICE, |
92 | MPTSAS_ADD_RAID, | 92 | MPTSAS_ADD_RAID, |
93 | MPTSAS_DEL_RAID, | 93 | MPTSAS_DEL_RAID, |
94 | MPTSAS_IGNORE_EVENT, | ||
94 | }; | 95 | }; |
95 | 96 | ||
96 | struct mptsas_hotplug_event { | 97 | struct mptsas_hotplug_event { |
@@ -298,6 +299,26 @@ mptsas_find_portinfo_by_handle(MPT_ADAPTER *ioc, u16 handle) | |||
298 | return rc; | 299 | return rc; |
299 | } | 300 | } |
300 | 301 | ||
302 | /* | ||
303 | * Returns true if there is a scsi end device | ||
304 | */ | ||
305 | static inline int | ||
306 | mptsas_is_end_device(struct mptsas_devinfo * attached) | ||
307 | { | ||
308 | if ((attached->handle) && | ||
309 | (attached->device_info & | ||
310 | MPI_SAS_DEVICE_INFO_END_DEVICE) && | ||
311 | ((attached->device_info & | ||
312 | MPI_SAS_DEVICE_INFO_SSP_TARGET) | | ||
313 | (attached->device_info & | ||
314 | MPI_SAS_DEVICE_INFO_STP_TARGET) | | ||
315 | (attached->device_info & | ||
316 | MPI_SAS_DEVICE_INFO_SATA_DEVICE))) | ||
317 | return 1; | ||
318 | else | ||
319 | return 0; | ||
320 | } | ||
321 | |||
301 | static int | 322 | static int |
302 | mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc, struct mptsas_enclosure *enclosure, | 323 | mptsas_sas_enclosure_pg0(MPT_ADAPTER *ioc, struct mptsas_enclosure *enclosure, |
303 | u32 form, u32 form_specific) | 324 | u32 form, u32 form_specific) |
@@ -872,7 +893,11 @@ mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info, | |||
872 | SasDevicePage0_t *buffer; | 893 | SasDevicePage0_t *buffer; |
873 | dma_addr_t dma_handle; | 894 | dma_addr_t dma_handle; |
874 | __le64 sas_address; | 895 | __le64 sas_address; |
875 | int error; | 896 | int error=0; |
897 | |||
898 | if (ioc->sas_discovery_runtime && | ||
899 | mptsas_is_end_device(device_info)) | ||
900 | goto out; | ||
876 | 901 | ||
877 | hdr.PageVersion = MPI_SASDEVICE0_PAGEVERSION; | 902 | hdr.PageVersion = MPI_SASDEVICE0_PAGEVERSION; |
878 | hdr.ExtPageLength = 0; | 903 | hdr.ExtPageLength = 0; |
@@ -1009,7 +1034,11 @@ mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, | |||
1009 | CONFIGPARMS cfg; | 1034 | CONFIGPARMS cfg; |
1010 | SasExpanderPage1_t *buffer; | 1035 | SasExpanderPage1_t *buffer; |
1011 | dma_addr_t dma_handle; | 1036 | dma_addr_t dma_handle; |
1012 | int error; | 1037 | int error=0; |
1038 | |||
1039 | if (ioc->sas_discovery_runtime && | ||
1040 | mptsas_is_end_device(&phy_info->attached)) | ||
1041 | goto out; | ||
1013 | 1042 | ||
1014 | hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION; | 1043 | hdr.PageVersion = MPI_SASEXPANDER0_PAGEVERSION; |
1015 | hdr.ExtPageLength = 0; | 1044 | hdr.ExtPageLength = 0; |
@@ -1068,26 +1097,6 @@ mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, | |||
1068 | return error; | 1097 | return error; |
1069 | } | 1098 | } |
1070 | 1099 | ||
1071 | /* | ||
1072 | * Returns true if there is a scsi end device | ||
1073 | */ | ||
1074 | static inline int | ||
1075 | mptsas_is_end_device(struct mptsas_devinfo * attached) | ||
1076 | { | ||
1077 | if ((attached->handle) && | ||
1078 | (attached->device_info & | ||
1079 | MPI_SAS_DEVICE_INFO_END_DEVICE) && | ||
1080 | ((attached->device_info & | ||
1081 | MPI_SAS_DEVICE_INFO_SSP_TARGET) | | ||
1082 | (attached->device_info & | ||
1083 | MPI_SAS_DEVICE_INFO_STP_TARGET) | | ||
1084 | (attached->device_info & | ||
1085 | MPI_SAS_DEVICE_INFO_SATA_DEVICE))) | ||
1086 | return 1; | ||
1087 | else | ||
1088 | return 0; | ||
1089 | } | ||
1090 | |||
1091 | static void | 1100 | static void |
1092 | mptsas_parse_device_info(struct sas_identify *identify, | 1101 | mptsas_parse_device_info(struct sas_identify *identify, |
1093 | struct mptsas_devinfo *device_info) | 1102 | struct mptsas_devinfo *device_info) |
@@ -1737,6 +1746,9 @@ mptsas_hotplug_work(void *arg) | |||
1737 | break; | 1746 | break; |
1738 | case MPTSAS_ADD_DEVICE: | 1747 | case MPTSAS_ADD_DEVICE: |
1739 | 1748 | ||
1749 | if (ev->phys_disk_num_valid) | ||
1750 | mpt_findImVolumes(ioc); | ||
1751 | |||
1740 | /* | 1752 | /* |
1741 | * Refresh sas device pg0 data | 1753 | * Refresh sas device pg0 data |
1742 | */ | 1754 | */ |
@@ -1868,6 +1880,9 @@ mptsas_hotplug_work(void *arg) | |||
1868 | scsi_device_put(sdev); | 1880 | scsi_device_put(sdev); |
1869 | mpt_findImVolumes(ioc); | 1881 | mpt_findImVolumes(ioc); |
1870 | break; | 1882 | break; |
1883 | case MPTSAS_IGNORE_EVENT: | ||
1884 | default: | ||
1885 | break; | ||
1871 | } | 1886 | } |
1872 | 1887 | ||
1873 | kfree(ev); | 1888 | kfree(ev); |
@@ -1940,7 +1955,8 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc, | |||
1940 | EVENT_DATA_RAID *raid_event_data) | 1955 | EVENT_DATA_RAID *raid_event_data) |
1941 | { | 1956 | { |
1942 | struct mptsas_hotplug_event *ev; | 1957 | struct mptsas_hotplug_event *ev; |
1943 | RAID_VOL0_STATUS * volumeStatus; | 1958 | int status = le32_to_cpu(raid_event_data->SettingsStatus); |
1959 | int state = (status >> 8) & 0xff; | ||
1944 | 1960 | ||
1945 | if (ioc->bus_type != SAS) | 1961 | if (ioc->bus_type != SAS) |
1946 | return; | 1962 | return; |
@@ -1955,6 +1971,7 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc, | |||
1955 | INIT_WORK(&ev->work, mptsas_hotplug_work, ev); | 1971 | INIT_WORK(&ev->work, mptsas_hotplug_work, ev); |
1956 | ev->ioc = ioc; | 1972 | ev->ioc = ioc; |
1957 | ev->id = raid_event_data->VolumeID; | 1973 | ev->id = raid_event_data->VolumeID; |
1974 | ev->event_type = MPTSAS_IGNORE_EVENT; | ||
1958 | 1975 | ||
1959 | switch (raid_event_data->ReasonCode) { | 1976 | switch (raid_event_data->ReasonCode) { |
1960 | case MPI_EVENT_RAID_RC_PHYSDISK_DELETED: | 1977 | case MPI_EVENT_RAID_RC_PHYSDISK_DELETED: |
@@ -1966,6 +1983,25 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc, | |||
1966 | ev->phys_disk_num = raid_event_data->PhysDiskNum; | 1983 | ev->phys_disk_num = raid_event_data->PhysDiskNum; |
1967 | ev->event_type = MPTSAS_DEL_DEVICE; | 1984 | ev->event_type = MPTSAS_DEL_DEVICE; |
1968 | break; | 1985 | break; |
1986 | case MPI_EVENT_RAID_RC_PHYSDISK_STATUS_CHANGED: | ||
1987 | switch (state) { | ||
1988 | case MPI_PD_STATE_ONLINE: | ||
1989 | ioc->raid_data.isRaid = 1; | ||
1990 | ev->phys_disk_num_valid = 1; | ||
1991 | ev->phys_disk_num = raid_event_data->PhysDiskNum; | ||
1992 | ev->event_type = MPTSAS_ADD_DEVICE; | ||
1993 | break; | ||
1994 | case MPI_PD_STATE_MISSING: | ||
1995 | case MPI_PD_STATE_NOT_COMPATIBLE: | ||
1996 | case MPI_PD_STATE_OFFLINE_AT_HOST_REQUEST: | ||
1997 | case MPI_PD_STATE_FAILED_AT_HOST_REQUEST: | ||
1998 | case MPI_PD_STATE_OFFLINE_FOR_ANOTHER_REASON: | ||
1999 | ev->event_type = MPTSAS_DEL_DEVICE; | ||
2000 | break; | ||
2001 | default: | ||
2002 | break; | ||
2003 | } | ||
2004 | break; | ||
1969 | case MPI_EVENT_RAID_RC_VOLUME_DELETED: | 2005 | case MPI_EVENT_RAID_RC_VOLUME_DELETED: |
1970 | ev->event_type = MPTSAS_DEL_RAID; | 2006 | ev->event_type = MPTSAS_DEL_RAID; |
1971 | break; | 2007 | break; |
@@ -1973,11 +2009,18 @@ mptscsih_send_raid_event(MPT_ADAPTER *ioc, | |||
1973 | ev->event_type = MPTSAS_ADD_RAID; | 2009 | ev->event_type = MPTSAS_ADD_RAID; |
1974 | break; | 2010 | break; |
1975 | case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED: | 2011 | case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED: |
1976 | volumeStatus = (RAID_VOL0_STATUS *) & | 2012 | switch (state) { |
1977 | raid_event_data->SettingsStatus; | 2013 | case MPI_RAIDVOL0_STATUS_STATE_FAILED: |
1978 | ev->event_type = (volumeStatus->State == | 2014 | case MPI_RAIDVOL0_STATUS_STATE_MISSING: |
1979 | MPI_RAIDVOL0_STATUS_STATE_FAILED) ? | 2015 | ev->event_type = MPTSAS_DEL_RAID; |
1980 | MPTSAS_DEL_RAID : MPTSAS_ADD_RAID; | 2016 | break; |
2017 | case MPI_RAIDVOL0_STATUS_STATE_OPTIMAL: | ||
2018 | case MPI_RAIDVOL0_STATUS_STATE_DEGRADED: | ||
2019 | ev->event_type = MPTSAS_ADD_RAID; | ||
2020 | break; | ||
2021 | default: | ||
2022 | break; | ||
2023 | } | ||
1981 | break; | 2024 | break; |
1982 | default: | 2025 | default: |
1983 | break; | 2026 | break; |
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 3729062db317..84fa271eb8f4 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c | |||
@@ -632,7 +632,11 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) | |||
632 | 632 | ||
633 | case MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE: /* 0x0043 */ | 633 | case MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE: /* 0x0043 */ |
634 | /* Spoof to SCSI Selection Timeout! */ | 634 | /* Spoof to SCSI Selection Timeout! */ |
635 | sc->result = DID_NO_CONNECT << 16; | 635 | if (ioc->bus_type != FC) |
636 | sc->result = DID_NO_CONNECT << 16; | ||
637 | /* else fibre, just stall until rescan event */ | ||
638 | else | ||
639 | sc->result = DID_REQUEUE << 16; | ||
636 | 640 | ||
637 | if (hd->sel_timeout[pScsiReq->TargetID] < 0xFFFF) | 641 | if (hd->sel_timeout[pScsiReq->TargetID] < 0xFFFF) |
638 | hd->sel_timeout[pScsiReq->TargetID]++; | 642 | hd->sel_timeout[pScsiReq->TargetID]++; |
@@ -877,7 +881,7 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice) | |||
877 | struct scsi_cmnd *sc; | 881 | struct scsi_cmnd *sc; |
878 | 882 | ||
879 | dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n", | 883 | dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n", |
880 | vdevice->target_id, vdevice->lun, max)); | 884 | vdevice->vtarget->target_id, vdevice->lun, max)); |
881 | 885 | ||
882 | for (ii=0; ii < max; ii++) { | 886 | for (ii=0; ii < max; ii++) { |
883 | if ((sc = hd->ScsiLookup[ii]) != NULL) { | 887 | if ((sc = hd->ScsiLookup[ii]) != NULL) { |
@@ -1645,7 +1649,6 @@ int | |||
1645 | mptscsih_abort(struct scsi_cmnd * SCpnt) | 1649 | mptscsih_abort(struct scsi_cmnd * SCpnt) |
1646 | { | 1650 | { |
1647 | MPT_SCSI_HOST *hd; | 1651 | MPT_SCSI_HOST *hd; |
1648 | MPT_ADAPTER *ioc; | ||
1649 | MPT_FRAME_HDR *mf; | 1652 | MPT_FRAME_HDR *mf; |
1650 | u32 ctx2abort; | 1653 | u32 ctx2abort; |
1651 | int scpnt_idx; | 1654 | int scpnt_idx; |
@@ -1663,14 +1666,6 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1663 | return FAILED; | 1666 | return FAILED; |
1664 | } | 1667 | } |
1665 | 1668 | ||
1666 | ioc = hd->ioc; | ||
1667 | if (hd->resetPending) { | ||
1668 | return FAILED; | ||
1669 | } | ||
1670 | |||
1671 | if (hd->timeouts < -1) | ||
1672 | hd->timeouts++; | ||
1673 | |||
1674 | /* Find this command | 1669 | /* Find this command |
1675 | */ | 1670 | */ |
1676 | if ((scpnt_idx = SCPNT_TO_LOOKUP_IDX(SCpnt)) < 0) { | 1671 | if ((scpnt_idx = SCPNT_TO_LOOKUP_IDX(SCpnt)) < 0) { |
@@ -1684,6 +1679,13 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1684 | return SUCCESS; | 1679 | return SUCCESS; |
1685 | } | 1680 | } |
1686 | 1681 | ||
1682 | if (hd->resetPending) { | ||
1683 | return FAILED; | ||
1684 | } | ||
1685 | |||
1686 | if (hd->timeouts < -1) | ||
1687 | hd->timeouts++; | ||
1688 | |||
1687 | printk(KERN_WARNING MYNAM ": %s: attempting task abort! (sc=%p)\n", | 1689 | printk(KERN_WARNING MYNAM ": %s: attempting task abort! (sc=%p)\n", |
1688 | hd->ioc->name, SCpnt); | 1690 | hd->ioc->name, SCpnt); |
1689 | scsi_print_command(SCpnt); | 1691 | scsi_print_command(SCpnt); |
@@ -1703,7 +1705,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) | |||
1703 | vdev = SCpnt->device->hostdata; | 1705 | vdev = SCpnt->device->hostdata; |
1704 | retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, | 1706 | retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, |
1705 | vdev->vtarget->bus_id, vdev->vtarget->target_id, vdev->lun, | 1707 | vdev->vtarget->bus_id, vdev->vtarget->target_id, vdev->lun, |
1706 | ctx2abort, mptscsih_get_tm_timeout(ioc)); | 1708 | ctx2abort, mptscsih_get_tm_timeout(hd->ioc)); |
1707 | 1709 | ||
1708 | printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n", | 1710 | printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n", |
1709 | hd->ioc->name, | 1711 | hd->ioc->name, |
@@ -2521,15 +2523,15 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | |||
2521 | 2523 | ||
2522 | /* 7. FC: Rescan for blocked rports which might have returned. | 2524 | /* 7. FC: Rescan for blocked rports which might have returned. |
2523 | */ | 2525 | */ |
2524 | else if (ioc->bus_type == FC) { | 2526 | if (ioc->bus_type == FC) { |
2525 | int work_count; | ||
2526 | unsigned long flags; | ||
2527 | |||
2528 | spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); | 2527 | spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); |
2529 | work_count = ++ioc->fc_rescan_work_count; | 2528 | if (ioc->fc_rescan_work_q) { |
2529 | if (ioc->fc_rescan_work_count++ == 0) { | ||
2530 | queue_work(ioc->fc_rescan_work_q, | ||
2531 | &ioc->fc_rescan_work); | ||
2532 | } | ||
2533 | } | ||
2530 | spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); | 2534 | spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); |
2531 | if (work_count == 1) | ||
2532 | schedule_work(&ioc->fc_rescan_work); | ||
2533 | } | 2535 | } |
2534 | dtmprintk((MYIOC_s_WARN_FMT "Post-Reset complete.\n", ioc->name)); | 2536 | dtmprintk((MYIOC_s_WARN_FMT "Post-Reset complete.\n", ioc->name)); |
2535 | 2537 | ||
@@ -2544,7 +2546,6 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | |||
2544 | { | 2546 | { |
2545 | MPT_SCSI_HOST *hd; | 2547 | MPT_SCSI_HOST *hd; |
2546 | u8 event = le32_to_cpu(pEvReply->Event) & 0xFF; | 2548 | u8 event = le32_to_cpu(pEvReply->Event) & 0xFF; |
2547 | int work_count; | ||
2548 | unsigned long flags; | 2549 | unsigned long flags; |
2549 | 2550 | ||
2550 | devtverboseprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n", | 2551 | devtverboseprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n", |
@@ -2569,10 +2570,13 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) | |||
2569 | 2570 | ||
2570 | case MPI_EVENT_RESCAN: /* 06 */ | 2571 | case MPI_EVENT_RESCAN: /* 06 */ |
2571 | spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); | 2572 | spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags); |
2572 | work_count = ++ioc->fc_rescan_work_count; | 2573 | if (ioc->fc_rescan_work_q) { |
2574 | if (ioc->fc_rescan_work_count++ == 0) { | ||
2575 | queue_work(ioc->fc_rescan_work_q, | ||
2576 | &ioc->fc_rescan_work); | ||
2577 | } | ||
2578 | } | ||
2573 | spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); | 2579 | spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags); |
2574 | if (work_count == 1) | ||
2575 | schedule_work(&ioc->fc_rescan_work); | ||
2576 | break; | 2580 | break; |
2577 | 2581 | ||
2578 | /* | 2582 | /* |
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 09c745b19cc8..f2a4d382ea19 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c | |||
@@ -783,6 +783,70 @@ static struct pci_device_id mptspi_pci_table[] = { | |||
783 | }; | 783 | }; |
784 | MODULE_DEVICE_TABLE(pci, mptspi_pci_table); | 784 | MODULE_DEVICE_TABLE(pci, mptspi_pci_table); |
785 | 785 | ||
786 | |||
787 | /* | ||
788 | * renegotiate for a given target | ||
789 | */ | ||
790 | static void | ||
791 | mptspi_dv_renegotiate_work(void *data) | ||
792 | { | ||
793 | struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data; | ||
794 | struct _MPT_SCSI_HOST *hd = wqw->hd; | ||
795 | struct scsi_device *sdev; | ||
796 | |||
797 | kfree(wqw); | ||
798 | |||
799 | shost_for_each_device(sdev, hd->ioc->sh) | ||
800 | mptspi_dv_device(hd, sdev); | ||
801 | } | ||
802 | |||
803 | static void | ||
804 | mptspi_dv_renegotiate(struct _MPT_SCSI_HOST *hd) | ||
805 | { | ||
806 | struct work_queue_wrapper *wqw = kmalloc(sizeof(*wqw), GFP_ATOMIC); | ||
807 | |||
808 | if (!wqw) | ||
809 | return; | ||
810 | |||
811 | INIT_WORK(&wqw->work, mptspi_dv_renegotiate_work, wqw); | ||
812 | wqw->hd = hd; | ||
813 | |||
814 | schedule_work(&wqw->work); | ||
815 | } | ||
816 | |||
817 | /* | ||
818 | * spi module reset handler | ||
819 | */ | ||
820 | static int | ||
821 | mptspi_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | ||
822 | { | ||
823 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)ioc->sh->hostdata; | ||
824 | int rc; | ||
825 | |||
826 | rc = mptscsih_ioc_reset(ioc, reset_phase); | ||
827 | |||
828 | if (reset_phase == MPT_IOC_POST_RESET) | ||
829 | mptspi_dv_renegotiate(hd); | ||
830 | |||
831 | return rc; | ||
832 | } | ||
833 | |||
834 | /* | ||
835 | * spi module resume handler | ||
836 | */ | ||
837 | static int | ||
838 | mptspi_resume(struct pci_dev *pdev) | ||
839 | { | ||
840 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | ||
841 | struct _MPT_SCSI_HOST *hd = (struct _MPT_SCSI_HOST *)ioc->sh->hostdata; | ||
842 | int rc; | ||
843 | |||
844 | rc = mptscsih_resume(pdev); | ||
845 | mptspi_dv_renegotiate(hd); | ||
846 | |||
847 | return rc; | ||
848 | } | ||
849 | |||
786 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 850 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
787 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 851 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
788 | /* | 852 | /* |
@@ -1032,7 +1096,7 @@ static struct pci_driver mptspi_driver = { | |||
1032 | .shutdown = mptscsih_shutdown, | 1096 | .shutdown = mptscsih_shutdown, |
1033 | #ifdef CONFIG_PM | 1097 | #ifdef CONFIG_PM |
1034 | .suspend = mptscsih_suspend, | 1098 | .suspend = mptscsih_suspend, |
1035 | .resume = mptscsih_resume, | 1099 | .resume = mptspi_resume, |
1036 | #endif | 1100 | #endif |
1037 | }; | 1101 | }; |
1038 | 1102 | ||
@@ -1061,7 +1125,7 @@ mptspi_init(void) | |||
1061 | ": Registered for IOC event notifications\n")); | 1125 | ": Registered for IOC event notifications\n")); |
1062 | } | 1126 | } |
1063 | 1127 | ||
1064 | if (mpt_reset_register(mptspiDoneCtx, mptscsih_ioc_reset) == 0) { | 1128 | if (mpt_reset_register(mptspiDoneCtx, mptspi_ioc_reset) == 0) { |
1065 | dprintk((KERN_INFO MYNAM | 1129 | dprintk((KERN_INFO MYNAM |
1066 | ": Registered for IOC reset notifications\n")); | 1130 | ": Registered for IOC reset notifications\n")); |
1067 | } | 1131 | } |
diff --git a/drivers/mmc/at91_mci.c b/drivers/mmc/at91_mci.c index 6061c2d101a0..88f0eef9cf33 100644 --- a/drivers/mmc/at91_mci.c +++ b/drivers/mmc/at91_mci.c | |||
@@ -621,9 +621,6 @@ static void at91_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
621 | struct at91mci_host *host = mmc_priv(mmc); | 621 | struct at91mci_host *host = mmc_priv(mmc); |
622 | unsigned long at91_master_clock = clk_get_rate(mci_clk); | 622 | unsigned long at91_master_clock = clk_get_rate(mci_clk); |
623 | 623 | ||
624 | DBG("Clock %uHz, busmode %u, powermode %u, Vdd %u\n", | ||
625 | ios->clock, ios->bus_mode, ios->power_mode, ios->vdd); | ||
626 | |||
627 | if (host) | 624 | if (host) |
628 | host->bus_mode = ios->bus_mode; | 625 | host->bus_mode = ios->bus_mode; |
629 | else | 626 | else |
diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/au1xmmc.c index c0326bbc5f28..914d62b24064 100644 --- a/drivers/mmc/au1xmmc.c +++ b/drivers/mmc/au1xmmc.c | |||
@@ -720,10 +720,6 @@ static void au1xmmc_set_ios(struct mmc_host* mmc, struct mmc_ios* ios) | |||
720 | { | 720 | { |
721 | struct au1xmmc_host *host = mmc_priv(mmc); | 721 | struct au1xmmc_host *host = mmc_priv(mmc); |
722 | 722 | ||
723 | DBG("set_ios (power=%u, clock=%uHz, vdd=%u, mode=%u)\n", | ||
724 | host->id, ios->power_mode, ios->clock, ios->vdd, | ||
725 | ios->bus_mode); | ||
726 | |||
727 | if (ios->power_mode == MMC_POWER_OFF) | 723 | if (ios->power_mode == MMC_POWER_OFF) |
728 | au1xmmc_set_power(host, 0); | 724 | au1xmmc_set_power(host, 0); |
729 | else if (ios->power_mode == MMC_POWER_ON) { | 725 | else if (ios->power_mode == MMC_POWER_ON) { |
diff --git a/drivers/mmc/imxmmc.c b/drivers/mmc/imxmmc.c index ffb7f55d3467..79358e223f57 100644 --- a/drivers/mmc/imxmmc.c +++ b/drivers/mmc/imxmmc.c | |||
@@ -102,6 +102,7 @@ struct imxmci_host { | |||
102 | #define IMXMCI_PEND_CPU_DATA_b 5 | 102 | #define IMXMCI_PEND_CPU_DATA_b 5 |
103 | #define IMXMCI_PEND_CARD_XCHG_b 6 | 103 | #define IMXMCI_PEND_CARD_XCHG_b 6 |
104 | #define IMXMCI_PEND_SET_INIT_b 7 | 104 | #define IMXMCI_PEND_SET_INIT_b 7 |
105 | #define IMXMCI_PEND_STARTED_b 8 | ||
105 | 106 | ||
106 | #define IMXMCI_PEND_IRQ_m (1 << IMXMCI_PEND_IRQ_b) | 107 | #define IMXMCI_PEND_IRQ_m (1 << IMXMCI_PEND_IRQ_b) |
107 | #define IMXMCI_PEND_DMA_END_m (1 << IMXMCI_PEND_DMA_END_b) | 108 | #define IMXMCI_PEND_DMA_END_m (1 << IMXMCI_PEND_DMA_END_b) |
@@ -111,6 +112,7 @@ struct imxmci_host { | |||
111 | #define IMXMCI_PEND_CPU_DATA_m (1 << IMXMCI_PEND_CPU_DATA_b) | 112 | #define IMXMCI_PEND_CPU_DATA_m (1 << IMXMCI_PEND_CPU_DATA_b) |
112 | #define IMXMCI_PEND_CARD_XCHG_m (1 << IMXMCI_PEND_CARD_XCHG_b) | 113 | #define IMXMCI_PEND_CARD_XCHG_m (1 << IMXMCI_PEND_CARD_XCHG_b) |
113 | #define IMXMCI_PEND_SET_INIT_m (1 << IMXMCI_PEND_SET_INIT_b) | 114 | #define IMXMCI_PEND_SET_INIT_m (1 << IMXMCI_PEND_SET_INIT_b) |
115 | #define IMXMCI_PEND_STARTED_m (1 << IMXMCI_PEND_STARTED_b) | ||
114 | 116 | ||
115 | static void imxmci_stop_clock(struct imxmci_host *host) | 117 | static void imxmci_stop_clock(struct imxmci_host *host) |
116 | { | 118 | { |
@@ -131,23 +133,52 @@ static void imxmci_stop_clock(struct imxmci_host *host) | |||
131 | dev_dbg(mmc_dev(host->mmc), "imxmci_stop_clock blocked, no luck\n"); | 133 | dev_dbg(mmc_dev(host->mmc), "imxmci_stop_clock blocked, no luck\n"); |
132 | } | 134 | } |
133 | 135 | ||
134 | static void imxmci_start_clock(struct imxmci_host *host) | 136 | static int imxmci_start_clock(struct imxmci_host *host) |
135 | { | 137 | { |
136 | int i = 0; | 138 | unsigned int trials = 0; |
139 | unsigned int delay_limit = 128; | ||
140 | unsigned long flags; | ||
141 | |||
137 | MMC_STR_STP_CLK &= ~STR_STP_CLK_STOP_CLK; | 142 | MMC_STR_STP_CLK &= ~STR_STP_CLK_STOP_CLK; |
138 | while(i < 0x1000) { | ||
139 | if(!(i & 0x7f)) | ||
140 | MMC_STR_STP_CLK |= STR_STP_CLK_START_CLK; | ||
141 | 143 | ||
142 | if(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN) { | 144 | clear_bit(IMXMCI_PEND_STARTED_b, &host->pending_events); |
143 | /* Check twice before cut */ | 145 | |
146 | /* | ||
147 | * Command start of the clock, this usually succeeds in less | ||
148 | * then 6 delay loops, but during card detection (low clockrate) | ||
149 | * it takes up to 5000 delay loops and sometimes fails for the first time | ||
150 | */ | ||
151 | MMC_STR_STP_CLK |= STR_STP_CLK_START_CLK; | ||
152 | |||
153 | do { | ||
154 | unsigned int delay = delay_limit; | ||
155 | |||
156 | while(delay--){ | ||
144 | if(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN) | 157 | if(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN) |
145 | return; | 158 | /* Check twice before cut */ |
159 | if(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN) | ||
160 | return 0; | ||
161 | |||
162 | if(test_bit(IMXMCI_PEND_STARTED_b, &host->pending_events)) | ||
163 | return 0; | ||
146 | } | 164 | } |
147 | 165 | ||
148 | i++; | 166 | local_irq_save(flags); |
149 | } | 167 | /* |
150 | dev_dbg(mmc_dev(host->mmc), "imxmci_start_clock blocked, no luck\n"); | 168 | * Ensure, that request is not doubled under all possible circumstances. |
169 | * It is possible, that cock running state is missed, because some other | ||
170 | * IRQ or schedule delays this function execution and the clocks has | ||
171 | * been already stopped by other means (response processing, SDHC HW) | ||
172 | */ | ||
173 | if(!test_bit(IMXMCI_PEND_STARTED_b, &host->pending_events)) | ||
174 | MMC_STR_STP_CLK |= STR_STP_CLK_START_CLK; | ||
175 | local_irq_restore(flags); | ||
176 | |||
177 | } while(++trials<256); | ||
178 | |||
179 | dev_err(mmc_dev(host->mmc), "imxmci_start_clock blocked, no luck\n"); | ||
180 | |||
181 | return -1; | ||
151 | } | 182 | } |
152 | 183 | ||
153 | static void imxmci_softreset(void) | 184 | static void imxmci_softreset(void) |
@@ -498,7 +529,7 @@ static int imxmci_data_done(struct imxmci_host *host, unsigned int stat) | |||
498 | 529 | ||
499 | data_error = imxmci_finish_data(host, stat); | 530 | data_error = imxmci_finish_data(host, stat); |
500 | 531 | ||
501 | if (host->req->stop && (data_error == MMC_ERR_NONE)) { | 532 | if (host->req->stop) { |
502 | imxmci_stop_clock(host); | 533 | imxmci_stop_clock(host); |
503 | imxmci_start_cmd(host, host->req->stop, 0); | 534 | imxmci_start_cmd(host, host->req->stop, 0); |
504 | } else { | 535 | } else { |
@@ -622,6 +653,7 @@ static irqreturn_t imxmci_irq(int irq, void *devid, struct pt_regs *regs) | |||
622 | atomic_set(&host->stuck_timeout, 0); | 653 | atomic_set(&host->stuck_timeout, 0); |
623 | host->status_reg = stat; | 654 | host->status_reg = stat; |
624 | set_bit(IMXMCI_PEND_IRQ_b, &host->pending_events); | 655 | set_bit(IMXMCI_PEND_IRQ_b, &host->pending_events); |
656 | set_bit(IMXMCI_PEND_STARTED_b, &host->pending_events); | ||
625 | tasklet_schedule(&host->tasklet); | 657 | tasklet_schedule(&host->tasklet); |
626 | 658 | ||
627 | return IRQ_RETVAL(handled);; | 659 | return IRQ_RETVAL(handled);; |
@@ -775,10 +807,6 @@ static void imxmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
775 | struct imxmci_host *host = mmc_priv(mmc); | 807 | struct imxmci_host *host = mmc_priv(mmc); |
776 | int prescaler; | 808 | int prescaler; |
777 | 809 | ||
778 | dev_dbg(mmc_dev(host->mmc), "clock %u power %u vdd %u width %u\n", | ||
779 | ios->clock, ios->power_mode, ios->vdd, | ||
780 | (ios->bus_width==MMC_BUS_WIDTH_4)?4:1); | ||
781 | |||
782 | if( ios->bus_width==MMC_BUS_WIDTH_4 ) { | 810 | if( ios->bus_width==MMC_BUS_WIDTH_4 ) { |
783 | host->actual_bus_width = MMC_BUS_WIDTH_4; | 811 | host->actual_bus_width = MMC_BUS_WIDTH_4; |
784 | imx_gpio_mode(PB11_PF_SD_DAT3); | 812 | imx_gpio_mode(PB11_PF_SD_DAT3); |
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index da6ddd910fc5..1ca2c8b9c9b5 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c | |||
@@ -59,21 +59,23 @@ static const unsigned int tacc_mant[] = { | |||
59 | 59 | ||
60 | 60 | ||
61 | /** | 61 | /** |
62 | * mmc_request_done - finish processing an MMC command | 62 | * mmc_request_done - finish processing an MMC request |
63 | * @host: MMC host which completed command | 63 | * @host: MMC host which completed request |
64 | * @mrq: MMC request which completed | 64 | * @mrq: MMC request which request |
65 | * | 65 | * |
66 | * MMC drivers should call this function when they have completed | 66 | * MMC drivers should call this function when they have completed |
67 | * their processing of a command. This should be called before the | 67 | * their processing of a request. |
68 | * data part of the command has completed. | ||
69 | */ | 68 | */ |
70 | void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) | 69 | void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) |
71 | { | 70 | { |
72 | struct mmc_command *cmd = mrq->cmd; | 71 | struct mmc_command *cmd = mrq->cmd; |
73 | int err = mrq->cmd->error; | 72 | int err = cmd->error; |
74 | pr_debug("MMC: req done (%02x): %d: %08x %08x %08x %08x\n", | 73 | |
75 | cmd->opcode, err, cmd->resp[0], cmd->resp[1], | 74 | pr_debug("%s: req done (CMD%u): %d/%d/%d: %08x %08x %08x %08x\n", |
76 | cmd->resp[2], cmd->resp[3]); | 75 | mmc_hostname(host), cmd->opcode, err, |
76 | mrq->data ? mrq->data->error : 0, | ||
77 | mrq->stop ? mrq->stop->error : 0, | ||
78 | cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]); | ||
77 | 79 | ||
78 | if (err && cmd->retries) { | 80 | if (err && cmd->retries) { |
79 | cmd->retries--; | 81 | cmd->retries--; |
@@ -97,8 +99,9 @@ EXPORT_SYMBOL(mmc_request_done); | |||
97 | void | 99 | void |
98 | mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) | 100 | mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) |
99 | { | 101 | { |
100 | pr_debug("MMC: starting cmd %02x arg %08x flags %08x\n", | 102 | pr_debug("%s: starting CMD%u arg %08x flags %08x\n", |
101 | mrq->cmd->opcode, mrq->cmd->arg, mrq->cmd->flags); | 103 | mmc_hostname(host), mrq->cmd->opcode, |
104 | mrq->cmd->arg, mrq->cmd->flags); | ||
102 | 105 | ||
103 | WARN_ON(host->card_busy == NULL); | 106 | WARN_ON(host->card_busy == NULL); |
104 | 107 | ||
@@ -312,6 +315,18 @@ void mmc_release_host(struct mmc_host *host) | |||
312 | 315 | ||
313 | EXPORT_SYMBOL(mmc_release_host); | 316 | EXPORT_SYMBOL(mmc_release_host); |
314 | 317 | ||
318 | static inline void mmc_set_ios(struct mmc_host *host) | ||
319 | { | ||
320 | struct mmc_ios *ios = &host->ios; | ||
321 | |||
322 | pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n", | ||
323 | mmc_hostname(host), ios->clock, ios->bus_mode, | ||
324 | ios->power_mode, ios->chip_select, ios->vdd, | ||
325 | ios->bus_width); | ||
326 | |||
327 | host->ops->set_ios(host, ios); | ||
328 | } | ||
329 | |||
315 | static int mmc_select_card(struct mmc_host *host, struct mmc_card *card) | 330 | static int mmc_select_card(struct mmc_host *host, struct mmc_card *card) |
316 | { | 331 | { |
317 | int err; | 332 | int err; |
@@ -364,7 +379,7 @@ static int mmc_select_card(struct mmc_host *host, struct mmc_card *card) | |||
364 | } | 379 | } |
365 | } | 380 | } |
366 | 381 | ||
367 | host->ops->set_ios(host, &host->ios); | 382 | mmc_set_ios(host); |
368 | 383 | ||
369 | return MMC_ERR_NONE; | 384 | return MMC_ERR_NONE; |
370 | } | 385 | } |
@@ -415,7 +430,7 @@ static u32 mmc_select_voltage(struct mmc_host *host, u32 ocr) | |||
415 | ocr = 3 << bit; | 430 | ocr = 3 << bit; |
416 | 431 | ||
417 | host->ios.vdd = bit; | 432 | host->ios.vdd = bit; |
418 | host->ops->set_ios(host, &host->ios); | 433 | mmc_set_ios(host); |
419 | } else { | 434 | } else { |
420 | ocr = 0; | 435 | ocr = 0; |
421 | } | 436 | } |
@@ -549,6 +564,7 @@ static void mmc_decode_csd(struct mmc_card *card) | |||
549 | csd->read_partial = UNSTUFF_BITS(resp, 79, 1); | 564 | csd->read_partial = UNSTUFF_BITS(resp, 79, 1); |
550 | csd->write_misalign = UNSTUFF_BITS(resp, 78, 1); | 565 | csd->write_misalign = UNSTUFF_BITS(resp, 78, 1); |
551 | csd->read_misalign = UNSTUFF_BITS(resp, 77, 1); | 566 | csd->read_misalign = UNSTUFF_BITS(resp, 77, 1); |
567 | csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3); | ||
552 | csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); | 568 | csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); |
553 | csd->write_partial = UNSTUFF_BITS(resp, 21, 1); | 569 | csd->write_partial = UNSTUFF_BITS(resp, 21, 1); |
554 | } else { | 570 | } else { |
@@ -583,6 +599,7 @@ static void mmc_decode_csd(struct mmc_card *card) | |||
583 | csd->read_partial = UNSTUFF_BITS(resp, 79, 1); | 599 | csd->read_partial = UNSTUFF_BITS(resp, 79, 1); |
584 | csd->write_misalign = UNSTUFF_BITS(resp, 78, 1); | 600 | csd->write_misalign = UNSTUFF_BITS(resp, 78, 1); |
585 | csd->read_misalign = UNSTUFF_BITS(resp, 77, 1); | 601 | csd->read_misalign = UNSTUFF_BITS(resp, 77, 1); |
602 | csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3); | ||
586 | csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); | 603 | csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); |
587 | csd->write_partial = UNSTUFF_BITS(resp, 21, 1); | 604 | csd->write_partial = UNSTUFF_BITS(resp, 21, 1); |
588 | } | 605 | } |
@@ -666,7 +683,7 @@ static void mmc_idle_cards(struct mmc_host *host) | |||
666 | struct mmc_command cmd; | 683 | struct mmc_command cmd; |
667 | 684 | ||
668 | host->ios.chip_select = MMC_CS_HIGH; | 685 | host->ios.chip_select = MMC_CS_HIGH; |
669 | host->ops->set_ios(host, &host->ios); | 686 | mmc_set_ios(host); |
670 | 687 | ||
671 | mmc_delay(1); | 688 | mmc_delay(1); |
672 | 689 | ||
@@ -679,7 +696,7 @@ static void mmc_idle_cards(struct mmc_host *host) | |||
679 | mmc_delay(1); | 696 | mmc_delay(1); |
680 | 697 | ||
681 | host->ios.chip_select = MMC_CS_DONTCARE; | 698 | host->ios.chip_select = MMC_CS_DONTCARE; |
682 | host->ops->set_ios(host, &host->ios); | 699 | mmc_set_ios(host); |
683 | 700 | ||
684 | mmc_delay(1); | 701 | mmc_delay(1); |
685 | } | 702 | } |
@@ -704,13 +721,13 @@ static void mmc_power_up(struct mmc_host *host) | |||
704 | host->ios.chip_select = MMC_CS_DONTCARE; | 721 | host->ios.chip_select = MMC_CS_DONTCARE; |
705 | host->ios.power_mode = MMC_POWER_UP; | 722 | host->ios.power_mode = MMC_POWER_UP; |
706 | host->ios.bus_width = MMC_BUS_WIDTH_1; | 723 | host->ios.bus_width = MMC_BUS_WIDTH_1; |
707 | host->ops->set_ios(host, &host->ios); | 724 | mmc_set_ios(host); |
708 | 725 | ||
709 | mmc_delay(1); | 726 | mmc_delay(1); |
710 | 727 | ||
711 | host->ios.clock = host->f_min; | 728 | host->ios.clock = host->f_min; |
712 | host->ios.power_mode = MMC_POWER_ON; | 729 | host->ios.power_mode = MMC_POWER_ON; |
713 | host->ops->set_ios(host, &host->ios); | 730 | mmc_set_ios(host); |
714 | 731 | ||
715 | mmc_delay(2); | 732 | mmc_delay(2); |
716 | } | 733 | } |
@@ -723,7 +740,7 @@ static void mmc_power_off(struct mmc_host *host) | |||
723 | host->ios.chip_select = MMC_CS_DONTCARE; | 740 | host->ios.chip_select = MMC_CS_DONTCARE; |
724 | host->ios.power_mode = MMC_POWER_OFF; | 741 | host->ios.power_mode = MMC_POWER_OFF; |
725 | host->ios.bus_width = MMC_BUS_WIDTH_1; | 742 | host->ios.bus_width = MMC_BUS_WIDTH_1; |
726 | host->ops->set_ios(host, &host->ios); | 743 | mmc_set_ios(host); |
727 | } | 744 | } |
728 | 745 | ||
729 | static int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | 746 | static int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) |
@@ -971,7 +988,8 @@ static unsigned int mmc_calculate_clock(struct mmc_host *host) | |||
971 | if (!mmc_card_dead(card) && max_dtr > card->csd.max_dtr) | 988 | if (!mmc_card_dead(card) && max_dtr > card->csd.max_dtr) |
972 | max_dtr = card->csd.max_dtr; | 989 | max_dtr = card->csd.max_dtr; |
973 | 990 | ||
974 | pr_debug("MMC: selected %d.%03dMHz transfer rate\n", | 991 | pr_debug("%s: selected %d.%03dMHz transfer rate\n", |
992 | mmc_hostname(host), | ||
975 | max_dtr / 1000000, (max_dtr / 1000) % 1000); | 993 | max_dtr / 1000000, (max_dtr / 1000) % 1000); |
976 | 994 | ||
977 | return max_dtr; | 995 | return max_dtr; |
@@ -1046,7 +1064,7 @@ static void mmc_setup(struct mmc_host *host) | |||
1046 | } else { | 1064 | } else { |
1047 | host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; | 1065 | host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; |
1048 | host->ios.clock = host->f_min; | 1066 | host->ios.clock = host->f_min; |
1049 | host->ops->set_ios(host, &host->ios); | 1067 | mmc_set_ios(host); |
1050 | 1068 | ||
1051 | /* | 1069 | /* |
1052 | * We should remember the OCR mask from the existing | 1070 | * We should remember the OCR mask from the existing |
@@ -1082,7 +1100,7 @@ static void mmc_setup(struct mmc_host *host) | |||
1082 | * Ok, now switch to push-pull mode. | 1100 | * Ok, now switch to push-pull mode. |
1083 | */ | 1101 | */ |
1084 | host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; | 1102 | host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; |
1085 | host->ops->set_ios(host, &host->ios); | 1103 | mmc_set_ios(host); |
1086 | 1104 | ||
1087 | mmc_read_csds(host); | 1105 | mmc_read_csds(host); |
1088 | 1106 | ||
@@ -1128,7 +1146,7 @@ static void mmc_rescan(void *data) | |||
1128 | * attached cards and the host support. | 1146 | * attached cards and the host support. |
1129 | */ | 1147 | */ |
1130 | host->ios.clock = mmc_calculate_clock(host); | 1148 | host->ios.clock = mmc_calculate_clock(host); |
1131 | host->ops->set_ios(host, &host->ios); | 1149 | mmc_set_ios(host); |
1132 | } | 1150 | } |
1133 | 1151 | ||
1134 | mmc_release_host(host); | 1152 | mmc_release_host(host); |
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c index 8eb2a2ede64b..06bd1f4cb9b1 100644 --- a/drivers/mmc/mmc_block.c +++ b/drivers/mmc/mmc_block.c | |||
@@ -187,6 +187,12 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
187 | brq.cmd.opcode = MMC_WRITE_BLOCK; | 187 | brq.cmd.opcode = MMC_WRITE_BLOCK; |
188 | brq.data.flags |= MMC_DATA_WRITE; | 188 | brq.data.flags |= MMC_DATA_WRITE; |
189 | brq.data.blocks = 1; | 189 | brq.data.blocks = 1; |
190 | |||
191 | /* | ||
192 | * Scale up the timeout by the r2w factor | ||
193 | */ | ||
194 | brq.data.timeout_ns <<= card->csd.r2w_factor; | ||
195 | brq.data.timeout_clks <<= card->csd.r2w_factor; | ||
190 | } | 196 | } |
191 | 197 | ||
192 | if (brq.data.blocks > 1) { | 198 | if (brq.data.blocks > 1) { |
diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index df7e861e2fc7..da8e4d7339cc 100644 --- a/drivers/mmc/mmci.c +++ b/drivers/mmc/mmci.c | |||
@@ -402,9 +402,6 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
402 | struct mmci_host *host = mmc_priv(mmc); | 402 | struct mmci_host *host = mmc_priv(mmc); |
403 | u32 clk = 0, pwr = 0; | 403 | u32 clk = 0, pwr = 0; |
404 | 404 | ||
405 | DBG(host, "clock %uHz busmode %u powermode %u Vdd %u\n", | ||
406 | ios->clock, ios->bus_mode, ios->power_mode, ios->vdd); | ||
407 | |||
408 | if (ios->clock) { | 405 | if (ios->clock) { |
409 | if (ios->clock >= host->mclk) { | 406 | if (ios->clock >= host->mclk) { |
410 | clk = MCI_CLK_BYPASS; | 407 | clk = MCI_CLK_BYPASS; |
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c index eb42cb349420..f97b472085cb 100644 --- a/drivers/mmc/pxamci.c +++ b/drivers/mmc/pxamci.c | |||
@@ -198,7 +198,6 @@ static void pxamci_start_cmd(struct pxamci_host *host, struct mmc_command *cmd, | |||
198 | 198 | ||
199 | static void pxamci_finish_request(struct pxamci_host *host, struct mmc_request *mrq) | 199 | static void pxamci_finish_request(struct pxamci_host *host, struct mmc_request *mrq) |
200 | { | 200 | { |
201 | pr_debug("PXAMCI: request done\n"); | ||
202 | host->mrq = NULL; | 201 | host->mrq = NULL; |
203 | host->cmd = NULL; | 202 | host->cmd = NULL; |
204 | host->data = NULL; | 203 | host->data = NULL; |
@@ -291,7 +290,7 @@ static int pxamci_data_done(struct pxamci_host *host, unsigned int stat) | |||
291 | pxamci_disable_irq(host, DATA_TRAN_DONE); | 290 | pxamci_disable_irq(host, DATA_TRAN_DONE); |
292 | 291 | ||
293 | host->data = NULL; | 292 | host->data = NULL; |
294 | if (host->mrq->stop && data->error == MMC_ERR_NONE) { | 293 | if (host->mrq->stop) { |
295 | pxamci_stop_clock(host); | 294 | pxamci_stop_clock(host); |
296 | pxamci_start_cmd(host, host->mrq->stop, 0); | 295 | pxamci_start_cmd(host, host->mrq->stop, 0); |
297 | } else { | 296 | } else { |
@@ -309,12 +308,10 @@ static irqreturn_t pxamci_irq(int irq, void *devid, struct pt_regs *regs) | |||
309 | 308 | ||
310 | ireg = readl(host->base + MMC_I_REG); | 309 | ireg = readl(host->base + MMC_I_REG); |
311 | 310 | ||
312 | pr_debug("PXAMCI: irq %08x\n", ireg); | ||
313 | |||
314 | if (ireg) { | 311 | if (ireg) { |
315 | unsigned stat = readl(host->base + MMC_STAT); | 312 | unsigned stat = readl(host->base + MMC_STAT); |
316 | 313 | ||
317 | pr_debug("PXAMCI: stat %08x\n", stat); | 314 | pr_debug("PXAMCI: irq %08x stat %08x\n", ireg, stat); |
318 | 315 | ||
319 | if (ireg & END_CMD_RES) | 316 | if (ireg & END_CMD_RES) |
320 | handled |= pxamci_cmd_done(host, stat); | 317 | handled |= pxamci_cmd_done(host, stat); |
@@ -368,10 +365,6 @@ static void pxamci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
368 | { | 365 | { |
369 | struct pxamci_host *host = mmc_priv(mmc); | 366 | struct pxamci_host *host = mmc_priv(mmc); |
370 | 367 | ||
371 | pr_debug("pxamci_set_ios: clock %u power %u vdd %u.%02u\n", | ||
372 | ios->clock, ios->power_mode, ios->vdd / 100, | ||
373 | ios->vdd % 100); | ||
374 | |||
375 | if (ios->clock) { | 368 | if (ios->clock) { |
376 | unsigned int clk = CLOCKRATE / ios->clock; | 369 | unsigned int clk = CLOCKRATE / ios->clock; |
377 | if (CLOCKRATE / clk > ios->clock) | 370 | if (CLOCKRATE / clk > ios->clock) |
@@ -397,7 +390,7 @@ static void pxamci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
397 | host->cmdat |= CMDAT_INIT; | 390 | host->cmdat |= CMDAT_INIT; |
398 | } | 391 | } |
399 | 392 | ||
400 | pr_debug("pxamci_set_ios: clkrt = %x cmdat = %x\n", | 393 | pr_debug("PXAMCI: clkrt = %x cmdat = %x\n", |
401 | host->clkrt, host->cmdat); | 394 | host->clkrt, host->cmdat); |
402 | } | 395 | } |
403 | 396 | ||
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index bdbfca050029..b0053280ff2d 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c | |||
@@ -570,10 +570,6 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
570 | 570 | ||
571 | spin_lock_irqsave(&host->lock, flags); | 571 | spin_lock_irqsave(&host->lock, flags); |
572 | 572 | ||
573 | DBG("clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n", | ||
574 | ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select, | ||
575 | ios->vdd, ios->bus_width); | ||
576 | |||
577 | /* | 573 | /* |
578 | * Reset the chip on each power off. | 574 | * Reset the chip on each power off. |
579 | * Should clear out any weird states. | 575 | * Should clear out any weird states. |
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c index 511f7b0b31d2..39b3d97f891e 100644 --- a/drivers/mmc/wbsd.c +++ b/drivers/mmc/wbsd.c | |||
@@ -931,10 +931,6 @@ static void wbsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
931 | struct wbsd_host *host = mmc_priv(mmc); | 931 | struct wbsd_host *host = mmc_priv(mmc); |
932 | u8 clk, setup, pwr; | 932 | u8 clk, setup, pwr; |
933 | 933 | ||
934 | DBGF("clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n", | ||
935 | ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select, | ||
936 | ios->vdd, ios->bus_width); | ||
937 | |||
938 | spin_lock_bh(&host->lock); | 934 | spin_lock_bh(&host->lock); |
939 | 935 | ||
940 | /* | 936 | /* |
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index fe00af3f9195..d0d5e521b564 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
@@ -399,7 +399,7 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary) | |||
399 | for (i=0; i< cfi->numchips; i++) { | 399 | for (i=0; i< cfi->numchips; i++) { |
400 | cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp; | 400 | cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp; |
401 | cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp; | 401 | cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp; |
402 | cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp; | 402 | cfi->chips[i].erase_time = 1000<<cfi->cfiq->BlockEraseTimeoutTyp; |
403 | cfi->chips[i].ref_point_counter = 0; | 403 | cfi->chips[i].ref_point_counter = 0; |
404 | init_waitqueue_head(&(cfi->chips[i].wq)); | 404 | init_waitqueue_head(&(cfi->chips[i].wq)); |
405 | } | 405 | } |
@@ -894,26 +894,33 @@ static void __xipram xip_enable(struct map_info *map, struct flchip *chip, | |||
894 | 894 | ||
895 | /* | 895 | /* |
896 | * When a delay is required for the flash operation to complete, the | 896 | * When a delay is required for the flash operation to complete, the |
897 | * xip_udelay() function is polling for both the given timeout and pending | 897 | * xip_wait_for_operation() function is polling for both the given timeout |
898 | * (but still masked) hardware interrupts. Whenever there is an interrupt | 898 | * and pending (but still masked) hardware interrupts. Whenever there is an |
899 | * pending then the flash erase or write operation is suspended, array mode | 899 | * interrupt pending then the flash erase or write operation is suspended, |
900 | * restored and interrupts unmasked. Task scheduling might also happen at that | 900 | * array mode restored and interrupts unmasked. Task scheduling might also |
901 | * point. The CPU eventually returns from the interrupt or the call to | 901 | * happen at that point. The CPU eventually returns from the interrupt or |
902 | * schedule() and the suspended flash operation is resumed for the remaining | 902 | * the call to schedule() and the suspended flash operation is resumed for |
903 | * of the delay period. | 903 | * the remaining of the delay period. |
904 | * | 904 | * |
905 | * Warning: this function _will_ fool interrupt latency tracing tools. | 905 | * Warning: this function _will_ fool interrupt latency tracing tools. |
906 | */ | 906 | */ |
907 | 907 | ||
908 | static void __xipram xip_udelay(struct map_info *map, struct flchip *chip, | 908 | static int __xipram xip_wait_for_operation( |
909 | unsigned long adr, int usec) | 909 | struct map_info *map, struct flchip *chip, |
910 | unsigned long adr, int *chip_op_time ) | ||
910 | { | 911 | { |
911 | struct cfi_private *cfi = map->fldrv_priv; | 912 | struct cfi_private *cfi = map->fldrv_priv; |
912 | struct cfi_pri_intelext *cfip = cfi->cmdset_priv; | 913 | struct cfi_pri_intelext *cfip = cfi->cmdset_priv; |
913 | map_word status, OK = CMD(0x80); | 914 | map_word status, OK = CMD(0x80); |
914 | unsigned long suspended, start = xip_currtime(); | 915 | unsigned long usec, suspended, start, done; |
915 | flstate_t oldstate, newstate; | 916 | flstate_t oldstate, newstate; |
916 | 917 | ||
918 | start = xip_currtime(); | ||
919 | usec = *chip_op_time * 8; | ||
920 | if (usec == 0) | ||
921 | usec = 500000; | ||
922 | done = 0; | ||
923 | |||
917 | do { | 924 | do { |
918 | cpu_relax(); | 925 | cpu_relax(); |
919 | if (xip_irqpending() && cfip && | 926 | if (xip_irqpending() && cfip && |
@@ -930,9 +937,9 @@ static void __xipram xip_udelay(struct map_info *map, struct flchip *chip, | |||
930 | * we resume the whole thing at once). Yes, it | 937 | * we resume the whole thing at once). Yes, it |
931 | * can happen! | 938 | * can happen! |
932 | */ | 939 | */ |
940 | usec -= done; | ||
933 | map_write(map, CMD(0xb0), adr); | 941 | map_write(map, CMD(0xb0), adr); |
934 | map_write(map, CMD(0x70), adr); | 942 | map_write(map, CMD(0x70), adr); |
935 | usec -= xip_elapsed_since(start); | ||
936 | suspended = xip_currtime(); | 943 | suspended = xip_currtime(); |
937 | do { | 944 | do { |
938 | if (xip_elapsed_since(suspended) > 100000) { | 945 | if (xip_elapsed_since(suspended) > 100000) { |
@@ -942,7 +949,7 @@ static void __xipram xip_udelay(struct map_info *map, struct flchip *chip, | |||
942 | * This is a critical error but there | 949 | * This is a critical error but there |
943 | * is not much we can do here. | 950 | * is not much we can do here. |
944 | */ | 951 | */ |
945 | return; | 952 | return -EIO; |
946 | } | 953 | } |
947 | status = map_read(map, adr); | 954 | status = map_read(map, adr); |
948 | } while (!map_word_andequal(map, status, OK, OK)); | 955 | } while (!map_word_andequal(map, status, OK, OK)); |
@@ -1002,65 +1009,107 @@ static void __xipram xip_udelay(struct map_info *map, struct flchip *chip, | |||
1002 | xip_cpu_idle(); | 1009 | xip_cpu_idle(); |
1003 | } | 1010 | } |
1004 | status = map_read(map, adr); | 1011 | status = map_read(map, adr); |
1012 | done = xip_elapsed_since(start); | ||
1005 | } while (!map_word_andequal(map, status, OK, OK) | 1013 | } while (!map_word_andequal(map, status, OK, OK) |
1006 | && xip_elapsed_since(start) < usec); | 1014 | && done < usec); |
1007 | } | ||
1008 | 1015 | ||
1009 | #define UDELAY(map, chip, adr, usec) xip_udelay(map, chip, adr, usec) | 1016 | return (done >= usec) ? -ETIME : 0; |
1017 | } | ||
1010 | 1018 | ||
1011 | /* | 1019 | /* |
1012 | * The INVALIDATE_CACHED_RANGE() macro is normally used in parallel while | 1020 | * The INVALIDATE_CACHED_RANGE() macro is normally used in parallel while |
1013 | * the flash is actively programming or erasing since we have to poll for | 1021 | * the flash is actively programming or erasing since we have to poll for |
1014 | * the operation to complete anyway. We can't do that in a generic way with | 1022 | * the operation to complete anyway. We can't do that in a generic way with |
1015 | * a XIP setup so do it before the actual flash operation in this case | 1023 | * a XIP setup so do it before the actual flash operation in this case |
1016 | * and stub it out from INVALIDATE_CACHE_UDELAY. | 1024 | * and stub it out from INVAL_CACHE_AND_WAIT. |
1017 | */ | 1025 | */ |
1018 | #define XIP_INVAL_CACHED_RANGE(map, from, size) \ | 1026 | #define XIP_INVAL_CACHED_RANGE(map, from, size) \ |
1019 | INVALIDATE_CACHED_RANGE(map, from, size) | 1027 | INVALIDATE_CACHED_RANGE(map, from, size) |
1020 | 1028 | ||
1021 | #define INVALIDATE_CACHE_UDELAY(map, chip, cmd_adr, adr, len, usec) \ | 1029 | #define INVAL_CACHE_AND_WAIT(map, chip, cmd_adr, inval_adr, inval_len, p_usec) \ |
1022 | UDELAY(map, chip, cmd_adr, usec) | 1030 | xip_wait_for_operation(map, chip, cmd_adr, p_usec) |
1023 | |||
1024 | /* | ||
1025 | * Extra notes: | ||
1026 | * | ||
1027 | * Activating this XIP support changes the way the code works a bit. For | ||
1028 | * example the code to suspend the current process when concurrent access | ||
1029 | * happens is never executed because xip_udelay() will always return with the | ||
1030 | * same chip state as it was entered with. This is why there is no care for | ||
1031 | * the presence of add_wait_queue() or schedule() calls from within a couple | ||
1032 | * xip_disable()'d areas of code, like in do_erase_oneblock for example. | ||
1033 | * The queueing and scheduling are always happening within xip_udelay(). | ||
1034 | * | ||
1035 | * Similarly, get_chip() and put_chip() just happen to always be executed | ||
1036 | * with chip->state set to FL_READY (or FL_XIP_WHILE_*) where flash state | ||
1037 | * is in array mode, therefore never executing many cases therein and not | ||
1038 | * causing any problem with XIP. | ||
1039 | */ | ||
1040 | 1031 | ||
1041 | #else | 1032 | #else |
1042 | 1033 | ||
1043 | #define xip_disable(map, chip, adr) | 1034 | #define xip_disable(map, chip, adr) |
1044 | #define xip_enable(map, chip, adr) | 1035 | #define xip_enable(map, chip, adr) |
1045 | #define XIP_INVAL_CACHED_RANGE(x...) | 1036 | #define XIP_INVAL_CACHED_RANGE(x...) |
1037 | #define INVAL_CACHE_AND_WAIT inval_cache_and_wait_for_operation | ||
1038 | |||
1039 | static int inval_cache_and_wait_for_operation( | ||
1040 | struct map_info *map, struct flchip *chip, | ||
1041 | unsigned long cmd_adr, unsigned long inval_adr, int inval_len, | ||
1042 | int *chip_op_time ) | ||
1043 | { | ||
1044 | struct cfi_private *cfi = map->fldrv_priv; | ||
1045 | map_word status, status_OK = CMD(0x80); | ||
1046 | int z, chip_state = chip->state; | ||
1047 | unsigned long timeo; | ||
1048 | |||
1049 | spin_unlock(chip->mutex); | ||
1050 | if (inval_len) | ||
1051 | INVALIDATE_CACHED_RANGE(map, inval_adr, inval_len); | ||
1052 | if (*chip_op_time) | ||
1053 | cfi_udelay(*chip_op_time); | ||
1054 | spin_lock(chip->mutex); | ||
1046 | 1055 | ||
1047 | #define UDELAY(map, chip, adr, usec) \ | 1056 | timeo = *chip_op_time * 8 * HZ / 1000000; |
1048 | do { \ | 1057 | if (timeo < HZ/2) |
1049 | spin_unlock(chip->mutex); \ | 1058 | timeo = HZ/2; |
1050 | cfi_udelay(usec); \ | 1059 | timeo += jiffies; |
1051 | spin_lock(chip->mutex); \ | 1060 | |
1052 | } while (0) | 1061 | z = 0; |
1053 | 1062 | for (;;) { | |
1054 | #define INVALIDATE_CACHE_UDELAY(map, chip, cmd_adr, adr, len, usec) \ | 1063 | if (chip->state != chip_state) { |
1055 | do { \ | 1064 | /* Someone's suspended the operation: sleep */ |
1056 | spin_unlock(chip->mutex); \ | 1065 | DECLARE_WAITQUEUE(wait, current); |
1057 | INVALIDATE_CACHED_RANGE(map, adr, len); \ | 1066 | |
1058 | cfi_udelay(usec); \ | 1067 | set_current_state(TASK_UNINTERRUPTIBLE); |
1059 | spin_lock(chip->mutex); \ | 1068 | add_wait_queue(&chip->wq, &wait); |
1060 | } while (0) | 1069 | spin_unlock(chip->mutex); |
1070 | schedule(); | ||
1071 | remove_wait_queue(&chip->wq, &wait); | ||
1072 | timeo = jiffies + (HZ / 2); /* FIXME */ | ||
1073 | spin_lock(chip->mutex); | ||
1074 | continue; | ||
1075 | } | ||
1076 | |||
1077 | status = map_read(map, cmd_adr); | ||
1078 | if (map_word_andequal(map, status, status_OK, status_OK)) | ||
1079 | break; | ||
1080 | |||
1081 | /* OK Still waiting */ | ||
1082 | if (time_after(jiffies, timeo)) { | ||
1083 | map_write(map, CMD(0x70), cmd_adr); | ||
1084 | chip->state = FL_STATUS; | ||
1085 | return -ETIME; | ||
1086 | } | ||
1087 | |||
1088 | /* Latency issues. Drop the lock, wait a while and retry */ | ||
1089 | z++; | ||
1090 | spin_unlock(chip->mutex); | ||
1091 | cfi_udelay(1); | ||
1092 | spin_lock(chip->mutex); | ||
1093 | } | ||
1094 | |||
1095 | if (!z) { | ||
1096 | if (!--(*chip_op_time)) | ||
1097 | *chip_op_time = 1; | ||
1098 | } else if (z > 1) | ||
1099 | ++(*chip_op_time); | ||
1100 | |||
1101 | /* Done and happy. */ | ||
1102 | chip->state = FL_STATUS; | ||
1103 | return 0; | ||
1104 | } | ||
1061 | 1105 | ||
1062 | #endif | 1106 | #endif |
1063 | 1107 | ||
1108 | #define WAIT_TIMEOUT(map, chip, adr, udelay) \ | ||
1109 | ({ int __udelay = (udelay); \ | ||
1110 | INVAL_CACHE_AND_WAIT(map, chip, adr, 0, 0, &__udelay); }) | ||
1111 | |||
1112 | |||
1064 | static int do_point_onechip (struct map_info *map, struct flchip *chip, loff_t adr, size_t len) | 1113 | static int do_point_onechip (struct map_info *map, struct flchip *chip, loff_t adr, size_t len) |
1065 | { | 1114 | { |
1066 | unsigned long cmd_addr; | 1115 | unsigned long cmd_addr; |
@@ -1250,14 +1299,11 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, | |||
1250 | unsigned long adr, map_word datum, int mode) | 1299 | unsigned long adr, map_word datum, int mode) |
1251 | { | 1300 | { |
1252 | struct cfi_private *cfi = map->fldrv_priv; | 1301 | struct cfi_private *cfi = map->fldrv_priv; |
1253 | map_word status, status_OK, write_cmd; | 1302 | map_word status, write_cmd; |
1254 | unsigned long timeo; | 1303 | int ret=0; |
1255 | int z, ret=0; | ||
1256 | 1304 | ||
1257 | adr += chip->start; | 1305 | adr += chip->start; |
1258 | 1306 | ||
1259 | /* Let's determine those according to the interleave only once */ | ||
1260 | status_OK = CMD(0x80); | ||
1261 | switch (mode) { | 1307 | switch (mode) { |
1262 | case FL_WRITING: | 1308 | case FL_WRITING: |
1263 | write_cmd = (cfi->cfiq->P_ID != 0x0200) ? CMD(0x40) : CMD(0x41); | 1309 | write_cmd = (cfi->cfiq->P_ID != 0x0200) ? CMD(0x40) : CMD(0x41); |
@@ -1283,57 +1329,17 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip, | |||
1283 | map_write(map, datum, adr); | 1329 | map_write(map, datum, adr); |
1284 | chip->state = mode; | 1330 | chip->state = mode; |
1285 | 1331 | ||
1286 | INVALIDATE_CACHE_UDELAY(map, chip, adr, | 1332 | ret = INVAL_CACHE_AND_WAIT(map, chip, adr, |
1287 | adr, map_bankwidth(map), | 1333 | adr, map_bankwidth(map), |
1288 | chip->word_write_time); | 1334 | &chip->word_write_time); |
1289 | 1335 | if (ret) { | |
1290 | timeo = jiffies + (HZ/2); | 1336 | xip_enable(map, chip, adr); |
1291 | z = 0; | 1337 | printk(KERN_ERR "%s: word write error (status timeout)\n", map->name); |
1292 | for (;;) { | 1338 | goto out; |
1293 | if (chip->state != mode) { | ||
1294 | /* Someone's suspended the write. Sleep */ | ||
1295 | DECLARE_WAITQUEUE(wait, current); | ||
1296 | |||
1297 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
1298 | add_wait_queue(&chip->wq, &wait); | ||
1299 | spin_unlock(chip->mutex); | ||
1300 | schedule(); | ||
1301 | remove_wait_queue(&chip->wq, &wait); | ||
1302 | timeo = jiffies + (HZ / 2); /* FIXME */ | ||
1303 | spin_lock(chip->mutex); | ||
1304 | continue; | ||
1305 | } | ||
1306 | |||
1307 | status = map_read(map, adr); | ||
1308 | if (map_word_andequal(map, status, status_OK, status_OK)) | ||
1309 | break; | ||
1310 | |||
1311 | /* OK Still waiting */ | ||
1312 | if (time_after(jiffies, timeo)) { | ||
1313 | map_write(map, CMD(0x70), adr); | ||
1314 | chip->state = FL_STATUS; | ||
1315 | xip_enable(map, chip, adr); | ||
1316 | printk(KERN_ERR "%s: word write error (status timeout)\n", map->name); | ||
1317 | ret = -EIO; | ||
1318 | goto out; | ||
1319 | } | ||
1320 | |||
1321 | /* Latency issues. Drop the lock, wait a while and retry */ | ||
1322 | z++; | ||
1323 | UDELAY(map, chip, adr, 1); | ||
1324 | } | ||
1325 | if (!z) { | ||
1326 | chip->word_write_time--; | ||
1327 | if (!chip->word_write_time) | ||
1328 | chip->word_write_time = 1; | ||
1329 | } | 1339 | } |
1330 | if (z > 1) | ||
1331 | chip->word_write_time++; | ||
1332 | |||
1333 | /* Done and happy. */ | ||
1334 | chip->state = FL_STATUS; | ||
1335 | 1340 | ||
1336 | /* check for errors */ | 1341 | /* check for errors */ |
1342 | status = map_read(map, adr); | ||
1337 | if (map_word_bitsset(map, status, CMD(0x1a))) { | 1343 | if (map_word_bitsset(map, status, CMD(0x1a))) { |
1338 | unsigned long chipstatus = MERGESTATUS(status); | 1344 | unsigned long chipstatus = MERGESTATUS(status); |
1339 | 1345 | ||
@@ -1450,9 +1456,9 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
1450 | unsigned long *pvec_seek, int len) | 1456 | unsigned long *pvec_seek, int len) |
1451 | { | 1457 | { |
1452 | struct cfi_private *cfi = map->fldrv_priv; | 1458 | struct cfi_private *cfi = map->fldrv_priv; |
1453 | map_word status, status_OK, write_cmd, datum; | 1459 | map_word status, write_cmd, datum; |
1454 | unsigned long cmd_adr, timeo; | 1460 | unsigned long cmd_adr; |
1455 | int wbufsize, z, ret=0, word_gap, words; | 1461 | int ret, wbufsize, word_gap, words; |
1456 | const struct kvec *vec; | 1462 | const struct kvec *vec; |
1457 | unsigned long vec_seek; | 1463 | unsigned long vec_seek; |
1458 | 1464 | ||
@@ -1461,7 +1467,6 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
1461 | cmd_adr = adr & ~(wbufsize-1); | 1467 | cmd_adr = adr & ~(wbufsize-1); |
1462 | 1468 | ||
1463 | /* Let's determine this according to the interleave only once */ | 1469 | /* Let's determine this according to the interleave only once */ |
1464 | status_OK = CMD(0x80); | ||
1465 | write_cmd = (cfi->cfiq->P_ID != 0x0200) ? CMD(0xe8) : CMD(0xe9); | 1470 | write_cmd = (cfi->cfiq->P_ID != 0x0200) ? CMD(0xe8) : CMD(0xe9); |
1466 | 1471 | ||
1467 | spin_lock(chip->mutex); | 1472 | spin_lock(chip->mutex); |
@@ -1475,12 +1480,14 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
1475 | ENABLE_VPP(map); | 1480 | ENABLE_VPP(map); |
1476 | xip_disable(map, chip, cmd_adr); | 1481 | xip_disable(map, chip, cmd_adr); |
1477 | 1482 | ||
1478 | /* §4.8 of the 28FxxxJ3A datasheet says "Any time SR.4 and/or SR.5 is set | 1483 | /* §4.8 of the 28FxxxJ3A datasheet says "Any time SR.4 and/or SR.5 is set |
1479 | [...], the device will not accept any more Write to Buffer commands". | 1484 | [...], the device will not accept any more Write to Buffer commands". |
1480 | So we must check here and reset those bits if they're set. Otherwise | 1485 | So we must check here and reset those bits if they're set. Otherwise |
1481 | we're just pissing in the wind */ | 1486 | we're just pissing in the wind */ |
1482 | if (chip->state != FL_STATUS) | 1487 | if (chip->state != FL_STATUS) { |
1483 | map_write(map, CMD(0x70), cmd_adr); | 1488 | map_write(map, CMD(0x70), cmd_adr); |
1489 | chip->state = FL_STATUS; | ||
1490 | } | ||
1484 | status = map_read(map, cmd_adr); | 1491 | status = map_read(map, cmd_adr); |
1485 | if (map_word_bitsset(map, status, CMD(0x30))) { | 1492 | if (map_word_bitsset(map, status, CMD(0x30))) { |
1486 | xip_enable(map, chip, cmd_adr); | 1493 | xip_enable(map, chip, cmd_adr); |
@@ -1491,32 +1498,20 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
1491 | } | 1498 | } |
1492 | 1499 | ||
1493 | chip->state = FL_WRITING_TO_BUFFER; | 1500 | chip->state = FL_WRITING_TO_BUFFER; |
1494 | 1501 | map_write(map, write_cmd, cmd_adr); | |
1495 | z = 0; | 1502 | ret = WAIT_TIMEOUT(map, chip, cmd_adr, 0); |
1496 | for (;;) { | 1503 | if (ret) { |
1497 | map_write(map, write_cmd, cmd_adr); | 1504 | /* Argh. Not ready for write to buffer */ |
1498 | 1505 | map_word Xstatus = map_read(map, cmd_adr); | |
1506 | map_write(map, CMD(0x70), cmd_adr); | ||
1507 | chip->state = FL_STATUS; | ||
1499 | status = map_read(map, cmd_adr); | 1508 | status = map_read(map, cmd_adr); |
1500 | if (map_word_andequal(map, status, status_OK, status_OK)) | 1509 | map_write(map, CMD(0x50), cmd_adr); |
1501 | break; | 1510 | map_write(map, CMD(0x70), cmd_adr); |
1502 | 1511 | xip_enable(map, chip, cmd_adr); | |
1503 | UDELAY(map, chip, cmd_adr, 1); | 1512 | printk(KERN_ERR "%s: Chip not ready for buffer write. Xstatus = %lx, status = %lx\n", |
1504 | 1513 | map->name, Xstatus.x[0], status.x[0]); | |
1505 | if (++z > 20) { | 1514 | goto out; |
1506 | /* Argh. Not ready for write to buffer */ | ||
1507 | map_word Xstatus; | ||
1508 | map_write(map, CMD(0x70), cmd_adr); | ||
1509 | chip->state = FL_STATUS; | ||
1510 | Xstatus = map_read(map, cmd_adr); | ||
1511 | /* Odd. Clear status bits */ | ||
1512 | map_write(map, CMD(0x50), cmd_adr); | ||
1513 | map_write(map, CMD(0x70), cmd_adr); | ||
1514 | xip_enable(map, chip, cmd_adr); | ||
1515 | printk(KERN_ERR "%s: Chip not ready for buffer write. status = %lx, Xstatus = %lx\n", | ||
1516 | map->name, status.x[0], Xstatus.x[0]); | ||
1517 | ret = -EIO; | ||
1518 | goto out; | ||
1519 | } | ||
1520 | } | 1515 | } |
1521 | 1516 | ||
1522 | /* Figure out the number of words to write */ | 1517 | /* Figure out the number of words to write */ |
@@ -1571,56 +1566,19 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
1571 | map_write(map, CMD(0xd0), cmd_adr); | 1566 | map_write(map, CMD(0xd0), cmd_adr); |
1572 | chip->state = FL_WRITING; | 1567 | chip->state = FL_WRITING; |
1573 | 1568 | ||
1574 | INVALIDATE_CACHE_UDELAY(map, chip, cmd_adr, | 1569 | ret = INVAL_CACHE_AND_WAIT(map, chip, cmd_adr, |
1575 | adr, len, | 1570 | adr, len, |
1576 | chip->buffer_write_time); | 1571 | &chip->buffer_write_time); |
1577 | 1572 | if (ret) { | |
1578 | timeo = jiffies + (HZ/2); | 1573 | map_write(map, CMD(0x70), cmd_adr); |
1579 | z = 0; | 1574 | chip->state = FL_STATUS; |
1580 | for (;;) { | 1575 | xip_enable(map, chip, cmd_adr); |
1581 | if (chip->state != FL_WRITING) { | 1576 | printk(KERN_ERR "%s: buffer write error (status timeout)\n", map->name); |
1582 | /* Someone's suspended the write. Sleep */ | 1577 | goto out; |
1583 | DECLARE_WAITQUEUE(wait, current); | ||
1584 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
1585 | add_wait_queue(&chip->wq, &wait); | ||
1586 | spin_unlock(chip->mutex); | ||
1587 | schedule(); | ||
1588 | remove_wait_queue(&chip->wq, &wait); | ||
1589 | timeo = jiffies + (HZ / 2); /* FIXME */ | ||
1590 | spin_lock(chip->mutex); | ||
1591 | continue; | ||
1592 | } | ||
1593 | |||
1594 | status = map_read(map, cmd_adr); | ||
1595 | if (map_word_andequal(map, status, status_OK, status_OK)) | ||
1596 | break; | ||
1597 | |||
1598 | /* OK Still waiting */ | ||
1599 | if (time_after(jiffies, timeo)) { | ||
1600 | map_write(map, CMD(0x70), cmd_adr); | ||
1601 | chip->state = FL_STATUS; | ||
1602 | xip_enable(map, chip, cmd_adr); | ||
1603 | printk(KERN_ERR "%s: buffer write error (status timeout)\n", map->name); | ||
1604 | ret = -EIO; | ||
1605 | goto out; | ||
1606 | } | ||
1607 | |||
1608 | /* Latency issues. Drop the lock, wait a while and retry */ | ||
1609 | z++; | ||
1610 | UDELAY(map, chip, cmd_adr, 1); | ||
1611 | } | ||
1612 | if (!z) { | ||
1613 | chip->buffer_write_time--; | ||
1614 | if (!chip->buffer_write_time) | ||
1615 | chip->buffer_write_time = 1; | ||
1616 | } | 1578 | } |
1617 | if (z > 1) | ||
1618 | chip->buffer_write_time++; | ||
1619 | |||
1620 | /* Done and happy. */ | ||
1621 | chip->state = FL_STATUS; | ||
1622 | 1579 | ||
1623 | /* check for errors */ | 1580 | /* check for errors */ |
1581 | status = map_read(map, cmd_adr); | ||
1624 | if (map_word_bitsset(map, status, CMD(0x1a))) { | 1582 | if (map_word_bitsset(map, status, CMD(0x1a))) { |
1625 | unsigned long chipstatus = MERGESTATUS(status); | 1583 | unsigned long chipstatus = MERGESTATUS(status); |
1626 | 1584 | ||
@@ -1691,6 +1649,11 @@ static int cfi_intelext_writev (struct mtd_info *mtd, const struct kvec *vecs, | |||
1691 | if (chipnum == cfi->numchips) | 1649 | if (chipnum == cfi->numchips) |
1692 | return 0; | 1650 | return 0; |
1693 | } | 1651 | } |
1652 | |||
1653 | /* Be nice and reschedule with the chip in a usable state for other | ||
1654 | processes. */ | ||
1655 | cond_resched(); | ||
1656 | |||
1694 | } while (len); | 1657 | } while (len); |
1695 | 1658 | ||
1696 | return 0; | 1659 | return 0; |
@@ -1711,17 +1674,12 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip, | |||
1711 | unsigned long adr, int len, void *thunk) | 1674 | unsigned long adr, int len, void *thunk) |
1712 | { | 1675 | { |
1713 | struct cfi_private *cfi = map->fldrv_priv; | 1676 | struct cfi_private *cfi = map->fldrv_priv; |
1714 | map_word status, status_OK; | 1677 | map_word status; |
1715 | unsigned long timeo; | ||
1716 | int retries = 3; | 1678 | int retries = 3; |
1717 | DECLARE_WAITQUEUE(wait, current); | 1679 | int ret; |
1718 | int ret = 0; | ||
1719 | 1680 | ||
1720 | adr += chip->start; | 1681 | adr += chip->start; |
1721 | 1682 | ||
1722 | /* Let's determine this according to the interleave only once */ | ||
1723 | status_OK = CMD(0x80); | ||
1724 | |||
1725 | retry: | 1683 | retry: |
1726 | spin_lock(chip->mutex); | 1684 | spin_lock(chip->mutex); |
1727 | ret = get_chip(map, chip, adr, FL_ERASING); | 1685 | ret = get_chip(map, chip, adr, FL_ERASING); |
@@ -1743,48 +1701,15 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip, | |||
1743 | chip->state = FL_ERASING; | 1701 | chip->state = FL_ERASING; |
1744 | chip->erase_suspended = 0; | 1702 | chip->erase_suspended = 0; |
1745 | 1703 | ||
1746 | INVALIDATE_CACHE_UDELAY(map, chip, adr, | 1704 | ret = INVAL_CACHE_AND_WAIT(map, chip, adr, |
1747 | adr, len, | 1705 | adr, len, |
1748 | chip->erase_time*1000/2); | 1706 | &chip->erase_time); |
1749 | 1707 | if (ret) { | |
1750 | /* FIXME. Use a timer to check this, and return immediately. */ | 1708 | map_write(map, CMD(0x70), adr); |
1751 | /* Once the state machine's known to be working I'll do that */ | 1709 | chip->state = FL_STATUS; |
1752 | 1710 | xip_enable(map, chip, adr); | |
1753 | timeo = jiffies + (HZ*20); | 1711 | printk(KERN_ERR "%s: block erase error: (status timeout)\n", map->name); |
1754 | for (;;) { | 1712 | goto out; |
1755 | if (chip->state != FL_ERASING) { | ||
1756 | /* Someone's suspended the erase. Sleep */ | ||
1757 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
1758 | add_wait_queue(&chip->wq, &wait); | ||
1759 | spin_unlock(chip->mutex); | ||
1760 | schedule(); | ||
1761 | remove_wait_queue(&chip->wq, &wait); | ||
1762 | spin_lock(chip->mutex); | ||
1763 | continue; | ||
1764 | } | ||
1765 | if (chip->erase_suspended) { | ||
1766 | /* This erase was suspended and resumed. | ||
1767 | Adjust the timeout */ | ||
1768 | timeo = jiffies + (HZ*20); /* FIXME */ | ||
1769 | chip->erase_suspended = 0; | ||
1770 | } | ||
1771 | |||
1772 | status = map_read(map, adr); | ||
1773 | if (map_word_andequal(map, status, status_OK, status_OK)) | ||
1774 | break; | ||
1775 | |||
1776 | /* OK Still waiting */ | ||
1777 | if (time_after(jiffies, timeo)) { | ||
1778 | map_write(map, CMD(0x70), adr); | ||
1779 | chip->state = FL_STATUS; | ||
1780 | xip_enable(map, chip, adr); | ||
1781 | printk(KERN_ERR "%s: block erase error: (status timeout)\n", map->name); | ||
1782 | ret = -EIO; | ||
1783 | goto out; | ||
1784 | } | ||
1785 | |||
1786 | /* Latency issues. Drop the lock, wait a while and retry */ | ||
1787 | UDELAY(map, chip, adr, 1000000/HZ); | ||
1788 | } | 1713 | } |
1789 | 1714 | ||
1790 | /* We've broken this before. It doesn't hurt to be safe */ | 1715 | /* We've broken this before. It doesn't hurt to be safe */ |
@@ -1813,7 +1738,6 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip, | |||
1813 | ret = -EIO; | 1738 | ret = -EIO; |
1814 | } else if (chipstatus & 0x20 && retries--) { | 1739 | } else if (chipstatus & 0x20 && retries--) { |
1815 | printk(KERN_DEBUG "block erase failed at 0x%08lx: status 0x%lx. Retrying...\n", adr, chipstatus); | 1740 | printk(KERN_DEBUG "block erase failed at 0x%08lx: status 0x%lx. Retrying...\n", adr, chipstatus); |
1816 | timeo = jiffies + HZ; | ||
1817 | put_chip(map, chip, adr); | 1741 | put_chip(map, chip, adr); |
1818 | spin_unlock(chip->mutex); | 1742 | spin_unlock(chip->mutex); |
1819 | goto retry; | 1743 | goto retry; |
@@ -1919,15 +1843,11 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip | |||
1919 | { | 1843 | { |
1920 | struct cfi_private *cfi = map->fldrv_priv; | 1844 | struct cfi_private *cfi = map->fldrv_priv; |
1921 | struct cfi_pri_intelext *extp = cfi->cmdset_priv; | 1845 | struct cfi_pri_intelext *extp = cfi->cmdset_priv; |
1922 | map_word status, status_OK; | 1846 | int udelay; |
1923 | unsigned long timeo = jiffies + HZ; | ||
1924 | int ret; | 1847 | int ret; |
1925 | 1848 | ||
1926 | adr += chip->start; | 1849 | adr += chip->start; |
1927 | 1850 | ||
1928 | /* Let's determine this according to the interleave only once */ | ||
1929 | status_OK = CMD(0x80); | ||
1930 | |||
1931 | spin_lock(chip->mutex); | 1851 | spin_lock(chip->mutex); |
1932 | ret = get_chip(map, chip, adr, FL_LOCKING); | 1852 | ret = get_chip(map, chip, adr, FL_LOCKING); |
1933 | if (ret) { | 1853 | if (ret) { |
@@ -1952,41 +1872,21 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip | |||
1952 | * If Instant Individual Block Locking supported then no need | 1872 | * If Instant Individual Block Locking supported then no need |
1953 | * to delay. | 1873 | * to delay. |
1954 | */ | 1874 | */ |
1875 | udelay = (!extp || !(extp->FeatureSupport & (1 << 5))) ? 1000000/HZ : 0; | ||
1955 | 1876 | ||
1956 | if (!extp || !(extp->FeatureSupport & (1 << 5))) | 1877 | ret = WAIT_TIMEOUT(map, chip, adr, udelay); |
1957 | UDELAY(map, chip, adr, 1000000/HZ); | 1878 | if (ret) { |
1958 | 1879 | map_write(map, CMD(0x70), adr); | |
1959 | /* FIXME. Use a timer to check this, and return immediately. */ | 1880 | chip->state = FL_STATUS; |
1960 | /* Once the state machine's known to be working I'll do that */ | 1881 | xip_enable(map, chip, adr); |
1961 | 1882 | printk(KERN_ERR "%s: block unlock error: (status timeout)\n", map->name); | |
1962 | timeo = jiffies + (HZ*20); | 1883 | goto out; |
1963 | for (;;) { | ||
1964 | |||
1965 | status = map_read(map, adr); | ||
1966 | if (map_word_andequal(map, status, status_OK, status_OK)) | ||
1967 | break; | ||
1968 | |||
1969 | /* OK Still waiting */ | ||
1970 | if (time_after(jiffies, timeo)) { | ||
1971 | map_write(map, CMD(0x70), adr); | ||
1972 | chip->state = FL_STATUS; | ||
1973 | xip_enable(map, chip, adr); | ||
1974 | printk(KERN_ERR "%s: block unlock error: (status timeout)\n", map->name); | ||
1975 | put_chip(map, chip, adr); | ||
1976 | spin_unlock(chip->mutex); | ||
1977 | return -EIO; | ||
1978 | } | ||
1979 | |||
1980 | /* Latency issues. Drop the lock, wait a while and retry */ | ||
1981 | UDELAY(map, chip, adr, 1); | ||
1982 | } | 1884 | } |
1983 | 1885 | ||
1984 | /* Done and happy. */ | ||
1985 | chip->state = FL_STATUS; | ||
1986 | xip_enable(map, chip, adr); | 1886 | xip_enable(map, chip, adr); |
1987 | put_chip(map, chip, adr); | 1887 | out: put_chip(map, chip, adr); |
1988 | spin_unlock(chip->mutex); | 1888 | spin_unlock(chip->mutex); |
1989 | return 0; | 1889 | return ret; |
1990 | } | 1890 | } |
1991 | 1891 | ||
1992 | static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len) | 1892 | static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len) |
diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c index e636aa86bc24..4bf9f8cac0dd 100644 --- a/drivers/mtd/chips/cfi_probe.c +++ b/drivers/mtd/chips/cfi_probe.c | |||
@@ -349,12 +349,12 @@ static void print_cfi_ident(struct cfi_ident *cfip) | |||
349 | else | 349 | else |
350 | printk("No Vpp line\n"); | 350 | printk("No Vpp line\n"); |
351 | 351 | ||
352 | printk("Typical byte/word write timeout: %d µs\n", 1<<cfip->WordWriteTimeoutTyp); | 352 | printk("Typical byte/word write timeout: %d µs\n", 1<<cfip->WordWriteTimeoutTyp); |
353 | printk("Maximum byte/word write timeout: %d µs\n", (1<<cfip->WordWriteTimeoutMax) * (1<<cfip->WordWriteTimeoutTyp)); | 353 | printk("Maximum byte/word write timeout: %d µs\n", (1<<cfip->WordWriteTimeoutMax) * (1<<cfip->WordWriteTimeoutTyp)); |
354 | 354 | ||
355 | if (cfip->BufWriteTimeoutTyp || cfip->BufWriteTimeoutMax) { | 355 | if (cfip->BufWriteTimeoutTyp || cfip->BufWriteTimeoutMax) { |
356 | printk("Typical full buffer write timeout: %d µs\n", 1<<cfip->BufWriteTimeoutTyp); | 356 | printk("Typical full buffer write timeout: %d µs\n", 1<<cfip->BufWriteTimeoutTyp); |
357 | printk("Maximum full buffer write timeout: %d µs\n", (1<<cfip->BufWriteTimeoutMax) * (1<<cfip->BufWriteTimeoutTyp)); | 357 | printk("Maximum full buffer write timeout: %d µs\n", (1<<cfip->BufWriteTimeoutMax) * (1<<cfip->BufWriteTimeoutTyp)); |
358 | } | 358 | } |
359 | else | 359 | else |
360 | printk("Full buffer write not supported\n"); | 360 | printk("Full buffer write not supported\n"); |
diff --git a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c index 9b252d2e4a70..52d59d35091d 100644 --- a/drivers/mtd/chips/gen_probe.c +++ b/drivers/mtd/chips/gen_probe.c | |||
@@ -37,8 +37,15 @@ struct mtd_info *mtd_do_chip_probe(struct map_info *map, struct chip_probe *cp) | |||
37 | if (!mtd) | 37 | if (!mtd) |
38 | mtd = check_cmd_set(map, 0); /* Then the secondary */ | 38 | mtd = check_cmd_set(map, 0); /* Then the secondary */ |
39 | 39 | ||
40 | if (mtd) | 40 | if (mtd) { |
41 | if (mtd->size > map->size) { | ||
42 | printk(KERN_WARNING "Reducing visibility of %ldKiB chip to %ldKiB\n", | ||
43 | (unsigned long)mtd->size >> 10, | ||
44 | (unsigned long)map->size >> 10); | ||
45 | mtd->size = map->size; | ||
46 | } | ||
41 | return mtd; | 47 | return mtd; |
48 | } | ||
42 | 49 | ||
43 | printk(KERN_WARNING"gen_probe: No supported Vendor Command Set found\n"); | 50 | printk(KERN_WARNING"gen_probe: No supported Vendor Command Set found\n"); |
44 | 51 | ||
@@ -100,7 +107,12 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi | |||
100 | * Align bitmap storage size to full byte. | 107 | * Align bitmap storage size to full byte. |
101 | */ | 108 | */ |
102 | max_chips = map->size >> cfi.chipshift; | 109 | max_chips = map->size >> cfi.chipshift; |
103 | mapsize = (max_chips / 8) + ((max_chips % 8) ? 1 : 0); | 110 | if (!max_chips) { |
111 | printk(KERN_WARNING "NOR chip too large to fit in mapping. Attempting to cope...\n"); | ||
112 | max_chips = 1; | ||
113 | } | ||
114 | |||
115 | mapsize = (max_chips + BITS_PER_LONG-1) / BITS_PER_LONG; | ||
104 | chip_map = kmalloc(mapsize, GFP_KERNEL); | 116 | chip_map = kmalloc(mapsize, GFP_KERNEL); |
105 | if (!chip_map) { | 117 | if (!chip_map) { |
106 | printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name); | 118 | printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name); |
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig index 6e9f880e2f98..16c02b5ccf7e 100644 --- a/drivers/mtd/devices/Kconfig +++ b/drivers/mtd/devices/Kconfig | |||
@@ -47,6 +47,11 @@ config MTD_MS02NV | |||
47 | accelerator. Say Y here if you have a DECstation 5000/2x0 or a | 47 | accelerator. Say Y here if you have a DECstation 5000/2x0 or a |
48 | DECsystem 5900 equipped with such a module. | 48 | DECsystem 5900 equipped with such a module. |
49 | 49 | ||
50 | If you want to compile this driver as a module ( = code which can be | ||
51 | inserted in and removed from the running kernel whenever you want), | ||
52 | say M here and read <file:Documentation/modules.txt>. The module will | ||
53 | be called ms02-nv.o. | ||
54 | |||
50 | config MTD_DATAFLASH | 55 | config MTD_DATAFLASH |
51 | tristate "Support for AT45xxx DataFlash" | 56 | tristate "Support for AT45xxx DataFlash" |
52 | depends on MTD && SPI_MASTER && EXPERIMENTAL | 57 | depends on MTD && SPI_MASTER && EXPERIMENTAL |
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index f54e4bf9b968..8ca04f4e03f0 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * block2mtd.c - create an mtd from a block device | 4 | * block2mtd.c - create an mtd from a block device |
5 | * | 5 | * |
6 | * Copyright (C) 2001,2002 Simon Evans <spse@secret.org.uk> | 6 | * Copyright (C) 2001,2002 Simon Evans <spse@secret.org.uk> |
7 | * Copyright (C) 2004-2006 Jörn Engel <joern@wh.fh-wedel.de> | 7 | * Copyright (C) 2004-2006 Jörn Engel <joern@wh.fh-wedel.de> |
8 | * | 8 | * |
9 | * Licence: GPL | 9 | * Licence: GPL |
10 | */ | 10 | */ |
@@ -429,7 +429,8 @@ static inline void kill_final_newline(char *str) | |||
429 | 429 | ||
430 | static int block2mtd_setup(const char *val, struct kernel_param *kp) | 430 | static int block2mtd_setup(const char *val, struct kernel_param *kp) |
431 | { | 431 | { |
432 | char buf[80+12], *str=buf; /* 80 for device, 12 for erase size */ | 432 | char buf[80+12]; /* 80 for device, 12 for erase size */ |
433 | char *str = buf; | ||
433 | char *token[2]; | 434 | char *token[2]; |
434 | char *name; | 435 | char *name; |
435 | size_t erase_size = PAGE_SIZE; | 436 | size_t erase_size = PAGE_SIZE; |
@@ -441,7 +442,7 @@ static int block2mtd_setup(const char *val, struct kernel_param *kp) | |||
441 | strcpy(str, val); | 442 | strcpy(str, val); |
442 | kill_final_newline(str); | 443 | kill_final_newline(str); |
443 | 444 | ||
444 | for (i=0; i<2; i++) | 445 | for (i = 0; i < 2; i++) |
445 | token[i] = strsep(&str, ","); | 446 | token[i] = strsep(&str, ","); |
446 | 447 | ||
447 | if (str) | 448 | if (str) |
@@ -460,8 +461,10 @@ static int block2mtd_setup(const char *val, struct kernel_param *kp) | |||
460 | 461 | ||
461 | if (token[1]) { | 462 | if (token[1]) { |
462 | ret = parse_num(&erase_size, token[1]); | 463 | ret = parse_num(&erase_size, token[1]); |
463 | if (ret) | 464 | if (ret) { |
465 | kfree(name); | ||
464 | parse_err("illegal erase size"); | 466 | parse_err("illegal erase size"); |
467 | } | ||
465 | } | 468 | } |
466 | 469 | ||
467 | add_device(name, erase_size); | 470 | add_device(name, erase_size); |
diff --git a/drivers/mtd/devices/docprobe.c b/drivers/mtd/devices/docprobe.c index 32f1d332f5b5..42ec08416a60 100644 --- a/drivers/mtd/devices/docprobe.c +++ b/drivers/mtd/devices/docprobe.c | |||
@@ -231,21 +231,21 @@ static inline int __init doccheck(void __iomem *potential, unsigned long physadr | |||
231 | 231 | ||
232 | static int docfound; | 232 | static int docfound; |
233 | 233 | ||
234 | #ifdef CONFIG_DOC2000 | 234 | #ifdef CONFIG_MTD_DOC2000 |
235 | extern void DoC2k_init(struct mtd_info *); | 235 | extern void DoC2k_init(struct mtd_info *); |
236 | #define doc2k_initfunc (&DoC2k_init) | 236 | #define doc2k_initfunc (&DoC2k_init) |
237 | #else | 237 | #else |
238 | #define doc2k_initfunc NULL | 238 | #define doc2k_initfunc NULL |
239 | #endif | 239 | #endif |
240 | 240 | ||
241 | #ifdef CONFIG_DOC2001 | 241 | #ifdef CONFIG_MTD_DOC2001 |
242 | extern void DoCMil_init(struct mtd_info *); | 242 | extern void DoCMil_init(struct mtd_info *); |
243 | #define docmil_initfunc (&DoCMil_init) | 243 | #define docmil_initfunc (&DoCMil_init) |
244 | #else | 244 | #else |
245 | #define docmil_initfunc NULL | 245 | #define docmil_initfunc NULL |
246 | #endif | 246 | #endif |
247 | 247 | ||
248 | #ifdef CONFIG_DOC2001PLUS | 248 | #ifdef CONFIG_MTD_DOC2001PLUS |
249 | extern void DoCMilPlus_init(struct mtd_info *); | 249 | extern void DoCMilPlus_init(struct mtd_info *); |
250 | #define docmplus_initfunc (&DoCMilPlus_init) | 250 | #define docmplus_initfunc (&DoCMilPlus_init) |
251 | #else | 251 | #else |
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index 41af9693d880..e09e416667d3 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /** | 1 | /** |
2 | * $Id: phram.c,v 1.16 2005/11/07 11:14:25 gleixner Exp $ | 2 | * $Id: phram.c,v 1.16 2005/11/07 11:14:25 gleixner Exp $ |
3 | * | 3 | * |
4 | * Copyright (c) ???? Jochen Schäuble <psionic@psionic.de> | 4 | * Copyright (c) ???? Jochen Schäuble <psionic@psionic.de> |
5 | * Copyright (c) 2003-2004 Jörn Engel <joern@wh.fh-wedel.de> | 5 | * Copyright (c) 2003-2004 Jörn Engel <joern@wh.fh-wedel.de> |
6 | * | 6 | * |
7 | * Usage: | 7 | * Usage: |
8 | * | 8 | * |
@@ -266,12 +266,16 @@ static int phram_setup(const char *val, struct kernel_param *kp) | |||
266 | return 0; | 266 | return 0; |
267 | 267 | ||
268 | ret = parse_num32(&start, token[1]); | 268 | ret = parse_num32(&start, token[1]); |
269 | if (ret) | 269 | if (ret) { |
270 | kfree(name); | ||
270 | parse_err("illegal start address\n"); | 271 | parse_err("illegal start address\n"); |
272 | } | ||
271 | 273 | ||
272 | ret = parse_num32(&len, token[2]); | 274 | ret = parse_num32(&len, token[2]); |
273 | if (ret) | 275 | if (ret) { |
276 | kfree(name); | ||
274 | parse_err("illegal device length\n"); | 277 | parse_err("illegal device length\n"); |
278 | } | ||
275 | 279 | ||
276 | register_device(name, start, len); | 280 | register_device(name, start, len); |
277 | 281 | ||
@@ -296,5 +300,5 @@ module_init(init_phram); | |||
296 | module_exit(cleanup_phram); | 300 | module_exit(cleanup_phram); |
297 | 301 | ||
298 | MODULE_LICENSE("GPL"); | 302 | MODULE_LICENSE("GPL"); |
299 | MODULE_AUTHOR("Jörn Engel <joern@wh.fh-wedel.de>"); | 303 | MODULE_AUTHOR("Jörn Engel <joern@wh.fh-wedel.de>"); |
300 | MODULE_DESCRIPTION("MTD driver for physical RAM"); | 304 | MODULE_DESCRIPTION("MTD driver for physical RAM"); |
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index 4e2bd37b3d8a..6bdaacc6d6f9 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig | |||
@@ -200,8 +200,8 @@ config MTD_TSUNAMI | |||
200 | Support for the flash chip on Tsunami TIG bus. | 200 | Support for the flash chip on Tsunami TIG bus. |
201 | 201 | ||
202 | config MTD_LASAT | 202 | config MTD_LASAT |
203 | tristate "Flash chips on LASAT board" | 203 | tristate "LASAT flash device" |
204 | depends on LASAT | 204 | depends on LASAT && MTD_CFI |
205 | help | 205 | help |
206 | Support for the flash chips on the Lasat 100 and 200 boards. | 206 | Support for the flash chips on the Lasat 100 and 200 boards. |
207 | 207 | ||
diff --git a/drivers/mtd/maps/cfi_flagadm.c b/drivers/mtd/maps/cfi_flagadm.c index fd0f0d3187de..92b5d883d7b0 100644 --- a/drivers/mtd/maps/cfi_flagadm.c +++ b/drivers/mtd/maps/cfi_flagadm.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright © 2001 Flaga hf. Medical Devices, Kári Davíðsson <kd@flaga.is> | 2 | * Copyright © 2001 Flaga hf. Medical Devices, Kári DavÃðsson <kd@flaga.is> |
3 | * | 3 | * |
4 | * $Id: cfi_flagadm.c,v 1.15 2005/11/07 11:14:26 gleixner Exp $ | 4 | * $Id: cfi_flagadm.c,v 1.15 2005/11/07 11:14:26 gleixner Exp $ |
5 | * | 5 | * |
@@ -135,5 +135,5 @@ module_exit(cleanup_flagadm); | |||
135 | 135 | ||
136 | 136 | ||
137 | MODULE_LICENSE("GPL"); | 137 | MODULE_LICENSE("GPL"); |
138 | MODULE_AUTHOR("Kári Davíðsson <kd@flaga.is>"); | 138 | MODULE_AUTHOR("Kári DavÃðsson <kd@flaga.is>"); |
139 | MODULE_DESCRIPTION("MTD map driver for Flaga digital module"); | 139 | MODULE_DESCRIPTION("MTD map driver for Flaga digital module"); |
diff --git a/drivers/mtd/maps/dbox2-flash.c b/drivers/mtd/maps/dbox2-flash.c index 652813cd6c2d..85c2a9e22b1e 100644 --- a/drivers/mtd/maps/dbox2-flash.c +++ b/drivers/mtd/maps/dbox2-flash.c | |||
@@ -122,5 +122,5 @@ module_exit(cleanup_dbox2_flash); | |||
122 | 122 | ||
123 | 123 | ||
124 | MODULE_LICENSE("GPL"); | 124 | MODULE_LICENSE("GPL"); |
125 | MODULE_AUTHOR("Kári Davíðsson <kd@flaga.is>, Bastian Blank <waldi@tuxbox.org>, Alexander Wild <wild@te-elektronik.com>"); | 125 | MODULE_AUTHOR("Kári DavÃðsson <kd@flaga.is>, Bastian Blank <waldi@tuxbox.org>, Alexander Wild <wild@te-elektronik.com>"); |
126 | MODULE_DESCRIPTION("MTD map driver for D-Box 2 board"); | 126 | MODULE_DESCRIPTION("MTD map driver for D-Box 2 board"); |
diff --git a/drivers/mtd/maps/mtx-1_flash.c b/drivers/mtd/maps/mtx-1_flash.c index d1e66e186746..5c25d4e552c6 100644 --- a/drivers/mtd/maps/mtx-1_flash.c +++ b/drivers/mtd/maps/mtx-1_flash.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * $Id: mtx-1_flash.c,v 1.2 2005/11/07 11:14:27 gleixner Exp $ | 4 | * $Id: mtx-1_flash.c,v 1.2 2005/11/07 11:14:27 gleixner Exp $ |
5 | * | 5 | * |
6 | * (C) 2005 Bruno Randolf <bruno.randolf@4g-systems.biz> | 6 | * (C) 2005 Bruno Randolf <bruno.randolf@4g-systems.biz> |
7 | * (C) 2005 Jörn Engel <joern@wohnheim.fh-wedel.de> | 7 | * (C) 2005 Jörn Engel <joern@wohnheim.fh-wedel.de> |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index d27f4129afd3..c861134cbc48 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -713,6 +713,7 @@ static void pcmciamtd_detach(struct pcmcia_device *link) | |||
713 | 713 | ||
714 | if(dev->mtd_info) { | 714 | if(dev->mtd_info) { |
715 | del_mtd_device(dev->mtd_info); | 715 | del_mtd_device(dev->mtd_info); |
716 | map_destroy(dev->mtd_info); | ||
716 | info("mtd%d: Removed", dev->mtd_info->index); | 717 | info("mtd%d: Removed", dev->mtd_info->index); |
717 | } | 718 | } |
718 | 719 | ||
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c index 76ce9bd943aa..bc82f702aa3c 100644 --- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/mtd/partitions.h> | 22 | #include <linux/mtd/partitions.h> |
23 | #include <linux/mtd/physmap.h> | 23 | #include <linux/mtd/physmap.h> |
24 | #include <asm/io.h> | 24 | #include <asm/io.h> |
25 | #include <asm/mach/flash.h> | ||
26 | 25 | ||
27 | struct physmap_flash_info { | 26 | struct physmap_flash_info { |
28 | struct mtd_info *mtd; | 27 | struct mtd_info *mtd; |
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 9af840364a74..b7de90845c2d 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
@@ -251,6 +251,106 @@ concat_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
251 | } | 251 | } |
252 | 252 | ||
253 | static int | 253 | static int |
254 | concat_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, | ||
255 | unsigned long count, loff_t to, size_t * retlen, | ||
256 | u_char *eccbuf, struct nand_oobinfo *oobsel) | ||
257 | { | ||
258 | struct mtd_concat *concat = CONCAT(mtd); | ||
259 | struct kvec *vecs_copy; | ||
260 | unsigned long entry_low, entry_high; | ||
261 | size_t total_len = 0; | ||
262 | int i; | ||
263 | int err = -EINVAL; | ||
264 | |||
265 | if (!(mtd->flags & MTD_WRITEABLE)) | ||
266 | return -EROFS; | ||
267 | |||
268 | *retlen = 0; | ||
269 | |||
270 | /* Calculate total length of data */ | ||
271 | for (i = 0; i < count; i++) | ||
272 | total_len += vecs[i].iov_len; | ||
273 | |||
274 | /* Do not allow write past end of device */ | ||
275 | if ((to + total_len) > mtd->size) | ||
276 | return -EINVAL; | ||
277 | |||
278 | /* Check alignment */ | ||
279 | if (mtd->oobblock > 1) | ||
280 | if ((to % mtd->oobblock) || (total_len % mtd->oobblock)) | ||
281 | return -EINVAL; | ||
282 | |||
283 | /* make a copy of vecs */ | ||
284 | vecs_copy = kmalloc(sizeof(struct kvec) * count, GFP_KERNEL); | ||
285 | if (!vecs_copy) | ||
286 | return -ENOMEM; | ||
287 | memcpy(vecs_copy, vecs, sizeof(struct kvec) * count); | ||
288 | |||
289 | entry_low = 0; | ||
290 | for (i = 0; i < concat->num_subdev; i++) { | ||
291 | struct mtd_info *subdev = concat->subdev[i]; | ||
292 | size_t size, wsize, retsize, old_iov_len; | ||
293 | |||
294 | if (to >= subdev->size) { | ||
295 | to -= subdev->size; | ||
296 | continue; | ||
297 | } | ||
298 | |||
299 | size = min(total_len, (size_t)(subdev->size - to)); | ||
300 | wsize = size; /* store for future use */ | ||
301 | |||
302 | entry_high = entry_low; | ||
303 | while (entry_high < count) { | ||
304 | if (size <= vecs_copy[entry_high].iov_len) | ||
305 | break; | ||
306 | size -= vecs_copy[entry_high++].iov_len; | ||
307 | } | ||
308 | |||
309 | old_iov_len = vecs_copy[entry_high].iov_len; | ||
310 | vecs_copy[entry_high].iov_len = size; | ||
311 | |||
312 | if (!(subdev->flags & MTD_WRITEABLE)) | ||
313 | err = -EROFS; | ||
314 | else if (eccbuf) | ||
315 | err = subdev->writev_ecc(subdev, &vecs_copy[entry_low], | ||
316 | entry_high - entry_low + 1, to, &retsize, | ||
317 | eccbuf, oobsel); | ||
318 | else | ||
319 | err = subdev->writev(subdev, &vecs_copy[entry_low], | ||
320 | entry_high - entry_low + 1, to, &retsize); | ||
321 | |||
322 | vecs_copy[entry_high].iov_len = old_iov_len - size; | ||
323 | vecs_copy[entry_high].iov_base += size; | ||
324 | |||
325 | entry_low = entry_high; | ||
326 | |||
327 | if (err) | ||
328 | break; | ||
329 | |||
330 | *retlen += retsize; | ||
331 | total_len -= wsize; | ||
332 | if (concat->mtd.type == MTD_NANDFLASH && eccbuf) | ||
333 | eccbuf += mtd->oobavail * (wsize / mtd->oobblock); | ||
334 | |||
335 | if (total_len == 0) | ||
336 | break; | ||
337 | |||
338 | err = -EINVAL; | ||
339 | to = 0; | ||
340 | } | ||
341 | |||
342 | kfree(vecs_copy); | ||
343 | return err; | ||
344 | } | ||
345 | |||
346 | static int | ||
347 | concat_writev(struct mtd_info *mtd, const struct kvec *vecs, | ||
348 | unsigned long count, loff_t to, size_t * retlen) | ||
349 | { | ||
350 | return concat_writev_ecc(mtd, vecs, count, to, retlen, NULL, NULL); | ||
351 | } | ||
352 | |||
353 | static int | ||
254 | concat_read_oob(struct mtd_info *mtd, loff_t from, size_t len, | 354 | concat_read_oob(struct mtd_info *mtd, loff_t from, size_t len, |
255 | size_t * retlen, u_char * buf) | 355 | size_t * retlen, u_char * buf) |
256 | { | 356 | { |
@@ -636,6 +736,58 @@ static void concat_resume(struct mtd_info *mtd) | |||
636 | } | 736 | } |
637 | } | 737 | } |
638 | 738 | ||
739 | static int concat_block_isbad(struct mtd_info *mtd, loff_t ofs) | ||
740 | { | ||
741 | struct mtd_concat *concat = CONCAT(mtd); | ||
742 | int i, res = 0; | ||
743 | |||
744 | if (!concat->subdev[0]->block_isbad) | ||
745 | return res; | ||
746 | |||
747 | if (ofs > mtd->size) | ||
748 | return -EINVAL; | ||
749 | |||
750 | for (i = 0; i < concat->num_subdev; i++) { | ||
751 | struct mtd_info *subdev = concat->subdev[i]; | ||
752 | |||
753 | if (ofs >= subdev->size) { | ||
754 | ofs -= subdev->size; | ||
755 | continue; | ||
756 | } | ||
757 | |||
758 | res = subdev->block_isbad(subdev, ofs); | ||
759 | break; | ||
760 | } | ||
761 | |||
762 | return res; | ||
763 | } | ||
764 | |||
765 | static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs) | ||
766 | { | ||
767 | struct mtd_concat *concat = CONCAT(mtd); | ||
768 | int i, err = -EINVAL; | ||
769 | |||
770 | if (!concat->subdev[0]->block_markbad) | ||
771 | return 0; | ||
772 | |||
773 | if (ofs > mtd->size) | ||
774 | return -EINVAL; | ||
775 | |||
776 | for (i = 0; i < concat->num_subdev; i++) { | ||
777 | struct mtd_info *subdev = concat->subdev[i]; | ||
778 | |||
779 | if (ofs >= subdev->size) { | ||
780 | ofs -= subdev->size; | ||
781 | continue; | ||
782 | } | ||
783 | |||
784 | err = subdev->block_markbad(subdev, ofs); | ||
785 | break; | ||
786 | } | ||
787 | |||
788 | return err; | ||
789 | } | ||
790 | |||
639 | /* | 791 | /* |
640 | * This function constructs a virtual MTD device by concatenating | 792 | * This function constructs a virtual MTD device by concatenating |
641 | * num_devs MTD devices. A pointer to the new device object is | 793 | * num_devs MTD devices. A pointer to the new device object is |
@@ -685,10 +837,18 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
685 | concat->mtd.read_ecc = concat_read_ecc; | 837 | concat->mtd.read_ecc = concat_read_ecc; |
686 | if (subdev[0]->write_ecc) | 838 | if (subdev[0]->write_ecc) |
687 | concat->mtd.write_ecc = concat_write_ecc; | 839 | concat->mtd.write_ecc = concat_write_ecc; |
840 | if (subdev[0]->writev) | ||
841 | concat->mtd.writev = concat_writev; | ||
842 | if (subdev[0]->writev_ecc) | ||
843 | concat->mtd.writev_ecc = concat_writev_ecc; | ||
688 | if (subdev[0]->read_oob) | 844 | if (subdev[0]->read_oob) |
689 | concat->mtd.read_oob = concat_read_oob; | 845 | concat->mtd.read_oob = concat_read_oob; |
690 | if (subdev[0]->write_oob) | 846 | if (subdev[0]->write_oob) |
691 | concat->mtd.write_oob = concat_write_oob; | 847 | concat->mtd.write_oob = concat_write_oob; |
848 | if (subdev[0]->block_isbad) | ||
849 | concat->mtd.block_isbad = concat_block_isbad; | ||
850 | if (subdev[0]->block_markbad) | ||
851 | concat->mtd.block_markbad = concat_block_markbad; | ||
692 | 852 | ||
693 | concat->subdev[0] = subdev[0]; | 853 | concat->subdev[0] = subdev[0]; |
694 | 854 | ||
@@ -734,14 +894,13 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
734 | 894 | ||
735 | } | 895 | } |
736 | 896 | ||
897 | if(concat->mtd.type == MTD_NANDFLASH) | ||
898 | memcpy(&concat->mtd.oobinfo, &subdev[0]->oobinfo, | ||
899 | sizeof(struct nand_oobinfo)); | ||
900 | |||
737 | concat->num_subdev = num_devs; | 901 | concat->num_subdev = num_devs; |
738 | concat->mtd.name = name; | 902 | concat->mtd.name = name; |
739 | 903 | ||
740 | /* | ||
741 | * NOTE: for now, we do not provide any readv()/writev() methods | ||
742 | * because they are messy to implement and they are not | ||
743 | * used to a great extent anyway. | ||
744 | */ | ||
745 | concat->mtd.erase = concat_erase; | 904 | concat->mtd.erase = concat_erase; |
746 | concat->mtd.read = concat_read; | 905 | concat->mtd.read = concat_read; |
747 | concat->mtd.write = concat_write; | 906 | concat->mtd.write = concat_write; |
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 99395911d26f..29ed5abe70c4 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -400,6 +400,7 @@ int add_mtd_partitions(struct mtd_info *master, | |||
400 | slave->mtd.size = parts[i].size; | 400 | slave->mtd.size = parts[i].size; |
401 | slave->mtd.oobblock = master->oobblock; | 401 | slave->mtd.oobblock = master->oobblock; |
402 | slave->mtd.oobsize = master->oobsize; | 402 | slave->mtd.oobsize = master->oobsize; |
403 | slave->mtd.oobavail = master->oobavail; | ||
403 | slave->mtd.ecctype = master->ecctype; | 404 | slave->mtd.ecctype = master->ecctype; |
404 | slave->mtd.eccsize = master->eccsize; | 405 | slave->mtd.eccsize = master->eccsize; |
405 | 406 | ||
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index b4a7086b219c..b1f807980b79 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig | |||
@@ -192,12 +192,21 @@ config MTD_NAND_SHARPSL | |||
192 | config MTD_NAND_CS553X | 192 | config MTD_NAND_CS553X |
193 | tristate "NAND support for CS5535/CS5536 (AMD Geode companion chip)" | 193 | tristate "NAND support for CS5535/CS5536 (AMD Geode companion chip)" |
194 | depends on MTD_NAND && X86_PC && PCI | 194 | depends on MTD_NAND && X86_PC && PCI |
195 | 195 | help | |
196 | The CS553x companion chips for the AMD Geode processor | ||
197 | include NAND flash controllers with built-in hardware ECC | ||
198 | capabilities; enabling this option will allow you to use | ||
199 | these. The driver will check the MSRs to verify that the | ||
200 | controller is enabled for NAND, and currently requires that | ||
201 | the controller be in MMIO mode. | ||
202 | |||
203 | If you say "m", the module will be called "cs553x_nand.ko". | ||
204 | |||
196 | config MTD_NAND_NANDSIM | 205 | config MTD_NAND_NANDSIM |
197 | tristate "Support for NAND Flash Simulator" | 206 | tristate "Support for NAND Flash Simulator" |
198 | depends on MTD_NAND && MTD_PARTITIONS | 207 | depends on MTD_NAND && MTD_PARTITIONS |
199 | help | 208 | help |
200 | The simulator may simulate verious NAND flash chips for the | 209 | The simulator may simulate various NAND flash chips for the |
201 | MTD nand layer. | 210 | MTD nand layer. |
202 | 211 | ||
203 | endmenu | 212 | endmenu |
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c index bde3550910a2..d9a0143e1d3a 100644 --- a/drivers/mtd/nand/au1550nd.c +++ b/drivers/mtd/nand/au1550nd.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/interrupt.h> | ||
17 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
18 | #include <linux/mtd/nand.h> | 19 | #include <linux/mtd/nand.h> |
19 | #include <linux/mtd/partitions.h> | 20 | #include <linux/mtd/partitions.h> |
@@ -38,22 +39,20 @@ | |||
38 | */ | 39 | */ |
39 | static struct mtd_info *au1550_mtd = NULL; | 40 | static struct mtd_info *au1550_mtd = NULL; |
40 | static void __iomem *p_nand; | 41 | static void __iomem *p_nand; |
41 | static int nand_width = 1; /* default x8*/ | 42 | static int nand_width = 1; /* default x8 */ |
42 | 43 | ||
43 | /* | 44 | /* |
44 | * Define partitions for flash device | 45 | * Define partitions for flash device |
45 | */ | 46 | */ |
46 | static const struct mtd_partition partition_info[] = { | 47 | static const struct mtd_partition partition_info[] = { |
47 | { | 48 | { |
48 | .name = "NAND FS 0", | 49 | .name = "NAND FS 0", |
49 | .offset = 0, | 50 | .offset = 0, |
50 | .size = 8*1024*1024 | 51 | .size = 8 * 1024 * 1024}, |
51 | }, | ||
52 | { | 52 | { |
53 | .name = "NAND FS 1", | 53 | .name = "NAND FS 1", |
54 | .offset = MTDPART_OFS_APPEND, | 54 | .offset = MTDPART_OFS_APPEND, |
55 | .size = MTDPART_SIZ_FULL | 55 | .size = MTDPART_SIZ_FULL} |
56 | } | ||
57 | }; | 56 | }; |
58 | 57 | ||
59 | /** | 58 | /** |
@@ -157,7 +156,7 @@ static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len) | |||
157 | int i; | 156 | int i; |
158 | struct nand_chip *this = mtd->priv; | 157 | struct nand_chip *this = mtd->priv; |
159 | 158 | ||
160 | for (i=0; i<len; i++) { | 159 | for (i = 0; i < len; i++) { |
161 | writeb(buf[i], this->IO_ADDR_W); | 160 | writeb(buf[i], this->IO_ADDR_W); |
162 | au_sync(); | 161 | au_sync(); |
163 | } | 162 | } |
@@ -176,7 +175,7 @@ static void au_read_buf(struct mtd_info *mtd, u_char *buf, int len) | |||
176 | int i; | 175 | int i; |
177 | struct nand_chip *this = mtd->priv; | 176 | struct nand_chip *this = mtd->priv; |
178 | 177 | ||
179 | for (i=0; i<len; i++) { | 178 | for (i = 0; i < len; i++) { |
180 | buf[i] = readb(this->IO_ADDR_R); | 179 | buf[i] = readb(this->IO_ADDR_R); |
181 | au_sync(); | 180 | au_sync(); |
182 | } | 181 | } |
@@ -195,7 +194,7 @@ static int au_verify_buf(struct mtd_info *mtd, const u_char *buf, int len) | |||
195 | int i; | 194 | int i; |
196 | struct nand_chip *this = mtd->priv; | 195 | struct nand_chip *this = mtd->priv; |
197 | 196 | ||
198 | for (i=0; i<len; i++) { | 197 | for (i = 0; i < len; i++) { |
199 | if (buf[i] != readb(this->IO_ADDR_R)) | 198 | if (buf[i] != readb(this->IO_ADDR_R)) |
200 | return -EFAULT; | 199 | return -EFAULT; |
201 | au_sync(); | 200 | au_sync(); |
@@ -219,7 +218,7 @@ static void au_write_buf16(struct mtd_info *mtd, const u_char *buf, int len) | |||
219 | u16 *p = (u16 *) buf; | 218 | u16 *p = (u16 *) buf; |
220 | len >>= 1; | 219 | len >>= 1; |
221 | 220 | ||
222 | for (i=0; i<len; i++) { | 221 | for (i = 0; i < len; i++) { |
223 | writew(p[i], this->IO_ADDR_W); | 222 | writew(p[i], this->IO_ADDR_W); |
224 | au_sync(); | 223 | au_sync(); |
225 | } | 224 | } |
@@ -241,7 +240,7 @@ static void au_read_buf16(struct mtd_info *mtd, u_char *buf, int len) | |||
241 | u16 *p = (u16 *) buf; | 240 | u16 *p = (u16 *) buf; |
242 | len >>= 1; | 241 | len >>= 1; |
243 | 242 | ||
244 | for (i=0; i<len; i++) { | 243 | for (i = 0; i < len; i++) { |
245 | p[i] = readw(this->IO_ADDR_R); | 244 | p[i] = readw(this->IO_ADDR_R); |
246 | au_sync(); | 245 | au_sync(); |
247 | } | 246 | } |
@@ -262,7 +261,7 @@ static int au_verify_buf16(struct mtd_info *mtd, const u_char *buf, int len) | |||
262 | u16 *p = (u16 *) buf; | 261 | u16 *p = (u16 *) buf; |
263 | len >>= 1; | 262 | len >>= 1; |
264 | 263 | ||
265 | for (i=0; i<len; i++) { | 264 | for (i = 0; i < len; i++) { |
266 | if (p[i] != readw(this->IO_ADDR_R)) | 265 | if (p[i] != readw(this->IO_ADDR_R)) |
267 | return -EFAULT; | 266 | return -EFAULT; |
268 | au_sync(); | 267 | au_sync(); |
@@ -275,27 +274,35 @@ static void au1550_hwcontrol(struct mtd_info *mtd, int cmd) | |||
275 | { | 274 | { |
276 | register struct nand_chip *this = mtd->priv; | 275 | register struct nand_chip *this = mtd->priv; |
277 | 276 | ||
278 | switch(cmd){ | 277 | switch (cmd) { |
278 | |||
279 | case NAND_CTL_SETCLE: | ||
280 | this->IO_ADDR_W = p_nand + MEM_STNAND_CMD; | ||
281 | break; | ||
279 | 282 | ||
280 | case NAND_CTL_SETCLE: this->IO_ADDR_W = p_nand + MEM_STNAND_CMD; break; | 283 | case NAND_CTL_CLRCLE: |
281 | case NAND_CTL_CLRCLE: this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; break; | 284 | this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; |
285 | break; | ||
286 | |||
287 | case NAND_CTL_SETALE: | ||
288 | this->IO_ADDR_W = p_nand + MEM_STNAND_ADDR; | ||
289 | break; | ||
282 | 290 | ||
283 | case NAND_CTL_SETALE: this->IO_ADDR_W = p_nand + MEM_STNAND_ADDR; break; | ||
284 | case NAND_CTL_CLRALE: | 291 | case NAND_CTL_CLRALE: |
285 | this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; | 292 | this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; |
286 | /* FIXME: Nobody knows why this is neccecary, | 293 | /* FIXME: Nobody knows why this is necessary, |
287 | * but it works only that way */ | 294 | * but it works only that way */ |
288 | udelay(1); | 295 | udelay(1); |
289 | break; | 296 | break; |
290 | 297 | ||
291 | case NAND_CTL_SETNCE: | 298 | case NAND_CTL_SETNCE: |
292 | /* assert (force assert) chip enable */ | 299 | /* assert (force assert) chip enable */ |
293 | au_writel((1<<(4+NAND_CS)) , MEM_STNDCTL); break; | 300 | au_writel((1 << (4 + NAND_CS)), MEM_STNDCTL); |
294 | break; | 301 | break; |
295 | 302 | ||
296 | case NAND_CTL_CLRNCE: | 303 | case NAND_CTL_CLRNCE: |
297 | /* deassert chip enable */ | 304 | /* deassert chip enable */ |
298 | au_writel(0, MEM_STNDCTL); break; | 305 | au_writel(0, MEM_STNDCTL); |
299 | break; | 306 | break; |
300 | } | 307 | } |
301 | 308 | ||
@@ -312,69 +319,200 @@ int au1550_device_ready(struct mtd_info *mtd) | |||
312 | return ret; | 319 | return ret; |
313 | } | 320 | } |
314 | 321 | ||
322 | /** | ||
323 | * au1550_select_chip - control -CE line | ||
324 | * Forbid driving -CE manually permitting the NAND controller to do this. | ||
325 | * Keeping -CE asserted during the whole sector reads interferes with the | ||
326 | * NOR flash and PCMCIA drivers as it causes contention on the static bus. | ||
327 | * We only have to hold -CE low for the NAND read commands since the flash | ||
328 | * chip needs it to be asserted during chip not ready time but the NAND | ||
329 | * controller keeps it released. | ||
330 | * | ||
331 | * @mtd: MTD device structure | ||
332 | * @chip: chipnumber to select, -1 for deselect | ||
333 | */ | ||
334 | static void au1550_select_chip(struct mtd_info *mtd, int chip) | ||
335 | { | ||
336 | } | ||
337 | |||
338 | /** | ||
339 | * au1550_command - Send command to NAND device | ||
340 | * @mtd: MTD device structure | ||
341 | * @command: the command to be sent | ||
342 | * @column: the column address for this command, -1 if none | ||
343 | * @page_addr: the page address for this command, -1 if none | ||
344 | */ | ||
345 | static void au1550_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) | ||
346 | { | ||
347 | register struct nand_chip *this = mtd->priv; | ||
348 | int ce_override = 0, i; | ||
349 | ulong flags; | ||
350 | |||
351 | /* Begin command latch cycle */ | ||
352 | this->hwcontrol(mtd, NAND_CTL_SETCLE); | ||
353 | /* | ||
354 | * Write out the command to the device. | ||
355 | */ | ||
356 | if (command == NAND_CMD_SEQIN) { | ||
357 | int readcmd; | ||
358 | |||
359 | if (column >= mtd->oobblock) { | ||
360 | /* OOB area */ | ||
361 | column -= mtd->oobblock; | ||
362 | readcmd = NAND_CMD_READOOB; | ||
363 | } else if (column < 256) { | ||
364 | /* First 256 bytes --> READ0 */ | ||
365 | readcmd = NAND_CMD_READ0; | ||
366 | } else { | ||
367 | column -= 256; | ||
368 | readcmd = NAND_CMD_READ1; | ||
369 | } | ||
370 | this->write_byte(mtd, readcmd); | ||
371 | } | ||
372 | this->write_byte(mtd, command); | ||
373 | |||
374 | /* Set ALE and clear CLE to start address cycle */ | ||
375 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); | ||
376 | |||
377 | if (column != -1 || page_addr != -1) { | ||
378 | this->hwcontrol(mtd, NAND_CTL_SETALE); | ||
379 | |||
380 | /* Serially input address */ | ||
381 | if (column != -1) { | ||
382 | /* Adjust columns for 16 bit buswidth */ | ||
383 | if (this->options & NAND_BUSWIDTH_16) | ||
384 | column >>= 1; | ||
385 | this->write_byte(mtd, column); | ||
386 | } | ||
387 | if (page_addr != -1) { | ||
388 | this->write_byte(mtd, (u8)(page_addr & 0xff)); | ||
389 | |||
390 | if (command == NAND_CMD_READ0 || | ||
391 | command == NAND_CMD_READ1 || | ||
392 | command == NAND_CMD_READOOB) { | ||
393 | /* | ||
394 | * NAND controller will release -CE after | ||
395 | * the last address byte is written, so we'll | ||
396 | * have to forcibly assert it. No interrupts | ||
397 | * are allowed while we do this as we don't | ||
398 | * want the NOR flash or PCMCIA drivers to | ||
399 | * steal our precious bytes of data... | ||
400 | */ | ||
401 | ce_override = 1; | ||
402 | local_irq_save(flags); | ||
403 | this->hwcontrol(mtd, NAND_CTL_SETNCE); | ||
404 | } | ||
405 | |||
406 | this->write_byte(mtd, (u8)(page_addr >> 8)); | ||
407 | |||
408 | /* One more address cycle for devices > 32MiB */ | ||
409 | if (this->chipsize > (32 << 20)) | ||
410 | this->write_byte(mtd, (u8)((page_addr >> 16) & 0x0f)); | ||
411 | } | ||
412 | /* Latch in address */ | ||
413 | this->hwcontrol(mtd, NAND_CTL_CLRALE); | ||
414 | } | ||
415 | |||
416 | /* | ||
417 | * Program and erase have their own busy handlers. | ||
418 | * Status and sequential in need no delay. | ||
419 | */ | ||
420 | switch (command) { | ||
421 | |||
422 | case NAND_CMD_PAGEPROG: | ||
423 | case NAND_CMD_ERASE1: | ||
424 | case NAND_CMD_ERASE2: | ||
425 | case NAND_CMD_SEQIN: | ||
426 | case NAND_CMD_STATUS: | ||
427 | return; | ||
428 | |||
429 | case NAND_CMD_RESET: | ||
430 | break; | ||
431 | |||
432 | case NAND_CMD_READ0: | ||
433 | case NAND_CMD_READ1: | ||
434 | case NAND_CMD_READOOB: | ||
435 | /* Check if we're really driving -CE low (just in case) */ | ||
436 | if (unlikely(!ce_override)) | ||
437 | break; | ||
438 | |||
439 | /* Apply a short delay always to ensure that we do wait tWB. */ | ||
440 | ndelay(100); | ||
441 | /* Wait for a chip to become ready... */ | ||
442 | for (i = this->chip_delay; !this->dev_ready(mtd) && i > 0; --i) | ||
443 | udelay(1); | ||
444 | |||
445 | /* Release -CE and re-enable interrupts. */ | ||
446 | this->hwcontrol(mtd, NAND_CTL_CLRNCE); | ||
447 | local_irq_restore(flags); | ||
448 | return; | ||
449 | } | ||
450 | /* Apply this short delay always to ensure that we do wait tWB. */ | ||
451 | ndelay(100); | ||
452 | |||
453 | while(!this->dev_ready(mtd)); | ||
454 | } | ||
455 | |||
456 | |||
315 | /* | 457 | /* |
316 | * Main initialization routine | 458 | * Main initialization routine |
317 | */ | 459 | */ |
318 | int __init au1xxx_nand_init (void) | 460 | static int __init au1xxx_nand_init(void) |
319 | { | 461 | { |
320 | struct nand_chip *this; | 462 | struct nand_chip *this; |
321 | u16 boot_swapboot = 0; /* default value */ | 463 | u16 boot_swapboot = 0; /* default value */ |
322 | int retval; | 464 | int retval; |
323 | u32 mem_staddr; | 465 | u32 mem_staddr; |
324 | u32 nand_phys; | 466 | u32 nand_phys; |
325 | 467 | ||
326 | /* Allocate memory for MTD device structure and private data */ | 468 | /* Allocate memory for MTD device structure and private data */ |
327 | au1550_mtd = kmalloc (sizeof(struct mtd_info) + | 469 | au1550_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
328 | sizeof (struct nand_chip), GFP_KERNEL); | ||
329 | if (!au1550_mtd) { | 470 | if (!au1550_mtd) { |
330 | printk ("Unable to allocate NAND MTD dev structure.\n"); | 471 | printk("Unable to allocate NAND MTD dev structure.\n"); |
331 | return -ENOMEM; | 472 | return -ENOMEM; |
332 | } | 473 | } |
333 | 474 | ||
334 | /* Get pointer to private data */ | 475 | /* Get pointer to private data */ |
335 | this = (struct nand_chip *) (&au1550_mtd[1]); | 476 | this = (struct nand_chip *)(&au1550_mtd[1]); |
336 | 477 | ||
337 | /* Initialize structures */ | 478 | /* Initialize structures */ |
338 | memset((char *) au1550_mtd, 0, sizeof(struct mtd_info)); | 479 | memset(au1550_mtd, 0, sizeof(struct mtd_info)); |
339 | memset((char *) this, 0, sizeof(struct nand_chip)); | 480 | memset(this, 0, sizeof(struct nand_chip)); |
340 | 481 | ||
341 | /* Link the private data with the MTD structure */ | 482 | /* Link the private data with the MTD structure */ |
342 | au1550_mtd->priv = this; | 483 | au1550_mtd->priv = this; |
484 | au1550_mtd->owner = THIS_MODULE; | ||
343 | 485 | ||
344 | 486 | ||
345 | /* disable interrupts */ | 487 | /* MEM_STNDCTL: disable ints, disable nand boot */ |
346 | au_writel(au_readl(MEM_STNDCTL) & ~(1<<8), MEM_STNDCTL); | 488 | au_writel(0, MEM_STNDCTL); |
347 | |||
348 | /* disable NAND boot */ | ||
349 | au_writel(au_readl(MEM_STNDCTL) & ~(1<<0), MEM_STNDCTL); | ||
350 | 489 | ||
351 | #ifdef CONFIG_MIPS_PB1550 | 490 | #ifdef CONFIG_MIPS_PB1550 |
352 | /* set gpio206 high */ | 491 | /* set gpio206 high */ |
353 | au_writel(au_readl(GPIO2_DIR) & ~(1<<6), GPIO2_DIR); | 492 | au_writel(au_readl(GPIO2_DIR) & ~(1 << 6), GPIO2_DIR); |
354 | 493 | ||
355 | boot_swapboot = (au_readl(MEM_STSTAT) & (0x7<<1)) | | 494 | boot_swapboot = (au_readl(MEM_STSTAT) & (0x7 << 1)) | ((bcsr->status >> 6) & 0x1); |
356 | ((bcsr->status >> 6) & 0x1); | ||
357 | switch (boot_swapboot) { | 495 | switch (boot_swapboot) { |
358 | case 0: | 496 | case 0: |
359 | case 2: | 497 | case 2: |
360 | case 8: | 498 | case 8: |
361 | case 0xC: | 499 | case 0xC: |
362 | case 0xD: | 500 | case 0xD: |
363 | /* x16 NAND Flash */ | 501 | /* x16 NAND Flash */ |
364 | nand_width = 0; | 502 | nand_width = 0; |
365 | break; | 503 | break; |
366 | case 1: | 504 | case 1: |
367 | case 9: | 505 | case 9: |
368 | case 3: | 506 | case 3: |
369 | case 0xE: | 507 | case 0xE: |
370 | case 0xF: | 508 | case 0xF: |
371 | /* x8 NAND Flash */ | 509 | /* x8 NAND Flash */ |
372 | nand_width = 1; | 510 | nand_width = 1; |
373 | break; | 511 | break; |
374 | default: | 512 | default: |
375 | printk("Pb1550 NAND: bad boot:swap\n"); | 513 | printk("Pb1550 NAND: bad boot:swap\n"); |
376 | retval = -EINVAL; | 514 | retval = -EINVAL; |
377 | goto outmem; | 515 | goto outmem; |
378 | } | 516 | } |
379 | #endif | 517 | #endif |
380 | 518 | ||
@@ -424,18 +562,20 @@ int __init au1xxx_nand_init (void) | |||
424 | 562 | ||
425 | /* make controller and MTD agree */ | 563 | /* make controller and MTD agree */ |
426 | if (NAND_CS == 0) | 564 | if (NAND_CS == 0) |
427 | nand_width = au_readl(MEM_STCFG0) & (1<<22); | 565 | nand_width = au_readl(MEM_STCFG0) & (1 << 22); |
428 | if (NAND_CS == 1) | 566 | if (NAND_CS == 1) |
429 | nand_width = au_readl(MEM_STCFG1) & (1<<22); | 567 | nand_width = au_readl(MEM_STCFG1) & (1 << 22); |
430 | if (NAND_CS == 2) | 568 | if (NAND_CS == 2) |
431 | nand_width = au_readl(MEM_STCFG2) & (1<<22); | 569 | nand_width = au_readl(MEM_STCFG2) & (1 << 22); |
432 | if (NAND_CS == 3) | 570 | if (NAND_CS == 3) |
433 | nand_width = au_readl(MEM_STCFG3) & (1<<22); | 571 | nand_width = au_readl(MEM_STCFG3) & (1 << 22); |
434 | |||
435 | 572 | ||
436 | /* Set address of hardware control function */ | 573 | /* Set address of hardware control function */ |
437 | this->hwcontrol = au1550_hwcontrol; | 574 | this->hwcontrol = au1550_hwcontrol; |
438 | this->dev_ready = au1550_device_ready; | 575 | this->dev_ready = au1550_device_ready; |
576 | this->select_chip = au1550_select_chip; | ||
577 | this->cmdfunc = au1550_command; | ||
578 | |||
439 | /* 30 us command delay time */ | 579 | /* 30 us command delay time */ |
440 | this->chip_delay = 30; | 580 | this->chip_delay = 30; |
441 | this->eccmode = NAND_ECC_SOFT; | 581 | this->eccmode = NAND_ECC_SOFT; |
@@ -454,7 +594,7 @@ int __init au1xxx_nand_init (void) | |||
454 | this->verify_buf = (!nand_width) ? au_verify_buf16 : au_verify_buf; | 594 | this->verify_buf = (!nand_width) ? au_verify_buf16 : au_verify_buf; |
455 | 595 | ||
456 | /* Scan to find existence of the device */ | 596 | /* Scan to find existence of the device */ |
457 | if (nand_scan (au1550_mtd, 1)) { | 597 | if (nand_scan(au1550_mtd, 1)) { |
458 | retval = -ENXIO; | 598 | retval = -ENXIO; |
459 | goto outio; | 599 | goto outio; |
460 | } | 600 | } |
@@ -465,10 +605,10 @@ int __init au1xxx_nand_init (void) | |||
465 | return 0; | 605 | return 0; |
466 | 606 | ||
467 | outio: | 607 | outio: |
468 | iounmap ((void *)p_nand); | 608 | iounmap((void *)p_nand); |
469 | 609 | ||
470 | outmem: | 610 | outmem: |
471 | kfree (au1550_mtd); | 611 | kfree(au1550_mtd); |
472 | return retval; | 612 | return retval; |
473 | } | 613 | } |
474 | 614 | ||
@@ -477,22 +617,21 @@ module_init(au1xxx_nand_init); | |||
477 | /* | 617 | /* |
478 | * Clean up routine | 618 | * Clean up routine |
479 | */ | 619 | */ |
480 | #ifdef MODULE | 620 | static void __exit au1550_cleanup(void) |
481 | static void __exit au1550_cleanup (void) | ||
482 | { | 621 | { |
483 | struct nand_chip *this = (struct nand_chip *) &au1550_mtd[1]; | 622 | struct nand_chip *this = (struct nand_chip *)&au1550_mtd[1]; |
484 | 623 | ||
485 | /* Release resources, unregister device */ | 624 | /* Release resources, unregister device */ |
486 | nand_release (au1550_mtd); | 625 | nand_release(au1550_mtd); |
487 | 626 | ||
488 | /* Free the MTD device structure */ | 627 | /* Free the MTD device structure */ |
489 | kfree (au1550_mtd); | 628 | kfree(au1550_mtd); |
490 | 629 | ||
491 | /* Unmap */ | 630 | /* Unmap */ |
492 | iounmap ((void *)p_nand); | 631 | iounmap((void *)p_nand); |
493 | } | 632 | } |
633 | |||
494 | module_exit(au1550_cleanup); | 634 | module_exit(au1550_cleanup); |
495 | #endif | ||
496 | 635 | ||
497 | MODULE_LICENSE("GPL"); | 636 | MODULE_LICENSE("GPL"); |
498 | MODULE_AUTHOR("Embedded Edge, LLC"); | 637 | MODULE_AUTHOR("Embedded Edge, LLC"); |
diff --git a/drivers/mtd/nand/autcpu12.c b/drivers/mtd/nand/autcpu12.c index a3c7fea404d0..43b296040d7f 100644 --- a/drivers/mtd/nand/autcpu12.c +++ b/drivers/mtd/nand/autcpu12.c | |||
@@ -47,7 +47,7 @@ static int autcpu12_io_base = CS89712_VIRT_BASE; | |||
47 | static int autcpu12_fio_pbase = AUTCPU12_PHYS_SMC; | 47 | static int autcpu12_fio_pbase = AUTCPU12_PHYS_SMC; |
48 | static int autcpu12_fio_ctrl = AUTCPU12_SMC_SELECT_OFFSET; | 48 | static int autcpu12_fio_ctrl = AUTCPU12_SMC_SELECT_OFFSET; |
49 | static int autcpu12_pedr = AUTCPU12_SMC_PORT_OFFSET; | 49 | static int autcpu12_pedr = AUTCPU12_SMC_PORT_OFFSET; |
50 | static void __iomem * autcpu12_fio_base; | 50 | static void __iomem *autcpu12_fio_base; |
51 | 51 | ||
52 | /* | 52 | /* |
53 | * Define partitions for flash devices | 53 | * Define partitions for flash devices |
@@ -95,10 +95,10 @@ static struct mtd_partition partition_info128k[] = { | |||
95 | /* | 95 | /* |
96 | * hardware specific access to control-lines | 96 | * hardware specific access to control-lines |
97 | */ | 97 | */ |
98 | |||
98 | static void autcpu12_hwcontrol(struct mtd_info *mtd, int cmd) | 99 | static void autcpu12_hwcontrol(struct mtd_info *mtd, int cmd) |
99 | { | 100 | { |
100 | 101 | switch (cmd) { | |
101 | switch(cmd){ | ||
102 | 102 | ||
103 | case NAND_CTL_SETCLE: (*(volatile unsigned char *) (autcpu12_io_base + autcpu12_pedr)) |= AUTCPU12_SMC_CLE; break; | 103 | case NAND_CTL_SETCLE: (*(volatile unsigned char *) (autcpu12_io_base + autcpu12_pedr)) |= AUTCPU12_SMC_CLE; break; |
104 | case NAND_CTL_CLRCLE: (*(volatile unsigned char *) (autcpu12_io_base + autcpu12_pedr)) &= ~AUTCPU12_SMC_CLE; break; | 104 | case NAND_CTL_CLRCLE: (*(volatile unsigned char *) (autcpu12_io_base + autcpu12_pedr)) &= ~AUTCPU12_SMC_CLE; break; |
@@ -117,44 +117,44 @@ static void autcpu12_hwcontrol(struct mtd_info *mtd, int cmd) | |||
117 | int autcpu12_device_ready(struct mtd_info *mtd) | 117 | int autcpu12_device_ready(struct mtd_info *mtd) |
118 | { | 118 | { |
119 | 119 | ||
120 | return ( (*(volatile unsigned char *) (autcpu12_io_base + autcpu12_pedr)) & AUTCPU12_SMC_RDY) ? 1 : 0; | 120 | return ((*(volatile unsigned char *)(autcpu12_io_base + autcpu12_pedr)) & AUTCPU12_SMC_RDY) ? 1 : 0; |
121 | 121 | ||
122 | } | 122 | } |
123 | 123 | ||
124 | /* | 124 | /* |
125 | * Main initialization routine | 125 | * Main initialization routine |
126 | */ | 126 | */ |
127 | int __init autcpu12_init (void) | 127 | static int __init autcpu12_init(void) |
128 | { | 128 | { |
129 | struct nand_chip *this; | 129 | struct nand_chip *this; |
130 | int err = 0; | 130 | int err = 0; |
131 | 131 | ||
132 | /* Allocate memory for MTD device structure and private data */ | 132 | /* Allocate memory for MTD device structure and private data */ |
133 | autcpu12_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), | 133 | autcpu12_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
134 | GFP_KERNEL); | ||
135 | if (!autcpu12_mtd) { | 134 | if (!autcpu12_mtd) { |
136 | printk ("Unable to allocate AUTCPU12 NAND MTD device structure.\n"); | 135 | printk("Unable to allocate AUTCPU12 NAND MTD device structure.\n"); |
137 | err = -ENOMEM; | 136 | err = -ENOMEM; |
138 | goto out; | 137 | goto out; |
139 | } | 138 | } |
140 | 139 | ||
141 | /* map physical adress */ | 140 | /* map physical adress */ |
142 | autcpu12_fio_base = ioremap(autcpu12_fio_pbase,SZ_1K); | 141 | autcpu12_fio_base = ioremap(autcpu12_fio_pbase, SZ_1K); |
143 | if(!autcpu12_fio_base){ | 142 | if (!autcpu12_fio_base) { |
144 | printk("Ioremap autcpu12 SmartMedia Card failed\n"); | 143 | printk("Ioremap autcpu12 SmartMedia Card failed\n"); |
145 | err = -EIO; | 144 | err = -EIO; |
146 | goto out_mtd; | 145 | goto out_mtd; |
147 | } | 146 | } |
148 | 147 | ||
149 | /* Get pointer to private data */ | 148 | /* Get pointer to private data */ |
150 | this = (struct nand_chip *) (&autcpu12_mtd[1]); | 149 | this = (struct nand_chip *)(&autcpu12_mtd[1]); |
151 | 150 | ||
152 | /* Initialize structures */ | 151 | /* Initialize structures */ |
153 | memset((char *) autcpu12_mtd, 0, sizeof(struct mtd_info)); | 152 | memset(autcpu12_mtd, 0, sizeof(struct mtd_info)); |
154 | memset((char *) this, 0, sizeof(struct nand_chip)); | 153 | memset(this, 0, sizeof(struct nand_chip)); |
155 | 154 | ||
156 | /* Link the private data with the MTD structure */ | 155 | /* Link the private data with the MTD structure */ |
157 | autcpu12_mtd->priv = this; | 156 | autcpu12_mtd->priv = this; |
157 | autcpu12_mtd->owner = THIS_MODULE; | ||
158 | 158 | ||
159 | /* Set address of NAND IO lines */ | 159 | /* Set address of NAND IO lines */ |
160 | this->IO_ADDR_R = autcpu12_fio_base; | 160 | this->IO_ADDR_R = autcpu12_fio_base; |
@@ -167,35 +167,34 @@ int __init autcpu12_init (void) | |||
167 | 167 | ||
168 | /* Enable the following for a flash based bad block table */ | 168 | /* Enable the following for a flash based bad block table */ |
169 | /* | 169 | /* |
170 | this->options = NAND_USE_FLASH_BBT; | 170 | this->options = NAND_USE_FLASH_BBT; |
171 | */ | 171 | */ |
172 | this->options = NAND_USE_FLASH_BBT; | 172 | this->options = NAND_USE_FLASH_BBT; |
173 | 173 | ||
174 | /* Scan to find existance of the device */ | 174 | /* Scan to find existance of the device */ |
175 | if (nand_scan (autcpu12_mtd, 1)) { | 175 | if (nand_scan(autcpu12_mtd, 1)) { |
176 | err = -ENXIO; | 176 | err = -ENXIO; |
177 | goto out_ior; | 177 | goto out_ior; |
178 | } | 178 | } |
179 | 179 | ||
180 | /* Register the partitions */ | 180 | /* Register the partitions */ |
181 | switch(autcpu12_mtd->size){ | 181 | switch (autcpu12_mtd->size) { |
182 | case SZ_16M: add_mtd_partitions(autcpu12_mtd, partition_info16k, NUM_PARTITIONS16K); break; | 182 | case SZ_16M: add_mtd_partitions(autcpu12_mtd, partition_info16k, NUM_PARTITIONS16K); break; |
183 | case SZ_32M: add_mtd_partitions(autcpu12_mtd, partition_info32k, NUM_PARTITIONS32K); break; | 183 | case SZ_32M: add_mtd_partitions(autcpu12_mtd, partition_info32k, NUM_PARTITIONS32K); break; |
184 | case SZ_64M: add_mtd_partitions(autcpu12_mtd, partition_info64k, NUM_PARTITIONS64K); break; | 184 | case SZ_64M: add_mtd_partitions(autcpu12_mtd, partition_info64k, NUM_PARTITIONS64K); break; |
185 | case SZ_128M: add_mtd_partitions(autcpu12_mtd, partition_info128k, NUM_PARTITIONS128K); break; | 185 | case SZ_128M: add_mtd_partitions(autcpu12_mtd, partition_info128k, NUM_PARTITIONS128K); break; |
186 | default: { | 186 | default: |
187 | printk ("Unsupported SmartMedia device\n"); | 187 | printk("Unsupported SmartMedia device\n"); |
188 | err = -ENXIO; | 188 | err = -ENXIO; |
189 | goto out_ior; | 189 | goto out_ior; |
190 | } | ||
191 | } | 190 | } |
192 | goto out; | 191 | goto out; |
193 | 192 | ||
194 | out_ior: | 193 | out_ior: |
195 | iounmap((void *)autcpu12_fio_base); | 194 | iounmap((void *)autcpu12_fio_base); |
196 | out_mtd: | 195 | out_mtd: |
197 | kfree (autcpu12_mtd); | 196 | kfree(autcpu12_mtd); |
198 | out: | 197 | out: |
199 | return err; | 198 | return err; |
200 | } | 199 | } |
201 | 200 | ||
@@ -204,20 +203,19 @@ module_init(autcpu12_init); | |||
204 | /* | 203 | /* |
205 | * Clean up routine | 204 | * Clean up routine |
206 | */ | 205 | */ |
207 | #ifdef MODULE | 206 | static void __exit autcpu12_cleanup(void) |
208 | static void __exit autcpu12_cleanup (void) | ||
209 | { | 207 | { |
210 | /* Release resources, unregister device */ | 208 | /* Release resources, unregister device */ |
211 | nand_release (autcpu12_mtd); | 209 | nand_release(autcpu12_mtd); |
212 | 210 | ||
213 | /* unmap physical adress */ | 211 | /* unmap physical adress */ |
214 | iounmap((void *)autcpu12_fio_base); | 212 | iounmap((void *)autcpu12_fio_base); |
215 | 213 | ||
216 | /* Free the MTD device structure */ | 214 | /* Free the MTD device structure */ |
217 | kfree (autcpu12_mtd); | 215 | kfree(autcpu12_mtd); |
218 | } | 216 | } |
217 | |||
219 | module_exit(autcpu12_cleanup); | 218 | module_exit(autcpu12_cleanup); |
220 | #endif | ||
221 | 219 | ||
222 | MODULE_LICENSE("GPL"); | 220 | MODULE_LICENSE("GPL"); |
223 | MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>"); | 221 | MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>"); |
diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c index 91207a45ad55..bf251253ea1f 100644 --- a/drivers/mtd/nand/cs553x_nand.c +++ b/drivers/mtd/nand/cs553x_nand.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * (C) 2005, 2006 Red Hat Inc. | 4 | * (C) 2005, 2006 Red Hat Inc. |
5 | * | 5 | * |
6 | * Author: David Woodhouse <dwmw2@infradead.org> | 6 | * Author: David Woodhouse <dwmw2@infradead.org> |
7 | * Tom Sylla <tom.sylla@amd.com> | ||
7 | * | 8 | * |
8 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License version 2 as | 10 | * it under the terms of the GNU General Public License version 2 as |
@@ -22,6 +23,7 @@ | |||
22 | #include <linux/pci.h> | 23 | #include <linux/pci.h> |
23 | #include <linux/mtd/mtd.h> | 24 | #include <linux/mtd/mtd.h> |
24 | #include <linux/mtd/nand.h> | 25 | #include <linux/mtd/nand.h> |
26 | #include <linux/mtd/nand_ecc.h> | ||
25 | #include <linux/mtd/partitions.h> | 27 | #include <linux/mtd/partitions.h> |
26 | 28 | ||
27 | #include <asm/msr.h> | 29 | #include <asm/msr.h> |
@@ -48,7 +50,7 @@ | |||
48 | 50 | ||
49 | /* Pin function selection MSR (IDE vs. flash on the IDE pins) */ | 51 | /* Pin function selection MSR (IDE vs. flash on the IDE pins) */ |
50 | #define MSR_DIVIL_BALL_OPTS 0x51400015 | 52 | #define MSR_DIVIL_BALL_OPTS 0x51400015 |
51 | #define PIN_OPT_IDE (1<<0) /* 0 for flash, 1 for IDE */ | 53 | #define PIN_OPT_IDE (1<<0) /* 0 for flash, 1 for IDE */ |
52 | 54 | ||
53 | /* Registers within the NAND flash controller BAR -- memory mapped */ | 55 | /* Registers within the NAND flash controller BAR -- memory mapped */ |
54 | #define MM_NAND_DATA 0x00 /* 0 to 0x7ff, in fact */ | 56 | #define MM_NAND_DATA 0x00 /* 0 to 0x7ff, in fact */ |
@@ -87,11 +89,34 @@ | |||
87 | #define CS_NAND_ECC_CLRECC (1<<1) | 89 | #define CS_NAND_ECC_CLRECC (1<<1) |
88 | #define CS_NAND_ECC_ENECC (1<<0) | 90 | #define CS_NAND_ECC_ENECC (1<<0) |
89 | 91 | ||
92 | static void cs553x_read_buf(struct mtd_info *mtd, u_char *buf, int len) | ||
93 | { | ||
94 | struct nand_chip *this = mtd->priv; | ||
95 | |||
96 | while (unlikely(len > 0x800)) { | ||
97 | memcpy_fromio(buf, this->IO_ADDR_R, 0x800); | ||
98 | buf += 0x800; | ||
99 | len -= 0x800; | ||
100 | } | ||
101 | memcpy_fromio(buf, this->IO_ADDR_R, len); | ||
102 | } | ||
103 | |||
104 | static void cs553x_write_buf(struct mtd_info *mtd, const u_char *buf, int len) | ||
105 | { | ||
106 | struct nand_chip *this = mtd->priv; | ||
107 | |||
108 | while (unlikely(len > 0x800)) { | ||
109 | memcpy_toio(this->IO_ADDR_R, buf, 0x800); | ||
110 | buf += 0x800; | ||
111 | len -= 0x800; | ||
112 | } | ||
113 | memcpy_toio(this->IO_ADDR_R, buf, len); | ||
114 | } | ||
115 | |||
90 | static unsigned char cs553x_read_byte(struct mtd_info *mtd) | 116 | static unsigned char cs553x_read_byte(struct mtd_info *mtd) |
91 | { | 117 | { |
92 | struct nand_chip *this = mtd->priv; | 118 | struct nand_chip *this = mtd->priv; |
93 | unsigned char foo = readb(this->IO_ADDR_R); | 119 | return readb(this->IO_ADDR_R); |
94 | return foo; | ||
95 | } | 120 | } |
96 | 121 | ||
97 | static void cs553x_write_byte(struct mtd_info *mtd, u_char byte) | 122 | static void cs553x_write_byte(struct mtd_info *mtd, u_char byte) |
@@ -103,52 +128,67 @@ static void cs553x_write_byte(struct mtd_info *mtd, u_char byte) | |||
103 | udelay(1); | 128 | udelay(1); |
104 | i--; | 129 | i--; |
105 | } | 130 | } |
106 | writeb(byte, this->IO_ADDR_W+0x801); | 131 | writeb(byte, this->IO_ADDR_W + 0x801); |
107 | } | 132 | } |
108 | 133 | ||
109 | static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd) | 134 | static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd) |
110 | { | 135 | { |
111 | struct nand_chip *this = mtd->priv; | 136 | struct nand_chip *this = mtd->priv; |
112 | void __iomem *mmio_base = this->IO_ADDR_R; | 137 | void __iomem *mmio_base = this->IO_ADDR_R; |
138 | unsigned char ctl; | ||
113 | 139 | ||
114 | uint8_t old = readb(mmio_base + MM_NAND_CTL); | 140 | switch (cmd) { |
115 | |||
116 | switch(cmd) { | ||
117 | case NAND_CTL_SETCLE: | 141 | case NAND_CTL_SETCLE: |
118 | old |= CS_NAND_CTL_CLE; | 142 | ctl = CS_NAND_CTL_CLE; |
119 | break; | 143 | break; |
120 | 144 | ||
121 | case NAND_CTL_CLRCLE: | 145 | case NAND_CTL_CLRCLE: |
122 | old &= ~CS_NAND_CTL_CLE; | ||
123 | break; | ||
124 | |||
125 | case NAND_CTL_SETALE: | ||
126 | old |= CS_NAND_CTL_ALE; | ||
127 | break; | ||
128 | |||
129 | case NAND_CTL_CLRALE: | 146 | case NAND_CTL_CLRALE: |
130 | old &= ~CS_NAND_CTL_ALE; | 147 | case NAND_CTL_SETNCE: |
148 | ctl = 0; | ||
131 | break; | 149 | break; |
132 | 150 | ||
133 | case NAND_CTL_SETNCE: | 151 | case NAND_CTL_SETALE: |
134 | old &= ~CS_NAND_CTL_CE; | 152 | ctl = CS_NAND_CTL_ALE; |
135 | break; | 153 | break; |
136 | 154 | ||
155 | default: | ||
137 | case NAND_CTL_CLRNCE: | 156 | case NAND_CTL_CLRNCE: |
138 | old |= CS_NAND_CTL_CE; | 157 | ctl = CS_NAND_CTL_CE; |
139 | break; | 158 | break; |
140 | } | 159 | } |
141 | writeb(old, mmio_base + MM_NAND_CTL); | 160 | writeb(ctl, mmio_base + MM_NAND_CTL); |
142 | } | 161 | } |
143 | 162 | ||
144 | |||
145 | static int cs553x_device_ready(struct mtd_info *mtd) | 163 | static int cs553x_device_ready(struct mtd_info *mtd) |
146 | { | 164 | { |
147 | struct nand_chip *this = mtd->priv; | 165 | struct nand_chip *this = mtd->priv; |
148 | void __iomem *mmio_base = this->IO_ADDR_R; | 166 | void __iomem *mmio_base = this->IO_ADDR_R; |
149 | unsigned char foo = readb(mmio_base + MM_NAND_STS); | 167 | unsigned char foo = readb(mmio_base + MM_NAND_STS); |
150 | 168 | ||
151 | return (foo & CS_NAND_STS_FLASH_RDY) && !(foo & CS_NAND_CTLR_BUSY); | 169 | return (foo & CS_NAND_STS_FLASH_RDY) && !(foo & CS_NAND_CTLR_BUSY); |
170 | } | ||
171 | |||
172 | static void cs_enable_hwecc(struct mtd_info *mtd, int mode) | ||
173 | { | ||
174 | struct nand_chip *this = mtd->priv; | ||
175 | void __iomem *mmio_base = this->IO_ADDR_R; | ||
176 | |||
177 | writeb(0x07, mmio_base + MM_NAND_ECC_CTL); | ||
178 | } | ||
179 | |||
180 | static int cs_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) | ||
181 | { | ||
182 | uint32_t ecc; | ||
183 | struct nand_chip *this = mtd->priv; | ||
184 | void __iomem *mmio_base = this->IO_ADDR_R; | ||
185 | |||
186 | ecc = readl(mmio_base + MM_NAND_STS); | ||
187 | |||
188 | ecc_code[1] = ecc >> 8; | ||
189 | ecc_code[0] = ecc >> 16; | ||
190 | ecc_code[2] = ecc >> 24; | ||
191 | return 0; | ||
152 | } | 192 | } |
153 | 193 | ||
154 | static struct mtd_info *cs553x_mtd[4]; | 194 | static struct mtd_info *cs553x_mtd[4]; |
@@ -167,7 +207,7 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) | |||
167 | } | 207 | } |
168 | 208 | ||
169 | /* Allocate memory for MTD device structure and private data */ | 209 | /* Allocate memory for MTD device structure and private data */ |
170 | new_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), GFP_KERNEL); | 210 | new_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
171 | if (!new_mtd) { | 211 | if (!new_mtd) { |
172 | printk(KERN_WARNING "Unable to allocate CS553X NAND MTD device structure.\n"); | 212 | printk(KERN_WARNING "Unable to allocate CS553X NAND MTD device structure.\n"); |
173 | err = -ENOMEM; | 213 | err = -ENOMEM; |
@@ -175,14 +215,15 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) | |||
175 | } | 215 | } |
176 | 216 | ||
177 | /* Get pointer to private data */ | 217 | /* Get pointer to private data */ |
178 | this = (struct nand_chip *) (&new_mtd[1]); | 218 | this = (struct nand_chip *)(&new_mtd[1]); |
179 | 219 | ||
180 | /* Initialize structures */ | 220 | /* Initialize structures */ |
181 | memset((char *) new_mtd, 0, sizeof(struct mtd_info)); | 221 | memset(new_mtd, 0, sizeof(struct mtd_info)); |
182 | memset((char *) this, 0, sizeof(struct nand_chip)); | 222 | memset(this, 0, sizeof(struct nand_chip)); |
183 | 223 | ||
184 | /* Link the private data with the MTD structure */ | 224 | /* Link the private data with the MTD structure */ |
185 | new_mtd->priv = this; | 225 | new_mtd->priv = this; |
226 | new_mtd->owner = THIS_MODULE; | ||
186 | 227 | ||
187 | /* map physical address */ | 228 | /* map physical address */ |
188 | this->IO_ADDR_R = this->IO_ADDR_W = ioremap(adr, 4096); | 229 | this->IO_ADDR_R = this->IO_ADDR_W = ioremap(adr, 4096); |
@@ -196,16 +237,21 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) | |||
196 | this->dev_ready = cs553x_device_ready; | 237 | this->dev_ready = cs553x_device_ready; |
197 | this->read_byte = cs553x_read_byte; | 238 | this->read_byte = cs553x_read_byte; |
198 | this->write_byte = cs553x_write_byte; | 239 | this->write_byte = cs553x_write_byte; |
240 | this->read_buf = cs553x_read_buf; | ||
241 | this->write_buf = cs553x_write_buf; | ||
199 | 242 | ||
200 | /* 20 us command delay time */ | 243 | this->chip_delay = 0; |
201 | this->chip_delay = 20; | ||
202 | this->eccmode = NAND_ECC_SOFT; | ||
203 | 244 | ||
245 | this->eccmode = NAND_ECC_HW3_256; | ||
246 | this->enable_hwecc = cs_enable_hwecc; | ||
247 | this->calculate_ecc = cs_calculate_ecc; | ||
248 | this->correct_data = nand_correct_data; | ||
249 | |||
204 | /* Enable the following for a flash based bad block table */ | 250 | /* Enable the following for a flash based bad block table */ |
205 | // this->options = NAND_USE_FLASH_BBT; | 251 | this->options = NAND_USE_FLASH_BBT | NAND_NO_AUTOINCR; |
206 | 252 | ||
207 | /* Scan to find existance of the device */ | 253 | /* Scan to find existance of the device */ |
208 | if (nand_scan (new_mtd, 1)) { | 254 | if (nand_scan(new_mtd, 1)) { |
209 | err = -ENXIO; | 255 | err = -ENXIO; |
210 | goto out_ior; | 256 | goto out_ior; |
211 | } | 257 | } |
@@ -216,12 +262,12 @@ static int __init cs553x_init_one(int cs, int mmio, unsigned long adr) | |||
216 | out_ior: | 262 | out_ior: |
217 | iounmap((void *)this->IO_ADDR_R); | 263 | iounmap((void *)this->IO_ADDR_R); |
218 | out_mtd: | 264 | out_mtd: |
219 | kfree (new_mtd); | 265 | kfree(new_mtd); |
220 | out: | 266 | out: |
221 | return err; | 267 | return err; |
222 | } | 268 | } |
223 | 269 | ||
224 | int __init cs553x_init(void) | 270 | static int __init cs553x_init(void) |
225 | { | 271 | { |
226 | int err = -ENXIO; | 272 | int err = -ENXIO; |
227 | int i; | 273 | int i; |
@@ -238,16 +284,16 @@ int __init cs553x_init(void) | |||
238 | return -ENXIO; | 284 | return -ENXIO; |
239 | } | 285 | } |
240 | 286 | ||
241 | for (i=0; i<NR_CS553X_CONTROLLERS; i++) { | 287 | for (i = 0; i < NR_CS553X_CONTROLLERS; i++) { |
242 | rdmsrl(MSR_DIVIL_LBAR_FLSH0+i, val); | 288 | rdmsrl(MSR_DIVIL_LBAR_FLSH0 + i, val); |
243 | 289 | ||
244 | if ((val & (FLSH_LBAR_EN|FLSH_NOR_NAND)) == (FLSH_LBAR_EN|FLSH_NOR_NAND)) | 290 | if ((val & (FLSH_LBAR_EN|FLSH_NOR_NAND)) == (FLSH_LBAR_EN|FLSH_NOR_NAND)) |
245 | err = cs553x_init_one(i, !!(val & FLSH_MEM_IO), val & 0xFFFFFFFF); | 291 | err = cs553x_init_one(i, !!(val & FLSH_MEM_IO), val & 0xFFFFFFFF); |
246 | } | 292 | } |
247 | 293 | ||
248 | /* Register all devices together here. This means we can easily hack it to | 294 | /* Register all devices together here. This means we can easily hack it to |
249 | do mtdconcat etc. if we want to. */ | 295 | do mtdconcat etc. if we want to. */ |
250 | for (i=0; i<NR_CS553X_CONTROLLERS; i++) { | 296 | for (i = 0; i < NR_CS553X_CONTROLLERS; i++) { |
251 | if (cs553x_mtd[i]) { | 297 | if (cs553x_mtd[i]) { |
252 | add_mtd_device(cs553x_mtd[i]); | 298 | add_mtd_device(cs553x_mtd[i]); |
253 | 299 | ||
@@ -258,13 +304,14 @@ int __init cs553x_init(void) | |||
258 | 304 | ||
259 | return err; | 305 | return err; |
260 | } | 306 | } |
307 | |||
261 | module_init(cs553x_init); | 308 | module_init(cs553x_init); |
262 | 309 | ||
263 | static void __exit cs553x_cleanup (void) | 310 | static void __exit cs553x_cleanup(void) |
264 | { | 311 | { |
265 | int i; | 312 | int i; |
266 | 313 | ||
267 | for (i=0; i<NR_CS553X_CONTROLLERS; i++) { | 314 | for (i = 0; i < NR_CS553X_CONTROLLERS; i++) { |
268 | struct mtd_info *mtd = cs553x_mtd[i]; | 315 | struct mtd_info *mtd = cs553x_mtd[i]; |
269 | struct nand_chip *this; | 316 | struct nand_chip *this; |
270 | void __iomem *mmio_base; | 317 | void __iomem *mmio_base; |
@@ -276,16 +323,17 @@ static void __exit cs553x_cleanup (void) | |||
276 | mmio_base = this->IO_ADDR_R; | 323 | mmio_base = this->IO_ADDR_R; |
277 | 324 | ||
278 | /* Release resources, unregister device */ | 325 | /* Release resources, unregister device */ |
279 | nand_release (cs553x_mtd[i]); | 326 | nand_release(cs553x_mtd[i]); |
280 | cs553x_mtd[i] = NULL; | 327 | cs553x_mtd[i] = NULL; |
281 | 328 | ||
282 | /* unmap physical adress */ | 329 | /* unmap physical adress */ |
283 | iounmap(mmio_base); | 330 | iounmap(mmio_base); |
284 | 331 | ||
285 | /* Free the MTD device structure */ | 332 | /* Free the MTD device structure */ |
286 | kfree (mtd); | 333 | kfree(mtd); |
287 | } | 334 | } |
288 | } | 335 | } |
336 | |||
289 | module_exit(cs553x_cleanup); | 337 | module_exit(cs553x_cleanup); |
290 | 338 | ||
291 | MODULE_LICENSE("GPL"); | 339 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index ec5e45e4e4ef..a2391c66a63f 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c | |||
@@ -58,10 +58,10 @@ static unsigned long __initdata doc_locations[] = { | |||
58 | 0xe4000000, | 58 | 0xe4000000, |
59 | #elif defined(CONFIG_MOMENCO_OCELOT) | 59 | #elif defined(CONFIG_MOMENCO_OCELOT) |
60 | 0x2f000000, | 60 | 0x2f000000, |
61 | 0xff000000, | 61 | 0xff000000, |
62 | #elif defined(CONFIG_MOMENCO_OCELOT_G) || defined (CONFIG_MOMENCO_OCELOT_C) | 62 | #elif defined(CONFIG_MOMENCO_OCELOT_G) || defined (CONFIG_MOMENCO_OCELOT_C) |
63 | 0xff000000, | 63 | 0xff000000, |
64 | ##else | 64 | #else |
65 | #warning Unknown architecture for DiskOnChip. No default probe locations defined | 65 | #warning Unknown architecture for DiskOnChip. No default probe locations defined |
66 | #endif | 66 | #endif |
67 | 0xffffffff }; | 67 | 0xffffffff }; |
@@ -73,7 +73,7 @@ struct doc_priv { | |||
73 | unsigned long physadr; | 73 | unsigned long physadr; |
74 | u_char ChipID; | 74 | u_char ChipID; |
75 | u_char CDSNControl; | 75 | u_char CDSNControl; |
76 | int chips_per_floor; /* The number of chips detected on each floor */ | 76 | int chips_per_floor; /* The number of chips detected on each floor */ |
77 | int curfloor; | 77 | int curfloor; |
78 | int curchip; | 78 | int curchip; |
79 | int mh0_page; | 79 | int mh0_page; |
@@ -84,6 +84,7 @@ struct doc_priv { | |||
84 | /* This is the syndrome computed by the HW ecc generator upon reading an empty | 84 | /* This is the syndrome computed by the HW ecc generator upon reading an empty |
85 | page, one with all 0xff for data and stored ecc code. */ | 85 | page, one with all 0xff for data and stored ecc code. */ |
86 | static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a }; | 86 | static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a }; |
87 | |||
87 | /* This is the ecc value computed by the HW ecc generator upon writing an empty | 88 | /* This is the ecc value computed by the HW ecc generator upon writing an empty |
88 | page, one with all 0xff for data. */ | 89 | page, one with all 0xff for data. */ |
89 | static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 }; | 90 | static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 }; |
@@ -97,25 +98,25 @@ static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 }; | |||
97 | static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd); | 98 | static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd); |
98 | static void doc200x_select_chip(struct mtd_info *mtd, int chip); | 99 | static void doc200x_select_chip(struct mtd_info *mtd, int chip); |
99 | 100 | ||
100 | static int debug=0; | 101 | static int debug = 0; |
101 | module_param(debug, int, 0); | 102 | module_param(debug, int, 0); |
102 | 103 | ||
103 | static int try_dword=1; | 104 | static int try_dword = 1; |
104 | module_param(try_dword, int, 0); | 105 | module_param(try_dword, int, 0); |
105 | 106 | ||
106 | static int no_ecc_failures=0; | 107 | static int no_ecc_failures = 0; |
107 | module_param(no_ecc_failures, int, 0); | 108 | module_param(no_ecc_failures, int, 0); |
108 | 109 | ||
109 | static int no_autopart=0; | 110 | static int no_autopart = 0; |
110 | module_param(no_autopart, int, 0); | 111 | module_param(no_autopart, int, 0); |
111 | 112 | ||
112 | static int show_firmware_partition=0; | 113 | static int show_firmware_partition = 0; |
113 | module_param(show_firmware_partition, int, 0); | 114 | module_param(show_firmware_partition, int, 0); |
114 | 115 | ||
115 | #ifdef MTD_NAND_DISKONCHIP_BBTWRITE | 116 | #ifdef MTD_NAND_DISKONCHIP_BBTWRITE |
116 | static int inftl_bbt_write=1; | 117 | static int inftl_bbt_write = 1; |
117 | #else | 118 | #else |
118 | static int inftl_bbt_write=0; | 119 | static int inftl_bbt_write = 0; |
119 | #endif | 120 | #endif |
120 | module_param(inftl_bbt_write, int, 0); | 121 | module_param(inftl_bbt_write, int, 0); |
121 | 122 | ||
@@ -123,7 +124,6 @@ static unsigned long doc_config_location = CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDR | |||
123 | module_param(doc_config_location, ulong, 0); | 124 | module_param(doc_config_location, ulong, 0); |
124 | MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip"); | 125 | MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip"); |
125 | 126 | ||
126 | |||
127 | /* Sector size for HW ECC */ | 127 | /* Sector size for HW ECC */ |
128 | #define SECTOR_SIZE 512 | 128 | #define SECTOR_SIZE 512 |
129 | /* The sector bytes are packed into NB_DATA 10 bit words */ | 129 | /* The sector bytes are packed into NB_DATA 10 bit words */ |
@@ -147,7 +147,7 @@ static struct rs_control *rs_decoder; | |||
147 | * some comments, improved a minor bit and converted it to make use | 147 | * some comments, improved a minor bit and converted it to make use |
148 | * of the generic Reed-Solomon libary. tglx | 148 | * of the generic Reed-Solomon libary. tglx |
149 | */ | 149 | */ |
150 | static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | 150 | static int doc_ecc_decode(struct rs_control *rs, uint8_t *data, uint8_t *ecc) |
151 | { | 151 | { |
152 | int i, j, nerr, errpos[8]; | 152 | int i, j, nerr, errpos[8]; |
153 | uint8_t parity; | 153 | uint8_t parity; |
@@ -168,18 +168,18 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
168 | * s[i] = ds[3]x^3 + ds[2]x^2 + ds[1]x^1 + ds[0] | 168 | * s[i] = ds[3]x^3 + ds[2]x^2 + ds[1]x^1 + ds[0] |
169 | * where x = alpha^(FCR + i) | 169 | * where x = alpha^(FCR + i) |
170 | */ | 170 | */ |
171 | for(j = 1; j < NROOTS; j++) { | 171 | for (j = 1; j < NROOTS; j++) { |
172 | if(ds[j] == 0) | 172 | if (ds[j] == 0) |
173 | continue; | 173 | continue; |
174 | tmp = rs->index_of[ds[j]]; | 174 | tmp = rs->index_of[ds[j]]; |
175 | for(i = 0; i < NROOTS; i++) | 175 | for (i = 0; i < NROOTS; i++) |
176 | s[i] ^= rs->alpha_to[rs_modnn(rs, tmp + (FCR + i) * j)]; | 176 | s[i] ^= rs->alpha_to[rs_modnn(rs, tmp + (FCR + i) * j)]; |
177 | } | 177 | } |
178 | 178 | ||
179 | /* Calc s[i] = s[i] / alpha^(v + i) */ | 179 | /* Calc s[i] = s[i] / alpha^(v + i) */ |
180 | for (i = 0; i < NROOTS; i++) { | 180 | for (i = 0; i < NROOTS; i++) { |
181 | if (syn[i]) | 181 | if (syn[i]) |
182 | syn[i] = rs_modnn(rs, rs->index_of[s[i]] + (NN - FCR - i)); | 182 | syn[i] = rs_modnn(rs, rs->index_of[s[i]] + (NN - FCR - i)); |
183 | } | 183 | } |
184 | /* Call the decoder library */ | 184 | /* Call the decoder library */ |
185 | nerr = decode_rs16(rs, NULL, NULL, 1019, syn, 0, errpos, 0, errval); | 185 | nerr = decode_rs16(rs, NULL, NULL, 1019, syn, 0, errpos, 0, errval); |
@@ -193,7 +193,7 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
193 | * but they are given by the design of the de/encoder circuit | 193 | * but they are given by the design of the de/encoder circuit |
194 | * in the DoC ASIC's. | 194 | * in the DoC ASIC's. |
195 | */ | 195 | */ |
196 | for(i = 0;i < nerr; i++) { | 196 | for (i = 0; i < nerr; i++) { |
197 | int index, bitpos, pos = 1015 - errpos[i]; | 197 | int index, bitpos, pos = 1015 - errpos[i]; |
198 | uint8_t val; | 198 | uint8_t val; |
199 | if (pos >= NB_DATA && pos < 1019) | 199 | if (pos >= NB_DATA && pos < 1019) |
@@ -205,8 +205,7 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
205 | can be modified since pos is even */ | 205 | can be modified since pos is even */ |
206 | index = (pos >> 3) ^ 1; | 206 | index = (pos >> 3) ^ 1; |
207 | bitpos = pos & 7; | 207 | bitpos = pos & 7; |
208 | if ((index >= 0 && index < SECTOR_SIZE) || | 208 | if ((index >= 0 && index < SECTOR_SIZE) || index == (SECTOR_SIZE + 1)) { |
209 | index == (SECTOR_SIZE + 1)) { | ||
210 | val = (uint8_t) (errval[i] >> (2 + bitpos)); | 209 | val = (uint8_t) (errval[i] >> (2 + bitpos)); |
211 | parity ^= val; | 210 | parity ^= val; |
212 | if (index < SECTOR_SIZE) | 211 | if (index < SECTOR_SIZE) |
@@ -216,9 +215,8 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc) | |||
216 | bitpos = (bitpos + 10) & 7; | 215 | bitpos = (bitpos + 10) & 7; |
217 | if (bitpos == 0) | 216 | if (bitpos == 0) |
218 | bitpos = 8; | 217 | bitpos = 8; |
219 | if ((index >= 0 && index < SECTOR_SIZE) || | 218 | if ((index >= 0 && index < SECTOR_SIZE) || index == (SECTOR_SIZE + 1)) { |
220 | index == (SECTOR_SIZE + 1)) { | 219 | val = (uint8_t) (errval[i] << (8 - bitpos)); |
221 | val = (uint8_t)(errval[i] << (8 - bitpos)); | ||
222 | parity ^= val; | 220 | parity ^= val; |
223 | if (index < SECTOR_SIZE) | 221 | if (index < SECTOR_SIZE) |
224 | data[index] ^= val; | 222 | data[index] ^= val; |
@@ -250,10 +248,11 @@ static void DoC_Delay(struct doc_priv *doc, unsigned short cycles) | |||
250 | /* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */ | 248 | /* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */ |
251 | static int _DoC_WaitReady(struct doc_priv *doc) | 249 | static int _DoC_WaitReady(struct doc_priv *doc) |
252 | { | 250 | { |
253 | void __iomem *docptr = doc->virtadr; | 251 | void __iomem *docptr = doc->virtadr; |
254 | unsigned long timeo = jiffies + (HZ * 10); | 252 | unsigned long timeo = jiffies + (HZ * 10); |
255 | 253 | ||
256 | if(debug) printk("_DoC_WaitReady...\n"); | 254 | if (debug) |
255 | printk("_DoC_WaitReady...\n"); | ||
257 | /* Out-of-line routine to wait for chip response */ | 256 | /* Out-of-line routine to wait for chip response */ |
258 | if (DoC_is_MillenniumPlus(doc)) { | 257 | if (DoC_is_MillenniumPlus(doc)) { |
259 | while ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { | 258 | while ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { |
@@ -280,7 +279,7 @@ static int _DoC_WaitReady(struct doc_priv *doc) | |||
280 | 279 | ||
281 | static inline int DoC_WaitReady(struct doc_priv *doc) | 280 | static inline int DoC_WaitReady(struct doc_priv *doc) |
282 | { | 281 | { |
283 | void __iomem *docptr = doc->virtadr; | 282 | void __iomem *docptr = doc->virtadr; |
284 | int ret = 0; | 283 | int ret = 0; |
285 | 284 | ||
286 | if (DoC_is_MillenniumPlus(doc)) { | 285 | if (DoC_is_MillenniumPlus(doc)) { |
@@ -298,7 +297,8 @@ static inline int DoC_WaitReady(struct doc_priv *doc) | |||
298 | DoC_Delay(doc, 2); | 297 | DoC_Delay(doc, 2); |
299 | } | 298 | } |
300 | 299 | ||
301 | if(debug) printk("DoC_WaitReady OK\n"); | 300 | if (debug) |
301 | printk("DoC_WaitReady OK\n"); | ||
302 | return ret; | 302 | return ret; |
303 | } | 303 | } |
304 | 304 | ||
@@ -306,9 +306,10 @@ static void doc2000_write_byte(struct mtd_info *mtd, u_char datum) | |||
306 | { | 306 | { |
307 | struct nand_chip *this = mtd->priv; | 307 | struct nand_chip *this = mtd->priv; |
308 | struct doc_priv *doc = this->priv; | 308 | struct doc_priv *doc = this->priv; |
309 | void __iomem *docptr = doc->virtadr; | 309 | void __iomem *docptr = doc->virtadr; |
310 | 310 | ||
311 | if(debug)printk("write_byte %02x\n", datum); | 311 | if (debug) |
312 | printk("write_byte %02x\n", datum); | ||
312 | WriteDOC(datum, docptr, CDSNSlowIO); | 313 | WriteDOC(datum, docptr, CDSNSlowIO); |
313 | WriteDOC(datum, docptr, 2k_CDSN_IO); | 314 | WriteDOC(datum, docptr, 2k_CDSN_IO); |
314 | } | 315 | } |
@@ -317,77 +318,78 @@ static u_char doc2000_read_byte(struct mtd_info *mtd) | |||
317 | { | 318 | { |
318 | struct nand_chip *this = mtd->priv; | 319 | struct nand_chip *this = mtd->priv; |
319 | struct doc_priv *doc = this->priv; | 320 | struct doc_priv *doc = this->priv; |
320 | void __iomem *docptr = doc->virtadr; | 321 | void __iomem *docptr = doc->virtadr; |
321 | u_char ret; | 322 | u_char ret; |
322 | 323 | ||
323 | ReadDOC(docptr, CDSNSlowIO); | 324 | ReadDOC(docptr, CDSNSlowIO); |
324 | DoC_Delay(doc, 2); | 325 | DoC_Delay(doc, 2); |
325 | ret = ReadDOC(docptr, 2k_CDSN_IO); | 326 | ret = ReadDOC(docptr, 2k_CDSN_IO); |
326 | if (debug) printk("read_byte returns %02x\n", ret); | 327 | if (debug) |
328 | printk("read_byte returns %02x\n", ret); | ||
327 | return ret; | 329 | return ret; |
328 | } | 330 | } |
329 | 331 | ||
330 | static void doc2000_writebuf(struct mtd_info *mtd, | 332 | static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len) |
331 | const u_char *buf, int len) | ||
332 | { | 333 | { |
333 | struct nand_chip *this = mtd->priv; | 334 | struct nand_chip *this = mtd->priv; |
334 | struct doc_priv *doc = this->priv; | 335 | struct doc_priv *doc = this->priv; |
335 | void __iomem *docptr = doc->virtadr; | 336 | void __iomem *docptr = doc->virtadr; |
336 | int i; | 337 | int i; |
337 | if (debug)printk("writebuf of %d bytes: ", len); | 338 | if (debug) |
338 | for (i=0; i < len; i++) { | 339 | printk("writebuf of %d bytes: ", len); |
340 | for (i = 0; i < len; i++) { | ||
339 | WriteDOC_(buf[i], docptr, DoC_2k_CDSN_IO + i); | 341 | WriteDOC_(buf[i], docptr, DoC_2k_CDSN_IO + i); |
340 | if (debug && i < 16) | 342 | if (debug && i < 16) |
341 | printk("%02x ", buf[i]); | 343 | printk("%02x ", buf[i]); |
342 | } | 344 | } |
343 | if (debug) printk("\n"); | 345 | if (debug) |
346 | printk("\n"); | ||
344 | } | 347 | } |
345 | 348 | ||
346 | static void doc2000_readbuf(struct mtd_info *mtd, | 349 | static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len) |
347 | u_char *buf, int len) | ||
348 | { | 350 | { |
349 | struct nand_chip *this = mtd->priv; | 351 | struct nand_chip *this = mtd->priv; |
350 | struct doc_priv *doc = this->priv; | 352 | struct doc_priv *doc = this->priv; |
351 | void __iomem *docptr = doc->virtadr; | 353 | void __iomem *docptr = doc->virtadr; |
352 | int i; | 354 | int i; |
353 | 355 | ||
354 | if (debug)printk("readbuf of %d bytes: ", len); | 356 | if (debug) |
357 | printk("readbuf of %d bytes: ", len); | ||
355 | 358 | ||
356 | for (i=0; i < len; i++) { | 359 | for (i = 0; i < len; i++) { |
357 | buf[i] = ReadDOC(docptr, 2k_CDSN_IO + i); | 360 | buf[i] = ReadDOC(docptr, 2k_CDSN_IO + i); |
358 | } | 361 | } |
359 | } | 362 | } |
360 | 363 | ||
361 | static void doc2000_readbuf_dword(struct mtd_info *mtd, | 364 | static void doc2000_readbuf_dword(struct mtd_info *mtd, u_char *buf, int len) |
362 | u_char *buf, int len) | ||
363 | { | 365 | { |
364 | struct nand_chip *this = mtd->priv; | 366 | struct nand_chip *this = mtd->priv; |
365 | struct doc_priv *doc = this->priv; | 367 | struct doc_priv *doc = this->priv; |
366 | void __iomem *docptr = doc->virtadr; | 368 | void __iomem *docptr = doc->virtadr; |
367 | int i; | 369 | int i; |
368 | 370 | ||
369 | if (debug) printk("readbuf_dword of %d bytes: ", len); | 371 | if (debug) |
372 | printk("readbuf_dword of %d bytes: ", len); | ||
370 | 373 | ||
371 | if (unlikely((((unsigned long)buf)|len) & 3)) { | 374 | if (unlikely((((unsigned long)buf) | len) & 3)) { |
372 | for (i=0; i < len; i++) { | 375 | for (i = 0; i < len; i++) { |
373 | *(uint8_t *)(&buf[i]) = ReadDOC(docptr, 2k_CDSN_IO + i); | 376 | *(uint8_t *) (&buf[i]) = ReadDOC(docptr, 2k_CDSN_IO + i); |
374 | } | 377 | } |
375 | } else { | 378 | } else { |
376 | for (i=0; i < len; i+=4) { | 379 | for (i = 0; i < len; i += 4) { |
377 | *(uint32_t*)(&buf[i]) = readl(docptr + DoC_2k_CDSN_IO + i); | 380 | *(uint32_t *) (&buf[i]) = readl(docptr + DoC_2k_CDSN_IO + i); |
378 | } | 381 | } |
379 | } | 382 | } |
380 | } | 383 | } |
381 | 384 | ||
382 | static int doc2000_verifybuf(struct mtd_info *mtd, | 385 | static int doc2000_verifybuf(struct mtd_info *mtd, const u_char *buf, int len) |
383 | const u_char *buf, int len) | ||
384 | { | 386 | { |
385 | struct nand_chip *this = mtd->priv; | 387 | struct nand_chip *this = mtd->priv; |
386 | struct doc_priv *doc = this->priv; | 388 | struct doc_priv *doc = this->priv; |
387 | void __iomem *docptr = doc->virtadr; | 389 | void __iomem *docptr = doc->virtadr; |
388 | int i; | 390 | int i; |
389 | 391 | ||
390 | for (i=0; i < len; i++) | 392 | for (i = 0; i < len; i++) |
391 | if (buf[i] != ReadDOC(docptr, 2k_CDSN_IO)) | 393 | if (buf[i] != ReadDOC(docptr, 2k_CDSN_IO)) |
392 | return -EFAULT; | 394 | return -EFAULT; |
393 | return 0; | 395 | return 0; |
@@ -482,7 +484,7 @@ static void doc2001_write_byte(struct mtd_info *mtd, u_char datum) | |||
482 | { | 484 | { |
483 | struct nand_chip *this = mtd->priv; | 485 | struct nand_chip *this = mtd->priv; |
484 | struct doc_priv *doc = this->priv; | 486 | struct doc_priv *doc = this->priv; |
485 | void __iomem *docptr = doc->virtadr; | 487 | void __iomem *docptr = doc->virtadr; |
486 | 488 | ||
487 | WriteDOC(datum, docptr, CDSNSlowIO); | 489 | WriteDOC(datum, docptr, CDSNSlowIO); |
488 | WriteDOC(datum, docptr, Mil_CDSN_IO); | 490 | WriteDOC(datum, docptr, Mil_CDSN_IO); |
@@ -493,7 +495,7 @@ static u_char doc2001_read_byte(struct mtd_info *mtd) | |||
493 | { | 495 | { |
494 | struct nand_chip *this = mtd->priv; | 496 | struct nand_chip *this = mtd->priv; |
495 | struct doc_priv *doc = this->priv; | 497 | struct doc_priv *doc = this->priv; |
496 | void __iomem *docptr = doc->virtadr; | 498 | void __iomem *docptr = doc->virtadr; |
497 | 499 | ||
498 | //ReadDOC(docptr, CDSNSlowIO); | 500 | //ReadDOC(docptr, CDSNSlowIO); |
499 | /* 11.4.5 -- delay twice to allow extended length cycle */ | 501 | /* 11.4.5 -- delay twice to allow extended length cycle */ |
@@ -503,50 +505,47 @@ static u_char doc2001_read_byte(struct mtd_info *mtd) | |||
503 | return ReadDOC(docptr, LastDataRead); | 505 | return ReadDOC(docptr, LastDataRead); |
504 | } | 506 | } |
505 | 507 | ||
506 | static void doc2001_writebuf(struct mtd_info *mtd, | 508 | static void doc2001_writebuf(struct mtd_info *mtd, const u_char *buf, int len) |
507 | const u_char *buf, int len) | ||
508 | { | 509 | { |
509 | struct nand_chip *this = mtd->priv; | 510 | struct nand_chip *this = mtd->priv; |
510 | struct doc_priv *doc = this->priv; | 511 | struct doc_priv *doc = this->priv; |
511 | void __iomem *docptr = doc->virtadr; | 512 | void __iomem *docptr = doc->virtadr; |
512 | int i; | 513 | int i; |
513 | 514 | ||
514 | for (i=0; i < len; i++) | 515 | for (i = 0; i < len; i++) |
515 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); | 516 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); |
516 | /* Terminate write pipeline */ | 517 | /* Terminate write pipeline */ |
517 | WriteDOC(0x00, docptr, WritePipeTerm); | 518 | WriteDOC(0x00, docptr, WritePipeTerm); |
518 | } | 519 | } |
519 | 520 | ||
520 | static void doc2001_readbuf(struct mtd_info *mtd, | 521 | static void doc2001_readbuf(struct mtd_info *mtd, u_char *buf, int len) |
521 | u_char *buf, int len) | ||
522 | { | 522 | { |
523 | struct nand_chip *this = mtd->priv; | 523 | struct nand_chip *this = mtd->priv; |
524 | struct doc_priv *doc = this->priv; | 524 | struct doc_priv *doc = this->priv; |
525 | void __iomem *docptr = doc->virtadr; | 525 | void __iomem *docptr = doc->virtadr; |
526 | int i; | 526 | int i; |
527 | 527 | ||
528 | /* Start read pipeline */ | 528 | /* Start read pipeline */ |
529 | ReadDOC(docptr, ReadPipeInit); | 529 | ReadDOC(docptr, ReadPipeInit); |
530 | 530 | ||
531 | for (i=0; i < len-1; i++) | 531 | for (i = 0; i < len - 1; i++) |
532 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO + (i & 0xff)); | 532 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO + (i & 0xff)); |
533 | 533 | ||
534 | /* Terminate read pipeline */ | 534 | /* Terminate read pipeline */ |
535 | buf[i] = ReadDOC(docptr, LastDataRead); | 535 | buf[i] = ReadDOC(docptr, LastDataRead); |
536 | } | 536 | } |
537 | 537 | ||
538 | static int doc2001_verifybuf(struct mtd_info *mtd, | 538 | static int doc2001_verifybuf(struct mtd_info *mtd, const u_char *buf, int len) |
539 | const u_char *buf, int len) | ||
540 | { | 539 | { |
541 | struct nand_chip *this = mtd->priv; | 540 | struct nand_chip *this = mtd->priv; |
542 | struct doc_priv *doc = this->priv; | 541 | struct doc_priv *doc = this->priv; |
543 | void __iomem *docptr = doc->virtadr; | 542 | void __iomem *docptr = doc->virtadr; |
544 | int i; | 543 | int i; |
545 | 544 | ||
546 | /* Start read pipeline */ | 545 | /* Start read pipeline */ |
547 | ReadDOC(docptr, ReadPipeInit); | 546 | ReadDOC(docptr, ReadPipeInit); |
548 | 547 | ||
549 | for (i=0; i < len-1; i++) | 548 | for (i = 0; i < len - 1; i++) |
550 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { | 549 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { |
551 | ReadDOC(docptr, LastDataRead); | 550 | ReadDOC(docptr, LastDataRead); |
552 | return i; | 551 | return i; |
@@ -560,87 +559,90 @@ static u_char doc2001plus_read_byte(struct mtd_info *mtd) | |||
560 | { | 559 | { |
561 | struct nand_chip *this = mtd->priv; | 560 | struct nand_chip *this = mtd->priv; |
562 | struct doc_priv *doc = this->priv; | 561 | struct doc_priv *doc = this->priv; |
563 | void __iomem *docptr = doc->virtadr; | 562 | void __iomem *docptr = doc->virtadr; |
564 | u_char ret; | 563 | u_char ret; |
565 | 564 | ||
566 | ReadDOC(docptr, Mplus_ReadPipeInit); | 565 | ReadDOC(docptr, Mplus_ReadPipeInit); |
567 | ReadDOC(docptr, Mplus_ReadPipeInit); | 566 | ReadDOC(docptr, Mplus_ReadPipeInit); |
568 | ret = ReadDOC(docptr, Mplus_LastDataRead); | 567 | ret = ReadDOC(docptr, Mplus_LastDataRead); |
569 | if (debug) printk("read_byte returns %02x\n", ret); | 568 | if (debug) |
569 | printk("read_byte returns %02x\n", ret); | ||
570 | return ret; | 570 | return ret; |
571 | } | 571 | } |
572 | 572 | ||
573 | static void doc2001plus_writebuf(struct mtd_info *mtd, | 573 | static void doc2001plus_writebuf(struct mtd_info *mtd, const u_char *buf, int len) |
574 | const u_char *buf, int len) | ||
575 | { | 574 | { |
576 | struct nand_chip *this = mtd->priv; | 575 | struct nand_chip *this = mtd->priv; |
577 | struct doc_priv *doc = this->priv; | 576 | struct doc_priv *doc = this->priv; |
578 | void __iomem *docptr = doc->virtadr; | 577 | void __iomem *docptr = doc->virtadr; |
579 | int i; | 578 | int i; |
580 | 579 | ||
581 | if (debug)printk("writebuf of %d bytes: ", len); | 580 | if (debug) |
582 | for (i=0; i < len; i++) { | 581 | printk("writebuf of %d bytes: ", len); |
582 | for (i = 0; i < len; i++) { | ||
583 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); | 583 | WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i); |
584 | if (debug && i < 16) | 584 | if (debug && i < 16) |
585 | printk("%02x ", buf[i]); | 585 | printk("%02x ", buf[i]); |
586 | } | 586 | } |
587 | if (debug) printk("\n"); | 587 | if (debug) |
588 | printk("\n"); | ||
588 | } | 589 | } |
589 | 590 | ||
590 | static void doc2001plus_readbuf(struct mtd_info *mtd, | 591 | static void doc2001plus_readbuf(struct mtd_info *mtd, u_char *buf, int len) |
591 | u_char *buf, int len) | ||
592 | { | 592 | { |
593 | struct nand_chip *this = mtd->priv; | 593 | struct nand_chip *this = mtd->priv; |
594 | struct doc_priv *doc = this->priv; | 594 | struct doc_priv *doc = this->priv; |
595 | void __iomem *docptr = doc->virtadr; | 595 | void __iomem *docptr = doc->virtadr; |
596 | int i; | 596 | int i; |
597 | 597 | ||
598 | if (debug)printk("readbuf of %d bytes: ", len); | 598 | if (debug) |
599 | printk("readbuf of %d bytes: ", len); | ||
599 | 600 | ||
600 | /* Start read pipeline */ | 601 | /* Start read pipeline */ |
601 | ReadDOC(docptr, Mplus_ReadPipeInit); | 602 | ReadDOC(docptr, Mplus_ReadPipeInit); |
602 | ReadDOC(docptr, Mplus_ReadPipeInit); | 603 | ReadDOC(docptr, Mplus_ReadPipeInit); |
603 | 604 | ||
604 | for (i=0; i < len-2; i++) { | 605 | for (i = 0; i < len - 2; i++) { |
605 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO); | 606 | buf[i] = ReadDOC(docptr, Mil_CDSN_IO); |
606 | if (debug && i < 16) | 607 | if (debug && i < 16) |
607 | printk("%02x ", buf[i]); | 608 | printk("%02x ", buf[i]); |
608 | } | 609 | } |
609 | 610 | ||
610 | /* Terminate read pipeline */ | 611 | /* Terminate read pipeline */ |
611 | buf[len-2] = ReadDOC(docptr, Mplus_LastDataRead); | 612 | buf[len - 2] = ReadDOC(docptr, Mplus_LastDataRead); |
612 | if (debug && i < 16) | 613 | if (debug && i < 16) |
613 | printk("%02x ", buf[len-2]); | 614 | printk("%02x ", buf[len - 2]); |
614 | buf[len-1] = ReadDOC(docptr, Mplus_LastDataRead); | 615 | buf[len - 1] = ReadDOC(docptr, Mplus_LastDataRead); |
615 | if (debug && i < 16) | 616 | if (debug && i < 16) |
616 | printk("%02x ", buf[len-1]); | 617 | printk("%02x ", buf[len - 1]); |
617 | if (debug) printk("\n"); | 618 | if (debug) |
619 | printk("\n"); | ||
618 | } | 620 | } |
619 | 621 | ||
620 | static int doc2001plus_verifybuf(struct mtd_info *mtd, | 622 | static int doc2001plus_verifybuf(struct mtd_info *mtd, const u_char *buf, int len) |
621 | const u_char *buf, int len) | ||
622 | { | 623 | { |
623 | struct nand_chip *this = mtd->priv; | 624 | struct nand_chip *this = mtd->priv; |
624 | struct doc_priv *doc = this->priv; | 625 | struct doc_priv *doc = this->priv; |
625 | void __iomem *docptr = doc->virtadr; | 626 | void __iomem *docptr = doc->virtadr; |
626 | int i; | 627 | int i; |
627 | 628 | ||
628 | if (debug)printk("verifybuf of %d bytes: ", len); | 629 | if (debug) |
630 | printk("verifybuf of %d bytes: ", len); | ||
629 | 631 | ||
630 | /* Start read pipeline */ | 632 | /* Start read pipeline */ |
631 | ReadDOC(docptr, Mplus_ReadPipeInit); | 633 | ReadDOC(docptr, Mplus_ReadPipeInit); |
632 | ReadDOC(docptr, Mplus_ReadPipeInit); | 634 | ReadDOC(docptr, Mplus_ReadPipeInit); |
633 | 635 | ||
634 | for (i=0; i < len-2; i++) | 636 | for (i = 0; i < len - 2; i++) |
635 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { | 637 | if (buf[i] != ReadDOC(docptr, Mil_CDSN_IO)) { |
636 | ReadDOC(docptr, Mplus_LastDataRead); | 638 | ReadDOC(docptr, Mplus_LastDataRead); |
637 | ReadDOC(docptr, Mplus_LastDataRead); | 639 | ReadDOC(docptr, Mplus_LastDataRead); |
638 | return i; | 640 | return i; |
639 | } | 641 | } |
640 | if (buf[len-2] != ReadDOC(docptr, Mplus_LastDataRead)) | 642 | if (buf[len - 2] != ReadDOC(docptr, Mplus_LastDataRead)) |
641 | return len-2; | 643 | return len - 2; |
642 | if (buf[len-1] != ReadDOC(docptr, Mplus_LastDataRead)) | 644 | if (buf[len - 1] != ReadDOC(docptr, Mplus_LastDataRead)) |
643 | return len-1; | 645 | return len - 1; |
644 | return 0; | 646 | return 0; |
645 | } | 647 | } |
646 | 648 | ||
@@ -648,10 +650,11 @@ static void doc2001plus_select_chip(struct mtd_info *mtd, int chip) | |||
648 | { | 650 | { |
649 | struct nand_chip *this = mtd->priv; | 651 | struct nand_chip *this = mtd->priv; |
650 | struct doc_priv *doc = this->priv; | 652 | struct doc_priv *doc = this->priv; |
651 | void __iomem *docptr = doc->virtadr; | 653 | void __iomem *docptr = doc->virtadr; |
652 | int floor = 0; | 654 | int floor = 0; |
653 | 655 | ||
654 | if(debug)printk("select chip (%d)\n", chip); | 656 | if (debug) |
657 | printk("select chip (%d)\n", chip); | ||
655 | 658 | ||
656 | if (chip == -1) { | 659 | if (chip == -1) { |
657 | /* Disable flash internally */ | 660 | /* Disable flash internally */ |
@@ -660,7 +663,7 @@ static void doc2001plus_select_chip(struct mtd_info *mtd, int chip) | |||
660 | } | 663 | } |
661 | 664 | ||
662 | floor = chip / doc->chips_per_floor; | 665 | floor = chip / doc->chips_per_floor; |
663 | chip -= (floor * doc->chips_per_floor); | 666 | chip -= (floor * doc->chips_per_floor); |
664 | 667 | ||
665 | /* Assert ChipEnable and deassert WriteProtect */ | 668 | /* Assert ChipEnable and deassert WriteProtect */ |
666 | WriteDOC((DOC_FLASH_CE), docptr, Mplus_FlashSelect); | 669 | WriteDOC((DOC_FLASH_CE), docptr, Mplus_FlashSelect); |
@@ -674,16 +677,17 @@ static void doc200x_select_chip(struct mtd_info *mtd, int chip) | |||
674 | { | 677 | { |
675 | struct nand_chip *this = mtd->priv; | 678 | struct nand_chip *this = mtd->priv; |
676 | struct doc_priv *doc = this->priv; | 679 | struct doc_priv *doc = this->priv; |
677 | void __iomem *docptr = doc->virtadr; | 680 | void __iomem *docptr = doc->virtadr; |
678 | int floor = 0; | 681 | int floor = 0; |
679 | 682 | ||
680 | if(debug)printk("select chip (%d)\n", chip); | 683 | if (debug) |
684 | printk("select chip (%d)\n", chip); | ||
681 | 685 | ||
682 | if (chip == -1) | 686 | if (chip == -1) |
683 | return; | 687 | return; |
684 | 688 | ||
685 | floor = chip / doc->chips_per_floor; | 689 | floor = chip / doc->chips_per_floor; |
686 | chip -= (floor * doc->chips_per_floor); | 690 | chip -= (floor * doc->chips_per_floor); |
687 | 691 | ||
688 | /* 11.4.4 -- deassert CE before changing chip */ | 692 | /* 11.4.4 -- deassert CE before changing chip */ |
689 | doc200x_hwcontrol(mtd, NAND_CTL_CLRNCE); | 693 | doc200x_hwcontrol(mtd, NAND_CTL_CLRNCE); |
@@ -701,9 +705,9 @@ static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd) | |||
701 | { | 705 | { |
702 | struct nand_chip *this = mtd->priv; | 706 | struct nand_chip *this = mtd->priv; |
703 | struct doc_priv *doc = this->priv; | 707 | struct doc_priv *doc = this->priv; |
704 | void __iomem *docptr = doc->virtadr; | 708 | void __iomem *docptr = doc->virtadr; |
705 | 709 | ||
706 | switch(cmd) { | 710 | switch (cmd) { |
707 | case NAND_CTL_SETNCE: | 711 | case NAND_CTL_SETNCE: |
708 | doc->CDSNControl |= CDSN_CTRL_CE; | 712 | doc->CDSNControl |= CDSN_CTRL_CE; |
709 | break; | 713 | break; |
@@ -729,17 +733,18 @@ static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd) | |||
729 | doc->CDSNControl &= ~CDSN_CTRL_WP; | 733 | doc->CDSNControl &= ~CDSN_CTRL_WP; |
730 | break; | 734 | break; |
731 | } | 735 | } |
732 | if (debug)printk("hwcontrol(%d): %02x\n", cmd, doc->CDSNControl); | 736 | if (debug) |
737 | printk("hwcontrol(%d): %02x\n", cmd, doc->CDSNControl); | ||
733 | WriteDOC(doc->CDSNControl, docptr, CDSNControl); | 738 | WriteDOC(doc->CDSNControl, docptr, CDSNControl); |
734 | /* 11.4.3 -- 4 NOPs after CSDNControl write */ | 739 | /* 11.4.3 -- 4 NOPs after CSDNControl write */ |
735 | DoC_Delay(doc, 4); | 740 | DoC_Delay(doc, 4); |
736 | } | 741 | } |
737 | 742 | ||
738 | static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int column, int page_addr) | 743 | static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) |
739 | { | 744 | { |
740 | struct nand_chip *this = mtd->priv; | 745 | struct nand_chip *this = mtd->priv; |
741 | struct doc_priv *doc = this->priv; | 746 | struct doc_priv *doc = this->priv; |
742 | void __iomem *docptr = doc->virtadr; | 747 | void __iomem *docptr = doc->virtadr; |
743 | 748 | ||
744 | /* | 749 | /* |
745 | * Must terminate write pipeline before sending any commands | 750 | * Must terminate write pipeline before sending any commands |
@@ -782,25 +787,26 @@ static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int col | |||
782 | WriteDOC(column, docptr, Mplus_FlashAddress); | 787 | WriteDOC(column, docptr, Mplus_FlashAddress); |
783 | } | 788 | } |
784 | if (page_addr != -1) { | 789 | if (page_addr != -1) { |
785 | WriteDOC((unsigned char) (page_addr & 0xff), docptr, Mplus_FlashAddress); | 790 | WriteDOC((unsigned char)(page_addr & 0xff), docptr, Mplus_FlashAddress); |
786 | WriteDOC((unsigned char) ((page_addr >> 8) & 0xff), docptr, Mplus_FlashAddress); | 791 | WriteDOC((unsigned char)((page_addr >> 8) & 0xff), docptr, Mplus_FlashAddress); |
787 | /* One more address cycle for higher density devices */ | 792 | /* One more address cycle for higher density devices */ |
788 | if (this->chipsize & 0x0c000000) { | 793 | if (this->chipsize & 0x0c000000) { |
789 | WriteDOC((unsigned char) ((page_addr >> 16) & 0x0f), docptr, Mplus_FlashAddress); | 794 | WriteDOC((unsigned char)((page_addr >> 16) & 0x0f), docptr, Mplus_FlashAddress); |
790 | printk("high density\n"); | 795 | printk("high density\n"); |
791 | } | 796 | } |
792 | } | 797 | } |
793 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 798 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
794 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 799 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
795 | /* deassert ALE */ | 800 | /* deassert ALE */ |
796 | if (command == NAND_CMD_READ0 || command == NAND_CMD_READ1 || command == NAND_CMD_READOOB || command == NAND_CMD_READID) | 801 | if (command == NAND_CMD_READ0 || command == NAND_CMD_READ1 || |
802 | command == NAND_CMD_READOOB || command == NAND_CMD_READID) | ||
797 | WriteDOC(0, docptr, Mplus_FlashControl); | 803 | WriteDOC(0, docptr, Mplus_FlashControl); |
798 | } | 804 | } |
799 | 805 | ||
800 | /* | 806 | /* |
801 | * program and erase have their own busy handlers | 807 | * program and erase have their own busy handlers |
802 | * status and sequential in needs no delay | 808 | * status and sequential in needs no delay |
803 | */ | 809 | */ |
804 | switch (command) { | 810 | switch (command) { |
805 | 811 | ||
806 | case NAND_CMD_PAGEPROG: | 812 | case NAND_CMD_PAGEPROG: |
@@ -817,55 +823,57 @@ static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int col | |||
817 | WriteDOC(NAND_CMD_STATUS, docptr, Mplus_FlashCmd); | 823 | WriteDOC(NAND_CMD_STATUS, docptr, Mplus_FlashCmd); |
818 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 824 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
819 | WriteDOC(0, docptr, Mplus_WritePipeTerm); | 825 | WriteDOC(0, docptr, Mplus_WritePipeTerm); |
820 | while ( !(this->read_byte(mtd) & 0x40)); | 826 | while (!(this->read_byte(mtd) & 0x40)) ; |
821 | return; | 827 | return; |
822 | 828 | ||
823 | /* This applies to read commands */ | 829 | /* This applies to read commands */ |
824 | default: | 830 | default: |
825 | /* | 831 | /* |
826 | * If we don't have access to the busy pin, we apply the given | 832 | * If we don't have access to the busy pin, we apply the given |
827 | * command delay | 833 | * command delay |
828 | */ | 834 | */ |
829 | if (!this->dev_ready) { | 835 | if (!this->dev_ready) { |
830 | udelay (this->chip_delay); | 836 | udelay(this->chip_delay); |
831 | return; | 837 | return; |
832 | } | 838 | } |
833 | } | 839 | } |
834 | 840 | ||
835 | /* Apply this short delay always to ensure that we do wait tWB in | 841 | /* Apply this short delay always to ensure that we do wait tWB in |
836 | * any case on any machine. */ | 842 | * any case on any machine. */ |
837 | ndelay (100); | 843 | ndelay(100); |
838 | /* wait until command is processed */ | 844 | /* wait until command is processed */ |
839 | while (!this->dev_ready(mtd)); | 845 | while (!this->dev_ready(mtd)) ; |
840 | } | 846 | } |
841 | 847 | ||
842 | static int doc200x_dev_ready(struct mtd_info *mtd) | 848 | static int doc200x_dev_ready(struct mtd_info *mtd) |
843 | { | 849 | { |
844 | struct nand_chip *this = mtd->priv; | 850 | struct nand_chip *this = mtd->priv; |
845 | struct doc_priv *doc = this->priv; | 851 | struct doc_priv *doc = this->priv; |
846 | void __iomem *docptr = doc->virtadr; | 852 | void __iomem *docptr = doc->virtadr; |
847 | 853 | ||
848 | if (DoC_is_MillenniumPlus(doc)) { | 854 | if (DoC_is_MillenniumPlus(doc)) { |
849 | /* 11.4.2 -- must NOP four times before checking FR/B# */ | 855 | /* 11.4.2 -- must NOP four times before checking FR/B# */ |
850 | DoC_Delay(doc, 4); | 856 | DoC_Delay(doc, 4); |
851 | if ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { | 857 | if ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) { |
852 | if(debug) | 858 | if (debug) |
853 | printk("not ready\n"); | 859 | printk("not ready\n"); |
854 | return 0; | 860 | return 0; |
855 | } | 861 | } |
856 | if (debug)printk("was ready\n"); | 862 | if (debug) |
863 | printk("was ready\n"); | ||
857 | return 1; | 864 | return 1; |
858 | } else { | 865 | } else { |
859 | /* 11.4.2 -- must NOP four times before checking FR/B# */ | 866 | /* 11.4.2 -- must NOP four times before checking FR/B# */ |
860 | DoC_Delay(doc, 4); | 867 | DoC_Delay(doc, 4); |
861 | if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) { | 868 | if (!(ReadDOC(docptr, CDSNControl) & CDSN_CTRL_FR_B)) { |
862 | if(debug) | 869 | if (debug) |
863 | printk("not ready\n"); | 870 | printk("not ready\n"); |
864 | return 0; | 871 | return 0; |
865 | } | 872 | } |
866 | /* 11.4.2 -- Must NOP twice if it's ready */ | 873 | /* 11.4.2 -- Must NOP twice if it's ready */ |
867 | DoC_Delay(doc, 2); | 874 | DoC_Delay(doc, 2); |
868 | if (debug)printk("was ready\n"); | 875 | if (debug) |
876 | printk("was ready\n"); | ||
869 | return 1; | 877 | return 1; |
870 | } | 878 | } |
871 | } | 879 | } |
@@ -881,10 +889,10 @@ static void doc200x_enable_hwecc(struct mtd_info *mtd, int mode) | |||
881 | { | 889 | { |
882 | struct nand_chip *this = mtd->priv; | 890 | struct nand_chip *this = mtd->priv; |
883 | struct doc_priv *doc = this->priv; | 891 | struct doc_priv *doc = this->priv; |
884 | void __iomem *docptr = doc->virtadr; | 892 | void __iomem *docptr = doc->virtadr; |
885 | 893 | ||
886 | /* Prime the ECC engine */ | 894 | /* Prime the ECC engine */ |
887 | switch(mode) { | 895 | switch (mode) { |
888 | case NAND_ECC_READ: | 896 | case NAND_ECC_READ: |
889 | WriteDOC(DOC_ECC_RESET, docptr, ECCConf); | 897 | WriteDOC(DOC_ECC_RESET, docptr, ECCConf); |
890 | WriteDOC(DOC_ECC_EN, docptr, ECCConf); | 898 | WriteDOC(DOC_ECC_EN, docptr, ECCConf); |
@@ -900,10 +908,10 @@ static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode) | |||
900 | { | 908 | { |
901 | struct nand_chip *this = mtd->priv; | 909 | struct nand_chip *this = mtd->priv; |
902 | struct doc_priv *doc = this->priv; | 910 | struct doc_priv *doc = this->priv; |
903 | void __iomem *docptr = doc->virtadr; | 911 | void __iomem *docptr = doc->virtadr; |
904 | 912 | ||
905 | /* Prime the ECC engine */ | 913 | /* Prime the ECC engine */ |
906 | switch(mode) { | 914 | switch (mode) { |
907 | case NAND_ECC_READ: | 915 | case NAND_ECC_READ: |
908 | WriteDOC(DOC_ECC_RESET, docptr, Mplus_ECCConf); | 916 | WriteDOC(DOC_ECC_RESET, docptr, Mplus_ECCConf); |
909 | WriteDOC(DOC_ECC_EN, docptr, Mplus_ECCConf); | 917 | WriteDOC(DOC_ECC_EN, docptr, Mplus_ECCConf); |
@@ -916,12 +924,11 @@ static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode) | |||
916 | } | 924 | } |
917 | 925 | ||
918 | /* This code is only called on write */ | 926 | /* This code is only called on write */ |
919 | static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | 927 | static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, unsigned char *ecc_code) |
920 | unsigned char *ecc_code) | ||
921 | { | 928 | { |
922 | struct nand_chip *this = mtd->priv; | 929 | struct nand_chip *this = mtd->priv; |
923 | struct doc_priv *doc = this->priv; | 930 | struct doc_priv *doc = this->priv; |
924 | void __iomem *docptr = doc->virtadr; | 931 | void __iomem *docptr = doc->virtadr; |
925 | int i; | 932 | int i; |
926 | int emptymatch = 1; | 933 | int emptymatch = 1; |
927 | 934 | ||
@@ -961,7 +968,8 @@ static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | |||
961 | often. It could be optimized away by examining the data in | 968 | often. It could be optimized away by examining the data in |
962 | the writebuf routine, and remembering the result. */ | 969 | the writebuf routine, and remembering the result. */ |
963 | for (i = 0; i < 512; i++) { | 970 | for (i = 0; i < 512; i++) { |
964 | if (dat[i] == 0xff) continue; | 971 | if (dat[i] == 0xff) |
972 | continue; | ||
965 | emptymatch = 0; | 973 | emptymatch = 0; |
966 | break; | 974 | break; |
967 | } | 975 | } |
@@ -969,7 +977,8 @@ static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, | |||
969 | /* If emptymatch still =1, we do have an all-0xff data buffer. | 977 | /* If emptymatch still =1, we do have an all-0xff data buffer. |
970 | Return all-0xff ecc value instead of the computed one, so | 978 | Return all-0xff ecc value instead of the computed one, so |
971 | it'll look just like a freshly-erased page. */ | 979 | it'll look just like a freshly-erased page. */ |
972 | if (emptymatch) memset(ecc_code, 0xff, 6); | 980 | if (emptymatch) |
981 | memset(ecc_code, 0xff, 6); | ||
973 | #endif | 982 | #endif |
974 | return 0; | 983 | return 0; |
975 | } | 984 | } |
@@ -979,7 +988,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
979 | int i, ret = 0; | 988 | int i, ret = 0; |
980 | struct nand_chip *this = mtd->priv; | 989 | struct nand_chip *this = mtd->priv; |
981 | struct doc_priv *doc = this->priv; | 990 | struct doc_priv *doc = this->priv; |
982 | void __iomem *docptr = doc->virtadr; | 991 | void __iomem *docptr = doc->virtadr; |
983 | volatile u_char dummy; | 992 | volatile u_char dummy; |
984 | int emptymatch = 1; | 993 | int emptymatch = 1; |
985 | 994 | ||
@@ -1012,18 +1021,20 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
1012 | all-0xff data and stored ecc block. Check the stored ecc. */ | 1021 | all-0xff data and stored ecc block. Check the stored ecc. */ |
1013 | if (emptymatch) { | 1022 | if (emptymatch) { |
1014 | for (i = 0; i < 6; i++) { | 1023 | for (i = 0; i < 6; i++) { |
1015 | if (read_ecc[i] == 0xff) continue; | 1024 | if (read_ecc[i] == 0xff) |
1025 | continue; | ||
1016 | emptymatch = 0; | 1026 | emptymatch = 0; |
1017 | break; | 1027 | break; |
1018 | } | 1028 | } |
1019 | } | 1029 | } |
1020 | /* If emptymatch still =1, check the data block. */ | 1030 | /* If emptymatch still =1, check the data block. */ |
1021 | if (emptymatch) { | 1031 | if (emptymatch) { |
1022 | /* Note: this somewhat expensive test should not be triggered | 1032 | /* Note: this somewhat expensive test should not be triggered |
1023 | often. It could be optimized away by examining the data in | 1033 | often. It could be optimized away by examining the data in |
1024 | the readbuf routine, and remembering the result. */ | 1034 | the readbuf routine, and remembering the result. */ |
1025 | for (i = 0; i < 512; i++) { | 1035 | for (i = 0; i < 512; i++) { |
1026 | if (dat[i] == 0xff) continue; | 1036 | if (dat[i] == 0xff) |
1037 | continue; | ||
1027 | emptymatch = 0; | 1038 | emptymatch = 0; |
1028 | break; | 1039 | break; |
1029 | } | 1040 | } |
@@ -1032,7 +1043,8 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
1032 | erased block, in which case the ECC will not come out right. | 1043 | erased block, in which case the ECC will not come out right. |
1033 | We'll suppress the error and tell the caller everything's | 1044 | We'll suppress the error and tell the caller everything's |
1034 | OK. Because it is. */ | 1045 | OK. Because it is. */ |
1035 | if (!emptymatch) ret = doc_ecc_decode (rs_decoder, dat, calc_ecc); | 1046 | if (!emptymatch) |
1047 | ret = doc_ecc_decode(rs_decoder, dat, calc_ecc); | ||
1036 | if (ret > 0) | 1048 | if (ret > 0) |
1037 | printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret); | 1049 | printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret); |
1038 | } | 1050 | } |
@@ -1060,10 +1072,10 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ | |||
1060 | * be able to handle out-of-order segments. | 1072 | * be able to handle out-of-order segments. |
1061 | */ | 1073 | */ |
1062 | static struct nand_oobinfo doc200x_oobinfo = { | 1074 | static struct nand_oobinfo doc200x_oobinfo = { |
1063 | .useecc = MTD_NANDECC_AUTOPLACE, | 1075 | .useecc = MTD_NANDECC_AUTOPLACE, |
1064 | .eccbytes = 6, | 1076 | .eccbytes = 6, |
1065 | .eccpos = {0, 1, 2, 3, 4, 5}, | 1077 | .eccpos = {0, 1, 2, 3, 4, 5}, |
1066 | .oobfree = { {8, 8}, {6, 2} } | 1078 | .oobfree = {{8, 8}, {6, 2}} |
1067 | }; | 1079 | }; |
1068 | 1080 | ||
1069 | /* Find the (I)NFTL Media Header, and optionally also the mirror media header. | 1081 | /* Find the (I)NFTL Media Header, and optionally also the mirror media header. |
@@ -1072,8 +1084,7 @@ static struct nand_oobinfo doc200x_oobinfo = { | |||
1072 | either "ANAND" or "BNAND". If findmirror=1, also look for the mirror media | 1084 | either "ANAND" or "BNAND". If findmirror=1, also look for the mirror media |
1073 | header. The page #s of the found media headers are placed in mh0_page and | 1085 | header. The page #s of the found media headers are placed in mh0_page and |
1074 | mh1_page in the DOC private structure. */ | 1086 | mh1_page in the DOC private structure. */ |
1075 | static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, | 1087 | static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const char *id, int findmirror) |
1076 | const char *id, int findmirror) | ||
1077 | { | 1088 | { |
1078 | struct nand_chip *this = mtd->priv; | 1089 | struct nand_chip *this = mtd->priv; |
1079 | struct doc_priv *doc = this->priv; | 1090 | struct doc_priv *doc = this->priv; |
@@ -1083,16 +1094,18 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, | |||
1083 | 1094 | ||
1084 | for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { | 1095 | for (offs = 0; offs < mtd->size; offs += mtd->erasesize) { |
1085 | ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); | 1096 | ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf); |
1086 | if (retlen != mtd->oobblock) continue; | 1097 | if (retlen != mtd->oobblock) |
1098 | continue; | ||
1087 | if (ret) { | 1099 | if (ret) { |
1088 | printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n", | 1100 | printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n", offs); |
1089 | offs); | ||
1090 | } | 1101 | } |
1091 | if (memcmp(buf, id, 6)) continue; | 1102 | if (memcmp(buf, id, 6)) |
1103 | continue; | ||
1092 | printk(KERN_INFO "Found DiskOnChip %s Media Header at 0x%x\n", id, offs); | 1104 | printk(KERN_INFO "Found DiskOnChip %s Media Header at 0x%x\n", id, offs); |
1093 | if (doc->mh0_page == -1) { | 1105 | if (doc->mh0_page == -1) { |
1094 | doc->mh0_page = offs >> this->page_shift; | 1106 | doc->mh0_page = offs >> this->page_shift; |
1095 | if (!findmirror) return 1; | 1107 | if (!findmirror) |
1108 | return 1; | ||
1096 | continue; | 1109 | continue; |
1097 | } | 1110 | } |
1098 | doc->mh1_page = offs >> this->page_shift; | 1111 | doc->mh1_page = offs >> this->page_shift; |
@@ -1114,8 +1127,7 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, | |||
1114 | return 1; | 1127 | return 1; |
1115 | } | 1128 | } |
1116 | 1129 | ||
1117 | static inline int __init nftl_partscan(struct mtd_info *mtd, | 1130 | static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts) |
1118 | struct mtd_partition *parts) | ||
1119 | { | 1131 | { |
1120 | struct nand_chip *this = mtd->priv; | 1132 | struct nand_chip *this = mtd->priv; |
1121 | struct doc_priv *doc = this->priv; | 1133 | struct doc_priv *doc = this->priv; |
@@ -1132,8 +1144,9 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, | |||
1132 | printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n"); | 1144 | printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n"); |
1133 | return 0; | 1145 | return 0; |
1134 | } | 1146 | } |
1135 | if (!(numheaders=find_media_headers(mtd, buf, "ANAND", 1))) goto out; | 1147 | if (!(numheaders = find_media_headers(mtd, buf, "ANAND", 1))) |
1136 | mh = (struct NFTLMediaHeader *) buf; | 1148 | goto out; |
1149 | mh = (struct NFTLMediaHeader *)buf; | ||
1137 | 1150 | ||
1138 | mh->NumEraseUnits = le16_to_cpu(mh->NumEraseUnits); | 1151 | mh->NumEraseUnits = le16_to_cpu(mh->NumEraseUnits); |
1139 | mh->FirstPhysicalEUN = le16_to_cpu(mh->FirstPhysicalEUN); | 1152 | mh->FirstPhysicalEUN = le16_to_cpu(mh->FirstPhysicalEUN); |
@@ -1155,8 +1168,8 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, | |||
1155 | /* Auto-determine UnitSizeFactor. The constraints are: | 1168 | /* Auto-determine UnitSizeFactor. The constraints are: |
1156 | - There can be at most 32768 virtual blocks. | 1169 | - There can be at most 32768 virtual blocks. |
1157 | - There can be at most (virtual block size - page size) | 1170 | - There can be at most (virtual block size - page size) |
1158 | virtual blocks (because MediaHeader+BBT must fit in 1). | 1171 | virtual blocks (because MediaHeader+BBT must fit in 1). |
1159 | */ | 1172 | */ |
1160 | mh->UnitSizeFactor = 0xff; | 1173 | mh->UnitSizeFactor = 0xff; |
1161 | while (blocks > maxblocks) { | 1174 | while (blocks > maxblocks) { |
1162 | blocks >>= 1; | 1175 | blocks >>= 1; |
@@ -1211,14 +1224,13 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, | |||
1211 | } | 1224 | } |
1212 | 1225 | ||
1213 | ret = numparts; | 1226 | ret = numparts; |
1214 | out: | 1227 | out: |
1215 | kfree(buf); | 1228 | kfree(buf); |
1216 | return ret; | 1229 | return ret; |
1217 | } | 1230 | } |
1218 | 1231 | ||
1219 | /* This is a stripped-down copy of the code in inftlmount.c */ | 1232 | /* This is a stripped-down copy of the code in inftlmount.c */ |
1220 | static inline int __init inftl_partscan(struct mtd_info *mtd, | 1233 | static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts) |
1221 | struct mtd_partition *parts) | ||
1222 | { | 1234 | { |
1223 | struct nand_chip *this = mtd->priv; | 1235 | struct nand_chip *this = mtd->priv; |
1224 | struct doc_priv *doc = this->priv; | 1236 | struct doc_priv *doc = this->priv; |
@@ -1241,9 +1253,10 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, | |||
1241 | return 0; | 1253 | return 0; |
1242 | } | 1254 | } |
1243 | 1255 | ||
1244 | if (!find_media_headers(mtd, buf, "BNAND", 0)) goto out; | 1256 | if (!find_media_headers(mtd, buf, "BNAND", 0)) |
1257 | goto out; | ||
1245 | doc->mh1_page = doc->mh0_page + (4096 >> this->page_shift); | 1258 | doc->mh1_page = doc->mh0_page + (4096 >> this->page_shift); |
1246 | mh = (struct INFTLMediaHeader *) buf; | 1259 | mh = (struct INFTLMediaHeader *)buf; |
1247 | 1260 | ||
1248 | mh->NoOfBootImageBlocks = le32_to_cpu(mh->NoOfBootImageBlocks); | 1261 | mh->NoOfBootImageBlocks = le32_to_cpu(mh->NoOfBootImageBlocks); |
1249 | mh->NoOfBinaryPartitions = le32_to_cpu(mh->NoOfBinaryPartitions); | 1262 | mh->NoOfBinaryPartitions = le32_to_cpu(mh->NoOfBinaryPartitions); |
@@ -1319,8 +1332,10 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, | |||
1319 | parts[numparts].offset = ip->firstUnit << vshift; | 1332 | parts[numparts].offset = ip->firstUnit << vshift; |
1320 | parts[numparts].size = (1 + ip->lastUnit - ip->firstUnit) << vshift; | 1333 | parts[numparts].size = (1 + ip->lastUnit - ip->firstUnit) << vshift; |
1321 | numparts++; | 1334 | numparts++; |
1322 | if (ip->lastUnit > lastvunit) lastvunit = ip->lastUnit; | 1335 | if (ip->lastUnit > lastvunit) |
1323 | if (ip->flags & INFTL_LAST) break; | 1336 | lastvunit = ip->lastUnit; |
1337 | if (ip->flags & INFTL_LAST) | ||
1338 | break; | ||
1324 | } | 1339 | } |
1325 | lastvunit++; | 1340 | lastvunit++; |
1326 | if ((lastvunit << vshift) < end) { | 1341 | if ((lastvunit << vshift) < end) { |
@@ -1330,7 +1345,7 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, | |||
1330 | numparts++; | 1345 | numparts++; |
1331 | } | 1346 | } |
1332 | ret = numparts; | 1347 | ret = numparts; |
1333 | out: | 1348 | out: |
1334 | kfree(buf); | 1349 | kfree(buf); |
1335 | return ret; | 1350 | return ret; |
1336 | } | 1351 | } |
@@ -1342,11 +1357,12 @@ static int __init nftl_scan_bbt(struct mtd_info *mtd) | |||
1342 | struct doc_priv *doc = this->priv; | 1357 | struct doc_priv *doc = this->priv; |
1343 | struct mtd_partition parts[2]; | 1358 | struct mtd_partition parts[2]; |
1344 | 1359 | ||
1345 | memset((char *) parts, 0, sizeof(parts)); | 1360 | memset((char *)parts, 0, sizeof(parts)); |
1346 | /* On NFTL, we have to find the media headers before we can read the | 1361 | /* On NFTL, we have to find the media headers before we can read the |
1347 | BBTs, since they're stored in the media header eraseblocks. */ | 1362 | BBTs, since they're stored in the media header eraseblocks. */ |
1348 | numparts = nftl_partscan(mtd, parts); | 1363 | numparts = nftl_partscan(mtd, parts); |
1349 | if (!numparts) return -EIO; | 1364 | if (!numparts) |
1365 | return -EIO; | ||
1350 | this->bbt_td->options = NAND_BBT_ABSPAGE | NAND_BBT_8BIT | | 1366 | this->bbt_td->options = NAND_BBT_ABSPAGE | NAND_BBT_8BIT | |
1351 | NAND_BBT_SAVECONTENT | NAND_BBT_WRITE | | 1367 | NAND_BBT_SAVECONTENT | NAND_BBT_WRITE | |
1352 | NAND_BBT_VERSION; | 1368 | NAND_BBT_VERSION; |
@@ -1393,8 +1409,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) | |||
1393 | this->bbt_td->pages[0] = 2; | 1409 | this->bbt_td->pages[0] = 2; |
1394 | this->bbt_md = NULL; | 1410 | this->bbt_md = NULL; |
1395 | } else { | 1411 | } else { |
1396 | this->bbt_td->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | | 1412 | this->bbt_td->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | NAND_BBT_VERSION; |
1397 | NAND_BBT_VERSION; | ||
1398 | if (inftl_bbt_write) | 1413 | if (inftl_bbt_write) |
1399 | this->bbt_td->options |= NAND_BBT_WRITE; | 1414 | this->bbt_td->options |= NAND_BBT_WRITE; |
1400 | this->bbt_td->offs = 8; | 1415 | this->bbt_td->offs = 8; |
@@ -1404,8 +1419,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) | |||
1404 | this->bbt_td->reserved_block_code = 0x01; | 1419 | this->bbt_td->reserved_block_code = 0x01; |
1405 | this->bbt_td->pattern = "MSYS_BBT"; | 1420 | this->bbt_td->pattern = "MSYS_BBT"; |
1406 | 1421 | ||
1407 | this->bbt_md->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | | 1422 | this->bbt_md->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | NAND_BBT_VERSION; |
1408 | NAND_BBT_VERSION; | ||
1409 | if (inftl_bbt_write) | 1423 | if (inftl_bbt_write) |
1410 | this->bbt_md->options |= NAND_BBT_WRITE; | 1424 | this->bbt_md->options |= NAND_BBT_WRITE; |
1411 | this->bbt_md->offs = 8; | 1425 | this->bbt_md->offs = 8; |
@@ -1420,12 +1434,13 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) | |||
1420 | At least as nand_bbt.c is currently written. */ | 1434 | At least as nand_bbt.c is currently written. */ |
1421 | if ((ret = nand_scan_bbt(mtd, NULL))) | 1435 | if ((ret = nand_scan_bbt(mtd, NULL))) |
1422 | return ret; | 1436 | return ret; |
1423 | memset((char *) parts, 0, sizeof(parts)); | 1437 | memset((char *)parts, 0, sizeof(parts)); |
1424 | numparts = inftl_partscan(mtd, parts); | 1438 | numparts = inftl_partscan(mtd, parts); |
1425 | /* At least for now, require the INFTL Media Header. We could probably | 1439 | /* At least for now, require the INFTL Media Header. We could probably |
1426 | do without it for non-INFTL use, since all it gives us is | 1440 | do without it for non-INFTL use, since all it gives us is |
1427 | autopartitioning, but I want to give it more thought. */ | 1441 | autopartitioning, but I want to give it more thought. */ |
1428 | if (!numparts) return -EIO; | 1442 | if (!numparts) |
1443 | return -EIO; | ||
1429 | add_mtd_device(mtd); | 1444 | add_mtd_device(mtd); |
1430 | #ifdef CONFIG_MTD_PARTITIONS | 1445 | #ifdef CONFIG_MTD_PARTITIONS |
1431 | if (!no_autopart) | 1446 | if (!no_autopart) |
@@ -1535,20 +1550,16 @@ static int __init doc_probe(unsigned long physadr) | |||
1535 | save_control = ReadDOC(virtadr, DOCControl); | 1550 | save_control = ReadDOC(virtadr, DOCControl); |
1536 | 1551 | ||
1537 | /* Reset the DiskOnChip ASIC */ | 1552 | /* Reset the DiskOnChip ASIC */ |
1538 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, | 1553 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, virtadr, DOCControl); |
1539 | virtadr, DOCControl); | 1554 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, virtadr, DOCControl); |
1540 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, | ||
1541 | virtadr, DOCControl); | ||
1542 | 1555 | ||
1543 | /* Enable the DiskOnChip ASIC */ | 1556 | /* Enable the DiskOnChip ASIC */ |
1544 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, | 1557 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, virtadr, DOCControl); |
1545 | virtadr, DOCControl); | 1558 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, virtadr, DOCControl); |
1546 | WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, | ||
1547 | virtadr, DOCControl); | ||
1548 | 1559 | ||
1549 | ChipID = ReadDOC(virtadr, ChipID); | 1560 | ChipID = ReadDOC(virtadr, ChipID); |
1550 | 1561 | ||
1551 | switch(ChipID) { | 1562 | switch (ChipID) { |
1552 | case DOC_ChipID_Doc2k: | 1563 | case DOC_ChipID_Doc2k: |
1553 | reg = DoC_2k_ECCStatus; | 1564 | reg = DoC_2k_ECCStatus; |
1554 | break; | 1565 | break; |
@@ -1564,15 +1575,13 @@ static int __init doc_probe(unsigned long physadr) | |||
1564 | ReadDOC(virtadr, Mplus_Power); | 1575 | ReadDOC(virtadr, Mplus_Power); |
1565 | 1576 | ||
1566 | /* Reset the Millennium Plus ASIC */ | 1577 | /* Reset the Millennium Plus ASIC */ |
1567 | tmp = DOC_MODE_RESET | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | | 1578 | tmp = DOC_MODE_RESET | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | DOC_MODE_BDECT; |
1568 | DOC_MODE_BDECT; | ||
1569 | WriteDOC(tmp, virtadr, Mplus_DOCControl); | 1579 | WriteDOC(tmp, virtadr, Mplus_DOCControl); |
1570 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); | 1580 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); |
1571 | 1581 | ||
1572 | mdelay(1); | 1582 | mdelay(1); |
1573 | /* Enable the Millennium Plus ASIC */ | 1583 | /* Enable the Millennium Plus ASIC */ |
1574 | tmp = DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | | 1584 | tmp = DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | DOC_MODE_BDECT; |
1575 | DOC_MODE_BDECT; | ||
1576 | WriteDOC(tmp, virtadr, Mplus_DOCControl); | 1585 | WriteDOC(tmp, virtadr, Mplus_DOCControl); |
1577 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); | 1586 | WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm); |
1578 | mdelay(1); | 1587 | mdelay(1); |
@@ -1596,7 +1605,7 @@ static int __init doc_probe(unsigned long physadr) | |||
1596 | goto notfound; | 1605 | goto notfound; |
1597 | } | 1606 | } |
1598 | /* Check the TOGGLE bit in the ECC register */ | 1607 | /* Check the TOGGLE bit in the ECC register */ |
1599 | tmp = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; | 1608 | tmp = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; |
1600 | tmpb = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; | 1609 | tmpb = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; |
1601 | tmpc = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; | 1610 | tmpc = ReadDOC_(virtadr, reg) & DOC_TOGGLE_BIT; |
1602 | if ((tmp == tmpb) || (tmp != tmpc)) { | 1611 | if ((tmp == tmpb) || (tmp != tmpc)) { |
@@ -1626,11 +1635,11 @@ static int __init doc_probe(unsigned long physadr) | |||
1626 | if (ChipID == DOC_ChipID_DocMilPlus16) { | 1635 | if (ChipID == DOC_ChipID_DocMilPlus16) { |
1627 | WriteDOC(~newval, virtadr, Mplus_AliasResolution); | 1636 | WriteDOC(~newval, virtadr, Mplus_AliasResolution); |
1628 | oldval = ReadDOC(doc->virtadr, Mplus_AliasResolution); | 1637 | oldval = ReadDOC(doc->virtadr, Mplus_AliasResolution); |
1629 | WriteDOC(newval, virtadr, Mplus_AliasResolution); // restore it | 1638 | WriteDOC(newval, virtadr, Mplus_AliasResolution); // restore it |
1630 | } else { | 1639 | } else { |
1631 | WriteDOC(~newval, virtadr, AliasResolution); | 1640 | WriteDOC(~newval, virtadr, AliasResolution); |
1632 | oldval = ReadDOC(doc->virtadr, AliasResolution); | 1641 | oldval = ReadDOC(doc->virtadr, AliasResolution); |
1633 | WriteDOC(newval, virtadr, AliasResolution); // restore it | 1642 | WriteDOC(newval, virtadr, AliasResolution); // restore it |
1634 | } | 1643 | } |
1635 | newval = ~newval; | 1644 | newval = ~newval; |
1636 | if (oldval == newval) { | 1645 | if (oldval == newval) { |
@@ -1642,10 +1651,8 @@ static int __init doc_probe(unsigned long physadr) | |||
1642 | printk(KERN_NOTICE "DiskOnChip found at 0x%lx\n", physadr); | 1651 | printk(KERN_NOTICE "DiskOnChip found at 0x%lx\n", physadr); |
1643 | 1652 | ||
1644 | len = sizeof(struct mtd_info) + | 1653 | len = sizeof(struct mtd_info) + |
1645 | sizeof(struct nand_chip) + | 1654 | sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr)); |
1646 | sizeof(struct doc_priv) + | 1655 | mtd = kmalloc(len, GFP_KERNEL); |
1647 | (2 * sizeof(struct nand_bbt_descr)); | ||
1648 | mtd = kmalloc(len, GFP_KERNEL); | ||
1649 | if (!mtd) { | 1656 | if (!mtd) { |
1650 | printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); | 1657 | printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); |
1651 | ret = -ENOMEM; | 1658 | ret = -ENOMEM; |
@@ -1707,18 +1714,18 @@ static int __init doc_probe(unsigned long physadr) | |||
1707 | doclist = mtd; | 1714 | doclist = mtd; |
1708 | return 0; | 1715 | return 0; |
1709 | 1716 | ||
1710 | notfound: | 1717 | notfound: |
1711 | /* Put back the contents of the DOCControl register, in case it's not | 1718 | /* Put back the contents of the DOCControl register, in case it's not |
1712 | actually a DiskOnChip. */ | 1719 | actually a DiskOnChip. */ |
1713 | WriteDOC(save_control, virtadr, DOCControl); | 1720 | WriteDOC(save_control, virtadr, DOCControl); |
1714 | fail: | 1721 | fail: |
1715 | iounmap(virtadr); | 1722 | iounmap(virtadr); |
1716 | return ret; | 1723 | return ret; |
1717 | } | 1724 | } |
1718 | 1725 | ||
1719 | static void release_nanddoc(void) | 1726 | static void release_nanddoc(void) |
1720 | { | 1727 | { |
1721 | struct mtd_info *mtd, *nextmtd; | 1728 | struct mtd_info *mtd, *nextmtd; |
1722 | struct nand_chip *nand; | 1729 | struct nand_chip *nand; |
1723 | struct doc_priv *doc; | 1730 | struct doc_priv *doc; |
1724 | 1731 | ||
@@ -1747,8 +1754,8 @@ static int __init init_nanddoc(void) | |||
1747 | * generator polinomial degree = 4 | 1754 | * generator polinomial degree = 4 |
1748 | */ | 1755 | */ |
1749 | rs_decoder = init_rs(10, 0x409, FCR, 1, NROOTS); | 1756 | rs_decoder = init_rs(10, 0x409, FCR, 1, NROOTS); |
1750 | if (!rs_decoder) { | 1757 | if (!rs_decoder) { |
1751 | printk (KERN_ERR "DiskOnChip: Could not create a RS decoder\n"); | 1758 | printk(KERN_ERR "DiskOnChip: Could not create a RS decoder\n"); |
1752 | return -ENOMEM; | 1759 | return -ENOMEM; |
1753 | } | 1760 | } |
1754 | 1761 | ||
@@ -1758,7 +1765,7 @@ static int __init init_nanddoc(void) | |||
1758 | if (ret < 0) | 1765 | if (ret < 0) |
1759 | goto outerr; | 1766 | goto outerr; |
1760 | } else { | 1767 | } else { |
1761 | for (i=0; (doc_locations[i] != 0xffffffff); i++) { | 1768 | for (i = 0; (doc_locations[i] != 0xffffffff); i++) { |
1762 | doc_probe(doc_locations[i]); | 1769 | doc_probe(doc_locations[i]); |
1763 | } | 1770 | } |
1764 | } | 1771 | } |
@@ -1770,7 +1777,7 @@ static int __init init_nanddoc(void) | |||
1770 | goto outerr; | 1777 | goto outerr; |
1771 | } | 1778 | } |
1772 | return 0; | 1779 | return 0; |
1773 | outerr: | 1780 | outerr: |
1774 | free_rs(rs_decoder); | 1781 | free_rs(rs_decoder); |
1775 | return ret; | 1782 | return ret; |
1776 | } | 1783 | } |
diff --git a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c index 9b1fd2f387fa..8e56570af91f 100644 --- a/drivers/mtd/nand/edb7312.c +++ b/drivers/mtd/nand/edb7312.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/mtd/nand/edb7312.c | 2 | * drivers/mtd/nand/edb7312.c |
3 | * | 3 | * |
4 | * Copyright (C) 2002 Marius Gröger (mag@sysgo.de) | 4 | * Copyright (C) 2002 Marius Gröger (mag@sysgo.de) |
5 | * | 5 | * |
6 | * Derived from drivers/mtd/nand/autcpu12.c | 6 | * Derived from drivers/mtd/nand/autcpu12.c |
7 | * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) | 7 | * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) |
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/mtd/nand.h> | 25 | #include <linux/mtd/nand.h> |
26 | #include <linux/mtd/partitions.h> | 26 | #include <linux/mtd/partitions.h> |
27 | #include <asm/io.h> | 27 | #include <asm/io.h> |
28 | #include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */ | 28 | #include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */ |
29 | #include <asm/sizes.h> | 29 | #include <asm/sizes.h> |
30 | #include <asm/hardware/clps7111.h> | 30 | #include <asm/hardware/clps7111.h> |
31 | 31 | ||
@@ -54,29 +54,29 @@ static struct mtd_info *ep7312_mtd = NULL; | |||
54 | */ | 54 | */ |
55 | 55 | ||
56 | static unsigned long ep7312_fio_pbase = EP7312_FIO_PBASE; | 56 | static unsigned long ep7312_fio_pbase = EP7312_FIO_PBASE; |
57 | static void __iomem * ep7312_pxdr = (void __iomem *) EP7312_PXDR; | 57 | static void __iomem *ep7312_pxdr = (void __iomem *)EP7312_PXDR; |
58 | static void __iomem * ep7312_pxddr = (void __iomem *) EP7312_PXDDR; | 58 | static void __iomem *ep7312_pxddr = (void __iomem *)EP7312_PXDDR; |
59 | 59 | ||
60 | #ifdef CONFIG_MTD_PARTITIONS | 60 | #ifdef CONFIG_MTD_PARTITIONS |
61 | /* | 61 | /* |
62 | * Define static partitions for flash device | 62 | * Define static partitions for flash device |
63 | */ | 63 | */ |
64 | static struct mtd_partition partition_info[] = { | 64 | static struct mtd_partition partition_info[] = { |
65 | { .name = "EP7312 Nand Flash", | 65 | {.name = "EP7312 Nand Flash", |
66 | .offset = 0, | 66 | .offset = 0, |
67 | .size = 8*1024*1024 } | 67 | .size = 8 * 1024 * 1024} |
68 | }; | 68 | }; |
69 | |||
69 | #define NUM_PARTITIONS 1 | 70 | #define NUM_PARTITIONS 1 |
70 | 71 | ||
71 | #endif | 72 | #endif |
72 | 73 | ||
73 | |||
74 | /* | 74 | /* |
75 | * hardware specific access to control-lines | 75 | * hardware specific access to control-lines |
76 | */ | 76 | */ |
77 | static void ep7312_hwcontrol(struct mtd_info *mtd, int cmd) | 77 | static void ep7312_hwcontrol(struct mtd_info *mtd, int cmd) |
78 | { | 78 | { |
79 | switch(cmd) { | 79 | switch (cmd) { |
80 | 80 | ||
81 | case NAND_CTL_SETCLE: | 81 | case NAND_CTL_SETCLE: |
82 | clps_writeb(clps_readb(ep7312_pxdr) | 0x10, ep7312_pxdr); | 82 | clps_writeb(clps_readb(ep7312_pxdr) | 0x10, ep7312_pxdr); |
@@ -108,6 +108,7 @@ static int ep7312_device_ready(struct mtd_info *mtd) | |||
108 | { | 108 | { |
109 | return 1; | 109 | return 1; |
110 | } | 110 | } |
111 | |||
111 | #ifdef CONFIG_MTD_PARTITIONS | 112 | #ifdef CONFIG_MTD_PARTITIONS |
112 | const char *part_probes[] = { "cmdlinepart", NULL }; | 113 | const char *part_probes[] = { "cmdlinepart", NULL }; |
113 | #endif | 114 | #endif |
@@ -115,18 +116,16 @@ const char *part_probes[] = { "cmdlinepart", NULL }; | |||
115 | /* | 116 | /* |
116 | * Main initialization routine | 117 | * Main initialization routine |
117 | */ | 118 | */ |
118 | static int __init ep7312_init (void) | 119 | static int __init ep7312_init(void) |
119 | { | 120 | { |
120 | struct nand_chip *this; | 121 | struct nand_chip *this; |
121 | const char *part_type = 0; | 122 | const char *part_type = 0; |
122 | int mtd_parts_nb = 0; | 123 | int mtd_parts_nb = 0; |
123 | struct mtd_partition *mtd_parts = 0; | 124 | struct mtd_partition *mtd_parts = 0; |
124 | void __iomem * ep7312_fio_base; | 125 | void __iomem *ep7312_fio_base; |
125 | 126 | ||
126 | /* Allocate memory for MTD device structure and private data */ | 127 | /* Allocate memory for MTD device structure and private data */ |
127 | ep7312_mtd = kmalloc(sizeof(struct mtd_info) + | 128 | ep7312_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
128 | sizeof(struct nand_chip), | ||
129 | GFP_KERNEL); | ||
130 | if (!ep7312_mtd) { | 129 | if (!ep7312_mtd) { |
131 | printk("Unable to allocate EDB7312 NAND MTD device structure.\n"); | 130 | printk("Unable to allocate EDB7312 NAND MTD device structure.\n"); |
132 | return -ENOMEM; | 131 | return -ENOMEM; |
@@ -134,21 +133,22 @@ static int __init ep7312_init (void) | |||
134 | 133 | ||
135 | /* map physical adress */ | 134 | /* map physical adress */ |
136 | ep7312_fio_base = ioremap(ep7312_fio_pbase, SZ_1K); | 135 | ep7312_fio_base = ioremap(ep7312_fio_pbase, SZ_1K); |
137 | if(!ep7312_fio_base) { | 136 | if (!ep7312_fio_base) { |
138 | printk("ioremap EDB7312 NAND flash failed\n"); | 137 | printk("ioremap EDB7312 NAND flash failed\n"); |
139 | kfree(ep7312_mtd); | 138 | kfree(ep7312_mtd); |
140 | return -EIO; | 139 | return -EIO; |
141 | } | 140 | } |
142 | 141 | ||
143 | /* Get pointer to private data */ | 142 | /* Get pointer to private data */ |
144 | this = (struct nand_chip *) (&ep7312_mtd[1]); | 143 | this = (struct nand_chip *)(&ep7312_mtd[1]); |
145 | 144 | ||
146 | /* Initialize structures */ | 145 | /* Initialize structures */ |
147 | memset((char *) ep7312_mtd, 0, sizeof(struct mtd_info)); | 146 | memset(ep7312_mtd, 0, sizeof(struct mtd_info)); |
148 | memset((char *) this, 0, sizeof(struct nand_chip)); | 147 | memset(this, 0, sizeof(struct nand_chip)); |
149 | 148 | ||
150 | /* Link the private data with the MTD structure */ | 149 | /* Link the private data with the MTD structure */ |
151 | ep7312_mtd->priv = this; | 150 | ep7312_mtd->priv = this; |
151 | ep7312_mtd->owner = THIS_MODULE; | ||
152 | 152 | ||
153 | /* | 153 | /* |
154 | * Set GPIO Port B control register so that the pins are configured | 154 | * Set GPIO Port B control register so that the pins are configured |
@@ -165,16 +165,14 @@ static int __init ep7312_init (void) | |||
165 | this->chip_delay = 15; | 165 | this->chip_delay = 15; |
166 | 166 | ||
167 | /* Scan to find existence of the device */ | 167 | /* Scan to find existence of the device */ |
168 | if (nand_scan (ep7312_mtd, 1)) { | 168 | if (nand_scan(ep7312_mtd, 1)) { |
169 | iounmap((void *)ep7312_fio_base); | 169 | iounmap((void *)ep7312_fio_base); |
170 | kfree (ep7312_mtd); | 170 | kfree(ep7312_mtd); |
171 | return -ENXIO; | 171 | return -ENXIO; |
172 | } | 172 | } |
173 | |||
174 | #ifdef CONFIG_MTD_PARTITIONS | 173 | #ifdef CONFIG_MTD_PARTITIONS |
175 | ep7312_mtd->name = "edb7312-nand"; | 174 | ep7312_mtd->name = "edb7312-nand"; |
176 | mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, part_probes, | 175 | mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, part_probes, &mtd_parts, 0); |
177 | &mtd_parts, 0); | ||
178 | if (mtd_parts_nb > 0) | 176 | if (mtd_parts_nb > 0) |
179 | part_type = "command line"; | 177 | part_type = "command line"; |
180 | else | 178 | else |
@@ -193,24 +191,26 @@ static int __init ep7312_init (void) | |||
193 | /* Return happy */ | 191 | /* Return happy */ |
194 | return 0; | 192 | return 0; |
195 | } | 193 | } |
194 | |||
196 | module_init(ep7312_init); | 195 | module_init(ep7312_init); |
197 | 196 | ||
198 | /* | 197 | /* |
199 | * Clean up routine | 198 | * Clean up routine |
200 | */ | 199 | */ |
201 | static void __exit ep7312_cleanup (void) | 200 | static void __exit ep7312_cleanup(void) |
202 | { | 201 | { |
203 | struct nand_chip *this = (struct nand_chip *) &ep7312_mtd[1]; | 202 | struct nand_chip *this = (struct nand_chip *)&ep7312_mtd[1]; |
204 | 203 | ||
205 | /* Release resources, unregister device */ | 204 | /* Release resources, unregister device */ |
206 | nand_release (ap7312_mtd); | 205 | nand_release(ap7312_mtd); |
207 | 206 | ||
208 | /* Free internal data buffer */ | 207 | /* Free internal data buffer */ |
209 | kfree (this->data_buf); | 208 | kfree(this->data_buf); |
210 | 209 | ||
211 | /* Free the MTD device structure */ | 210 | /* Free the MTD device structure */ |
212 | kfree (ep7312_mtd); | 211 | kfree(ep7312_mtd); |
213 | } | 212 | } |
213 | |||
214 | module_exit(ep7312_cleanup); | 214 | module_exit(ep7312_cleanup); |
215 | 215 | ||
216 | MODULE_LICENSE("GPL"); | 216 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mtd/nand/h1910.c b/drivers/mtd/nand/h1910.c index f68f7a99a630..9848eb09b884 100644 --- a/drivers/mtd/nand/h1910.c +++ b/drivers/mtd/nand/h1910.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Copyright (C) 2003 Joshua Wise (joshua@joshuawise.com) | 4 | * Copyright (C) 2003 Joshua Wise (joshua@joshuawise.com) |
5 | * | 5 | * |
6 | * Derived from drivers/mtd/nand/edb7312.c | 6 | * Derived from drivers/mtd/nand/edb7312.c |
7 | * Copyright (C) 2002 Marius Gröger (mag@sysgo.de) | 7 | * Copyright (C) 2002 Marius Gröger (mag@sysgo.de) |
8 | * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) | 8 | * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) |
9 | * | 9 | * |
10 | * $Id: h1910.c,v 1.6 2005/11/07 11:14:30 gleixner Exp $ | 10 | * $Id: h1910.c,v 1.6 2005/11/07 11:14:30 gleixner Exp $ |
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/mtd/nand.h> | 26 | #include <linux/mtd/nand.h> |
27 | #include <linux/mtd/partitions.h> | 27 | #include <linux/mtd/partitions.h> |
28 | #include <asm/io.h> | 28 | #include <asm/io.h> |
29 | #include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */ | 29 | #include <asm/arch/hardware.h> /* for CLPS7111_VIRT_BASE */ |
30 | #include <asm/sizes.h> | 30 | #include <asm/sizes.h> |
31 | #include <asm/arch/h1900-gpio.h> | 31 | #include <asm/arch/h1900-gpio.h> |
32 | #include <asm/arch/ipaq.h> | 32 | #include <asm/arch/ipaq.h> |
@@ -45,23 +45,23 @@ static struct mtd_info *h1910_nand_mtd = NULL; | |||
45 | * Define static partitions for flash device | 45 | * Define static partitions for flash device |
46 | */ | 46 | */ |
47 | static struct mtd_partition partition_info[] = { | 47 | static struct mtd_partition partition_info[] = { |
48 | { name: "h1910 NAND Flash", | 48 | {name:"h1910 NAND Flash", |
49 | offset: 0, | 49 | offset:0, |
50 | size: 16*1024*1024 } | 50 | size:16 * 1024 * 1024} |
51 | }; | 51 | }; |
52 | |||
52 | #define NUM_PARTITIONS 1 | 53 | #define NUM_PARTITIONS 1 |
53 | 54 | ||
54 | #endif | 55 | #endif |
55 | 56 | ||
56 | |||
57 | /* | 57 | /* |
58 | * hardware specific access to control-lines | 58 | * hardware specific access to control-lines |
59 | */ | 59 | */ |
60 | static void h1910_hwcontrol(struct mtd_info *mtd, int cmd) | 60 | static void h1910_hwcontrol(struct mtd_info *mtd, int cmd) |
61 | { | 61 | { |
62 | struct nand_chip* this = (struct nand_chip *) (mtd->priv); | 62 | struct nand_chip *this = (struct nand_chip *)(mtd->priv); |
63 | 63 | ||
64 | switch(cmd) { | 64 | switch (cmd) { |
65 | 65 | ||
66 | case NAND_CTL_SETCLE: | 66 | case NAND_CTL_SETCLE: |
67 | this->IO_ADDR_R |= (1 << 2); | 67 | this->IO_ADDR_R |= (1 << 2); |
@@ -101,7 +101,7 @@ static int h1910_device_ready(struct mtd_info *mtd) | |||
101 | /* | 101 | /* |
102 | * Main initialization routine | 102 | * Main initialization routine |
103 | */ | 103 | */ |
104 | static int __init h1910_init (void) | 104 | static int __init h1910_init(void) |
105 | { | 105 | { |
106 | struct nand_chip *this; | 106 | struct nand_chip *this; |
107 | const char *part_type = 0; | 107 | const char *part_type = 0; |
@@ -119,24 +119,23 @@ static int __init h1910_init (void) | |||
119 | } | 119 | } |
120 | 120 | ||
121 | /* Allocate memory for MTD device structure and private data */ | 121 | /* Allocate memory for MTD device structure and private data */ |
122 | h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) + | 122 | h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
123 | sizeof(struct nand_chip), | ||
124 | GFP_KERNEL); | ||
125 | if (!h1910_nand_mtd) { | 123 | if (!h1910_nand_mtd) { |
126 | printk("Unable to allocate h1910 NAND MTD device structure.\n"); | 124 | printk("Unable to allocate h1910 NAND MTD device structure.\n"); |
127 | iounmap ((void *) nandaddr); | 125 | iounmap((void *)nandaddr); |
128 | return -ENOMEM; | 126 | return -ENOMEM; |
129 | } | 127 | } |
130 | 128 | ||
131 | /* Get pointer to private data */ | 129 | /* Get pointer to private data */ |
132 | this = (struct nand_chip *) (&h1910_nand_mtd[1]); | 130 | this = (struct nand_chip *)(&h1910_nand_mtd[1]); |
133 | 131 | ||
134 | /* Initialize structures */ | 132 | /* Initialize structures */ |
135 | memset((char *) h1910_nand_mtd, 0, sizeof(struct mtd_info)); | 133 | memset(h1910_nand_mtd, 0, sizeof(struct mtd_info)); |
136 | memset((char *) this, 0, sizeof(struct nand_chip)); | 134 | memset(this, 0, sizeof(struct nand_chip)); |
137 | 135 | ||
138 | /* Link the private data with the MTD structure */ | 136 | /* Link the private data with the MTD structure */ |
139 | h1910_nand_mtd->priv = this; | 137 | h1910_nand_mtd->priv = this; |
138 | h1910_nand_mtd->owner = THIS_MODULE; | ||
140 | 139 | ||
141 | /* | 140 | /* |
142 | * Enable VPEN | 141 | * Enable VPEN |
@@ -154,23 +153,20 @@ static int __init h1910_init (void) | |||
154 | this->options = NAND_NO_AUTOINCR; | 153 | this->options = NAND_NO_AUTOINCR; |
155 | 154 | ||
156 | /* Scan to find existence of the device */ | 155 | /* Scan to find existence of the device */ |
157 | if (nand_scan (h1910_nand_mtd, 1)) { | 156 | if (nand_scan(h1910_nand_mtd, 1)) { |
158 | printk(KERN_NOTICE "No NAND device - returning -ENXIO\n"); | 157 | printk(KERN_NOTICE "No NAND device - returning -ENXIO\n"); |
159 | kfree (h1910_nand_mtd); | 158 | kfree(h1910_nand_mtd); |
160 | iounmap ((void *) nandaddr); | 159 | iounmap((void *)nandaddr); |
161 | return -ENXIO; | 160 | return -ENXIO; |
162 | } | 161 | } |
163 | |||
164 | #ifdef CONFIG_MTD_CMDLINE_PARTS | 162 | #ifdef CONFIG_MTD_CMDLINE_PARTS |
165 | mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts, | 163 | mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts, "h1910-nand"); |
166 | "h1910-nand"); | ||
167 | if (mtd_parts_nb > 0) | 164 | if (mtd_parts_nb > 0) |
168 | part_type = "command line"; | 165 | part_type = "command line"; |
169 | else | 166 | else |
170 | mtd_parts_nb = 0; | 167 | mtd_parts_nb = 0; |
171 | #endif | 168 | #endif |
172 | if (mtd_parts_nb == 0) | 169 | if (mtd_parts_nb == 0) { |
173 | { | ||
174 | mtd_parts = partition_info; | 170 | mtd_parts = partition_info; |
175 | mtd_parts_nb = NUM_PARTITIONS; | 171 | mtd_parts_nb = NUM_PARTITIONS; |
176 | part_type = "static"; | 172 | part_type = "static"; |
@@ -183,24 +179,26 @@ static int __init h1910_init (void) | |||
183 | /* Return happy */ | 179 | /* Return happy */ |
184 | return 0; | 180 | return 0; |
185 | } | 181 | } |
182 | |||
186 | module_init(h1910_init); | 183 | module_init(h1910_init); |
187 | 184 | ||
188 | /* | 185 | /* |
189 | * Clean up routine | 186 | * Clean up routine |
190 | */ | 187 | */ |
191 | static void __exit h1910_cleanup (void) | 188 | static void __exit h1910_cleanup(void) |
192 | { | 189 | { |
193 | struct nand_chip *this = (struct nand_chip *) &h1910_nand_mtd[1]; | 190 | struct nand_chip *this = (struct nand_chip *)&h1910_nand_mtd[1]; |
194 | 191 | ||
195 | /* Release resources, unregister device */ | 192 | /* Release resources, unregister device */ |
196 | nand_release (h1910_nand_mtd); | 193 | nand_release(h1910_nand_mtd); |
197 | 194 | ||
198 | /* Release io resource */ | 195 | /* Release io resource */ |
199 | iounmap ((void *) this->IO_ADDR_W); | 196 | iounmap((void *)this->IO_ADDR_W); |
200 | 197 | ||
201 | /* Free the MTD device structure */ | 198 | /* Free the MTD device structure */ |
202 | kfree (h1910_nand_mtd); | 199 | kfree(h1910_nand_mtd); |
203 | } | 200 | } |
201 | |||
204 | module_exit(h1910_cleanup); | 202 | module_exit(h1910_cleanup); |
205 | 203 | ||
206 | MODULE_LICENSE("GPL"); | 204 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 95e96fa1fceb..08dffb7a9389 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -69,6 +69,7 @@ | |||
69 | * | 69 | * |
70 | */ | 70 | */ |
71 | 71 | ||
72 | #include <linux/module.h> | ||
72 | #include <linux/delay.h> | 73 | #include <linux/delay.h> |
73 | #include <linux/errno.h> | 74 | #include <linux/errno.h> |
74 | #include <linux/sched.h> | 75 | #include <linux/sched.h> |
@@ -92,24 +93,24 @@ static struct nand_oobinfo nand_oob_8 = { | |||
92 | .useecc = MTD_NANDECC_AUTOPLACE, | 93 | .useecc = MTD_NANDECC_AUTOPLACE, |
93 | .eccbytes = 3, | 94 | .eccbytes = 3, |
94 | .eccpos = {0, 1, 2}, | 95 | .eccpos = {0, 1, 2}, |
95 | .oobfree = { {3, 2}, {6, 2} } | 96 | .oobfree = {{3, 2}, {6, 2}} |
96 | }; | 97 | }; |
97 | 98 | ||
98 | static struct nand_oobinfo nand_oob_16 = { | 99 | static struct nand_oobinfo nand_oob_16 = { |
99 | .useecc = MTD_NANDECC_AUTOPLACE, | 100 | .useecc = MTD_NANDECC_AUTOPLACE, |
100 | .eccbytes = 6, | 101 | .eccbytes = 6, |
101 | .eccpos = {0, 1, 2, 3, 6, 7}, | 102 | .eccpos = {0, 1, 2, 3, 6, 7}, |
102 | .oobfree = { {8, 8} } | 103 | .oobfree = {{8, 8}} |
103 | }; | 104 | }; |
104 | 105 | ||
105 | static struct nand_oobinfo nand_oob_64 = { | 106 | static struct nand_oobinfo nand_oob_64 = { |
106 | .useecc = MTD_NANDECC_AUTOPLACE, | 107 | .useecc = MTD_NANDECC_AUTOPLACE, |
107 | .eccbytes = 24, | 108 | .eccbytes = 24, |
108 | .eccpos = { | 109 | .eccpos = { |
109 | 40, 41, 42, 43, 44, 45, 46, 47, | 110 | 40, 41, 42, 43, 44, 45, 46, 47, |
110 | 48, 49, 50, 51, 52, 53, 54, 55, | 111 | 48, 49, 50, 51, 52, 53, 54, 55, |
111 | 56, 57, 58, 59, 60, 61, 62, 63}, | 112 | 56, 57, 58, 59, 60, 61, 62, 63}, |
112 | .oobfree = { {2, 38} } | 113 | .oobfree = {{2, 38}} |
113 | }; | 114 | }; |
114 | 115 | ||
115 | /* This is used for padding purposes in nand_write_oob */ | 116 | /* This is used for padding purposes in nand_write_oob */ |
@@ -131,32 +132,32 @@ static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len); | |||
131 | static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len); | 132 | static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len); |
132 | static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len); | 133 | static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len); |
133 | 134 | ||
134 | static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf); | 135 | static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
135 | static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | 136 | static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, |
136 | size_t * retlen, u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel); | 137 | size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); |
137 | static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf); | 138 | static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); |
138 | static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf); | 139 | static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); |
139 | static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | 140 | static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, |
140 | size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel); | 141 | size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); |
141 | static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char *buf); | 142 | static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); |
142 | static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, | 143 | static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen); |
143 | unsigned long count, loff_t to, size_t * retlen); | 144 | static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, |
144 | static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, | 145 | unsigned long count, loff_t to, size_t *retlen, u_char *eccbuf, |
145 | unsigned long count, loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel); | 146 | struct nand_oobinfo *oobsel); |
146 | static int nand_erase (struct mtd_info *mtd, struct erase_info *instr); | 147 | static int nand_erase(struct mtd_info *mtd, struct erase_info *instr); |
147 | static void nand_sync (struct mtd_info *mtd); | 148 | static void nand_sync(struct mtd_info *mtd); |
148 | 149 | ||
149 | /* Some internal functions */ | 150 | /* Some internal functions */ |
150 | static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, u_char *oob_buf, | 151 | static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int page, u_char * oob_buf, |
151 | struct nand_oobinfo *oobsel, int mode); | 152 | struct nand_oobinfo *oobsel, int mode); |
152 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE | 153 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE |
153 | static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, | 154 | static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, |
154 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode); | 155 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode); |
155 | #else | 156 | #else |
156 | #define nand_verify_pages(...) (0) | 157 | #define nand_verify_pages(...) (0) |
157 | #endif | 158 | #endif |
158 | 159 | ||
159 | static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state); | 160 | static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state); |
160 | 161 | ||
161 | /** | 162 | /** |
162 | * nand_release_device - [GENERIC] release chip | 163 | * nand_release_device - [GENERIC] release chip |
@@ -164,7 +165,7 @@ static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int ne | |||
164 | * | 165 | * |
165 | * Deselect, release chip lock and wake up anyone waiting on the device | 166 | * Deselect, release chip lock and wake up anyone waiting on the device |
166 | */ | 167 | */ |
167 | static void nand_release_device (struct mtd_info *mtd) | 168 | static void nand_release_device(struct mtd_info *mtd) |
168 | { | 169 | { |
169 | struct nand_chip *this = mtd->priv; | 170 | struct nand_chip *this = mtd->priv; |
170 | 171 | ||
@@ -276,7 +277,7 @@ static void nand_write_word(struct mtd_info *mtd, u16 word) | |||
276 | static void nand_select_chip(struct mtd_info *mtd, int chip) | 277 | static void nand_select_chip(struct mtd_info *mtd, int chip) |
277 | { | 278 | { |
278 | struct nand_chip *this = mtd->priv; | 279 | struct nand_chip *this = mtd->priv; |
279 | switch(chip) { | 280 | switch (chip) { |
280 | case -1: | 281 | case -1: |
281 | this->hwcontrol(mtd, NAND_CTL_CLRNCE); | 282 | this->hwcontrol(mtd, NAND_CTL_CLRNCE); |
282 | break; | 283 | break; |
@@ -302,7 +303,7 @@ static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) | |||
302 | int i; | 303 | int i; |
303 | struct nand_chip *this = mtd->priv; | 304 | struct nand_chip *this = mtd->priv; |
304 | 305 | ||
305 | for (i=0; i<len; i++) | 306 | for (i = 0; i < len; i++) |
306 | writeb(buf[i], this->IO_ADDR_W); | 307 | writeb(buf[i], this->IO_ADDR_W); |
307 | } | 308 | } |
308 | 309 | ||
@@ -319,7 +320,7 @@ static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) | |||
319 | int i; | 320 | int i; |
320 | struct nand_chip *this = mtd->priv; | 321 | struct nand_chip *this = mtd->priv; |
321 | 322 | ||
322 | for (i=0; i<len; i++) | 323 | for (i = 0; i < len; i++) |
323 | buf[i] = readb(this->IO_ADDR_R); | 324 | buf[i] = readb(this->IO_ADDR_R); |
324 | } | 325 | } |
325 | 326 | ||
@@ -336,7 +337,7 @@ static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len) | |||
336 | int i; | 337 | int i; |
337 | struct nand_chip *this = mtd->priv; | 338 | struct nand_chip *this = mtd->priv; |
338 | 339 | ||
339 | for (i=0; i<len; i++) | 340 | for (i = 0; i < len; i++) |
340 | if (buf[i] != readb(this->IO_ADDR_R)) | 341 | if (buf[i] != readb(this->IO_ADDR_R)) |
341 | return -EFAULT; | 342 | return -EFAULT; |
342 | 343 | ||
@@ -358,7 +359,7 @@ static void nand_write_buf16(struct mtd_info *mtd, const u_char *buf, int len) | |||
358 | u16 *p = (u16 *) buf; | 359 | u16 *p = (u16 *) buf; |
359 | len >>= 1; | 360 | len >>= 1; |
360 | 361 | ||
361 | for (i=0; i<len; i++) | 362 | for (i = 0; i < len; i++) |
362 | writew(p[i], this->IO_ADDR_W); | 363 | writew(p[i], this->IO_ADDR_W); |
363 | 364 | ||
364 | } | 365 | } |
@@ -378,7 +379,7 @@ static void nand_read_buf16(struct mtd_info *mtd, u_char *buf, int len) | |||
378 | u16 *p = (u16 *) buf; | 379 | u16 *p = (u16 *) buf; |
379 | len >>= 1; | 380 | len >>= 1; |
380 | 381 | ||
381 | for (i=0; i<len; i++) | 382 | for (i = 0; i < len; i++) |
382 | p[i] = readw(this->IO_ADDR_R); | 383 | p[i] = readw(this->IO_ADDR_R); |
383 | } | 384 | } |
384 | 385 | ||
@@ -397,7 +398,7 @@ static int nand_verify_buf16(struct mtd_info *mtd, const u_char *buf, int len) | |||
397 | u16 *p = (u16 *) buf; | 398 | u16 *p = (u16 *) buf; |
398 | len >>= 1; | 399 | len >>= 1; |
399 | 400 | ||
400 | for (i=0; i<len; i++) | 401 | for (i = 0; i < len; i++) |
401 | if (p[i] != readw(this->IO_ADDR_R)) | 402 | if (p[i] != readw(this->IO_ADDR_R)) |
402 | return -EFAULT; | 403 | return -EFAULT; |
403 | 404 | ||
@@ -423,22 +424,22 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) | |||
423 | chipnr = (int)(ofs >> this->chip_shift); | 424 | chipnr = (int)(ofs >> this->chip_shift); |
424 | 425 | ||
425 | /* Grab the lock and see if the device is available */ | 426 | /* Grab the lock and see if the device is available */ |
426 | nand_get_device (this, mtd, FL_READING); | 427 | nand_get_device(this, mtd, FL_READING); |
427 | 428 | ||
428 | /* Select the NAND device */ | 429 | /* Select the NAND device */ |
429 | this->select_chip(mtd, chipnr); | 430 | this->select_chip(mtd, chipnr); |
430 | } else | 431 | } else |
431 | page = (int) ofs; | 432 | page = (int)ofs; |
432 | 433 | ||
433 | if (this->options & NAND_BUSWIDTH_16) { | 434 | if (this->options & NAND_BUSWIDTH_16) { |
434 | this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask); | 435 | this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask); |
435 | bad = cpu_to_le16(this->read_word(mtd)); | 436 | bad = cpu_to_le16(this->read_word(mtd)); |
436 | if (this->badblockpos & 0x1) | 437 | if (this->badblockpos & 0x1) |
437 | bad >>= 8; | 438 | bad >>= 8; |
438 | if ((bad & 0xFF) != 0xff) | 439 | if ((bad & 0xFF) != 0xff) |
439 | res = 1; | 440 | res = 1; |
440 | } else { | 441 | } else { |
441 | this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos, page & this->pagemask); | 442 | this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos, page & this->pagemask); |
442 | if (this->read_byte(mtd) != 0xff) | 443 | if (this->read_byte(mtd) != 0xff) |
443 | res = 1; | 444 | res = 1; |
444 | } | 445 | } |
@@ -462,22 +463,22 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) | |||
462 | static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | 463 | static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) |
463 | { | 464 | { |
464 | struct nand_chip *this = mtd->priv; | 465 | struct nand_chip *this = mtd->priv; |
465 | u_char buf[2] = {0, 0}; | 466 | u_char buf[2] = { 0, 0 }; |
466 | size_t retlen; | 467 | size_t retlen; |
467 | int block; | 468 | int block; |
468 | 469 | ||
469 | /* Get block number */ | 470 | /* Get block number */ |
470 | block = ((int) ofs) >> this->bbt_erase_shift; | 471 | block = ((int)ofs) >> this->bbt_erase_shift; |
471 | if (this->bbt) | 472 | if (this->bbt) |
472 | this->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1); | 473 | this->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1); |
473 | 474 | ||
474 | /* Do we have a flash based bad block table ? */ | 475 | /* Do we have a flash based bad block table ? */ |
475 | if (this->options & NAND_USE_FLASH_BBT) | 476 | if (this->options & NAND_USE_FLASH_BBT) |
476 | return nand_update_bbt (mtd, ofs); | 477 | return nand_update_bbt(mtd, ofs); |
477 | 478 | ||
478 | /* We write two bytes, so we dont have to mess with 16 bit access */ | 479 | /* We write two bytes, so we dont have to mess with 16 bit access */ |
479 | ofs += mtd->oobsize + (this->badblockpos & ~0x01); | 480 | ofs += mtd->oobsize + (this->badblockpos & ~0x01); |
480 | return nand_write_oob (mtd, ofs , 2, &retlen, buf); | 481 | return nand_write_oob(mtd, ofs, 2, &retlen, buf); |
481 | } | 482 | } |
482 | 483 | ||
483 | /** | 484 | /** |
@@ -487,11 +488,11 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
487 | * | 488 | * |
488 | * The function expects, that the device is already selected | 489 | * The function expects, that the device is already selected |
489 | */ | 490 | */ |
490 | static int nand_check_wp (struct mtd_info *mtd) | 491 | static int nand_check_wp(struct mtd_info *mtd) |
491 | { | 492 | { |
492 | struct nand_chip *this = mtd->priv; | 493 | struct nand_chip *this = mtd->priv; |
493 | /* Check the WP bit */ | 494 | /* Check the WP bit */ |
494 | this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); | 495 | this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); |
495 | return (this->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1; | 496 | return (this->read_byte(mtd) & NAND_STATUS_WP) ? 0 : 1; |
496 | } | 497 | } |
497 | 498 | ||
@@ -505,7 +506,7 @@ static int nand_check_wp (struct mtd_info *mtd) | |||
505 | * Check, if the block is bad. Either by reading the bad block table or | 506 | * Check, if the block is bad. Either by reading the bad block table or |
506 | * calling of the scan function. | 507 | * calling of the scan function. |
507 | */ | 508 | */ |
508 | static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt) | 509 | static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt) |
509 | { | 510 | { |
510 | struct nand_chip *this = mtd->priv; | 511 | struct nand_chip *this = mtd->priv; |
511 | 512 | ||
@@ -513,7 +514,7 @@ static int nand_block_checkbad (struct mtd_info *mtd, loff_t ofs, int getchip, i | |||
513 | return this->block_bad(mtd, ofs, getchip); | 514 | return this->block_bad(mtd, ofs, getchip); |
514 | 515 | ||
515 | /* Return info from the table */ | 516 | /* Return info from the table */ |
516 | return nand_isbad_bbt (mtd, ofs, allowbbt); | 517 | return nand_isbad_bbt(mtd, ofs, allowbbt); |
517 | } | 518 | } |
518 | 519 | ||
519 | DEFINE_LED_TRIGGER(nand_led_trigger); | 520 | DEFINE_LED_TRIGGER(nand_led_trigger); |
@@ -525,7 +526,7 @@ DEFINE_LED_TRIGGER(nand_led_trigger); | |||
525 | static void nand_wait_ready(struct mtd_info *mtd) | 526 | static void nand_wait_ready(struct mtd_info *mtd) |
526 | { | 527 | { |
527 | struct nand_chip *this = mtd->priv; | 528 | struct nand_chip *this = mtd->priv; |
528 | unsigned long timeo = jiffies + 2; | 529 | unsigned long timeo = jiffies + 2; |
529 | 530 | ||
530 | led_trigger_event(nand_led_trigger, LED_FULL); | 531 | led_trigger_event(nand_led_trigger, LED_FULL); |
531 | /* wait until command is processed or timeout occures */ | 532 | /* wait until command is processed or timeout occures */ |
@@ -547,7 +548,7 @@ static void nand_wait_ready(struct mtd_info *mtd) | |||
547 | * Send command to NAND device. This function is used for small page | 548 | * Send command to NAND device. This function is used for small page |
548 | * devices (256/512 Bytes per page) | 549 | * devices (256/512 Bytes per page) |
549 | */ | 550 | */ |
550 | static void nand_command (struct mtd_info *mtd, unsigned command, int column, int page_addr) | 551 | static void nand_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) |
551 | { | 552 | { |
552 | register struct nand_chip *this = mtd->priv; | 553 | register struct nand_chip *this = mtd->priv; |
553 | 554 | ||
@@ -588,11 +589,11 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in | |||
588 | this->write_byte(mtd, column); | 589 | this->write_byte(mtd, column); |
589 | } | 590 | } |
590 | if (page_addr != -1) { | 591 | if (page_addr != -1) { |
591 | this->write_byte(mtd, (unsigned char) (page_addr & 0xff)); | 592 | this->write_byte(mtd, (unsigned char)(page_addr & 0xff)); |
592 | this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff)); | 593 | this->write_byte(mtd, (unsigned char)((page_addr >> 8) & 0xff)); |
593 | /* One more address cycle for devices > 32MiB */ | 594 | /* One more address cycle for devices > 32MiB */ |
594 | if (this->chipsize > (32 << 20)) | 595 | if (this->chipsize > (32 << 20)) |
595 | this->write_byte(mtd, (unsigned char) ((page_addr >> 16) & 0x0f)); | 596 | this->write_byte(mtd, (unsigned char)((page_addr >> 16) & 0x0f)); |
596 | } | 597 | } |
597 | /* Latch in address */ | 598 | /* Latch in address */ |
598 | this->hwcontrol(mtd, NAND_CTL_CLRALE); | 599 | this->hwcontrol(mtd, NAND_CTL_CLRALE); |
@@ -601,7 +602,7 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in | |||
601 | /* | 602 | /* |
602 | * program and erase have their own busy handlers | 603 | * program and erase have their own busy handlers |
603 | * status and sequential in needs no delay | 604 | * status and sequential in needs no delay |
604 | */ | 605 | */ |
605 | switch (command) { | 606 | switch (command) { |
606 | 607 | ||
607 | case NAND_CMD_PAGEPROG: | 608 | case NAND_CMD_PAGEPROG: |
@@ -618,23 +619,23 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in | |||
618 | this->hwcontrol(mtd, NAND_CTL_SETCLE); | 619 | this->hwcontrol(mtd, NAND_CTL_SETCLE); |
619 | this->write_byte(mtd, NAND_CMD_STATUS); | 620 | this->write_byte(mtd, NAND_CMD_STATUS); |
620 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); | 621 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); |
621 | while ( !(this->read_byte(mtd) & NAND_STATUS_READY)); | 622 | while (!(this->read_byte(mtd) & NAND_STATUS_READY)) ; |
622 | return; | 623 | return; |
623 | 624 | ||
624 | /* This applies to read commands */ | 625 | /* This applies to read commands */ |
625 | default: | 626 | default: |
626 | /* | 627 | /* |
627 | * If we don't have access to the busy pin, we apply the given | 628 | * If we don't have access to the busy pin, we apply the given |
628 | * command delay | 629 | * command delay |
629 | */ | 630 | */ |
630 | if (!this->dev_ready) { | 631 | if (!this->dev_ready) { |
631 | udelay (this->chip_delay); | 632 | udelay(this->chip_delay); |
632 | return; | 633 | return; |
633 | } | 634 | } |
634 | } | 635 | } |
635 | /* Apply this short delay always to ensure that we do wait tWB in | 636 | /* Apply this short delay always to ensure that we do wait tWB in |
636 | * any case on any machine. */ | 637 | * any case on any machine. */ |
637 | ndelay (100); | 638 | ndelay(100); |
638 | 639 | ||
639 | nand_wait_ready(mtd); | 640 | nand_wait_ready(mtd); |
640 | } | 641 | } |
@@ -647,11 +648,11 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in | |||
647 | * @page_addr: the page address for this command, -1 if none | 648 | * @page_addr: the page address for this command, -1 if none |
648 | * | 649 | * |
649 | * Send command to NAND device. This is the version for the new large page devices | 650 | * Send command to NAND device. This is the version for the new large page devices |
650 | * We dont have the seperate regions as we have in the small page devices. | 651 | * We dont have the separate regions as we have in the small page devices. |
651 | * We must emulate NAND_CMD_READOOB to keep the code compatible. | 652 | * We must emulate NAND_CMD_READOOB to keep the code compatible. |
652 | * | 653 | * |
653 | */ | 654 | */ |
654 | static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, int page_addr) | 655 | static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column, int page_addr) |
655 | { | 656 | { |
656 | register struct nand_chip *this = mtd->priv; | 657 | register struct nand_chip *this = mtd->priv; |
657 | 658 | ||
@@ -661,7 +662,6 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
661 | command = NAND_CMD_READ0; | 662 | command = NAND_CMD_READ0; |
662 | } | 663 | } |
663 | 664 | ||
664 | |||
665 | /* Begin command latch cycle */ | 665 | /* Begin command latch cycle */ |
666 | this->hwcontrol(mtd, NAND_CTL_SETCLE); | 666 | this->hwcontrol(mtd, NAND_CTL_SETCLE); |
667 | /* Write out the command to the device. */ | 667 | /* Write out the command to the device. */ |
@@ -681,11 +681,11 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
681 | this->write_byte(mtd, column >> 8); | 681 | this->write_byte(mtd, column >> 8); |
682 | } | 682 | } |
683 | if (page_addr != -1) { | 683 | if (page_addr != -1) { |
684 | this->write_byte(mtd, (unsigned char) (page_addr & 0xff)); | 684 | this->write_byte(mtd, (unsigned char)(page_addr & 0xff)); |
685 | this->write_byte(mtd, (unsigned char) ((page_addr >> 8) & 0xff)); | 685 | this->write_byte(mtd, (unsigned char)((page_addr >> 8) & 0xff)); |
686 | /* One more address cycle for devices > 128MiB */ | 686 | /* One more address cycle for devices > 128MiB */ |
687 | if (this->chipsize > (128 << 20)) | 687 | if (this->chipsize > (128 << 20)) |
688 | this->write_byte(mtd, (unsigned char) ((page_addr >> 16) & 0xff)); | 688 | this->write_byte(mtd, (unsigned char)((page_addr >> 16) & 0xff)); |
689 | } | 689 | } |
690 | /* Latch in address */ | 690 | /* Latch in address */ |
691 | this->hwcontrol(mtd, NAND_CTL_CLRALE); | 691 | this->hwcontrol(mtd, NAND_CTL_CLRALE); |
@@ -706,9 +706,9 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
706 | case NAND_CMD_DEPLETE1: | 706 | case NAND_CMD_DEPLETE1: |
707 | return; | 707 | return; |
708 | 708 | ||
709 | /* | 709 | /* |
710 | * read error status commands require only a short delay | 710 | * read error status commands require only a short delay |
711 | */ | 711 | */ |
712 | case NAND_CMD_STATUS_ERROR: | 712 | case NAND_CMD_STATUS_ERROR: |
713 | case NAND_CMD_STATUS_ERROR0: | 713 | case NAND_CMD_STATUS_ERROR0: |
714 | case NAND_CMD_STATUS_ERROR1: | 714 | case NAND_CMD_STATUS_ERROR1: |
@@ -724,7 +724,7 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
724 | this->hwcontrol(mtd, NAND_CTL_SETCLE); | 724 | this->hwcontrol(mtd, NAND_CTL_SETCLE); |
725 | this->write_byte(mtd, NAND_CMD_STATUS); | 725 | this->write_byte(mtd, NAND_CMD_STATUS); |
726 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); | 726 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); |
727 | while ( !(this->read_byte(mtd) & NAND_STATUS_READY)); | 727 | while (!(this->read_byte(mtd) & NAND_STATUS_READY)) ; |
728 | return; | 728 | return; |
729 | 729 | ||
730 | case NAND_CMD_READ0: | 730 | case NAND_CMD_READ0: |
@@ -736,21 +736,21 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
736 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); | 736 | this->hwcontrol(mtd, NAND_CTL_CLRCLE); |
737 | /* Fall through into ready check */ | 737 | /* Fall through into ready check */ |
738 | 738 | ||
739 | /* This applies to read commands */ | 739 | /* This applies to read commands */ |
740 | default: | 740 | default: |
741 | /* | 741 | /* |
742 | * If we don't have access to the busy pin, we apply the given | 742 | * If we don't have access to the busy pin, we apply the given |
743 | * command delay | 743 | * command delay |
744 | */ | 744 | */ |
745 | if (!this->dev_ready) { | 745 | if (!this->dev_ready) { |
746 | udelay (this->chip_delay); | 746 | udelay(this->chip_delay); |
747 | return; | 747 | return; |
748 | } | 748 | } |
749 | } | 749 | } |
750 | 750 | ||
751 | /* Apply this short delay always to ensure that we do wait tWB in | 751 | /* Apply this short delay always to ensure that we do wait tWB in |
752 | * any case on any machine. */ | 752 | * any case on any machine. */ |
753 | ndelay (100); | 753 | ndelay(100); |
754 | 754 | ||
755 | nand_wait_ready(mtd); | 755 | nand_wait_ready(mtd); |
756 | } | 756 | } |
@@ -763,16 +763,16 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column, | |||
763 | * | 763 | * |
764 | * Get the device and lock it for exclusive access | 764 | * Get the device and lock it for exclusive access |
765 | */ | 765 | */ |
766 | static int nand_get_device (struct nand_chip *this, struct mtd_info *mtd, int new_state) | 766 | static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state) |
767 | { | 767 | { |
768 | struct nand_chip *active; | 768 | struct nand_chip *active; |
769 | spinlock_t *lock; | 769 | spinlock_t *lock; |
770 | wait_queue_head_t *wq; | 770 | wait_queue_head_t *wq; |
771 | DECLARE_WAITQUEUE (wait, current); | 771 | DECLARE_WAITQUEUE(wait, current); |
772 | 772 | ||
773 | lock = (this->controller) ? &this->controller->lock : &this->chip_lock; | 773 | lock = (this->controller) ? &this->controller->lock : &this->chip_lock; |
774 | wq = (this->controller) ? &this->controller->wq : &this->wq; | 774 | wq = (this->controller) ? &this->controller->wq : &this->wq; |
775 | retry: | 775 | retry: |
776 | active = this; | 776 | active = this; |
777 | spin_lock(lock); | 777 | spin_lock(lock); |
778 | 778 | ||
@@ -814,24 +814,24 @@ retry: | |||
814 | static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) | 814 | static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) |
815 | { | 815 | { |
816 | 816 | ||
817 | unsigned long timeo = jiffies; | 817 | unsigned long timeo = jiffies; |
818 | int status; | 818 | int status; |
819 | 819 | ||
820 | if (state == FL_ERASING) | 820 | if (state == FL_ERASING) |
821 | timeo += (HZ * 400) / 1000; | 821 | timeo += (HZ * 400) / 1000; |
822 | else | 822 | else |
823 | timeo += (HZ * 20) / 1000; | 823 | timeo += (HZ * 20) / 1000; |
824 | 824 | ||
825 | led_trigger_event(nand_led_trigger, LED_FULL); | 825 | led_trigger_event(nand_led_trigger, LED_FULL); |
826 | 826 | ||
827 | /* Apply this short delay always to ensure that we do wait tWB in | 827 | /* Apply this short delay always to ensure that we do wait tWB in |
828 | * any case on any machine. */ | 828 | * any case on any machine. */ |
829 | ndelay (100); | 829 | ndelay(100); |
830 | 830 | ||
831 | if ((state == FL_ERASING) && (this->options & NAND_IS_AND)) | 831 | if ((state == FL_ERASING) && (this->options & NAND_IS_AND)) |
832 | this->cmdfunc (mtd, NAND_CMD_STATUS_MULTI, -1, -1); | 832 | this->cmdfunc(mtd, NAND_CMD_STATUS_MULTI, -1, -1); |
833 | else | 833 | else |
834 | this->cmdfunc (mtd, NAND_CMD_STATUS, -1, -1); | 834 | this->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1); |
835 | 835 | ||
836 | while (time_before(jiffies, timeo)) { | 836 | while (time_before(jiffies, timeo)) { |
837 | /* Check, if we were interrupted */ | 837 | /* Check, if we were interrupted */ |
@@ -849,7 +849,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) | |||
849 | } | 849 | } |
850 | led_trigger_event(nand_led_trigger, LED_OFF); | 850 | led_trigger_event(nand_led_trigger, LED_OFF); |
851 | 851 | ||
852 | status = (int) this->read_byte(mtd); | 852 | status = (int)this->read_byte(mtd); |
853 | return status; | 853 | return status; |
854 | } | 854 | } |
855 | 855 | ||
@@ -868,31 +868,31 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *this, int state) | |||
868 | * | 868 | * |
869 | * Cached programming is not supported yet. | 869 | * Cached programming is not supported yet. |
870 | */ | 870 | */ |
871 | static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int page, | 871 | static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int page, |
872 | u_char *oob_buf, struct nand_oobinfo *oobsel, int cached) | 872 | u_char *oob_buf, struct nand_oobinfo *oobsel, int cached) |
873 | { | 873 | { |
874 | int i, status; | 874 | int i, status; |
875 | u_char ecc_code[32]; | 875 | u_char ecc_code[32]; |
876 | int eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE; | 876 | int eccmode = oobsel->useecc ? this->eccmode : NAND_ECC_NONE; |
877 | int *oob_config = oobsel->eccpos; | 877 | int *oob_config = oobsel->eccpos; |
878 | int datidx = 0, eccidx = 0, eccsteps = this->eccsteps; | 878 | int datidx = 0, eccidx = 0, eccsteps = this->eccsteps; |
879 | int eccbytes = 0; | 879 | int eccbytes = 0; |
880 | 880 | ||
881 | /* FIXME: Enable cached programming */ | 881 | /* FIXME: Enable cached programming */ |
882 | cached = 0; | 882 | cached = 0; |
883 | 883 | ||
884 | /* Send command to begin auto page programming */ | 884 | /* Send command to begin auto page programming */ |
885 | this->cmdfunc (mtd, NAND_CMD_SEQIN, 0x00, page); | 885 | this->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page); |
886 | 886 | ||
887 | /* Write out complete page of data, take care of eccmode */ | 887 | /* Write out complete page of data, take care of eccmode */ |
888 | switch (eccmode) { | 888 | switch (eccmode) { |
889 | /* No ecc, write all */ | 889 | /* No ecc, write all */ |
890 | case NAND_ECC_NONE: | 890 | case NAND_ECC_NONE: |
891 | printk (KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); | 891 | printk(KERN_WARNING "Writing data without ECC to NAND-FLASH is not recommended\n"); |
892 | this->write_buf(mtd, this->data_poi, mtd->oobblock); | 892 | this->write_buf(mtd, this->data_poi, mtd->oobblock); |
893 | break; | 893 | break; |
894 | 894 | ||
895 | /* Software ecc 3/256, write all */ | 895 | /* Software ecc 3/256, write all */ |
896 | case NAND_ECC_SOFT: | 896 | case NAND_ECC_SOFT: |
897 | for (; eccsteps; eccsteps--) { | 897 | for (; eccsteps; eccsteps--) { |
898 | this->calculate_ecc(mtd, &this->data_poi[datidx], ecc_code); | 898 | this->calculate_ecc(mtd, &this->data_poi[datidx], ecc_code); |
@@ -928,11 +928,11 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa | |||
928 | this->write_buf(mtd, oob_buf, mtd->oobsize); | 928 | this->write_buf(mtd, oob_buf, mtd->oobsize); |
929 | 929 | ||
930 | /* Send command to actually program the data */ | 930 | /* Send command to actually program the data */ |
931 | this->cmdfunc (mtd, cached ? NAND_CMD_CACHEDPROG : NAND_CMD_PAGEPROG, -1, -1); | 931 | this->cmdfunc(mtd, cached ? NAND_CMD_CACHEDPROG : NAND_CMD_PAGEPROG, -1, -1); |
932 | 932 | ||
933 | if (!cached) { | 933 | if (!cached) { |
934 | /* call wait ready function */ | 934 | /* call wait ready function */ |
935 | status = this->waitfunc (mtd, this, FL_WRITING); | 935 | status = this->waitfunc(mtd, this, FL_WRITING); |
936 | 936 | ||
937 | /* See if operation failed and additional status checks are available */ | 937 | /* See if operation failed and additional status checks are available */ |
938 | if ((status & NAND_STATUS_FAIL) && (this->errstat)) { | 938 | if ((status & NAND_STATUS_FAIL) && (this->errstat)) { |
@@ -941,12 +941,12 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa | |||
941 | 941 | ||
942 | /* See if device thinks it succeeded */ | 942 | /* See if device thinks it succeeded */ |
943 | if (status & NAND_STATUS_FAIL) { | 943 | if (status & NAND_STATUS_FAIL) { |
944 | DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write, page 0x%08x, ", __FUNCTION__, page); | 944 | DEBUG(MTD_DEBUG_LEVEL0, "%s: " "Failed write, page 0x%08x, ", __FUNCTION__, page); |
945 | return -EIO; | 945 | return -EIO; |
946 | } | 946 | } |
947 | } else { | 947 | } else { |
948 | /* FIXME: Implement cached programming ! */ | 948 | /* FIXME: Implement cached programming ! */ |
949 | /* wait until cache is ready*/ | 949 | /* wait until cache is ready */ |
950 | // status = this->waitfunc (mtd, this, FL_CACHEDRPG); | 950 | // status = this->waitfunc (mtd, this, FL_CACHEDRPG); |
951 | } | 951 | } |
952 | return 0; | 952 | return 0; |
@@ -972,24 +972,24 @@ static int nand_write_page (struct mtd_info *mtd, struct nand_chip *this, int pa | |||
972 | * the error later when the ECC page check fails, but we would rather catch | 972 | * the error later when the ECC page check fails, but we would rather catch |
973 | * it early in the page write stage. Better to write no data than invalid data. | 973 | * it early in the page write stage. Better to write no data than invalid data. |
974 | */ | 974 | */ |
975 | static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, | 975 | static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, |
976 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode) | 976 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode) |
977 | { | 977 | { |
978 | int i, j, datidx = 0, oobofs = 0, res = -EIO; | 978 | int i, j, datidx = 0, oobofs = 0, res = -EIO; |
979 | int eccsteps = this->eccsteps; | 979 | int eccsteps = this->eccsteps; |
980 | int hweccbytes; | 980 | int hweccbytes; |
981 | u_char oobdata[64]; | 981 | u_char oobdata[64]; |
982 | 982 | ||
983 | hweccbytes = (this->options & NAND_HWECC_SYNDROME) ? (oobsel->eccbytes / eccsteps) : 0; | 983 | hweccbytes = (this->options & NAND_HWECC_SYNDROME) ? (oobsel->eccbytes / eccsteps) : 0; |
984 | 984 | ||
985 | /* Send command to read back the first page */ | 985 | /* Send command to read back the first page */ |
986 | this->cmdfunc (mtd, NAND_CMD_READ0, 0, page); | 986 | this->cmdfunc(mtd, NAND_CMD_READ0, 0, page); |
987 | 987 | ||
988 | for(;;) { | 988 | for (;;) { |
989 | for (j = 0; j < eccsteps; j++) { | 989 | for (j = 0; j < eccsteps; j++) { |
990 | /* Loop through and verify the data */ | 990 | /* Loop through and verify the data */ |
991 | if (this->verify_buf(mtd, &this->data_poi[datidx], mtd->eccsize)) { | 991 | if (this->verify_buf(mtd, &this->data_poi[datidx], mtd->eccsize)) { |
992 | DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); | 992 | DEBUG(MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); |
993 | goto out; | 993 | goto out; |
994 | } | 994 | } |
995 | datidx += mtd->eccsize; | 995 | datidx += mtd->eccsize; |
@@ -997,7 +997,7 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
997 | if (!hweccbytes) | 997 | if (!hweccbytes) |
998 | continue; | 998 | continue; |
999 | if (this->verify_buf(mtd, &this->oob_buf[oobofs], hweccbytes)) { | 999 | if (this->verify_buf(mtd, &this->oob_buf[oobofs], hweccbytes)) { |
1000 | DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); | 1000 | DEBUG(MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); |
1001 | goto out; | 1001 | goto out; |
1002 | } | 1002 | } |
1003 | oobofs += hweccbytes; | 1003 | oobofs += hweccbytes; |
@@ -1008,7 +1008,7 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
1008 | */ | 1008 | */ |
1009 | if (oobmode) { | 1009 | if (oobmode) { |
1010 | if (this->verify_buf(mtd, &oob_buf[oobofs], mtd->oobsize - hweccbytes * eccsteps)) { | 1010 | if (this->verify_buf(mtd, &oob_buf[oobofs], mtd->oobsize - hweccbytes * eccsteps)) { |
1011 | DEBUG (MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); | 1011 | DEBUG(MTD_DEBUG_LEVEL0, "%s: " "Failed write verify, page 0x%08x ", __FUNCTION__, page); |
1012 | goto out; | 1012 | goto out; |
1013 | } | 1013 | } |
1014 | } else { | 1014 | } else { |
@@ -1020,10 +1020,9 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
1020 | 1020 | ||
1021 | for (i = 0; i < ecccnt; i++) { | 1021 | for (i = 0; i < ecccnt; i++) { |
1022 | int idx = oobsel->eccpos[i]; | 1022 | int idx = oobsel->eccpos[i]; |
1023 | if (oobdata[idx] != oob_buf[oobofs + idx] ) { | 1023 | if (oobdata[idx] != oob_buf[oobofs + idx]) { |
1024 | DEBUG (MTD_DEBUG_LEVEL0, | 1024 | DEBUG(MTD_DEBUG_LEVEL0, "%s: Failed ECC write verify, page 0x%08x, %6i bytes were succesful\n", |
1025 | "%s: Failed ECC write " | 1025 | __FUNCTION__, page, i); |
1026 | "verify, page 0x%08x, " "%6i bytes were succesful\n", __FUNCTION__, page, i); | ||
1027 | goto out; | 1026 | goto out; |
1028 | } | 1027 | } |
1029 | } | 1028 | } |
@@ -1039,9 +1038,9 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
1039 | * is marked as NOAUTOINCR by the board driver. | 1038 | * is marked as NOAUTOINCR by the board driver. |
1040 | * Do this also before returning, so the chip is | 1039 | * Do this also before returning, so the chip is |
1041 | * ready for the next command. | 1040 | * ready for the next command. |
1042 | */ | 1041 | */ |
1043 | if (!this->dev_ready) | 1042 | if (!this->dev_ready) |
1044 | udelay (this->chip_delay); | 1043 | udelay(this->chip_delay); |
1045 | else | 1044 | else |
1046 | nand_wait_ready(mtd); | 1045 | nand_wait_ready(mtd); |
1047 | 1046 | ||
@@ -1049,17 +1048,16 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int | |||
1049 | if (!numpages) | 1048 | if (!numpages) |
1050 | return 0; | 1049 | return 0; |
1051 | 1050 | ||
1052 | |||
1053 | /* Check, if the chip supports auto page increment */ | 1051 | /* Check, if the chip supports auto page increment */ |
1054 | if (!NAND_CANAUTOINCR(this)) | 1052 | if (!NAND_CANAUTOINCR(this)) |
1055 | this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page); | 1053 | this->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page); |
1056 | } | 1054 | } |
1057 | /* | 1055 | /* |
1058 | * Terminate the read command. We come here in case of an error | 1056 | * Terminate the read command. We come here in case of an error |
1059 | * So we must issue a reset command. | 1057 | * So we must issue a reset command. |
1060 | */ | 1058 | */ |
1061 | out: | 1059 | out: |
1062 | this->cmdfunc (mtd, NAND_CMD_RESET, -1, -1); | 1060 | this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1); |
1063 | return res; | 1061 | return res; |
1064 | } | 1062 | } |
1065 | #endif | 1063 | #endif |
@@ -1075,12 +1073,11 @@ out: | |||
1075 | * This function simply calls nand_do_read_ecc with oob buffer and oobsel = NULL | 1073 | * This function simply calls nand_do_read_ecc with oob buffer and oobsel = NULL |
1076 | * and flags = 0xff | 1074 | * and flags = 0xff |
1077 | */ | 1075 | */ |
1078 | static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf) | 1076 | static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) |
1079 | { | 1077 | { |
1080 | return nand_do_read_ecc (mtd, from, len, retlen, buf, NULL, &mtd->oobinfo, 0xff); | 1078 | return nand_do_read_ecc(mtd, from, len, retlen, buf, NULL, &mtd->oobinfo, 0xff); |
1081 | } | 1079 | } |
1082 | 1080 | ||
1083 | |||
1084 | /** | 1081 | /** |
1085 | * nand_read_ecc - [MTD Interface] MTD compability function for nand_do_read_ecc | 1082 | * nand_read_ecc - [MTD Interface] MTD compability function for nand_do_read_ecc |
1086 | * @mtd: MTD device structure | 1083 | * @mtd: MTD device structure |
@@ -1093,8 +1090,8 @@ static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * re | |||
1093 | * | 1090 | * |
1094 | * This function simply calls nand_do_read_ecc with flags = 0xff | 1091 | * This function simply calls nand_do_read_ecc with flags = 0xff |
1095 | */ | 1092 | */ |
1096 | static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | 1093 | static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, |
1097 | size_t * retlen, u_char * buf, u_char * oob_buf, struct nand_oobinfo *oobsel) | 1094 | size_t *retlen, u_char *buf, u_char *oob_buf, struct nand_oobinfo *oobsel) |
1098 | { | 1095 | { |
1099 | /* use userspace supplied oobinfo, if zero */ | 1096 | /* use userspace supplied oobinfo, if zero */ |
1100 | if (oobsel == NULL) | 1097 | if (oobsel == NULL) |
@@ -1102,7 +1099,6 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1102 | return nand_do_read_ecc(mtd, from, len, retlen, buf, oob_buf, oobsel, 0xff); | 1099 | return nand_do_read_ecc(mtd, from, len, retlen, buf, oob_buf, oobsel, 0xff); |
1103 | } | 1100 | } |
1104 | 1101 | ||
1105 | |||
1106 | /** | 1102 | /** |
1107 | * nand_do_read_ecc - [MTD Interface] Read data with ECC | 1103 | * nand_do_read_ecc - [MTD Interface] Read data with ECC |
1108 | * @mtd: MTD device structure | 1104 | * @mtd: MTD device structure |
@@ -1119,9 +1115,8 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1119 | * | 1115 | * |
1120 | * NAND read with ECC | 1116 | * NAND read with ECC |
1121 | */ | 1117 | */ |
1122 | int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | 1118 | int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, |
1123 | size_t * retlen, u_char * buf, u_char * oob_buf, | 1119 | size_t *retlen, u_char *buf, u_char *oob_buf, struct nand_oobinfo *oobsel, int flags) |
1124 | struct nand_oobinfo *oobsel, int flags) | ||
1125 | { | 1120 | { |
1126 | 1121 | ||
1127 | int i, j, col, realpage, page, end, ecc, chipnr, sndcmd = 1; | 1122 | int i, j, col, realpage, page, end, ecc, chipnr, sndcmd = 1; |
@@ -1130,26 +1125,25 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1130 | u_char *data_poi, *oob_data = oob_buf; | 1125 | u_char *data_poi, *oob_data = oob_buf; |
1131 | u_char ecc_calc[32]; | 1126 | u_char ecc_calc[32]; |
1132 | u_char ecc_code[32]; | 1127 | u_char ecc_code[32]; |
1133 | int eccmode, eccsteps; | 1128 | int eccmode, eccsteps; |
1134 | int *oob_config, datidx; | 1129 | int *oob_config, datidx; |
1135 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; | 1130 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; |
1136 | int eccbytes; | 1131 | int eccbytes; |
1137 | int compareecc = 1; | 1132 | int compareecc = 1; |
1138 | int oobreadlen; | 1133 | int oobreadlen; |
1139 | 1134 | ||
1140 | 1135 | DEBUG(MTD_DEBUG_LEVEL3, "nand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int)from, (int)len); | |
1141 | DEBUG (MTD_DEBUG_LEVEL3, "nand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len); | ||
1142 | 1136 | ||
1143 | /* Do not allow reads past end of device */ | 1137 | /* Do not allow reads past end of device */ |
1144 | if ((from + len) > mtd->size) { | 1138 | if ((from + len) > mtd->size) { |
1145 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: Attempt read beyond end of device\n"); | 1139 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_ecc: Attempt read beyond end of device\n"); |
1146 | *retlen = 0; | 1140 | *retlen = 0; |
1147 | return -EINVAL; | 1141 | return -EINVAL; |
1148 | } | 1142 | } |
1149 | 1143 | ||
1150 | /* Grab the lock and see if the device is available */ | 1144 | /* Grab the lock and see if the device is available */ |
1151 | if (flags & NAND_GET_DEVICE) | 1145 | if (flags & NAND_GET_DEVICE) |
1152 | nand_get_device (this, mtd, FL_READING); | 1146 | nand_get_device(this, mtd, FL_READING); |
1153 | 1147 | ||
1154 | /* Autoplace of oob data ? Use the default placement scheme */ | 1148 | /* Autoplace of oob data ? Use the default placement scheme */ |
1155 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) | 1149 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) |
@@ -1163,7 +1157,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1163 | this->select_chip(mtd, chipnr); | 1157 | this->select_chip(mtd, chipnr); |
1164 | 1158 | ||
1165 | /* First we calculate the starting page */ | 1159 | /* First we calculate the starting page */ |
1166 | realpage = (int) (from >> this->page_shift); | 1160 | realpage = (int)(from >> this->page_shift); |
1167 | page = realpage & this->pagemask; | 1161 | page = realpage & this->pagemask; |
1168 | 1162 | ||
1169 | /* Get raw starting column */ | 1163 | /* Get raw starting column */ |
@@ -1201,13 +1195,13 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1201 | if (realpage == this->pagebuf && !oob_buf) { | 1195 | if (realpage == this->pagebuf && !oob_buf) { |
1202 | /* aligned read ? */ | 1196 | /* aligned read ? */ |
1203 | if (aligned) | 1197 | if (aligned) |
1204 | memcpy (data_poi, this->data_buf, end); | 1198 | memcpy(data_poi, this->data_buf, end); |
1205 | goto readdata; | 1199 | goto readdata; |
1206 | } | 1200 | } |
1207 | 1201 | ||
1208 | /* Check, if we must send the read command */ | 1202 | /* Check, if we must send the read command */ |
1209 | if (sndcmd) { | 1203 | if (sndcmd) { |
1210 | this->cmdfunc (mtd, NAND_CMD_READ0, 0x00, page); | 1204 | this->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page); |
1211 | sndcmd = 0; | 1205 | sndcmd = 0; |
1212 | } | 1206 | } |
1213 | 1207 | ||
@@ -1219,24 +1213,26 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1219 | eccsteps = this->eccsteps; | 1213 | eccsteps = this->eccsteps; |
1220 | 1214 | ||
1221 | switch (eccmode) { | 1215 | switch (eccmode) { |
1222 | case NAND_ECC_NONE: { /* No ECC, Read in a page */ | 1216 | case NAND_ECC_NONE:{ |
1223 | static unsigned long lastwhinge = 0; | 1217 | /* No ECC, Read in a page */ |
1224 | if ((lastwhinge / HZ) != (jiffies / HZ)) { | 1218 | static unsigned long lastwhinge = 0; |
1225 | printk (KERN_WARNING "Reading data from NAND FLASH without ECC is not recommended\n"); | 1219 | if ((lastwhinge / HZ) != (jiffies / HZ)) { |
1226 | lastwhinge = jiffies; | 1220 | printk(KERN_WARNING |
1221 | "Reading data from NAND FLASH without ECC is not recommended\n"); | ||
1222 | lastwhinge = jiffies; | ||
1223 | } | ||
1224 | this->read_buf(mtd, data_poi, end); | ||
1225 | break; | ||
1227 | } | 1226 | } |
1228 | this->read_buf(mtd, data_poi, end); | ||
1229 | break; | ||
1230 | } | ||
1231 | 1227 | ||
1232 | case NAND_ECC_SOFT: /* Software ECC 3/256: Read in a page + oob data */ | 1228 | case NAND_ECC_SOFT: /* Software ECC 3/256: Read in a page + oob data */ |
1233 | this->read_buf(mtd, data_poi, end); | 1229 | this->read_buf(mtd, data_poi, end); |
1234 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=3, datidx += ecc) | 1230 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i += 3, datidx += ecc) |
1235 | this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]); | 1231 | this->calculate_ecc(mtd, &data_poi[datidx], &ecc_calc[i]); |
1236 | break; | 1232 | break; |
1237 | 1233 | ||
1238 | default: | 1234 | default: |
1239 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i+=eccbytes, datidx += ecc) { | 1235 | for (i = 0, datidx = 0; eccsteps; eccsteps--, i += eccbytes, datidx += ecc) { |
1240 | this->enable_hwecc(mtd, NAND_ECC_READ); | 1236 | this->enable_hwecc(mtd, NAND_ECC_READ); |
1241 | this->read_buf(mtd, &data_poi[datidx], ecc); | 1237 | this->read_buf(mtd, &data_poi[datidx], ecc); |
1242 | 1238 | ||
@@ -1252,8 +1248,8 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1252 | * does the error correction on the fly */ | 1248 | * does the error correction on the fly */ |
1253 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]); | 1249 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &oob_data[i], &ecc_code[i]); |
1254 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { | 1250 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { |
1255 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " | 1251 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_ecc: " |
1256 | "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr); | 1252 | "Failed ECC read, page 0x%08x on chip %d\n", page, chipnr); |
1257 | ecc_failed++; | 1253 | ecc_failed++; |
1258 | } | 1254 | } |
1259 | } else { | 1255 | } else { |
@@ -1274,7 +1270,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1274 | for (j = 0; j < oobsel->eccbytes; j++) | 1270 | for (j = 0; j < oobsel->eccbytes; j++) |
1275 | ecc_code[j] = oob_data[oob_config[j]]; | 1271 | ecc_code[j] = oob_data[oob_config[j]]; |
1276 | 1272 | ||
1277 | /* correct data, if neccecary */ | 1273 | /* correct data, if necessary */ |
1278 | for (i = 0, j = 0, datidx = 0; i < this->eccsteps; i++, datidx += ecc) { | 1274 | for (i = 0, j = 0, datidx = 0; i < this->eccsteps; i++, datidx += ecc) { |
1279 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]); | 1275 | ecc_status = this->correct_data(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]); |
1280 | 1276 | ||
@@ -1291,16 +1287,16 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1291 | } | 1287 | } |
1292 | 1288 | ||
1293 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { | 1289 | if ((ecc_status == -1) || (ecc_status > (flags && 0xff))) { |
1294 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page); | 1290 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_ecc: " "Failed ECC read, page 0x%08x\n", page); |
1295 | ecc_failed++; | 1291 | ecc_failed++; |
1296 | } | 1292 | } |
1297 | } | 1293 | } |
1298 | 1294 | ||
1299 | readoob: | 1295 | readoob: |
1300 | /* check, if we have a fs supplied oob-buffer */ | 1296 | /* check, if we have a fs supplied oob-buffer */ |
1301 | if (oob_buf) { | 1297 | if (oob_buf) { |
1302 | /* without autoplace. Legacy mode used by YAFFS1 */ | 1298 | /* without autoplace. Legacy mode used by YAFFS1 */ |
1303 | switch(oobsel->useecc) { | 1299 | switch (oobsel->useecc) { |
1304 | case MTD_NANDECC_AUTOPLACE: | 1300 | case MTD_NANDECC_AUTOPLACE: |
1305 | case MTD_NANDECC_AUTOPL_USR: | 1301 | case MTD_NANDECC_AUTOPL_USR: |
1306 | /* Walk through the autoplace chunks */ | 1302 | /* Walk through the autoplace chunks */ |
@@ -1313,7 +1309,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1313 | break; | 1309 | break; |
1314 | case MTD_NANDECC_PLACE: | 1310 | case MTD_NANDECC_PLACE: |
1315 | /* YAFFS1 legacy mode */ | 1311 | /* YAFFS1 legacy mode */ |
1316 | oob_data += this->eccsteps * sizeof (int); | 1312 | oob_data += this->eccsteps * sizeof(int); |
1317 | default: | 1313 | default: |
1318 | oob_data += mtd->oobsize; | 1314 | oob_data += mtd->oobsize; |
1319 | } | 1315 | } |
@@ -1331,9 +1327,9 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1331 | * Do this before the AUTOINCR check, so no problems | 1327 | * Do this before the AUTOINCR check, so no problems |
1332 | * arise if a chip which does auto increment | 1328 | * arise if a chip which does auto increment |
1333 | * is marked as NOAUTOINCR by the board driver. | 1329 | * is marked as NOAUTOINCR by the board driver. |
1334 | */ | 1330 | */ |
1335 | if (!this->dev_ready) | 1331 | if (!this->dev_ready) |
1336 | udelay (this->chip_delay); | 1332 | udelay(this->chip_delay); |
1337 | else | 1333 | else |
1338 | nand_wait_ready(mtd); | 1334 | nand_wait_ready(mtd); |
1339 | 1335 | ||
@@ -1354,7 +1350,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1354 | } | 1350 | } |
1355 | /* Check, if the chip supports auto page increment | 1351 | /* Check, if the chip supports auto page increment |
1356 | * or if we have hit a block boundary. | 1352 | * or if we have hit a block boundary. |
1357 | */ | 1353 | */ |
1358 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) | 1354 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) |
1359 | sndcmd = 1; | 1355 | sndcmd = 1; |
1360 | } | 1356 | } |
@@ -1382,13 +1378,13 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | |||
1382 | * | 1378 | * |
1383 | * NAND read out-of-band data from the spare area | 1379 | * NAND read out-of-band data from the spare area |
1384 | */ | 1380 | */ |
1385 | static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, u_char * buf) | 1381 | static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) |
1386 | { | 1382 | { |
1387 | int i, col, page, chipnr; | 1383 | int i, col, page, chipnr; |
1388 | struct nand_chip *this = mtd->priv; | 1384 | struct nand_chip *this = mtd->priv; |
1389 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; | 1385 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; |
1390 | 1386 | ||
1391 | DEBUG (MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08x, len = %i\n", (unsigned int) from, (int) len); | 1387 | DEBUG(MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08x, len = %i\n", (unsigned int)from, (int)len); |
1392 | 1388 | ||
1393 | /* Shift to get page */ | 1389 | /* Shift to get page */ |
1394 | page = (int)(from >> this->page_shift); | 1390 | page = (int)(from >> this->page_shift); |
@@ -1402,19 +1398,19 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t | |||
1402 | 1398 | ||
1403 | /* Do not allow reads past end of device */ | 1399 | /* Do not allow reads past end of device */ |
1404 | if ((from + len) > mtd->size) { | 1400 | if ((from + len) > mtd->size) { |
1405 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_oob: Attempt read beyond end of device\n"); | 1401 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_oob: Attempt read beyond end of device\n"); |
1406 | *retlen = 0; | 1402 | *retlen = 0; |
1407 | return -EINVAL; | 1403 | return -EINVAL; |
1408 | } | 1404 | } |
1409 | 1405 | ||
1410 | /* Grab the lock and see if the device is available */ | 1406 | /* Grab the lock and see if the device is available */ |
1411 | nand_get_device (this, mtd , FL_READING); | 1407 | nand_get_device(this, mtd, FL_READING); |
1412 | 1408 | ||
1413 | /* Select the NAND device */ | 1409 | /* Select the NAND device */ |
1414 | this->select_chip(mtd, chipnr); | 1410 | this->select_chip(mtd, chipnr); |
1415 | 1411 | ||
1416 | /* Send the read command */ | 1412 | /* Send the read command */ |
1417 | this->cmdfunc (mtd, NAND_CMD_READOOB, col, page & this->pagemask); | 1413 | this->cmdfunc(mtd, NAND_CMD_READOOB, col, page & this->pagemask); |
1418 | /* | 1414 | /* |
1419 | * Read the data, if we read more than one page | 1415 | * Read the data, if we read more than one page |
1420 | * oob data, let the device transfer the data ! | 1416 | * oob data, let the device transfer the data ! |
@@ -1444,16 +1440,16 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t | |||
1444 | * is marked as NOAUTOINCR by the board driver. | 1440 | * is marked as NOAUTOINCR by the board driver. |
1445 | */ | 1441 | */ |
1446 | if (!this->dev_ready) | 1442 | if (!this->dev_ready) |
1447 | udelay (this->chip_delay); | 1443 | udelay(this->chip_delay); |
1448 | else | 1444 | else |
1449 | nand_wait_ready(mtd); | 1445 | nand_wait_ready(mtd); |
1450 | 1446 | ||
1451 | /* Check, if the chip supports auto page increment | 1447 | /* Check, if the chip supports auto page increment |
1452 | * or if we have hit a block boundary. | 1448 | * or if we have hit a block boundary. |
1453 | */ | 1449 | */ |
1454 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) { | 1450 | if (!NAND_CANAUTOINCR(this) || !(page & blockcheck)) { |
1455 | /* For subsequent page reads set offset to 0 */ | 1451 | /* For subsequent page reads set offset to 0 */ |
1456 | this->cmdfunc (mtd, NAND_CMD_READOOB, 0x0, page & this->pagemask); | 1452 | this->cmdfunc(mtd, NAND_CMD_READOOB, 0x0, page & this->pagemask); |
1457 | } | 1453 | } |
1458 | } | 1454 | } |
1459 | } | 1455 | } |
@@ -1476,43 +1472,43 @@ static int nand_read_oob (struct mtd_info *mtd, loff_t from, size_t len, size_t | |||
1476 | * | 1472 | * |
1477 | * Read raw data including oob into buffer | 1473 | * Read raw data including oob into buffer |
1478 | */ | 1474 | */ |
1479 | int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, size_t ooblen) | 1475 | int nand_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, size_t ooblen) |
1480 | { | 1476 | { |
1481 | struct nand_chip *this = mtd->priv; | 1477 | struct nand_chip *this = mtd->priv; |
1482 | int page = (int) (from >> this->page_shift); | 1478 | int page = (int)(from >> this->page_shift); |
1483 | int chip = (int) (from >> this->chip_shift); | 1479 | int chip = (int)(from >> this->chip_shift); |
1484 | int sndcmd = 1; | 1480 | int sndcmd = 1; |
1485 | int cnt = 0; | 1481 | int cnt = 0; |
1486 | int pagesize = mtd->oobblock + mtd->oobsize; | 1482 | int pagesize = mtd->oobblock + mtd->oobsize; |
1487 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; | 1483 | int blockcheck = (1 << (this->phys_erase_shift - this->page_shift)) - 1; |
1488 | 1484 | ||
1489 | /* Do not allow reads past end of device */ | 1485 | /* Do not allow reads past end of device */ |
1490 | if ((from + len) > mtd->size) { | 1486 | if ((from + len) > mtd->size) { |
1491 | DEBUG (MTD_DEBUG_LEVEL0, "nand_read_raw: Attempt read beyond end of device\n"); | 1487 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_raw: Attempt read beyond end of device\n"); |
1492 | return -EINVAL; | 1488 | return -EINVAL; |
1493 | } | 1489 | } |
1494 | 1490 | ||
1495 | /* Grab the lock and see if the device is available */ | 1491 | /* Grab the lock and see if the device is available */ |
1496 | nand_get_device (this, mtd , FL_READING); | 1492 | nand_get_device(this, mtd, FL_READING); |
1497 | 1493 | ||
1498 | this->select_chip (mtd, chip); | 1494 | this->select_chip(mtd, chip); |
1499 | 1495 | ||
1500 | /* Add requested oob length */ | 1496 | /* Add requested oob length */ |
1501 | len += ooblen; | 1497 | len += ooblen; |
1502 | 1498 | ||
1503 | while (len) { | 1499 | while (len) { |
1504 | if (sndcmd) | 1500 | if (sndcmd) |
1505 | this->cmdfunc (mtd, NAND_CMD_READ0, 0, page & this->pagemask); | 1501 | this->cmdfunc(mtd, NAND_CMD_READ0, 0, page & this->pagemask); |
1506 | sndcmd = 0; | 1502 | sndcmd = 0; |
1507 | 1503 | ||
1508 | this->read_buf (mtd, &buf[cnt], pagesize); | 1504 | this->read_buf(mtd, &buf[cnt], pagesize); |
1509 | 1505 | ||
1510 | len -= pagesize; | 1506 | len -= pagesize; |
1511 | cnt += pagesize; | 1507 | cnt += pagesize; |
1512 | page++; | 1508 | page++; |
1513 | 1509 | ||
1514 | if (!this->dev_ready) | 1510 | if (!this->dev_ready) |
1515 | udelay (this->chip_delay); | 1511 | udelay(this->chip_delay); |
1516 | else | 1512 | else |
1517 | nand_wait_ready(mtd); | 1513 | nand_wait_ready(mtd); |
1518 | 1514 | ||
@@ -1526,7 +1522,6 @@ int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, | |||
1526 | return 0; | 1522 | return 0; |
1527 | } | 1523 | } |
1528 | 1524 | ||
1529 | |||
1530 | /** | 1525 | /** |
1531 | * nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer | 1526 | * nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer |
1532 | * @mtd: MTD device structure | 1527 | * @mtd: MTD device structure |
@@ -1550,8 +1545,8 @@ int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, | |||
1550 | * forces the 0xff fill before using the buffer again. | 1545 | * forces the 0xff fill before using the buffer again. |
1551 | * | 1546 | * |
1552 | */ | 1547 | */ |
1553 | static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct nand_oobinfo *oobsel, | 1548 | static u_char *nand_prepare_oobbuf(struct mtd_info *mtd, u_char *fsbuf, struct nand_oobinfo *oobsel, |
1554 | int autoplace, int numpages) | 1549 | int autoplace, int numpages) |
1555 | { | 1550 | { |
1556 | struct nand_chip *this = mtd->priv; | 1551 | struct nand_chip *this = mtd->priv; |
1557 | int i, len, ofs; | 1552 | int i, len, ofs; |
@@ -1562,8 +1557,7 @@ static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct | |||
1562 | 1557 | ||
1563 | /* Check, if the buffer must be filled with ff again */ | 1558 | /* Check, if the buffer must be filled with ff again */ |
1564 | if (this->oobdirty) { | 1559 | if (this->oobdirty) { |
1565 | memset (this->oob_buf, 0xff, | 1560 | memset(this->oob_buf, 0xff, mtd->oobsize << (this->phys_erase_shift - this->page_shift)); |
1566 | mtd->oobsize << (this->phys_erase_shift - this->page_shift)); | ||
1567 | this->oobdirty = 0; | 1561 | this->oobdirty = 0; |
1568 | } | 1562 | } |
1569 | 1563 | ||
@@ -1578,7 +1572,7 @@ static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct | |||
1578 | for (i = 0, len = 0; len < mtd->oobavail; i++) { | 1572 | for (i = 0, len = 0; len < mtd->oobavail; i++) { |
1579 | int to = ofs + oobsel->oobfree[i][0]; | 1573 | int to = ofs + oobsel->oobfree[i][0]; |
1580 | int num = oobsel->oobfree[i][1]; | 1574 | int num = oobsel->oobfree[i][1]; |
1581 | memcpy (&this->oob_buf[to], fsbuf, num); | 1575 | memcpy(&this->oob_buf[to], fsbuf, num); |
1582 | len += num; | 1576 | len += num; |
1583 | fsbuf += num; | 1577 | fsbuf += num; |
1584 | } | 1578 | } |
@@ -1600,9 +1594,9 @@ static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct | |||
1600 | * This function simply calls nand_write_ecc with oob buffer and oobsel = NULL | 1594 | * This function simply calls nand_write_ecc with oob buffer and oobsel = NULL |
1601 | * | 1595 | * |
1602 | */ | 1596 | */ |
1603 | static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf) | 1597 | static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) |
1604 | { | 1598 | { |
1605 | return (nand_write_ecc (mtd, to, len, retlen, buf, NULL, NULL)); | 1599 | return (nand_write_ecc(mtd, to, len, retlen, buf, NULL, NULL)); |
1606 | } | 1600 | } |
1607 | 1601 | ||
1608 | /** | 1602 | /** |
@@ -1617,34 +1611,35 @@ static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * ret | |||
1617 | * | 1611 | * |
1618 | * NAND write with ECC | 1612 | * NAND write with ECC |
1619 | */ | 1613 | */ |
1620 | static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | 1614 | static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, |
1621 | size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel) | 1615 | size_t *retlen, const u_char *buf, u_char *eccbuf, |
1616 | struct nand_oobinfo *oobsel) | ||
1622 | { | 1617 | { |
1623 | int startpage, page, ret = -EIO, oob = 0, written = 0, chipnr; | 1618 | int startpage, page, ret = -EIO, oob = 0, written = 0, chipnr; |
1624 | int autoplace = 0, numpages, totalpages; | 1619 | int autoplace = 0, numpages, totalpages; |
1625 | struct nand_chip *this = mtd->priv; | 1620 | struct nand_chip *this = mtd->priv; |
1626 | u_char *oobbuf, *bufstart; | 1621 | u_char *oobbuf, *bufstart; |
1627 | int ppblock = (1 << (this->phys_erase_shift - this->page_shift)); | 1622 | int ppblock = (1 << (this->phys_erase_shift - this->page_shift)); |
1628 | 1623 | ||
1629 | DEBUG (MTD_DEBUG_LEVEL3, "nand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len); | 1624 | DEBUG(MTD_DEBUG_LEVEL3, "nand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int)to, (int)len); |
1630 | 1625 | ||
1631 | /* Initialize retlen, in case of early exit */ | 1626 | /* Initialize retlen, in case of early exit */ |
1632 | *retlen = 0; | 1627 | *retlen = 0; |
1633 | 1628 | ||
1634 | /* Do not allow write past end of device */ | 1629 | /* Do not allow write past end of device */ |
1635 | if ((to + len) > mtd->size) { | 1630 | if ((to + len) > mtd->size) { |
1636 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: Attempt to write past end of page\n"); | 1631 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: Attempt to write past end of page\n"); |
1637 | return -EINVAL; | 1632 | return -EINVAL; |
1638 | } | 1633 | } |
1639 | 1634 | ||
1640 | /* reject writes, which are not page aligned */ | 1635 | /* reject writes, which are not page aligned */ |
1641 | if (NOTALIGNED (to) || NOTALIGNED(len)) { | 1636 | if (NOTALIGNED(to) || NOTALIGNED(len)) { |
1642 | printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); | 1637 | printk(KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); |
1643 | return -EINVAL; | 1638 | return -EINVAL; |
1644 | } | 1639 | } |
1645 | 1640 | ||
1646 | /* Grab the lock and see if the device is available */ | 1641 | /* Grab the lock and see if the device is available */ |
1647 | nand_get_device (this, mtd, FL_WRITING); | 1642 | nand_get_device(this, mtd, FL_WRITING); |
1648 | 1643 | ||
1649 | /* Calculate chipnr */ | 1644 | /* Calculate chipnr */ |
1650 | chipnr = (int)(to >> this->chip_shift); | 1645 | chipnr = (int)(to >> this->chip_shift); |
@@ -1669,7 +1664,7 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1669 | 1664 | ||
1670 | /* Setup variables and oob buffer */ | 1665 | /* Setup variables and oob buffer */ |
1671 | totalpages = len >> this->page_shift; | 1666 | totalpages = len >> this->page_shift; |
1672 | page = (int) (to >> this->page_shift); | 1667 | page = (int)(to >> this->page_shift); |
1673 | /* Invalidate the page cache, if we write to the cached page */ | 1668 | /* Invalidate the page cache, if we write to the cached page */ |
1674 | if (page <= this->pagebuf && this->pagebuf < (page + totalpages)) | 1669 | if (page <= this->pagebuf && this->pagebuf < (page + totalpages)) |
1675 | this->pagebuf = -1; | 1670 | this->pagebuf = -1; |
@@ -1678,22 +1673,22 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1678 | page &= this->pagemask; | 1673 | page &= this->pagemask; |
1679 | startpage = page; | 1674 | startpage = page; |
1680 | /* Calc number of pages we can write in one go */ | 1675 | /* Calc number of pages we can write in one go */ |
1681 | numpages = min (ppblock - (startpage & (ppblock - 1)), totalpages); | 1676 | numpages = min(ppblock - (startpage & (ppblock - 1)), totalpages); |
1682 | oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel, autoplace, numpages); | 1677 | oobbuf = nand_prepare_oobbuf(mtd, eccbuf, oobsel, autoplace, numpages); |
1683 | bufstart = (u_char *)buf; | 1678 | bufstart = (u_char *) buf; |
1684 | 1679 | ||
1685 | /* Loop until all data is written */ | 1680 | /* Loop until all data is written */ |
1686 | while (written < len) { | 1681 | while (written < len) { |
1687 | 1682 | ||
1688 | this->data_poi = (u_char*) &buf[written]; | 1683 | this->data_poi = (u_char *) &buf[written]; |
1689 | /* Write one page. If this is the last page to write | 1684 | /* Write one page. If this is the last page to write |
1690 | * or the last page in this block, then use the | 1685 | * or the last page in this block, then use the |
1691 | * real pageprogram command, else select cached programming | 1686 | * real pageprogram command, else select cached programming |
1692 | * if supported by the chip. | 1687 | * if supported by the chip. |
1693 | */ | 1688 | */ |
1694 | ret = nand_write_page (mtd, this, page, &oobbuf[oob], oobsel, (--numpages > 0)); | 1689 | ret = nand_write_page(mtd, this, page, &oobbuf[oob], oobsel, (--numpages > 0)); |
1695 | if (ret) { | 1690 | if (ret) { |
1696 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: write_page failed %d\n", ret); | 1691 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: write_page failed %d\n", ret); |
1697 | goto out; | 1692 | goto out; |
1698 | } | 1693 | } |
1699 | /* Next oob page */ | 1694 | /* Next oob page */ |
@@ -1709,15 +1704,14 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1709 | /* Have we hit a block boundary ? Then we have to verify and | 1704 | /* Have we hit a block boundary ? Then we have to verify and |
1710 | * if verify is ok, we have to setup the oob buffer for | 1705 | * if verify is ok, we have to setup the oob buffer for |
1711 | * the next pages. | 1706 | * the next pages. |
1712 | */ | 1707 | */ |
1713 | if (!(page & (ppblock - 1))){ | 1708 | if (!(page & (ppblock - 1))) { |
1714 | int ofs; | 1709 | int ofs; |
1715 | this->data_poi = bufstart; | 1710 | this->data_poi = bufstart; |
1716 | ret = nand_verify_pages (mtd, this, startpage, | 1711 | ret = nand_verify_pages(mtd, this, startpage, page - startpage, |
1717 | page - startpage, | 1712 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); |
1718 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); | ||
1719 | if (ret) { | 1713 | if (ret) { |
1720 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); | 1714 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); |
1721 | goto out; | 1715 | goto out; |
1722 | } | 1716 | } |
1723 | *retlen = written; | 1717 | *retlen = written; |
@@ -1726,11 +1720,10 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1726 | if (eccbuf) | 1720 | if (eccbuf) |
1727 | eccbuf += (page - startpage) * ofs; | 1721 | eccbuf += (page - startpage) * ofs; |
1728 | totalpages -= page - startpage; | 1722 | totalpages -= page - startpage; |
1729 | numpages = min (totalpages, ppblock); | 1723 | numpages = min(totalpages, ppblock); |
1730 | page &= this->pagemask; | 1724 | page &= this->pagemask; |
1731 | startpage = page; | 1725 | startpage = page; |
1732 | oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel, | 1726 | oobbuf = nand_prepare_oobbuf(mtd, eccbuf, oobsel, autoplace, numpages); |
1733 | autoplace, numpages); | ||
1734 | oob = 0; | 1727 | oob = 0; |
1735 | /* Check, if we cross a chip boundary */ | 1728 | /* Check, if we cross a chip boundary */ |
1736 | if (!page) { | 1729 | if (!page) { |
@@ -1741,23 +1734,21 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len, | |||
1741 | } | 1734 | } |
1742 | } | 1735 | } |
1743 | /* Verify the remaining pages */ | 1736 | /* Verify the remaining pages */ |
1744 | cmp: | 1737 | cmp: |
1745 | this->data_poi = bufstart; | 1738 | this->data_poi = bufstart; |
1746 | ret = nand_verify_pages (mtd, this, startpage, totalpages, | 1739 | ret = nand_verify_pages(mtd, this, startpage, totalpages, oobbuf, oobsel, chipnr, (eccbuf != NULL)); |
1747 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); | ||
1748 | if (!ret) | 1740 | if (!ret) |
1749 | *retlen = written; | 1741 | *retlen = written; |
1750 | else | 1742 | else |
1751 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); | 1743 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); |
1752 | 1744 | ||
1753 | out: | 1745 | out: |
1754 | /* Deselect and wake up anyone waiting on the device */ | 1746 | /* Deselect and wake up anyone waiting on the device */ |
1755 | nand_release_device(mtd); | 1747 | nand_release_device(mtd); |
1756 | 1748 | ||
1757 | return ret; | 1749 | return ret; |
1758 | } | 1750 | } |
1759 | 1751 | ||
1760 | |||
1761 | /** | 1752 | /** |
1762 | * nand_write_oob - [MTD Interface] NAND write out-of-band | 1753 | * nand_write_oob - [MTD Interface] NAND write out-of-band |
1763 | * @mtd: MTD device structure | 1754 | * @mtd: MTD device structure |
@@ -1768,16 +1759,16 @@ out: | |||
1768 | * | 1759 | * |
1769 | * NAND write out-of-band | 1760 | * NAND write out-of-band |
1770 | */ | 1761 | */ |
1771 | static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * retlen, const u_char * buf) | 1762 | static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) |
1772 | { | 1763 | { |
1773 | int column, page, status, ret = -EIO, chipnr; | 1764 | int column, page, status, ret = -EIO, chipnr; |
1774 | struct nand_chip *this = mtd->priv; | 1765 | struct nand_chip *this = mtd->priv; |
1775 | 1766 | ||
1776 | DEBUG (MTD_DEBUG_LEVEL3, "nand_write_oob: to = 0x%08x, len = %i\n", (unsigned int) to, (int) len); | 1767 | DEBUG(MTD_DEBUG_LEVEL3, "nand_write_oob: to = 0x%08x, len = %i\n", (unsigned int)to, (int)len); |
1777 | 1768 | ||
1778 | /* Shift to get page */ | 1769 | /* Shift to get page */ |
1779 | page = (int) (to >> this->page_shift); | 1770 | page = (int)(to >> this->page_shift); |
1780 | chipnr = (int) (to >> this->chip_shift); | 1771 | chipnr = (int)(to >> this->chip_shift); |
1781 | 1772 | ||
1782 | /* Mask to get column */ | 1773 | /* Mask to get column */ |
1783 | column = to & (mtd->oobsize - 1); | 1774 | column = to & (mtd->oobsize - 1); |
@@ -1787,12 +1778,12 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * | |||
1787 | 1778 | ||
1788 | /* Do not allow write past end of page */ | 1779 | /* Do not allow write past end of page */ |
1789 | if ((column + len) > mtd->oobsize) { | 1780 | if ((column + len) > mtd->oobsize) { |
1790 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: Attempt to write past end of page\n"); | 1781 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_oob: Attempt to write past end of page\n"); |
1791 | return -EINVAL; | 1782 | return -EINVAL; |
1792 | } | 1783 | } |
1793 | 1784 | ||
1794 | /* Grab the lock and see if the device is available */ | 1785 | /* Grab the lock and see if the device is available */ |
1795 | nand_get_device (this, mtd, FL_WRITING); | 1786 | nand_get_device(this, mtd, FL_WRITING); |
1796 | 1787 | ||
1797 | /* Select the NAND device */ | 1788 | /* Select the NAND device */ |
1798 | this->select_chip(mtd, chipnr); | 1789 | this->select_chip(mtd, chipnr); |
@@ -1814,27 +1805,27 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * | |||
1814 | 1805 | ||
1815 | if (NAND_MUST_PAD(this)) { | 1806 | if (NAND_MUST_PAD(this)) { |
1816 | /* Write out desired data */ | 1807 | /* Write out desired data */ |
1817 | this->cmdfunc (mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask); | 1808 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock, page & this->pagemask); |
1818 | /* prepad 0xff for partial programming */ | 1809 | /* prepad 0xff for partial programming */ |
1819 | this->write_buf(mtd, ffchars, column); | 1810 | this->write_buf(mtd, ffchars, column); |
1820 | /* write data */ | 1811 | /* write data */ |
1821 | this->write_buf(mtd, buf, len); | 1812 | this->write_buf(mtd, buf, len); |
1822 | /* postpad 0xff for partial programming */ | 1813 | /* postpad 0xff for partial programming */ |
1823 | this->write_buf(mtd, ffchars, mtd->oobsize - (len+column)); | 1814 | this->write_buf(mtd, ffchars, mtd->oobsize - (len + column)); |
1824 | } else { | 1815 | } else { |
1825 | /* Write out desired data */ | 1816 | /* Write out desired data */ |
1826 | this->cmdfunc (mtd, NAND_CMD_SEQIN, mtd->oobblock + column, page & this->pagemask); | 1817 | this->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->oobblock + column, page & this->pagemask); |
1827 | /* write data */ | 1818 | /* write data */ |
1828 | this->write_buf(mtd, buf, len); | 1819 | this->write_buf(mtd, buf, len); |
1829 | } | 1820 | } |
1830 | /* Send command to program the OOB data */ | 1821 | /* Send command to program the OOB data */ |
1831 | this->cmdfunc (mtd, NAND_CMD_PAGEPROG, -1, -1); | 1822 | this->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); |
1832 | 1823 | ||
1833 | status = this->waitfunc (mtd, this, FL_WRITING); | 1824 | status = this->waitfunc(mtd, this, FL_WRITING); |
1834 | 1825 | ||
1835 | /* See if device thinks it succeeded */ | 1826 | /* See if device thinks it succeeded */ |
1836 | if (status & NAND_STATUS_FAIL) { | 1827 | if (status & NAND_STATUS_FAIL) { |
1837 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write, page 0x%08x\n", page); | 1828 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write, page 0x%08x\n", page); |
1838 | ret = -EIO; | 1829 | ret = -EIO; |
1839 | goto out; | 1830 | goto out; |
1840 | } | 1831 | } |
@@ -1843,23 +1834,22 @@ static int nand_write_oob (struct mtd_info *mtd, loff_t to, size_t len, size_t * | |||
1843 | 1834 | ||
1844 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE | 1835 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE |
1845 | /* Send command to read back the data */ | 1836 | /* Send command to read back the data */ |
1846 | this->cmdfunc (mtd, NAND_CMD_READOOB, column, page & this->pagemask); | 1837 | this->cmdfunc(mtd, NAND_CMD_READOOB, column, page & this->pagemask); |
1847 | 1838 | ||
1848 | if (this->verify_buf(mtd, buf, len)) { | 1839 | if (this->verify_buf(mtd, buf, len)) { |
1849 | DEBUG (MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write verify, page 0x%08x\n", page); | 1840 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_oob: " "Failed write verify, page 0x%08x\n", page); |
1850 | ret = -EIO; | 1841 | ret = -EIO; |
1851 | goto out; | 1842 | goto out; |
1852 | } | 1843 | } |
1853 | #endif | 1844 | #endif |
1854 | ret = 0; | 1845 | ret = 0; |
1855 | out: | 1846 | out: |
1856 | /* Deselect and wake up anyone waiting on the device */ | 1847 | /* Deselect and wake up anyone waiting on the device */ |
1857 | nand_release_device(mtd); | 1848 | nand_release_device(mtd); |
1858 | 1849 | ||
1859 | return ret; | 1850 | return ret; |
1860 | } | 1851 | } |
1861 | 1852 | ||
1862 | |||
1863 | /** | 1853 | /** |
1864 | * nand_writev - [MTD Interface] compabilty function for nand_writev_ecc | 1854 | * nand_writev - [MTD Interface] compabilty function for nand_writev_ecc |
1865 | * @mtd: MTD device structure | 1855 | * @mtd: MTD device structure |
@@ -1870,10 +1860,10 @@ out: | |||
1870 | * | 1860 | * |
1871 | * NAND write with kvec. This just calls the ecc function | 1861 | * NAND write with kvec. This just calls the ecc function |
1872 | */ | 1862 | */ |
1873 | static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, | 1863 | static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, |
1874 | loff_t to, size_t * retlen) | 1864 | loff_t to, size_t *retlen) |
1875 | { | 1865 | { |
1876 | return (nand_writev_ecc (mtd, vecs, count, to, retlen, NULL, NULL)); | 1866 | return (nand_writev_ecc(mtd, vecs, count, to, retlen, NULL, NULL)); |
1877 | } | 1867 | } |
1878 | 1868 | ||
1879 | /** | 1869 | /** |
@@ -1888,13 +1878,13 @@ static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs, unsigned | |||
1888 | * | 1878 | * |
1889 | * NAND write with iovec with ecc | 1879 | * NAND write with iovec with ecc |
1890 | */ | 1880 | */ |
1891 | static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, | 1881 | static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, |
1892 | loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel) | 1882 | loff_t to, size_t *retlen, u_char *eccbuf, struct nand_oobinfo *oobsel) |
1893 | { | 1883 | { |
1894 | int i, page, len, total_len, ret = -EIO, written = 0, chipnr; | 1884 | int i, page, len, total_len, ret = -EIO, written = 0, chipnr; |
1895 | int oob, numpages, autoplace = 0, startpage; | 1885 | int oob, numpages, autoplace = 0, startpage; |
1896 | struct nand_chip *this = mtd->priv; | 1886 | struct nand_chip *this = mtd->priv; |
1897 | int ppblock = (1 << (this->phys_erase_shift - this->page_shift)); | 1887 | int ppblock = (1 << (this->phys_erase_shift - this->page_shift)); |
1898 | u_char *oobbuf, *bufstart; | 1888 | u_char *oobbuf, *bufstart; |
1899 | 1889 | ||
1900 | /* Preset written len for early exit */ | 1890 | /* Preset written len for early exit */ |
@@ -1903,28 +1893,27 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1903 | /* Calculate total length of data */ | 1893 | /* Calculate total length of data */ |
1904 | total_len = 0; | 1894 | total_len = 0; |
1905 | for (i = 0; i < count; i++) | 1895 | for (i = 0; i < count; i++) |
1906 | total_len += (int) vecs[i].iov_len; | 1896 | total_len += (int)vecs[i].iov_len; |
1907 | 1897 | ||
1908 | DEBUG (MTD_DEBUG_LEVEL3, | 1898 | DEBUG(MTD_DEBUG_LEVEL3, "nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int)to, (unsigned int)total_len, count); |
1909 | "nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count); | ||
1910 | 1899 | ||
1911 | /* Do not allow write past end of page */ | 1900 | /* Do not allow write past end of page */ |
1912 | if ((to + total_len) > mtd->size) { | 1901 | if ((to + total_len) > mtd->size) { |
1913 | DEBUG (MTD_DEBUG_LEVEL0, "nand_writev: Attempted write past end of device\n"); | 1902 | DEBUG(MTD_DEBUG_LEVEL0, "nand_writev: Attempted write past end of device\n"); |
1914 | return -EINVAL; | 1903 | return -EINVAL; |
1915 | } | 1904 | } |
1916 | 1905 | ||
1917 | /* reject writes, which are not page aligned */ | 1906 | /* reject writes, which are not page aligned */ |
1918 | if (NOTALIGNED (to) || NOTALIGNED(total_len)) { | 1907 | if (NOTALIGNED(to) || NOTALIGNED(total_len)) { |
1919 | printk (KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); | 1908 | printk(KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); |
1920 | return -EINVAL; | 1909 | return -EINVAL; |
1921 | } | 1910 | } |
1922 | 1911 | ||
1923 | /* Grab the lock and see if the device is available */ | 1912 | /* Grab the lock and see if the device is available */ |
1924 | nand_get_device (this, mtd, FL_WRITING); | 1913 | nand_get_device(this, mtd, FL_WRITING); |
1925 | 1914 | ||
1926 | /* Get the current chip-nr */ | 1915 | /* Get the current chip-nr */ |
1927 | chipnr = (int) (to >> this->chip_shift); | 1916 | chipnr = (int)(to >> this->chip_shift); |
1928 | /* Select the NAND device */ | 1917 | /* Select the NAND device */ |
1929 | this->select_chip(mtd, chipnr); | 1918 | this->select_chip(mtd, chipnr); |
1930 | 1919 | ||
@@ -1945,7 +1934,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1945 | autoplace = 1; | 1934 | autoplace = 1; |
1946 | 1935 | ||
1947 | /* Setup start page */ | 1936 | /* Setup start page */ |
1948 | page = (int) (to >> this->page_shift); | 1937 | page = (int)(to >> this->page_shift); |
1949 | /* Invalidate the page cache, if we write to the cached page */ | 1938 | /* Invalidate the page cache, if we write to the cached page */ |
1950 | if (page <= this->pagebuf && this->pagebuf < ((to + total_len) >> this->page_shift)) | 1939 | if (page <= this->pagebuf && this->pagebuf < ((to + total_len) >> this->page_shift)) |
1951 | this->pagebuf = -1; | 1940 | this->pagebuf = -1; |
@@ -1963,9 +1952,9 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1963 | * out of this iov in one go */ | 1952 | * out of this iov in one go */ |
1964 | numpages = (vecs->iov_len - len) >> this->page_shift; | 1953 | numpages = (vecs->iov_len - len) >> this->page_shift; |
1965 | /* Do not cross block boundaries */ | 1954 | /* Do not cross block boundaries */ |
1966 | numpages = min (ppblock - (startpage & (ppblock - 1)), numpages); | 1955 | numpages = min(ppblock - (startpage & (ppblock - 1)), numpages); |
1967 | oobbuf = nand_prepare_oobbuf (mtd, NULL, oobsel, autoplace, numpages); | 1956 | oobbuf = nand_prepare_oobbuf(mtd, NULL, oobsel, autoplace, numpages); |
1968 | bufstart = (u_char *)vecs->iov_base; | 1957 | bufstart = (u_char *) vecs->iov_base; |
1969 | bufstart += len; | 1958 | bufstart += len; |
1970 | this->data_poi = bufstart; | 1959 | this->data_poi = bufstart; |
1971 | oob = 0; | 1960 | oob = 0; |
@@ -1974,8 +1963,8 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1974 | * then use the real pageprogram command, else select | 1963 | * then use the real pageprogram command, else select |
1975 | * cached programming if supported by the chip. | 1964 | * cached programming if supported by the chip. |
1976 | */ | 1965 | */ |
1977 | ret = nand_write_page (mtd, this, page & this->pagemask, | 1966 | ret = nand_write_page(mtd, this, page & this->pagemask, |
1978 | &oobbuf[oob], oobsel, i != numpages); | 1967 | &oobbuf[oob], oobsel, i != numpages); |
1979 | if (ret) | 1968 | if (ret) |
1980 | goto out; | 1969 | goto out; |
1981 | this->data_poi += mtd->oobblock; | 1970 | this->data_poi += mtd->oobblock; |
@@ -1984,7 +1973,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1984 | page++; | 1973 | page++; |
1985 | } | 1974 | } |
1986 | /* Check, if we have to switch to the next tuple */ | 1975 | /* Check, if we have to switch to the next tuple */ |
1987 | if (len >= (int) vecs->iov_len) { | 1976 | if (len >= (int)vecs->iov_len) { |
1988 | vecs++; | 1977 | vecs++; |
1989 | len = 0; | 1978 | len = 0; |
1990 | count--; | 1979 | count--; |
@@ -1998,7 +1987,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
1998 | if (vecs->iov_base != NULL && vecs->iov_len) | 1987 | if (vecs->iov_base != NULL && vecs->iov_len) |
1999 | this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++]; | 1988 | this->data_buf[cnt++] = ((u_char *) vecs->iov_base)[len++]; |
2000 | /* Check, if we have to switch to the next tuple */ | 1989 | /* Check, if we have to switch to the next tuple */ |
2001 | if (len >= (int) vecs->iov_len) { | 1990 | if (len >= (int)vecs->iov_len) { |
2002 | vecs++; | 1991 | vecs++; |
2003 | len = 0; | 1992 | len = 0; |
2004 | count--; | 1993 | count--; |
@@ -2008,16 +1997,15 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
2008 | this->data_poi = this->data_buf; | 1997 | this->data_poi = this->data_buf; |
2009 | bufstart = this->data_poi; | 1998 | bufstart = this->data_poi; |
2010 | numpages = 1; | 1999 | numpages = 1; |
2011 | oobbuf = nand_prepare_oobbuf (mtd, NULL, oobsel, autoplace, numpages); | 2000 | oobbuf = nand_prepare_oobbuf(mtd, NULL, oobsel, autoplace, numpages); |
2012 | ret = nand_write_page (mtd, this, page & this->pagemask, | 2001 | ret = nand_write_page(mtd, this, page & this->pagemask, oobbuf, oobsel, 0); |
2013 | oobbuf, oobsel, 0); | ||
2014 | if (ret) | 2002 | if (ret) |
2015 | goto out; | 2003 | goto out; |
2016 | page++; | 2004 | page++; |
2017 | } | 2005 | } |
2018 | 2006 | ||
2019 | this->data_poi = bufstart; | 2007 | this->data_poi = bufstart; |
2020 | ret = nand_verify_pages (mtd, this, startpage, numpages, oobbuf, oobsel, chipnr, 0); | 2008 | ret = nand_verify_pages(mtd, this, startpage, numpages, oobbuf, oobsel, chipnr, 0); |
2021 | if (ret) | 2009 | if (ret) |
2022 | goto out; | 2010 | goto out; |
2023 | 2011 | ||
@@ -2035,7 +2023,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig | |||
2035 | } | 2023 | } |
2036 | } | 2024 | } |
2037 | ret = 0; | 2025 | ret = 0; |
2038 | out: | 2026 | out: |
2039 | /* Deselect and wake up anyone waiting on the device */ | 2027 | /* Deselect and wake up anyone waiting on the device */ |
2040 | nand_release_device(mtd); | 2028 | nand_release_device(mtd); |
2041 | 2029 | ||
@@ -2050,12 +2038,12 @@ out: | |||
2050 | * | 2038 | * |
2051 | * Standard erase command for NAND chips | 2039 | * Standard erase command for NAND chips |
2052 | */ | 2040 | */ |
2053 | static void single_erase_cmd (struct mtd_info *mtd, int page) | 2041 | static void single_erase_cmd(struct mtd_info *mtd, int page) |
2054 | { | 2042 | { |
2055 | struct nand_chip *this = mtd->priv; | 2043 | struct nand_chip *this = mtd->priv; |
2056 | /* Send commands to erase a block */ | 2044 | /* Send commands to erase a block */ |
2057 | this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page); | 2045 | this->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page); |
2058 | this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1); | 2046 | this->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1); |
2059 | } | 2047 | } |
2060 | 2048 | ||
2061 | /** | 2049 | /** |
@@ -2066,15 +2054,15 @@ static void single_erase_cmd (struct mtd_info *mtd, int page) | |||
2066 | * AND multi block erase command function | 2054 | * AND multi block erase command function |
2067 | * Erase 4 consecutive blocks | 2055 | * Erase 4 consecutive blocks |
2068 | */ | 2056 | */ |
2069 | static void multi_erase_cmd (struct mtd_info *mtd, int page) | 2057 | static void multi_erase_cmd(struct mtd_info *mtd, int page) |
2070 | { | 2058 | { |
2071 | struct nand_chip *this = mtd->priv; | 2059 | struct nand_chip *this = mtd->priv; |
2072 | /* Send commands to erase a block */ | 2060 | /* Send commands to erase a block */ |
2073 | this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++); | 2061 | this->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page++); |
2074 | this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++); | 2062 | this->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page++); |
2075 | this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page++); | 2063 | this->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page++); |
2076 | this->cmdfunc (mtd, NAND_CMD_ERASE1, -1, page); | 2064 | this->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page); |
2077 | this->cmdfunc (mtd, NAND_CMD_ERASE2, -1, -1); | 2065 | this->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1); |
2078 | } | 2066 | } |
2079 | 2067 | ||
2080 | /** | 2068 | /** |
@@ -2084,9 +2072,9 @@ static void multi_erase_cmd (struct mtd_info *mtd, int page) | |||
2084 | * | 2072 | * |
2085 | * Erase one ore more blocks | 2073 | * Erase one ore more blocks |
2086 | */ | 2074 | */ |
2087 | static int nand_erase (struct mtd_info *mtd, struct erase_info *instr) | 2075 | static int nand_erase(struct mtd_info *mtd, struct erase_info *instr) |
2088 | { | 2076 | { |
2089 | return nand_erase_nand (mtd, instr, 0); | 2077 | return nand_erase_nand(mtd, instr, 0); |
2090 | } | 2078 | } |
2091 | 2079 | ||
2092 | #define BBT_PAGE_MASK 0xffffff3f | 2080 | #define BBT_PAGE_MASK 0xffffff3f |
@@ -2098,7 +2086,7 @@ static int nand_erase (struct mtd_info *mtd, struct erase_info *instr) | |||
2098 | * | 2086 | * |
2099 | * Erase one ore more blocks | 2087 | * Erase one ore more blocks |
2100 | */ | 2088 | */ |
2101 | int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbbt) | 2089 | int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, int allowbbt) |
2102 | { | 2090 | { |
2103 | int page, len, status, pages_per_block, ret, chipnr; | 2091 | int page, len, status, pages_per_block, ret, chipnr; |
2104 | struct nand_chip *this = mtd->priv; | 2092 | struct nand_chip *this = mtd->priv; |
@@ -2107,35 +2095,34 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2107 | /* It is used to see if the current page is in the same */ | 2095 | /* It is used to see if the current page is in the same */ |
2108 | /* 256 block group and the same bank as the bbt. */ | 2096 | /* 256 block group and the same bank as the bbt. */ |
2109 | 2097 | ||
2110 | DEBUG (MTD_DEBUG_LEVEL3, | 2098 | DEBUG(MTD_DEBUG_LEVEL3, "nand_erase: start = 0x%08x, len = %i\n", (unsigned int)instr->addr, (unsigned int)instr->len); |
2111 | "nand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len); | ||
2112 | 2099 | ||
2113 | /* Start address must align on block boundary */ | 2100 | /* Start address must align on block boundary */ |
2114 | if (instr->addr & ((1 << this->phys_erase_shift) - 1)) { | 2101 | if (instr->addr & ((1 << this->phys_erase_shift) - 1)) { |
2115 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Unaligned address\n"); | 2102 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: Unaligned address\n"); |
2116 | return -EINVAL; | 2103 | return -EINVAL; |
2117 | } | 2104 | } |
2118 | 2105 | ||
2119 | /* Length must align on block boundary */ | 2106 | /* Length must align on block boundary */ |
2120 | if (instr->len & ((1 << this->phys_erase_shift) - 1)) { | 2107 | if (instr->len & ((1 << this->phys_erase_shift) - 1)) { |
2121 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Length not block aligned\n"); | 2108 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: Length not block aligned\n"); |
2122 | return -EINVAL; | 2109 | return -EINVAL; |
2123 | } | 2110 | } |
2124 | 2111 | ||
2125 | /* Do not allow erase past end of device */ | 2112 | /* Do not allow erase past end of device */ |
2126 | if ((instr->len + instr->addr) > mtd->size) { | 2113 | if ((instr->len + instr->addr) > mtd->size) { |
2127 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Erase past end of device\n"); | 2114 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: Erase past end of device\n"); |
2128 | return -EINVAL; | 2115 | return -EINVAL; |
2129 | } | 2116 | } |
2130 | 2117 | ||
2131 | instr->fail_addr = 0xffffffff; | 2118 | instr->fail_addr = 0xffffffff; |
2132 | 2119 | ||
2133 | /* Grab the lock and see if the device is available */ | 2120 | /* Grab the lock and see if the device is available */ |
2134 | nand_get_device (this, mtd, FL_ERASING); | 2121 | nand_get_device(this, mtd, FL_ERASING); |
2135 | 2122 | ||
2136 | /* Shift to get first page */ | 2123 | /* Shift to get first page */ |
2137 | page = (int) (instr->addr >> this->page_shift); | 2124 | page = (int)(instr->addr >> this->page_shift); |
2138 | chipnr = (int) (instr->addr >> this->chip_shift); | 2125 | chipnr = (int)(instr->addr >> this->chip_shift); |
2139 | 2126 | ||
2140 | /* Calculate pages in each block */ | 2127 | /* Calculate pages in each block */ |
2141 | pages_per_block = 1 << (this->phys_erase_shift - this->page_shift); | 2128 | pages_per_block = 1 << (this->phys_erase_shift - this->page_shift); |
@@ -2146,7 +2133,7 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2146 | /* Check the WP bit */ | 2133 | /* Check the WP bit */ |
2147 | /* Check, if it is write protected */ | 2134 | /* Check, if it is write protected */ |
2148 | if (nand_check_wp(mtd)) { | 2135 | if (nand_check_wp(mtd)) { |
2149 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: Device is write protected!!!\n"); | 2136 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: Device is write protected!!!\n"); |
2150 | instr->state = MTD_ERASE_FAILED; | 2137 | instr->state = MTD_ERASE_FAILED; |
2151 | goto erase_exit; | 2138 | goto erase_exit; |
2152 | } | 2139 | } |
@@ -2166,7 +2153,7 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2166 | while (len) { | 2153 | while (len) { |
2167 | /* Check if we have a bad block, we do not erase bad blocks ! */ | 2154 | /* Check if we have a bad block, we do not erase bad blocks ! */ |
2168 | if (nand_block_checkbad(mtd, ((loff_t) page) << this->page_shift, 0, allowbbt)) { | 2155 | if (nand_block_checkbad(mtd, ((loff_t) page) << this->page_shift, 0, allowbbt)) { |
2169 | printk (KERN_WARNING "nand_erase: attempt to erase a bad block at page 0x%08x\n", page); | 2156 | printk(KERN_WARNING "nand_erase: attempt to erase a bad block at page 0x%08x\n", page); |
2170 | instr->state = MTD_ERASE_FAILED; | 2157 | instr->state = MTD_ERASE_FAILED; |
2171 | goto erase_exit; | 2158 | goto erase_exit; |
2172 | } | 2159 | } |
@@ -2176,9 +2163,9 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2176 | if (page <= this->pagebuf && this->pagebuf < (page + pages_per_block)) | 2163 | if (page <= this->pagebuf && this->pagebuf < (page + pages_per_block)) |
2177 | this->pagebuf = -1; | 2164 | this->pagebuf = -1; |
2178 | 2165 | ||
2179 | this->erase_cmd (mtd, page & this->pagemask); | 2166 | this->erase_cmd(mtd, page & this->pagemask); |
2180 | 2167 | ||
2181 | status = this->waitfunc (mtd, this, FL_ERASING); | 2168 | status = this->waitfunc(mtd, this, FL_ERASING); |
2182 | 2169 | ||
2183 | /* See if operation failed and additional status checks are available */ | 2170 | /* See if operation failed and additional status checks are available */ |
2184 | if ((status & NAND_STATUS_FAIL) && (this->errstat)) { | 2171 | if ((status & NAND_STATUS_FAIL) && (this->errstat)) { |
@@ -2187,7 +2174,7 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2187 | 2174 | ||
2188 | /* See if block erase succeeded */ | 2175 | /* See if block erase succeeded */ |
2189 | if (status & NAND_STATUS_FAIL) { | 2176 | if (status & NAND_STATUS_FAIL) { |
2190 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase: " "Failed erase, page 0x%08x\n", page); | 2177 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: " "Failed erase, page 0x%08x\n", page); |
2191 | instr->state = MTD_ERASE_FAILED; | 2178 | instr->state = MTD_ERASE_FAILED; |
2192 | instr->fail_addr = (page << this->page_shift); | 2179 | instr->fail_addr = (page << this->page_shift); |
2193 | goto erase_exit; | 2180 | goto erase_exit; |
@@ -2221,7 +2208,7 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb | |||
2221 | } | 2208 | } |
2222 | instr->state = MTD_ERASE_DONE; | 2209 | instr->state = MTD_ERASE_DONE; |
2223 | 2210 | ||
2224 | erase_exit: | 2211 | erase_exit: |
2225 | 2212 | ||
2226 | ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO; | 2213 | ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO; |
2227 | /* Do call back function */ | 2214 | /* Do call back function */ |
@@ -2236,9 +2223,9 @@ erase_exit: | |||
2236 | for (chipnr = 0; chipnr < this->numchips; chipnr++) { | 2223 | for (chipnr = 0; chipnr < this->numchips; chipnr++) { |
2237 | if (rewrite_bbt[chipnr]) { | 2224 | if (rewrite_bbt[chipnr]) { |
2238 | /* update the BBT for chip */ | 2225 | /* update the BBT for chip */ |
2239 | DEBUG (MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt (%d:0x%0x 0x%0x)\n", | 2226 | DEBUG(MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt (%d:0x%0x 0x%0x)\n", |
2240 | chipnr, rewrite_bbt[chipnr], this->bbt_td->pages[chipnr]); | 2227 | chipnr, rewrite_bbt[chipnr], this->bbt_td->pages[chipnr]); |
2241 | nand_update_bbt (mtd, rewrite_bbt[chipnr]); | 2228 | nand_update_bbt(mtd, rewrite_bbt[chipnr]); |
2242 | } | 2229 | } |
2243 | } | 2230 | } |
2244 | } | 2231 | } |
@@ -2253,31 +2240,30 @@ erase_exit: | |||
2253 | * | 2240 | * |
2254 | * Sync is actually a wait for chip ready function | 2241 | * Sync is actually a wait for chip ready function |
2255 | */ | 2242 | */ |
2256 | static void nand_sync (struct mtd_info *mtd) | 2243 | static void nand_sync(struct mtd_info *mtd) |
2257 | { | 2244 | { |
2258 | struct nand_chip *this = mtd->priv; | 2245 | struct nand_chip *this = mtd->priv; |
2259 | 2246 | ||
2260 | DEBUG (MTD_DEBUG_LEVEL3, "nand_sync: called\n"); | 2247 | DEBUG(MTD_DEBUG_LEVEL3, "nand_sync: called\n"); |
2261 | 2248 | ||
2262 | /* Grab the lock and see if the device is available */ | 2249 | /* Grab the lock and see if the device is available */ |
2263 | nand_get_device (this, mtd, FL_SYNCING); | 2250 | nand_get_device(this, mtd, FL_SYNCING); |
2264 | /* Release it and go back */ | 2251 | /* Release it and go back */ |
2265 | nand_release_device (mtd); | 2252 | nand_release_device(mtd); |
2266 | } | 2253 | } |
2267 | 2254 | ||
2268 | |||
2269 | /** | 2255 | /** |
2270 | * nand_block_isbad - [MTD Interface] Check whether the block at the given offset is bad | 2256 | * nand_block_isbad - [MTD Interface] Check whether the block at the given offset is bad |
2271 | * @mtd: MTD device structure | 2257 | * @mtd: MTD device structure |
2272 | * @ofs: offset relative to mtd start | 2258 | * @ofs: offset relative to mtd start |
2273 | */ | 2259 | */ |
2274 | static int nand_block_isbad (struct mtd_info *mtd, loff_t ofs) | 2260 | static int nand_block_isbad(struct mtd_info *mtd, loff_t ofs) |
2275 | { | 2261 | { |
2276 | /* Check for invalid offset */ | 2262 | /* Check for invalid offset */ |
2277 | if (ofs > mtd->size) | 2263 | if (ofs > mtd->size) |
2278 | return -EINVAL; | 2264 | return -EINVAL; |
2279 | 2265 | ||
2280 | return nand_block_checkbad (mtd, ofs, 1, 0); | 2266 | return nand_block_checkbad(mtd, ofs, 1, 0); |
2281 | } | 2267 | } |
2282 | 2268 | ||
2283 | /** | 2269 | /** |
@@ -2285,17 +2271,17 @@ static int nand_block_isbad (struct mtd_info *mtd, loff_t ofs) | |||
2285 | * @mtd: MTD device structure | 2271 | * @mtd: MTD device structure |
2286 | * @ofs: offset relative to mtd start | 2272 | * @ofs: offset relative to mtd start |
2287 | */ | 2273 | */ |
2288 | static int nand_block_markbad (struct mtd_info *mtd, loff_t ofs) | 2274 | static int nand_block_markbad(struct mtd_info *mtd, loff_t ofs) |
2289 | { | 2275 | { |
2290 | struct nand_chip *this = mtd->priv; | 2276 | struct nand_chip *this = mtd->priv; |
2291 | int ret; | 2277 | int ret; |
2292 | 2278 | ||
2293 | if ((ret = nand_block_isbad(mtd, ofs))) { | 2279 | if ((ret = nand_block_isbad(mtd, ofs))) { |
2294 | /* If it was bad already, return success and do nothing. */ | 2280 | /* If it was bad already, return success and do nothing. */ |
2295 | if (ret > 0) | 2281 | if (ret > 0) |
2296 | return 0; | 2282 | return 0; |
2297 | return ret; | 2283 | return ret; |
2298 | } | 2284 | } |
2299 | 2285 | ||
2300 | return this->block_markbad(mtd, ofs); | 2286 | return this->block_markbad(mtd, ofs); |
2301 | } | 2287 | } |
@@ -2308,7 +2294,7 @@ static int nand_suspend(struct mtd_info *mtd) | |||
2308 | { | 2294 | { |
2309 | struct nand_chip *this = mtd->priv; | 2295 | struct nand_chip *this = mtd->priv; |
2310 | 2296 | ||
2311 | return nand_get_device (this, mtd, FL_PM_SUSPENDED); | 2297 | return nand_get_device(this, mtd, FL_PM_SUSPENDED); |
2312 | } | 2298 | } |
2313 | 2299 | ||
2314 | /** | 2300 | /** |
@@ -2322,30 +2308,44 @@ static void nand_resume(struct mtd_info *mtd) | |||
2322 | if (this->state == FL_PM_SUSPENDED) | 2308 | if (this->state == FL_PM_SUSPENDED) |
2323 | nand_release_device(mtd); | 2309 | nand_release_device(mtd); |
2324 | else | 2310 | else |
2325 | printk(KERN_ERR "resume() called for the chip which is not " | 2311 | printk(KERN_ERR "resume() called for the chip which is not in suspended state\n"); |
2326 | "in suspended state\n"); | ||
2327 | 2312 | ||
2328 | } | 2313 | } |
2329 | 2314 | ||
2315 | /* module_text_address() isn't exported, and it's mostly a pointless | ||
2316 | test if this is a module _anyway_ -- they'd have to try _really_ hard | ||
2317 | to call us from in-kernel code if the core NAND support is modular. */ | ||
2318 | #ifdef MODULE | ||
2319 | #define caller_is_module() (1) | ||
2320 | #else | ||
2321 | #define caller_is_module() module_text_address((unsigned long)__builtin_return_address(0)) | ||
2322 | #endif | ||
2330 | 2323 | ||
2331 | /** | 2324 | /** |
2332 | * nand_scan - [NAND Interface] Scan for the NAND device | 2325 | * nand_scan - [NAND Interface] Scan for the NAND device |
2333 | * @mtd: MTD device structure | 2326 | * @mtd: MTD device structure |
2334 | * @maxchips: Number of chips to scan for | 2327 | * @maxchips: Number of chips to scan for |
2335 | * | 2328 | * |
2336 | * This fills out all the not initialized function pointers | 2329 | * This fills out all the uninitialized function pointers |
2337 | * with the defaults. | 2330 | * with the defaults. |
2338 | * The flash ID is read and the mtd/chip structures are | 2331 | * The flash ID is read and the mtd/chip structures are |
2339 | * filled with the appropriate values. Buffers are allocated if | 2332 | * filled with the appropriate values. Buffers are allocated if |
2340 | * they are not provided by the board driver | 2333 | * they are not provided by the board driver |
2334 | * The mtd->owner field must be set to the module of the caller | ||
2341 | * | 2335 | * |
2342 | */ | 2336 | */ |
2343 | int nand_scan (struct mtd_info *mtd, int maxchips) | 2337 | int nand_scan(struct mtd_info *mtd, int maxchips) |
2344 | { | 2338 | { |
2345 | int i, nand_maf_id, nand_dev_id, busw, maf_id; | 2339 | int i, nand_maf_id, nand_dev_id, busw, maf_id; |
2346 | struct nand_chip *this = mtd->priv; | 2340 | struct nand_chip *this = mtd->priv; |
2347 | 2341 | ||
2348 | /* Get buswidth to select the correct functions*/ | 2342 | /* Many callers got this wrong, so check for it for a while... */ |
2343 | if (!mtd->owner && caller_is_module()) { | ||
2344 | printk(KERN_CRIT "nand_scan() called with NULL mtd->owner!\n"); | ||
2345 | BUG(); | ||
2346 | } | ||
2347 | |||
2348 | /* Get buswidth to select the correct functions */ | ||
2349 | busw = this->options & NAND_BUSWIDTH_16; | 2349 | busw = this->options & NAND_BUSWIDTH_16; |
2350 | 2350 | ||
2351 | /* check for proper chip_delay setup, set 20us if not */ | 2351 | /* check for proper chip_delay setup, set 20us if not */ |
@@ -2387,7 +2387,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2387 | this->select_chip(mtd, 0); | 2387 | this->select_chip(mtd, 0); |
2388 | 2388 | ||
2389 | /* Send the command for reading device ID */ | 2389 | /* Send the command for reading device ID */ |
2390 | this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1); | 2390 | this->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); |
2391 | 2391 | ||
2392 | /* Read manufacturer and device IDs */ | 2392 | /* Read manufacturer and device IDs */ |
2393 | nand_maf_id = this->read_byte(mtd); | 2393 | nand_maf_id = this->read_byte(mtd); |
@@ -2399,7 +2399,8 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2399 | if (nand_dev_id != nand_flash_ids[i].id) | 2399 | if (nand_dev_id != nand_flash_ids[i].id) |
2400 | continue; | 2400 | continue; |
2401 | 2401 | ||
2402 | if (!mtd->name) mtd->name = nand_flash_ids[i].name; | 2402 | if (!mtd->name) |
2403 | mtd->name = nand_flash_ids[i].name; | ||
2403 | this->chipsize = nand_flash_ids[i].chipsize << 20; | 2404 | this->chipsize = nand_flash_ids[i].chipsize << 20; |
2404 | 2405 | ||
2405 | /* New devices have all the information in additional id bytes */ | 2406 | /* New devices have all the information in additional id bytes */ |
@@ -2416,7 +2417,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2416 | mtd->oobsize = (8 << (extid & 0x01)) * (mtd->oobblock >> 9); | 2417 | mtd->oobsize = (8 << (extid & 0x01)) * (mtd->oobblock >> 9); |
2417 | extid >>= 2; | 2418 | extid >>= 2; |
2418 | /* Calc blocksize. Blocksize is multiples of 64KiB */ | 2419 | /* Calc blocksize. Blocksize is multiples of 64KiB */ |
2419 | mtd->erasesize = (64 * 1024) << (extid & 0x03); | 2420 | mtd->erasesize = (64 * 1024) << (extid & 0x03); |
2420 | extid >>= 2; | 2421 | extid >>= 2; |
2421 | /* Get buswidth information */ | 2422 | /* Get buswidth information */ |
2422 | busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0; | 2423 | busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0; |
@@ -2439,13 +2440,12 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2439 | /* Check, if buswidth is correct. Hardware drivers should set | 2440 | /* Check, if buswidth is correct. Hardware drivers should set |
2440 | * this correct ! */ | 2441 | * this correct ! */ |
2441 | if (busw != (this->options & NAND_BUSWIDTH_16)) { | 2442 | if (busw != (this->options & NAND_BUSWIDTH_16)) { |
2442 | printk (KERN_INFO "NAND device: Manufacturer ID:" | 2443 | printk(KERN_INFO "NAND device: Manufacturer ID:" |
2443 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, | 2444 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, |
2444 | nand_manuf_ids[maf_id].name , mtd->name); | 2445 | nand_manuf_ids[maf_id].name, mtd->name); |
2445 | printk (KERN_WARNING | 2446 | printk(KERN_WARNING |
2446 | "NAND bus width %d instead %d bit\n", | 2447 | "NAND bus width %d instead %d bit\n", |
2447 | (this->options & NAND_BUSWIDTH_16) ? 16 : 8, | 2448 | (this->options & NAND_BUSWIDTH_16) ? 16 : 8, busw ? 16 : 8); |
2448 | busw ? 16 : 8); | ||
2449 | this->select_chip(mtd, -1); | 2449 | this->select_chip(mtd, -1); |
2450 | return 1; | 2450 | return 1; |
2451 | } | 2451 | } |
@@ -2456,13 +2456,12 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2456 | this->chip_shift = ffs(this->chipsize) - 1; | 2456 | this->chip_shift = ffs(this->chipsize) - 1; |
2457 | 2457 | ||
2458 | /* Set the bad block position */ | 2458 | /* Set the bad block position */ |
2459 | this->badblockpos = mtd->oobblock > 512 ? | 2459 | this->badblockpos = mtd->oobblock > 512 ? NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; |
2460 | NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS; | ||
2461 | 2460 | ||
2462 | /* Get chip options, preserve non chip based options */ | 2461 | /* Get chip options, preserve non chip based options */ |
2463 | this->options &= ~NAND_CHIPOPTIONS_MSK; | 2462 | this->options &= ~NAND_CHIPOPTIONS_MSK; |
2464 | this->options |= nand_flash_ids[i].options & NAND_CHIPOPTIONS_MSK; | 2463 | this->options |= nand_flash_ids[i].options & NAND_CHIPOPTIONS_MSK; |
2465 | /* Set this as a default. Board drivers can override it, if neccecary */ | 2464 | /* Set this as a default. Board drivers can override it, if necessary */ |
2466 | this->options |= NAND_NO_AUTOINCR; | 2465 | this->options |= NAND_NO_AUTOINCR; |
2467 | /* Check if this is a not a samsung device. Do not clear the options | 2466 | /* Check if this is a not a samsung device. Do not clear the options |
2468 | * for chips which are not having an extended id. | 2467 | * for chips which are not having an extended id. |
@@ -2480,23 +2479,23 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2480 | if (mtd->oobblock > 512 && this->cmdfunc == nand_command) | 2479 | if (mtd->oobblock > 512 && this->cmdfunc == nand_command) |
2481 | this->cmdfunc = nand_command_lp; | 2480 | this->cmdfunc = nand_command_lp; |
2482 | 2481 | ||
2483 | printk (KERN_INFO "NAND device: Manufacturer ID:" | 2482 | printk(KERN_INFO "NAND device: Manufacturer ID:" |
2484 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, | 2483 | " 0x%02x, Chip ID: 0x%02x (%s %s)\n", nand_maf_id, nand_dev_id, |
2485 | nand_manuf_ids[maf_id].name , nand_flash_ids[i].name); | 2484 | nand_manuf_ids[maf_id].name, nand_flash_ids[i].name); |
2486 | break; | 2485 | break; |
2487 | } | 2486 | } |
2488 | 2487 | ||
2489 | if (!nand_flash_ids[i].name) { | 2488 | if (!nand_flash_ids[i].name) { |
2490 | printk (KERN_WARNING "No NAND device found!!!\n"); | 2489 | printk(KERN_WARNING "No NAND device found!!!\n"); |
2491 | this->select_chip(mtd, -1); | 2490 | this->select_chip(mtd, -1); |
2492 | return 1; | 2491 | return 1; |
2493 | } | 2492 | } |
2494 | 2493 | ||
2495 | for (i=1; i < maxchips; i++) { | 2494 | for (i = 1; i < maxchips; i++) { |
2496 | this->select_chip(mtd, i); | 2495 | this->select_chip(mtd, i); |
2497 | 2496 | ||
2498 | /* Send the command for reading device ID */ | 2497 | /* Send the command for reading device ID */ |
2499 | this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1); | 2498 | this->cmdfunc(mtd, NAND_CMD_READID, 0x00, -1); |
2500 | 2499 | ||
2501 | /* Read manufacturer and device IDs */ | 2500 | /* Read manufacturer and device IDs */ |
2502 | if (nand_maf_id != this->read_byte(mtd) || | 2501 | if (nand_maf_id != this->read_byte(mtd) || |
@@ -2506,13 +2505,13 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2506 | if (i > 1) | 2505 | if (i > 1) |
2507 | printk(KERN_INFO "%d NAND chips detected\n", i); | 2506 | printk(KERN_INFO "%d NAND chips detected\n", i); |
2508 | 2507 | ||
2509 | /* Allocate buffers, if neccecary */ | 2508 | /* Allocate buffers, if necessary */ |
2510 | if (!this->oob_buf) { | 2509 | if (!this->oob_buf) { |
2511 | size_t len; | 2510 | size_t len; |
2512 | len = mtd->oobsize << (this->phys_erase_shift - this->page_shift); | 2511 | len = mtd->oobsize << (this->phys_erase_shift - this->page_shift); |
2513 | this->oob_buf = kmalloc (len, GFP_KERNEL); | 2512 | this->oob_buf = kmalloc(len, GFP_KERNEL); |
2514 | if (!this->oob_buf) { | 2513 | if (!this->oob_buf) { |
2515 | printk (KERN_ERR "nand_scan(): Cannot allocate oob_buf\n"); | 2514 | printk(KERN_ERR "nand_scan(): Cannot allocate oob_buf\n"); |
2516 | return -ENOMEM; | 2515 | return -ENOMEM; |
2517 | } | 2516 | } |
2518 | this->options |= NAND_OOBBUF_ALLOC; | 2517 | this->options |= NAND_OOBBUF_ALLOC; |
@@ -2521,11 +2520,11 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2521 | if (!this->data_buf) { | 2520 | if (!this->data_buf) { |
2522 | size_t len; | 2521 | size_t len; |
2523 | len = mtd->oobblock + mtd->oobsize; | 2522 | len = mtd->oobblock + mtd->oobsize; |
2524 | this->data_buf = kmalloc (len, GFP_KERNEL); | 2523 | this->data_buf = kmalloc(len, GFP_KERNEL); |
2525 | if (!this->data_buf) { | 2524 | if (!this->data_buf) { |
2526 | if (this->options & NAND_OOBBUF_ALLOC) | 2525 | if (this->options & NAND_OOBBUF_ALLOC) |
2527 | kfree (this->oob_buf); | 2526 | kfree(this->oob_buf); |
2528 | printk (KERN_ERR "nand_scan(): Cannot allocate data_buf\n"); | 2527 | printk(KERN_ERR "nand_scan(): Cannot allocate data_buf\n"); |
2529 | return -ENOMEM; | 2528 | return -ENOMEM; |
2530 | } | 2529 | } |
2531 | this->options |= NAND_DATABUF_ALLOC; | 2530 | this->options |= NAND_DATABUF_ALLOC; |
@@ -2555,8 +2554,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2555 | this->autooob = &nand_oob_64; | 2554 | this->autooob = &nand_oob_64; |
2556 | break; | 2555 | break; |
2557 | default: | 2556 | default: |
2558 | printk (KERN_WARNING "No oob scheme defined for oobsize %d\n", | 2557 | printk(KERN_WARNING "No oob scheme defined for oobsize %d\n", mtd->oobsize); |
2559 | mtd->oobsize); | ||
2560 | BUG(); | 2558 | BUG(); |
2561 | } | 2559 | } |
2562 | } | 2560 | } |
@@ -2571,7 +2569,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2571 | * check ECC mode, default to software | 2569 | * check ECC mode, default to software |
2572 | * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize | 2570 | * if 3byte/512byte hardware ECC is selected and we have 256 byte pagesize |
2573 | * fallback to software ECC | 2571 | * fallback to software ECC |
2574 | */ | 2572 | */ |
2575 | this->eccsize = 256; /* set default eccsize */ | 2573 | this->eccsize = 256; /* set default eccsize */ |
2576 | this->eccbytes = 3; | 2574 | this->eccbytes = 3; |
2577 | 2575 | ||
@@ -2591,19 +2589,19 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2591 | case NAND_ECC_HW6_512: | 2589 | case NAND_ECC_HW6_512: |
2592 | case NAND_ECC_HW8_512: | 2590 | case NAND_ECC_HW8_512: |
2593 | if (mtd->oobblock == 256) { | 2591 | if (mtd->oobblock == 256) { |
2594 | printk (KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n"); | 2592 | printk(KERN_WARNING "512 byte HW ECC not possible on 256 Byte pagesize, fallback to SW ECC \n"); |
2595 | this->eccmode = NAND_ECC_SOFT; | 2593 | this->eccmode = NAND_ECC_SOFT; |
2596 | this->calculate_ecc = nand_calculate_ecc; | 2594 | this->calculate_ecc = nand_calculate_ecc; |
2597 | this->correct_data = nand_correct_data; | 2595 | this->correct_data = nand_correct_data; |
2598 | } else | 2596 | } else |
2599 | this->eccsize = 512; /* set eccsize to 512 */ | 2597 | this->eccsize = 512; /* set eccsize to 512 */ |
2600 | break; | 2598 | break; |
2601 | 2599 | ||
2602 | case NAND_ECC_HW3_256: | 2600 | case NAND_ECC_HW3_256: |
2603 | break; | 2601 | break; |
2604 | 2602 | ||
2605 | case NAND_ECC_NONE: | 2603 | case NAND_ECC_NONE: |
2606 | printk (KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n"); | 2604 | printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. This is not recommended !!\n"); |
2607 | this->eccmode = NAND_ECC_NONE; | 2605 | this->eccmode = NAND_ECC_NONE; |
2608 | break; | 2606 | break; |
2609 | 2607 | ||
@@ -2613,13 +2611,13 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2613 | break; | 2611 | break; |
2614 | 2612 | ||
2615 | default: | 2613 | default: |
2616 | printk (KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode); | 2614 | printk(KERN_WARNING "Invalid NAND_ECC_MODE %d\n", this->eccmode); |
2617 | BUG(); | 2615 | BUG(); |
2618 | } | 2616 | } |
2619 | 2617 | ||
2620 | /* Check hardware ecc function availability and adjust number of ecc bytes per | 2618 | /* Check hardware ecc function availability and adjust number of ecc bytes per |
2621 | * calculation step | 2619 | * calculation step |
2622 | */ | 2620 | */ |
2623 | switch (this->eccmode) { | 2621 | switch (this->eccmode) { |
2624 | case NAND_ECC_HW12_2048: | 2622 | case NAND_ECC_HW12_2048: |
2625 | this->eccbytes += 4; | 2623 | this->eccbytes += 4; |
@@ -2631,7 +2629,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2631 | case NAND_ECC_HW3_256: | 2629 | case NAND_ECC_HW3_256: |
2632 | if (this->calculate_ecc && this->correct_data && this->enable_hwecc) | 2630 | if (this->calculate_ecc && this->correct_data && this->enable_hwecc) |
2633 | break; | 2631 | break; |
2634 | printk (KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n"); | 2632 | printk(KERN_WARNING "No ECC functions supplied, Hardware ECC not possible\n"); |
2635 | BUG(); | 2633 | BUG(); |
2636 | } | 2634 | } |
2637 | 2635 | ||
@@ -2659,8 +2657,8 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2659 | 2657 | ||
2660 | /* Initialize state, waitqueue and spinlock */ | 2658 | /* Initialize state, waitqueue and spinlock */ |
2661 | this->state = FL_READY; | 2659 | this->state = FL_READY; |
2662 | init_waitqueue_head (&this->wq); | 2660 | init_waitqueue_head(&this->wq); |
2663 | spin_lock_init (&this->chip_lock); | 2661 | spin_lock_init(&this->chip_lock); |
2664 | 2662 | ||
2665 | /* De-select the device */ | 2663 | /* De-select the device */ |
2666 | this->select_chip(mtd, -1); | 2664 | this->select_chip(mtd, -1); |
@@ -2695,44 +2693,41 @@ int nand_scan (struct mtd_info *mtd, int maxchips) | |||
2695 | /* and make the autooob the default one */ | 2693 | /* and make the autooob the default one */ |
2696 | memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo)); | 2694 | memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo)); |
2697 | 2695 | ||
2698 | mtd->owner = THIS_MODULE; | ||
2699 | |||
2700 | /* Check, if we should skip the bad block table scan */ | 2696 | /* Check, if we should skip the bad block table scan */ |
2701 | if (this->options & NAND_SKIP_BBTSCAN) | 2697 | if (this->options & NAND_SKIP_BBTSCAN) |
2702 | return 0; | 2698 | return 0; |
2703 | 2699 | ||
2704 | /* Build bad block table */ | 2700 | /* Build bad block table */ |
2705 | return this->scan_bbt (mtd); | 2701 | return this->scan_bbt(mtd); |
2706 | } | 2702 | } |
2707 | 2703 | ||
2708 | /** | 2704 | /** |
2709 | * nand_release - [NAND Interface] Free resources held by the NAND device | 2705 | * nand_release - [NAND Interface] Free resources held by the NAND device |
2710 | * @mtd: MTD device structure | 2706 | * @mtd: MTD device structure |
2711 | */ | 2707 | */ |
2712 | void nand_release (struct mtd_info *mtd) | 2708 | void nand_release(struct mtd_info *mtd) |
2713 | { | 2709 | { |
2714 | struct nand_chip *this = mtd->priv; | 2710 | struct nand_chip *this = mtd->priv; |
2715 | 2711 | ||
2716 | #ifdef CONFIG_MTD_PARTITIONS | 2712 | #ifdef CONFIG_MTD_PARTITIONS |
2717 | /* Deregister partitions */ | 2713 | /* Deregister partitions */ |
2718 | del_mtd_partitions (mtd); | 2714 | del_mtd_partitions(mtd); |
2719 | #endif | 2715 | #endif |
2720 | /* Deregister the device */ | 2716 | /* Deregister the device */ |
2721 | del_mtd_device (mtd); | 2717 | del_mtd_device(mtd); |
2722 | 2718 | ||
2723 | /* Free bad block table memory */ | 2719 | /* Free bad block table memory */ |
2724 | kfree (this->bbt); | 2720 | kfree(this->bbt); |
2725 | /* Buffer allocated by nand_scan ? */ | 2721 | /* Buffer allocated by nand_scan ? */ |
2726 | if (this->options & NAND_OOBBUF_ALLOC) | 2722 | if (this->options & NAND_OOBBUF_ALLOC) |
2727 | kfree (this->oob_buf); | 2723 | kfree(this->oob_buf); |
2728 | /* Buffer allocated by nand_scan ? */ | 2724 | /* Buffer allocated by nand_scan ? */ |
2729 | if (this->options & NAND_DATABUF_ALLOC) | 2725 | if (this->options & NAND_DATABUF_ALLOC) |
2730 | kfree (this->data_buf); | 2726 | kfree(this->data_buf); |
2731 | } | 2727 | } |
2732 | 2728 | ||
2733 | EXPORT_SYMBOL_GPL (nand_scan); | 2729 | EXPORT_SYMBOL_GPL(nand_scan); |
2734 | EXPORT_SYMBOL_GPL (nand_release); | 2730 | EXPORT_SYMBOL_GPL(nand_release); |
2735 | |||
2736 | 2731 | ||
2737 | static int __init nand_base_init(void) | 2732 | static int __init nand_base_init(void) |
2738 | { | 2733 | { |
@@ -2748,6 +2743,6 @@ static void __exit nand_base_exit(void) | |||
2748 | module_init(nand_base_init); | 2743 | module_init(nand_base_init); |
2749 | module_exit(nand_base_exit); | 2744 | module_exit(nand_base_exit); |
2750 | 2745 | ||
2751 | MODULE_LICENSE ("GPL"); | 2746 | MODULE_LICENSE("GPL"); |
2752 | MODULE_AUTHOR ("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>"); | 2747 | MODULE_AUTHOR("Steven J. Hill <sjhill@realitydiluted.com>, Thomas Gleixner <tglx@linutronix.de>"); |
2753 | MODULE_DESCRIPTION ("Generic NAND flash driver code"); | 2748 | MODULE_DESCRIPTION("Generic NAND flash driver code"); |
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index ca286999fe08..9adc6d62332a 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
@@ -48,7 +48,7 @@ | |||
48 | * | 48 | * |
49 | * Following assumptions are made: | 49 | * Following assumptions are made: |
50 | * - bbts start at a page boundary, if autolocated on a block boundary | 50 | * - bbts start at a page boundary, if autolocated on a block boundary |
51 | * - the space neccecary for a bbt in FLASH does not exceed a block boundary | 51 | * - the space necessary for a bbt in FLASH does not exceed a block boundary |
52 | * | 52 | * |
53 | */ | 53 | */ |
54 | 54 | ||
@@ -60,7 +60,7 @@ | |||
60 | #include <linux/mtd/compatmac.h> | 60 | #include <linux/mtd/compatmac.h> |
61 | #include <linux/bitops.h> | 61 | #include <linux/bitops.h> |
62 | #include <linux/delay.h> | 62 | #include <linux/delay.h> |
63 | 63 | #include <linux/vmalloc.h> | |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * check_pattern - [GENERIC] check if a pattern is in the buffer | 66 | * check_pattern - [GENERIC] check if a pattern is in the buffer |
@@ -75,7 +75,7 @@ | |||
75 | * pattern area contain 0xff | 75 | * pattern area contain 0xff |
76 | * | 76 | * |
77 | */ | 77 | */ |
78 | static int check_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td) | 78 | static int check_pattern(uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td) |
79 | { | 79 | { |
80 | int i, end = 0; | 80 | int i, end = 0; |
81 | uint8_t *p = buf; | 81 | uint8_t *p = buf; |
@@ -116,7 +116,7 @@ static int check_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_des | |||
116 | * no optional empty check | 116 | * no optional empty check |
117 | * | 117 | * |
118 | */ | 118 | */ |
119 | static int check_short_pattern (uint8_t *buf, struct nand_bbt_descr *td) | 119 | static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td) |
120 | { | 120 | { |
121 | int i; | 121 | int i; |
122 | uint8_t *p = buf; | 122 | uint8_t *p = buf; |
@@ -142,8 +142,8 @@ static int check_short_pattern (uint8_t *buf, struct nand_bbt_descr *td) | |||
142 | * Read the bad block table starting from page. | 142 | * Read the bad block table starting from page. |
143 | * | 143 | * |
144 | */ | 144 | */ |
145 | static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num, | 145 | static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, |
146 | int bits, int offs, int reserved_block_code) | 146 | int bits, int offs, int reserved_block_code) |
147 | { | 147 | { |
148 | int res, i, j, act = 0; | 148 | int res, i, j, act = 0; |
149 | struct nand_chip *this = mtd->priv; | 149 | struct nand_chip *this = mtd->priv; |
@@ -152,17 +152,17 @@ static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num, | |||
152 | uint8_t msk = (uint8_t) ((1 << bits) - 1); | 152 | uint8_t msk = (uint8_t) ((1 << bits) - 1); |
153 | 153 | ||
154 | totlen = (num * bits) >> 3; | 154 | totlen = (num * bits) >> 3; |
155 | from = ((loff_t)page) << this->page_shift; | 155 | from = ((loff_t) page) << this->page_shift; |
156 | 156 | ||
157 | while (totlen) { | 157 | while (totlen) { |
158 | len = min (totlen, (size_t) (1 << this->bbt_erase_shift)); | 158 | len = min(totlen, (size_t) (1 << this->bbt_erase_shift)); |
159 | res = mtd->read_ecc (mtd, from, len, &retlen, buf, NULL, this->autooob); | 159 | res = mtd->read_ecc(mtd, from, len, &retlen, buf, NULL, this->autooob); |
160 | if (res < 0) { | 160 | if (res < 0) { |
161 | if (retlen != len) { | 161 | if (retlen != len) { |
162 | printk (KERN_INFO "nand_bbt: Error reading bad block table\n"); | 162 | printk(KERN_INFO "nand_bbt: Error reading bad block table\n"); |
163 | return res; | 163 | return res; |
164 | } | 164 | } |
165 | printk (KERN_WARNING "nand_bbt: ECC error while reading bad block table\n"); | 165 | printk(KERN_WARNING "nand_bbt: ECC error while reading bad block table\n"); |
166 | } | 166 | } |
167 | 167 | ||
168 | /* Analyse data */ | 168 | /* Analyse data */ |
@@ -172,17 +172,16 @@ static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num, | |||
172 | uint8_t tmp = (dat >> j) & msk; | 172 | uint8_t tmp = (dat >> j) & msk; |
173 | if (tmp == msk) | 173 | if (tmp == msk) |
174 | continue; | 174 | continue; |
175 | if (reserved_block_code && | 175 | if (reserved_block_code && (tmp == reserved_block_code)) { |
176 | (tmp == reserved_block_code)) { | 176 | printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n", |
177 | printk (KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n", | 177 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); |
178 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); | ||
179 | this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06); | 178 | this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06); |
180 | continue; | 179 | continue; |
181 | } | 180 | } |
182 | /* Leave it for now, if its matured we can move this | 181 | /* Leave it for now, if its matured we can move this |
183 | * message to MTD_DEBUG_LEVEL0 */ | 182 | * message to MTD_DEBUG_LEVEL0 */ |
184 | printk (KERN_DEBUG "nand_read_bbt: Bad block at 0x%08x\n", | 183 | printk(KERN_DEBUG "nand_read_bbt: Bad block at 0x%08x\n", |
185 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); | 184 | ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); |
186 | /* Factory marked bad or worn out ? */ | 185 | /* Factory marked bad or worn out ? */ |
187 | if (tmp == 0) | 186 | if (tmp == 0) |
188 | this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); | 187 | this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); |
@@ -207,7 +206,7 @@ static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num, | |||
207 | * Read the bad block table for all chips starting at a given page | 206 | * Read the bad block table for all chips starting at a given page |
208 | * We assume that the bbt bits are in consecutive order. | 207 | * We assume that the bbt bits are in consecutive order. |
209 | */ | 208 | */ |
210 | static int read_abs_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, int chip) | 209 | static int read_abs_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, int chip) |
211 | { | 210 | { |
212 | struct nand_chip *this = mtd->priv; | 211 | struct nand_chip *this = mtd->priv; |
213 | int res = 0, i; | 212 | int res = 0, i; |
@@ -242,23 +241,22 @@ static int read_abs_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des | |||
242 | * We assume that the bbt bits are in consecutive order. | 241 | * We assume that the bbt bits are in consecutive order. |
243 | * | 242 | * |
244 | */ | 243 | */ |
245 | static int read_abs_bbts (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, | 244 | static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, struct nand_bbt_descr *md) |
246 | struct nand_bbt_descr *md) | ||
247 | { | 245 | { |
248 | struct nand_chip *this = mtd->priv; | 246 | struct nand_chip *this = mtd->priv; |
249 | 247 | ||
250 | /* Read the primary version, if available */ | 248 | /* Read the primary version, if available */ |
251 | if (td->options & NAND_BBT_VERSION) { | 249 | if (td->options & NAND_BBT_VERSION) { |
252 | nand_read_raw (mtd, buf, td->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); | 250 | nand_read_raw(mtd, buf, td->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); |
253 | td->version[0] = buf[mtd->oobblock + td->veroffs]; | 251 | td->version[0] = buf[mtd->oobblock + td->veroffs]; |
254 | printk (KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", td->pages[0], td->version[0]); | 252 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", td->pages[0], td->version[0]); |
255 | } | 253 | } |
256 | 254 | ||
257 | /* Read the mirror version, if available */ | 255 | /* Read the mirror version, if available */ |
258 | if (md && (md->options & NAND_BBT_VERSION)) { | 256 | if (md && (md->options & NAND_BBT_VERSION)) { |
259 | nand_read_raw (mtd, buf, md->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); | 257 | nand_read_raw(mtd, buf, md->pages[0] << this->page_shift, mtd->oobblock, mtd->oobsize); |
260 | md->version[0] = buf[mtd->oobblock + md->veroffs]; | 258 | md->version[0] = buf[mtd->oobblock + md->veroffs]; |
261 | printk (KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", md->pages[0], md->version[0]); | 259 | printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", md->pages[0], md->version[0]); |
262 | } | 260 | } |
263 | 261 | ||
264 | return 1; | 262 | return 1; |
@@ -275,7 +273,7 @@ static int read_abs_bbts (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_de | |||
275 | * Create a bad block table by scanning the device | 273 | * Create a bad block table by scanning the device |
276 | * for the given good/bad block identify pattern | 274 | * for the given good/bad block identify pattern |
277 | */ | 275 | */ |
278 | static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd, int chip) | 276 | static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd, int chip) |
279 | { | 277 | { |
280 | struct nand_chip *this = mtd->priv; | 278 | struct nand_chip *this = mtd->priv; |
281 | int i, j, numblocks, len, scanlen; | 279 | int i, j, numblocks, len, scanlen; |
@@ -283,7 +281,7 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
283 | loff_t from; | 281 | loff_t from; |
284 | size_t readlen, ooblen; | 282 | size_t readlen, ooblen; |
285 | 283 | ||
286 | printk (KERN_INFO "Scanning device for bad blocks\n"); | 284 | printk(KERN_INFO "Scanning device for bad blocks\n"); |
287 | 285 | ||
288 | if (bd->options & NAND_BBT_SCANALLPAGES) | 286 | if (bd->options & NAND_BBT_SCANALLPAGES) |
289 | len = 1 << (this->bbt_erase_shift - this->page_shift); | 287 | len = 1 << (this->bbt_erase_shift - this->page_shift); |
@@ -300,7 +298,7 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
300 | readlen = bd->len; | 298 | readlen = bd->len; |
301 | } else { | 299 | } else { |
302 | /* Full page content should be read */ | 300 | /* Full page content should be read */ |
303 | scanlen = mtd->oobblock + mtd->oobsize; | 301 | scanlen = mtd->oobblock + mtd->oobsize; |
304 | readlen = len * mtd->oobblock; | 302 | readlen = len * mtd->oobblock; |
305 | ooblen = len * mtd->oobsize; | 303 | ooblen = len * mtd->oobsize; |
306 | } | 304 | } |
@@ -313,8 +311,8 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
313 | from = 0; | 311 | from = 0; |
314 | } else { | 312 | } else { |
315 | if (chip >= this->numchips) { | 313 | if (chip >= this->numchips) { |
316 | printk (KERN_WARNING "create_bbt(): chipnr (%d) > available chips (%d)\n", | 314 | printk(KERN_WARNING "create_bbt(): chipnr (%d) > available chips (%d)\n", |
317 | chip + 1, this->numchips); | 315 | chip + 1, this->numchips); |
318 | return -EINVAL; | 316 | return -EINVAL; |
319 | } | 317 | } |
320 | numblocks = this->chipsize >> (this->bbt_erase_shift - 1); | 318 | numblocks = this->chipsize >> (this->bbt_erase_shift - 1); |
@@ -327,7 +325,7 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
327 | int ret; | 325 | int ret; |
328 | 326 | ||
329 | if (bd->options & NAND_BBT_SCANEMPTY) | 327 | if (bd->options & NAND_BBT_SCANEMPTY) |
330 | if ((ret = nand_read_raw (mtd, buf, from, readlen, ooblen))) | 328 | if ((ret = nand_read_raw(mtd, buf, from, readlen, ooblen))) |
331 | return ret; | 329 | return ret; |
332 | 330 | ||
333 | for (j = 0; j < len; j++) { | 331 | for (j = 0; j < len; j++) { |
@@ -336,22 +334,21 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
336 | 334 | ||
337 | /* Read the full oob until read_oob is fixed to | 335 | /* Read the full oob until read_oob is fixed to |
338 | * handle single byte reads for 16 bit buswidth */ | 336 | * handle single byte reads for 16 bit buswidth */ |
339 | ret = mtd->read_oob(mtd, from + j * mtd->oobblock, | 337 | ret = mtd->read_oob(mtd, from + j * mtd->oobblock, mtd->oobsize, &retlen, buf); |
340 | mtd->oobsize, &retlen, buf); | ||
341 | if (ret) | 338 | if (ret) |
342 | return ret; | 339 | return ret; |
343 | 340 | ||
344 | if (check_short_pattern (buf, bd)) { | 341 | if (check_short_pattern(buf, bd)) { |
345 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); | 342 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); |
346 | printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n", | 343 | printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", |
347 | i >> 1, (unsigned int) from); | 344 | i >> 1, (unsigned int)from); |
348 | break; | 345 | break; |
349 | } | 346 | } |
350 | } else { | 347 | } else { |
351 | if (check_pattern (&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { | 348 | if (check_pattern(&buf[j * scanlen], scanlen, mtd->oobblock, bd)) { |
352 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); | 349 | this->bbt[i >> 3] |= 0x03 << (i & 0x6); |
353 | printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n", | 350 | printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", |
354 | i >> 1, (unsigned int) from); | 351 | i >> 1, (unsigned int)from); |
355 | break; | 352 | break; |
356 | } | 353 | } |
357 | } | 354 | } |
@@ -374,12 +371,12 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
374 | * block. | 371 | * block. |
375 | * If the option NAND_BBT_PERCHIP is given, each chip is searched | 372 | * If the option NAND_BBT_PERCHIP is given, each chip is searched |
376 | * for a bbt, which contains the bad block information of this chip. | 373 | * for a bbt, which contains the bad block information of this chip. |
377 | * This is neccecary to provide support for certain DOC devices. | 374 | * This is necessary to provide support for certain DOC devices. |
378 | * | 375 | * |
379 | * The bbt ident pattern resides in the oob area of the first page | 376 | * The bbt ident pattern resides in the oob area of the first page |
380 | * in a block. | 377 | * in a block. |
381 | */ | 378 | */ |
382 | static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td) | 379 | static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td) |
383 | { | 380 | { |
384 | struct nand_chip *this = mtd->priv; | 381 | struct nand_chip *this = mtd->priv; |
385 | int i, chips; | 382 | int i, chips; |
@@ -389,7 +386,7 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
389 | 386 | ||
390 | /* Search direction top -> down ? */ | 387 | /* Search direction top -> down ? */ |
391 | if (td->options & NAND_BBT_LASTBLOCK) { | 388 | if (td->options & NAND_BBT_LASTBLOCK) { |
392 | startblock = (mtd->size >> this->bbt_erase_shift) -1; | 389 | startblock = (mtd->size >> this->bbt_erase_shift) - 1; |
393 | dir = -1; | 390 | dir = -1; |
394 | } else { | 391 | } else { |
395 | startblock = 0; | 392 | startblock = 0; |
@@ -417,7 +414,7 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
417 | for (block = 0; block < td->maxblocks; block++) { | 414 | for (block = 0; block < td->maxblocks; block++) { |
418 | int actblock = startblock + dir * block; | 415 | int actblock = startblock + dir * block; |
419 | /* Read first page */ | 416 | /* Read first page */ |
420 | nand_read_raw (mtd, buf, actblock << this->bbt_erase_shift, mtd->oobblock, mtd->oobsize); | 417 | nand_read_raw(mtd, buf, actblock << this->bbt_erase_shift, mtd->oobblock, mtd->oobsize); |
421 | if (!check_pattern(buf, scanlen, mtd->oobblock, td)) { | 418 | if (!check_pattern(buf, scanlen, mtd->oobblock, td)) { |
422 | td->pages[i] = actblock << (this->bbt_erase_shift - this->page_shift); | 419 | td->pages[i] = actblock << (this->bbt_erase_shift - this->page_shift); |
423 | if (td->options & NAND_BBT_VERSION) { | 420 | if (td->options & NAND_BBT_VERSION) { |
@@ -431,9 +428,10 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
431 | /* Check, if we found a bbt for each requested chip */ | 428 | /* Check, if we found a bbt for each requested chip */ |
432 | for (i = 0; i < chips; i++) { | 429 | for (i = 0; i < chips; i++) { |
433 | if (td->pages[i] == -1) | 430 | if (td->pages[i] == -1) |
434 | printk (KERN_WARNING "Bad block table not found for chip %d\n", i); | 431 | printk(KERN_WARNING "Bad block table not found for chip %d\n", i); |
435 | else | 432 | else |
436 | printk (KERN_DEBUG "Bad block table found at page %d, version 0x%02X\n", td->pages[i], td->version[i]); | 433 | printk(KERN_DEBUG "Bad block table found at page %d, version 0x%02X\n", td->pages[i], |
434 | td->version[i]); | ||
437 | } | 435 | } |
438 | return 0; | 436 | return 0; |
439 | } | 437 | } |
@@ -447,21 +445,19 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
447 | * | 445 | * |
448 | * Search and read the bad block table(s) | 446 | * Search and read the bad block table(s) |
449 | */ | 447 | */ |
450 | static int search_read_bbts (struct mtd_info *mtd, uint8_t *buf, | 448 | static int search_read_bbts(struct mtd_info *mtd, uint8_t * buf, struct nand_bbt_descr *td, struct nand_bbt_descr *md) |
451 | struct nand_bbt_descr *td, struct nand_bbt_descr *md) | ||
452 | { | 449 | { |
453 | /* Search the primary table */ | 450 | /* Search the primary table */ |
454 | search_bbt (mtd, buf, td); | 451 | search_bbt(mtd, buf, td); |
455 | 452 | ||
456 | /* Search the mirror table */ | 453 | /* Search the mirror table */ |
457 | if (md) | 454 | if (md) |
458 | search_bbt (mtd, buf, md); | 455 | search_bbt(mtd, buf, md); |
459 | 456 | ||
460 | /* Force result check */ | 457 | /* Force result check */ |
461 | return 1; | 458 | return 1; |
462 | } | 459 | } |
463 | 460 | ||
464 | |||
465 | /** | 461 | /** |
466 | * write_bbt - [GENERIC] (Re)write the bad block table | 462 | * write_bbt - [GENERIC] (Re)write the bad block table |
467 | * | 463 | * |
@@ -474,8 +470,8 @@ static int search_read_bbts (struct mtd_info *mtd, uint8_t *buf, | |||
474 | * (Re)write the bad block table | 470 | * (Re)write the bad block table |
475 | * | 471 | * |
476 | */ | 472 | */ |
477 | static int write_bbt (struct mtd_info *mtd, uint8_t *buf, | 473 | static int write_bbt(struct mtd_info *mtd, uint8_t *buf, |
478 | struct nand_bbt_descr *td, struct nand_bbt_descr *md, int chipsel) | 474 | struct nand_bbt_descr *td, struct nand_bbt_descr *md, int chipsel) |
479 | { | 475 | { |
480 | struct nand_chip *this = mtd->priv; | 476 | struct nand_chip *this = mtd->priv; |
481 | struct nand_oobinfo oobinfo; | 477 | struct nand_oobinfo oobinfo; |
@@ -492,7 +488,7 @@ static int write_bbt (struct mtd_info *mtd, uint8_t *buf, | |||
492 | rcode = 0xff; | 488 | rcode = 0xff; |
493 | /* Write bad block table per chip rather than per device ? */ | 489 | /* Write bad block table per chip rather than per device ? */ |
494 | if (td->options & NAND_BBT_PERCHIP) { | 490 | if (td->options & NAND_BBT_PERCHIP) { |
495 | numblocks = (int) (this->chipsize >> this->bbt_erase_shift); | 491 | numblocks = (int)(this->chipsize >> this->bbt_erase_shift); |
496 | /* Full device write or specific chip ? */ | 492 | /* Full device write or specific chip ? */ |
497 | if (chipsel == -1) { | 493 | if (chipsel == -1) { |
498 | nrchips = this->numchips; | 494 | nrchips = this->numchips; |
@@ -501,7 +497,7 @@ static int write_bbt (struct mtd_info *mtd, uint8_t *buf, | |||
501 | chip = chipsel; | 497 | chip = chipsel; |
502 | } | 498 | } |
503 | } else { | 499 | } else { |
504 | numblocks = (int) (mtd->size >> this->bbt_erase_shift); | 500 | numblocks = (int)(mtd->size >> this->bbt_erase_shift); |
505 | nrchips = 1; | 501 | nrchips = 1; |
506 | } | 502 | } |
507 | 503 | ||
@@ -540,9 +536,9 @@ static int write_bbt (struct mtd_info *mtd, uint8_t *buf, | |||
540 | if (!md || md->pages[chip] != page) | 536 | if (!md || md->pages[chip] != page) |
541 | goto write; | 537 | goto write; |
542 | } | 538 | } |
543 | printk (KERN_ERR "No space left to write bad block table\n"); | 539 | printk(KERN_ERR "No space left to write bad block table\n"); |
544 | return -ENOSPC; | 540 | return -ENOSPC; |
545 | write: | 541 | write: |
546 | 542 | ||
547 | /* Set up shift count and masks for the flash table */ | 543 | /* Set up shift count and masks for the flash table */ |
548 | bits = td->options & NAND_BBT_NRBITS_MSK; | 544 | bits = td->options & NAND_BBT_NRBITS_MSK; |
@@ -558,7 +554,7 @@ write: | |||
558 | 554 | ||
559 | to = ((loff_t) page) << this->page_shift; | 555 | to = ((loff_t) page) << this->page_shift; |
560 | 556 | ||
561 | memcpy (&oobinfo, this->autooob, sizeof(oobinfo)); | 557 | memcpy(&oobinfo, this->autooob, sizeof(oobinfo)); |
562 | oobinfo.useecc = MTD_NANDECC_PLACEONLY; | 558 | oobinfo.useecc = MTD_NANDECC_PLACEONLY; |
563 | 559 | ||
564 | /* Must we save the block contents ? */ | 560 | /* Must we save the block contents ? */ |
@@ -566,22 +562,23 @@ write: | |||
566 | /* Make it block aligned */ | 562 | /* Make it block aligned */ |
567 | to &= ~((loff_t) ((1 << this->bbt_erase_shift) - 1)); | 563 | to &= ~((loff_t) ((1 << this->bbt_erase_shift) - 1)); |
568 | len = 1 << this->bbt_erase_shift; | 564 | len = 1 << this->bbt_erase_shift; |
569 | res = mtd->read_ecc (mtd, to, len, &retlen, buf, &buf[len], &oobinfo); | 565 | res = mtd->read_ecc(mtd, to, len, &retlen, buf, &buf[len], &oobinfo); |
570 | if (res < 0) { | 566 | if (res < 0) { |
571 | if (retlen != len) { | 567 | if (retlen != len) { |
572 | printk (KERN_INFO "nand_bbt: Error reading block for writing the bad block table\n"); | 568 | printk(KERN_INFO |
569 | "nand_bbt: Error reading block for writing the bad block table\n"); | ||
573 | return res; | 570 | return res; |
574 | } | 571 | } |
575 | printk (KERN_WARNING "nand_bbt: ECC error while reading block for writing bad block table\n"); | 572 | printk(KERN_WARNING "nand_bbt: ECC error while reading block for writing bad block table\n"); |
576 | } | 573 | } |
577 | /* Calc the byte offset in the buffer */ | 574 | /* Calc the byte offset in the buffer */ |
578 | pageoffs = page - (int)(to >> this->page_shift); | 575 | pageoffs = page - (int)(to >> this->page_shift); |
579 | offs = pageoffs << this->page_shift; | 576 | offs = pageoffs << this->page_shift; |
580 | /* Preset the bbt area with 0xff */ | 577 | /* Preset the bbt area with 0xff */ |
581 | memset (&buf[offs], 0xff, (size_t)(numblocks >> sft)); | 578 | memset(&buf[offs], 0xff, (size_t) (numblocks >> sft)); |
582 | /* Preset the bbt's oob area with 0xff */ | 579 | /* Preset the bbt's oob area with 0xff */ |
583 | memset (&buf[len + pageoffs * mtd->oobsize], 0xff, | 580 | memset(&buf[len + pageoffs * mtd->oobsize], 0xff, |
584 | ((len >> this->page_shift) - pageoffs) * mtd->oobsize); | 581 | ((len >> this->page_shift) - pageoffs) * mtd->oobsize); |
585 | if (td->options & NAND_BBT_VERSION) { | 582 | if (td->options & NAND_BBT_VERSION) { |
586 | buf[len + (pageoffs * mtd->oobsize) + td->veroffs] = td->version[chip]; | 583 | buf[len + (pageoffs * mtd->oobsize) + td->veroffs] = td->version[chip]; |
587 | } | 584 | } |
@@ -589,22 +586,22 @@ write: | |||
589 | /* Calc length */ | 586 | /* Calc length */ |
590 | len = (size_t) (numblocks >> sft); | 587 | len = (size_t) (numblocks >> sft); |
591 | /* Make it page aligned ! */ | 588 | /* Make it page aligned ! */ |
592 | len = (len + (mtd->oobblock-1)) & ~(mtd->oobblock-1); | 589 | len = (len + (mtd->oobblock - 1)) & ~(mtd->oobblock - 1); |
593 | /* Preset the buffer with 0xff */ | 590 | /* Preset the buffer with 0xff */ |
594 | memset (buf, 0xff, len + (len >> this->page_shift) * mtd->oobsize); | 591 | memset(buf, 0xff, len + (len >> this->page_shift) * mtd->oobsize); |
595 | offs = 0; | 592 | offs = 0; |
596 | /* Pattern is located in oob area of first page */ | 593 | /* Pattern is located in oob area of first page */ |
597 | memcpy (&buf[len + td->offs], td->pattern, td->len); | 594 | memcpy(&buf[len + td->offs], td->pattern, td->len); |
598 | if (td->options & NAND_BBT_VERSION) { | 595 | if (td->options & NAND_BBT_VERSION) { |
599 | buf[len + td->veroffs] = td->version[chip]; | 596 | buf[len + td->veroffs] = td->version[chip]; |
600 | } | 597 | } |
601 | } | 598 | } |
602 | 599 | ||
603 | /* walk through the memory table */ | 600 | /* walk through the memory table */ |
604 | for (i = 0; i < numblocks; ) { | 601 | for (i = 0; i < numblocks;) { |
605 | uint8_t dat; | 602 | uint8_t dat; |
606 | dat = this->bbt[bbtoffs + (i >> 2)]; | 603 | dat = this->bbt[bbtoffs + (i >> 2)]; |
607 | for (j = 0; j < 4; j++ , i++) { | 604 | for (j = 0; j < 4; j++, i++) { |
608 | int sftcnt = (i << (3 - sft)) & sftmsk; | 605 | int sftcnt = (i << (3 - sft)) & sftmsk; |
609 | /* Do not store the reserved bbt blocks ! */ | 606 | /* Do not store the reserved bbt blocks ! */ |
610 | buf[offs + (i >> sft)] &= ~(msk[dat & 0x03] << sftcnt); | 607 | buf[offs + (i >> sft)] &= ~(msk[dat & 0x03] << sftcnt); |
@@ -612,23 +609,23 @@ write: | |||
612 | } | 609 | } |
613 | } | 610 | } |
614 | 611 | ||
615 | memset (&einfo, 0, sizeof (einfo)); | 612 | memset(&einfo, 0, sizeof(einfo)); |
616 | einfo.mtd = mtd; | 613 | einfo.mtd = mtd; |
617 | einfo.addr = (unsigned long) to; | 614 | einfo.addr = (unsigned long)to; |
618 | einfo.len = 1 << this->bbt_erase_shift; | 615 | einfo.len = 1 << this->bbt_erase_shift; |
619 | res = nand_erase_nand (mtd, &einfo, 1); | 616 | res = nand_erase_nand(mtd, &einfo, 1); |
620 | if (res < 0) { | 617 | if (res < 0) { |
621 | printk (KERN_WARNING "nand_bbt: Error during block erase: %d\n", res); | 618 | printk(KERN_WARNING "nand_bbt: Error during block erase: %d\n", res); |
622 | return res; | 619 | return res; |
623 | } | 620 | } |
624 | 621 | ||
625 | res = mtd->write_ecc (mtd, to, len, &retlen, buf, &buf[len], &oobinfo); | 622 | res = mtd->write_ecc(mtd, to, len, &retlen, buf, &buf[len], &oobinfo); |
626 | if (res < 0) { | 623 | if (res < 0) { |
627 | printk (KERN_WARNING "nand_bbt: Error while writing bad block table %d\n", res); | 624 | printk(KERN_WARNING "nand_bbt: Error while writing bad block table %d\n", res); |
628 | return res; | 625 | return res; |
629 | } | 626 | } |
630 | printk (KERN_DEBUG "Bad block table written to 0x%08x, version 0x%02X\n", | 627 | printk(KERN_DEBUG "Bad block table written to 0x%08x, version 0x%02X\n", |
631 | (unsigned int) to, td->version[chip]); | 628 | (unsigned int)to, td->version[chip]); |
632 | 629 | ||
633 | /* Mark it as used */ | 630 | /* Mark it as used */ |
634 | td->pages[chip] = page; | 631 | td->pages[chip] = page; |
@@ -644,27 +641,27 @@ write: | |||
644 | * The function creates a memory based bbt by scanning the device | 641 | * The function creates a memory based bbt by scanning the device |
645 | * for manufacturer / software marked good / bad blocks | 642 | * for manufacturer / software marked good / bad blocks |
646 | */ | 643 | */ |
647 | static inline int nand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) | 644 | static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) |
648 | { | 645 | { |
649 | struct nand_chip *this = mtd->priv; | 646 | struct nand_chip *this = mtd->priv; |
650 | 647 | ||
651 | bd->options &= ~NAND_BBT_SCANEMPTY; | 648 | bd->options &= ~NAND_BBT_SCANEMPTY; |
652 | return create_bbt (mtd, this->data_buf, bd, -1); | 649 | return create_bbt(mtd, this->data_buf, bd, -1); |
653 | } | 650 | } |
654 | 651 | ||
655 | /** | 652 | /** |
656 | * check_create - [GENERIC] create and write bbt(s) if neccecary | 653 | * check_create - [GENERIC] create and write bbt(s) if necessary |
657 | * @mtd: MTD device structure | 654 | * @mtd: MTD device structure |
658 | * @buf: temporary buffer | 655 | * @buf: temporary buffer |
659 | * @bd: descriptor for the good/bad block search pattern | 656 | * @bd: descriptor for the good/bad block search pattern |
660 | * | 657 | * |
661 | * The function checks the results of the previous call to read_bbt | 658 | * The function checks the results of the previous call to read_bbt |
662 | * and creates / updates the bbt(s) if neccecary | 659 | * and creates / updates the bbt(s) if necessary |
663 | * Creation is neccecary if no bbt was found for the chip/device | 660 | * Creation is necessary if no bbt was found for the chip/device |
664 | * Update is neccecary if one of the tables is missing or the | 661 | * Update is necessary if one of the tables is missing or the |
665 | * version nr. of one table is less than the other | 662 | * version nr. of one table is less than the other |
666 | */ | 663 | */ |
667 | static int check_create (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd) | 664 | static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd) |
668 | { | 665 | { |
669 | int i, chips, writeops, chipsel, res; | 666 | int i, chips, writeops, chipsel, res; |
670 | struct nand_chip *this = mtd->priv; | 667 | struct nand_chip *this = mtd->priv; |
@@ -732,35 +729,35 @@ static int check_create (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des | |||
732 | rd = td; | 729 | rd = td; |
733 | goto writecheck; | 730 | goto writecheck; |
734 | } | 731 | } |
735 | create: | 732 | create: |
736 | /* Create the bad block table by scanning the device ? */ | 733 | /* Create the bad block table by scanning the device ? */ |
737 | if (!(td->options & NAND_BBT_CREATE)) | 734 | if (!(td->options & NAND_BBT_CREATE)) |
738 | continue; | 735 | continue; |
739 | 736 | ||
740 | /* Create the table in memory by scanning the chip(s) */ | 737 | /* Create the table in memory by scanning the chip(s) */ |
741 | create_bbt (mtd, buf, bd, chipsel); | 738 | create_bbt(mtd, buf, bd, chipsel); |
742 | 739 | ||
743 | td->version[i] = 1; | 740 | td->version[i] = 1; |
744 | if (md) | 741 | if (md) |
745 | md->version[i] = 1; | 742 | md->version[i] = 1; |
746 | writecheck: | 743 | writecheck: |
747 | /* read back first ? */ | 744 | /* read back first ? */ |
748 | if (rd) | 745 | if (rd) |
749 | read_abs_bbt (mtd, buf, rd, chipsel); | 746 | read_abs_bbt(mtd, buf, rd, chipsel); |
750 | /* If they weren't versioned, read both. */ | 747 | /* If they weren't versioned, read both. */ |
751 | if (rd2) | 748 | if (rd2) |
752 | read_abs_bbt (mtd, buf, rd2, chipsel); | 749 | read_abs_bbt(mtd, buf, rd2, chipsel); |
753 | 750 | ||
754 | /* Write the bad block table to the device ? */ | 751 | /* Write the bad block table to the device ? */ |
755 | if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { | 752 | if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { |
756 | res = write_bbt (mtd, buf, td, md, chipsel); | 753 | res = write_bbt(mtd, buf, td, md, chipsel); |
757 | if (res < 0) | 754 | if (res < 0) |
758 | return res; | 755 | return res; |
759 | } | 756 | } |
760 | 757 | ||
761 | /* Write the mirror bad block table to the device ? */ | 758 | /* Write the mirror bad block table to the device ? */ |
762 | if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) { | 759 | if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) { |
763 | res = write_bbt (mtd, buf, md, td, chipsel); | 760 | res = write_bbt(mtd, buf, md, td, chipsel); |
764 | if (res < 0) | 761 | if (res < 0) |
765 | return res; | 762 | return res; |
766 | } | 763 | } |
@@ -777,7 +774,7 @@ writecheck: | |||
777 | * accidental erasures / writes. The regions are identified by | 774 | * accidental erasures / writes. The regions are identified by |
778 | * the mark 0x02. | 775 | * the mark 0x02. |
779 | */ | 776 | */ |
780 | static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td) | 777 | static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td) |
781 | { | 778 | { |
782 | struct nand_chip *this = mtd->priv; | 779 | struct nand_chip *this = mtd->priv; |
783 | int i, j, chips, block, nrblocks, update; | 780 | int i, j, chips, block, nrblocks, update; |
@@ -795,7 +792,8 @@ static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td) | |||
795 | for (i = 0; i < chips; i++) { | 792 | for (i = 0; i < chips; i++) { |
796 | if ((td->options & NAND_BBT_ABSPAGE) || | 793 | if ((td->options & NAND_BBT_ABSPAGE) || |
797 | !(td->options & NAND_BBT_WRITE)) { | 794 | !(td->options & NAND_BBT_WRITE)) { |
798 | if (td->pages[i] == -1) continue; | 795 | if (td->pages[i] == -1) |
796 | continue; | ||
799 | block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift); | 797 | block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift); |
800 | block <<= 1; | 798 | block <<= 1; |
801 | oldval = this->bbt[(block >> 3)]; | 799 | oldval = this->bbt[(block >> 3)]; |
@@ -815,7 +813,8 @@ static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td) | |||
815 | oldval = this->bbt[(block >> 3)]; | 813 | oldval = this->bbt[(block >> 3)]; |
816 | newval = oldval | (0x2 << (block & 0x06)); | 814 | newval = oldval | (0x2 << (block & 0x06)); |
817 | this->bbt[(block >> 3)] = newval; | 815 | this->bbt[(block >> 3)] = newval; |
818 | if (oldval != newval) update = 1; | 816 | if (oldval != newval) |
817 | update = 1; | ||
819 | block += 2; | 818 | block += 2; |
820 | } | 819 | } |
821 | /* If we want reserved blocks to be recorded to flash, and some | 820 | /* If we want reserved blocks to be recorded to flash, and some |
@@ -840,7 +839,7 @@ static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td) | |||
840 | * by calling the nand_free_bbt function. | 839 | * by calling the nand_free_bbt function. |
841 | * | 840 | * |
842 | */ | 841 | */ |
843 | int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) | 842 | int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) |
844 | { | 843 | { |
845 | struct nand_chip *this = mtd->priv; | 844 | struct nand_chip *this = mtd->priv; |
846 | int len, res = 0; | 845 | int len, res = 0; |
@@ -850,21 +849,21 @@ int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) | |||
850 | 849 | ||
851 | len = mtd->size >> (this->bbt_erase_shift + 2); | 850 | len = mtd->size >> (this->bbt_erase_shift + 2); |
852 | /* Allocate memory (2bit per block) */ | 851 | /* Allocate memory (2bit per block) */ |
853 | this->bbt = kmalloc (len, GFP_KERNEL); | 852 | this->bbt = kmalloc(len, GFP_KERNEL); |
854 | if (!this->bbt) { | 853 | if (!this->bbt) { |
855 | printk (KERN_ERR "nand_scan_bbt: Out of memory\n"); | 854 | printk(KERN_ERR "nand_scan_bbt: Out of memory\n"); |
856 | return -ENOMEM; | 855 | return -ENOMEM; |
857 | } | 856 | } |
858 | /* Clear the memory bad block table */ | 857 | /* Clear the memory bad block table */ |
859 | memset (this->bbt, 0x00, len); | 858 | memset(this->bbt, 0x00, len); |
860 | 859 | ||
861 | /* If no primary table decriptor is given, scan the device | 860 | /* If no primary table decriptor is given, scan the device |
862 | * to build a memory based bad block table | 861 | * to build a memory based bad block table |
863 | */ | 862 | */ |
864 | if (!td) { | 863 | if (!td) { |
865 | if ((res = nand_memory_bbt(mtd, bd))) { | 864 | if ((res = nand_memory_bbt(mtd, bd))) { |
866 | printk (KERN_ERR "nand_bbt: Can't scan flash and build the RAM-based BBT\n"); | 865 | printk(KERN_ERR "nand_bbt: Can't scan flash and build the RAM-based BBT\n"); |
867 | kfree (this->bbt); | 866 | kfree(this->bbt); |
868 | this->bbt = NULL; | 867 | this->bbt = NULL; |
869 | } | 868 | } |
870 | return res; | 869 | return res; |
@@ -873,35 +872,34 @@ int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) | |||
873 | /* Allocate a temporary buffer for one eraseblock incl. oob */ | 872 | /* Allocate a temporary buffer for one eraseblock incl. oob */ |
874 | len = (1 << this->bbt_erase_shift); | 873 | len = (1 << this->bbt_erase_shift); |
875 | len += (len >> this->page_shift) * mtd->oobsize; | 874 | len += (len >> this->page_shift) * mtd->oobsize; |
876 | buf = kmalloc (len, GFP_KERNEL); | 875 | buf = vmalloc(len); |
877 | if (!buf) { | 876 | if (!buf) { |
878 | printk (KERN_ERR "nand_bbt: Out of memory\n"); | 877 | printk(KERN_ERR "nand_bbt: Out of memory\n"); |
879 | kfree (this->bbt); | 878 | kfree(this->bbt); |
880 | this->bbt = NULL; | 879 | this->bbt = NULL; |
881 | return -ENOMEM; | 880 | return -ENOMEM; |
882 | } | 881 | } |
883 | 882 | ||
884 | /* Is the bbt at a given page ? */ | 883 | /* Is the bbt at a given page ? */ |
885 | if (td->options & NAND_BBT_ABSPAGE) { | 884 | if (td->options & NAND_BBT_ABSPAGE) { |
886 | res = read_abs_bbts (mtd, buf, td, md); | 885 | res = read_abs_bbts(mtd, buf, td, md); |
887 | } else { | 886 | } else { |
888 | /* Search the bad block table using a pattern in oob */ | 887 | /* Search the bad block table using a pattern in oob */ |
889 | res = search_read_bbts (mtd, buf, td, md); | 888 | res = search_read_bbts(mtd, buf, td, md); |
890 | } | 889 | } |
891 | 890 | ||
892 | if (res) | 891 | if (res) |
893 | res = check_create (mtd, buf, bd); | 892 | res = check_create(mtd, buf, bd); |
894 | 893 | ||
895 | /* Prevent the bbt regions from erasing / writing */ | 894 | /* Prevent the bbt regions from erasing / writing */ |
896 | mark_bbt_region (mtd, td); | 895 | mark_bbt_region(mtd, td); |
897 | if (md) | 896 | if (md) |
898 | mark_bbt_region (mtd, md); | 897 | mark_bbt_region(mtd, md); |
899 | 898 | ||
900 | kfree (buf); | 899 | vfree(buf); |
901 | return res; | 900 | return res; |
902 | } | 901 | } |
903 | 902 | ||
904 | |||
905 | /** | 903 | /** |
906 | * nand_update_bbt - [NAND Interface] update bad block table(s) | 904 | * nand_update_bbt - [NAND Interface] update bad block table(s) |
907 | * @mtd: MTD device structure | 905 | * @mtd: MTD device structure |
@@ -909,7 +907,7 @@ int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) | |||
909 | * | 907 | * |
910 | * The function updates the bad block table(s) | 908 | * The function updates the bad block table(s) |
911 | */ | 909 | */ |
912 | int nand_update_bbt (struct mtd_info *mtd, loff_t offs) | 910 | int nand_update_bbt(struct mtd_info *mtd, loff_t offs) |
913 | { | 911 | { |
914 | struct nand_chip *this = mtd->priv; | 912 | struct nand_chip *this = mtd->priv; |
915 | int len, res = 0, writeops = 0; | 913 | int len, res = 0, writeops = 0; |
@@ -925,9 +923,9 @@ int nand_update_bbt (struct mtd_info *mtd, loff_t offs) | |||
925 | /* Allocate a temporary buffer for one eraseblock incl. oob */ | 923 | /* Allocate a temporary buffer for one eraseblock incl. oob */ |
926 | len = (1 << this->bbt_erase_shift); | 924 | len = (1 << this->bbt_erase_shift); |
927 | len += (len >> this->page_shift) * mtd->oobsize; | 925 | len += (len >> this->page_shift) * mtd->oobsize; |
928 | buf = kmalloc (len, GFP_KERNEL); | 926 | buf = kmalloc(len, GFP_KERNEL); |
929 | if (!buf) { | 927 | if (!buf) { |
930 | printk (KERN_ERR "nand_update_bbt: Out of memory\n"); | 928 | printk(KERN_ERR "nand_update_bbt: Out of memory\n"); |
931 | return -ENOMEM; | 929 | return -ENOMEM; |
932 | } | 930 | } |
933 | 931 | ||
@@ -935,7 +933,7 @@ int nand_update_bbt (struct mtd_info *mtd, loff_t offs) | |||
935 | 933 | ||
936 | /* Do we have a bbt per chip ? */ | 934 | /* Do we have a bbt per chip ? */ |
937 | if (td->options & NAND_BBT_PERCHIP) { | 935 | if (td->options & NAND_BBT_PERCHIP) { |
938 | chip = (int) (offs >> this->chip_shift); | 936 | chip = (int)(offs >> this->chip_shift); |
939 | chipsel = chip; | 937 | chipsel = chip; |
940 | } else { | 938 | } else { |
941 | chip = 0; | 939 | chip = 0; |
@@ -948,17 +946,17 @@ int nand_update_bbt (struct mtd_info *mtd, loff_t offs) | |||
948 | 946 | ||
949 | /* Write the bad block table to the device ? */ | 947 | /* Write the bad block table to the device ? */ |
950 | if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { | 948 | if ((writeops & 0x01) && (td->options & NAND_BBT_WRITE)) { |
951 | res = write_bbt (mtd, buf, td, md, chipsel); | 949 | res = write_bbt(mtd, buf, td, md, chipsel); |
952 | if (res < 0) | 950 | if (res < 0) |
953 | goto out; | 951 | goto out; |
954 | } | 952 | } |
955 | /* Write the mirror bad block table to the device ? */ | 953 | /* Write the mirror bad block table to the device ? */ |
956 | if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) { | 954 | if ((writeops & 0x02) && md && (md->options & NAND_BBT_WRITE)) { |
957 | res = write_bbt (mtd, buf, md, td, chipsel); | 955 | res = write_bbt(mtd, buf, md, td, chipsel); |
958 | } | 956 | } |
959 | 957 | ||
960 | out: | 958 | out: |
961 | kfree (buf); | 959 | kfree(buf); |
962 | return res; | 960 | return res; |
963 | } | 961 | } |
964 | 962 | ||
@@ -981,14 +979,14 @@ static struct nand_bbt_descr largepage_memorybased = { | |||
981 | }; | 979 | }; |
982 | 980 | ||
983 | static struct nand_bbt_descr smallpage_flashbased = { | 981 | static struct nand_bbt_descr smallpage_flashbased = { |
984 | .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES, | 982 | .options = NAND_BBT_SCAN2NDPAGE, |
985 | .offs = 5, | 983 | .offs = 5, |
986 | .len = 1, | 984 | .len = 1, |
987 | .pattern = scan_ff_pattern | 985 | .pattern = scan_ff_pattern |
988 | }; | 986 | }; |
989 | 987 | ||
990 | static struct nand_bbt_descr largepage_flashbased = { | 988 | static struct nand_bbt_descr largepage_flashbased = { |
991 | .options = NAND_BBT_SCANEMPTY | NAND_BBT_SCANALLPAGES, | 989 | .options = NAND_BBT_SCAN2NDPAGE, |
992 | .offs = 0, | 990 | .offs = 0, |
993 | .len = 2, | 991 | .len = 2, |
994 | .pattern = scan_ff_pattern | 992 | .pattern = scan_ff_pattern |
@@ -1036,7 +1034,7 @@ static struct nand_bbt_descr bbt_mirror_descr = { | |||
1036 | * support for the device and calls the nand_scan_bbt function | 1034 | * support for the device and calls the nand_scan_bbt function |
1037 | * | 1035 | * |
1038 | */ | 1036 | */ |
1039 | int nand_default_bbt (struct mtd_info *mtd) | 1037 | int nand_default_bbt(struct mtd_info *mtd) |
1040 | { | 1038 | { |
1041 | struct nand_chip *this = mtd->priv; | 1039 | struct nand_chip *this = mtd->priv; |
1042 | 1040 | ||
@@ -1046,7 +1044,7 @@ int nand_default_bbt (struct mtd_info *mtd) | |||
1046 | * of the good / bad information, so we _must_ store | 1044 | * of the good / bad information, so we _must_ store |
1047 | * this information in a good / bad table during | 1045 | * this information in a good / bad table during |
1048 | * startup | 1046 | * startup |
1049 | */ | 1047 | */ |
1050 | if (this->options & NAND_IS_AND) { | 1048 | if (this->options & NAND_IS_AND) { |
1051 | /* Use the default pattern descriptors */ | 1049 | /* Use the default pattern descriptors */ |
1052 | if (!this->bbt_td) { | 1050 | if (!this->bbt_td) { |
@@ -1054,10 +1052,9 @@ int nand_default_bbt (struct mtd_info *mtd) | |||
1054 | this->bbt_md = &bbt_mirror_descr; | 1052 | this->bbt_md = &bbt_mirror_descr; |
1055 | } | 1053 | } |
1056 | this->options |= NAND_USE_FLASH_BBT; | 1054 | this->options |= NAND_USE_FLASH_BBT; |
1057 | return nand_scan_bbt (mtd, &agand_flashbased); | 1055 | return nand_scan_bbt(mtd, &agand_flashbased); |
1058 | } | 1056 | } |
1059 | 1057 | ||
1060 | |||
1061 | /* Is a flash based bad block table requested ? */ | 1058 | /* Is a flash based bad block table requested ? */ |
1062 | if (this->options & NAND_USE_FLASH_BBT) { | 1059 | if (this->options & NAND_USE_FLASH_BBT) { |
1063 | /* Use the default pattern descriptors */ | 1060 | /* Use the default pattern descriptors */ |
@@ -1066,18 +1063,17 @@ int nand_default_bbt (struct mtd_info *mtd) | |||
1066 | this->bbt_md = &bbt_mirror_descr; | 1063 | this->bbt_md = &bbt_mirror_descr; |
1067 | } | 1064 | } |
1068 | if (!this->badblock_pattern) { | 1065 | if (!this->badblock_pattern) { |
1069 | this->badblock_pattern = (mtd->oobblock > 512) ? | 1066 | this->badblock_pattern = (mtd->oobblock > 512) ? &largepage_flashbased : &smallpage_flashbased; |
1070 | &largepage_flashbased : &smallpage_flashbased; | ||
1071 | } | 1067 | } |
1072 | } else { | 1068 | } else { |
1073 | this->bbt_td = NULL; | 1069 | this->bbt_td = NULL; |
1074 | this->bbt_md = NULL; | 1070 | this->bbt_md = NULL; |
1075 | if (!this->badblock_pattern) { | 1071 | if (!this->badblock_pattern) { |
1076 | this->badblock_pattern = (mtd->oobblock > 512) ? | 1072 | this->badblock_pattern = (mtd->oobblock > 512) ? |
1077 | &largepage_memorybased : &smallpage_memorybased; | 1073 | &largepage_memorybased : &smallpage_memorybased; |
1078 | } | 1074 | } |
1079 | } | 1075 | } |
1080 | return nand_scan_bbt (mtd, this->badblock_pattern); | 1076 | return nand_scan_bbt(mtd, this->badblock_pattern); |
1081 | } | 1077 | } |
1082 | 1078 | ||
1083 | /** | 1079 | /** |
@@ -1087,26 +1083,29 @@ int nand_default_bbt (struct mtd_info *mtd) | |||
1087 | * @allowbbt: allow access to bad block table region | 1083 | * @allowbbt: allow access to bad block table region |
1088 | * | 1084 | * |
1089 | */ | 1085 | */ |
1090 | int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt) | 1086 | int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt) |
1091 | { | 1087 | { |
1092 | struct nand_chip *this = mtd->priv; | 1088 | struct nand_chip *this = mtd->priv; |
1093 | int block; | 1089 | int block; |
1094 | uint8_t res; | 1090 | uint8_t res; |
1095 | 1091 | ||
1096 | /* Get block number * 2 */ | 1092 | /* Get block number * 2 */ |
1097 | block = (int) (offs >> (this->bbt_erase_shift - 1)); | 1093 | block = (int)(offs >> (this->bbt_erase_shift - 1)); |
1098 | res = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03; | 1094 | res = (this->bbt[block >> 3] >> (block & 0x06)) & 0x03; |
1099 | 1095 | ||
1100 | DEBUG (MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n", | 1096 | DEBUG(MTD_DEBUG_LEVEL2, "nand_isbad_bbt(): bbt info for offs 0x%08x: (block %d) 0x%02x\n", |
1101 | (unsigned int)offs, block >> 1, res); | 1097 | (unsigned int)offs, block >> 1, res); |
1102 | 1098 | ||
1103 | switch ((int)res) { | 1099 | switch ((int)res) { |
1104 | case 0x00: return 0; | 1100 | case 0x00: |
1105 | case 0x01: return 1; | 1101 | return 0; |
1106 | case 0x02: return allowbbt ? 0 : 1; | 1102 | case 0x01: |
1103 | return 1; | ||
1104 | case 0x02: | ||
1105 | return allowbbt ? 0 : 1; | ||
1107 | } | 1106 | } |
1108 | return 1; | 1107 | return 1; |
1109 | } | 1108 | } |
1110 | 1109 | ||
1111 | EXPORT_SYMBOL (nand_scan_bbt); | 1110 | EXPORT_SYMBOL(nand_scan_bbt); |
1112 | EXPORT_SYMBOL (nand_default_bbt); | 1111 | EXPORT_SYMBOL(nand_default_bbt); |
diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c index 40ac909150a3..101892985b02 100644 --- a/drivers/mtd/nand/nand_ecc.c +++ b/drivers/mtd/nand/nand_ecc.c | |||
@@ -62,7 +62,6 @@ static const u_char nand_ecc_precalc_table[] = { | |||
62 | 0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a, 0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00 | 62 | 0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a, 0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00 |
63 | }; | 63 | }; |
64 | 64 | ||
65 | |||
66 | /** | 65 | /** |
67 | * nand_trans_result - [GENERIC] create non-inverted ECC | 66 | * nand_trans_result - [GENERIC] create non-inverted ECC |
68 | * @reg2: line parity reg 2 | 67 | * @reg2: line parity reg 2 |
@@ -71,8 +70,7 @@ static const u_char nand_ecc_precalc_table[] = { | |||
71 | * | 70 | * |
72 | * Creates non-inverted ECC code from line parity | 71 | * Creates non-inverted ECC code from line parity |
73 | */ | 72 | */ |
74 | static void nand_trans_result(u_char reg2, u_char reg3, | 73 | static void nand_trans_result(u_char reg2, u_char reg3, u_char *ecc_code) |
75 | u_char *ecc_code) | ||
76 | { | 74 | { |
77 | u_char a, b, i, tmp1, tmp2; | 75 | u_char a, b, i, tmp1, tmp2; |
78 | 76 | ||
@@ -82,10 +80,10 @@ static void nand_trans_result(u_char reg2, u_char reg3, | |||
82 | 80 | ||
83 | /* Calculate first ECC byte */ | 81 | /* Calculate first ECC byte */ |
84 | for (i = 0; i < 4; i++) { | 82 | for (i = 0; i < 4; i++) { |
85 | if (reg3 & a) /* LP15,13,11,9 --> ecc_code[0] */ | 83 | if (reg3 & a) /* LP15,13,11,9 --> ecc_code[0] */ |
86 | tmp1 |= b; | 84 | tmp1 |= b; |
87 | b >>= 1; | 85 | b >>= 1; |
88 | if (reg2 & a) /* LP14,12,10,8 --> ecc_code[0] */ | 86 | if (reg2 & a) /* LP14,12,10,8 --> ecc_code[0] */ |
89 | tmp1 |= b; | 87 | tmp1 |= b; |
90 | b >>= 1; | 88 | b >>= 1; |
91 | a >>= 1; | 89 | a >>= 1; |
@@ -94,10 +92,10 @@ static void nand_trans_result(u_char reg2, u_char reg3, | |||
94 | /* Calculate second ECC byte */ | 92 | /* Calculate second ECC byte */ |
95 | b = 0x80; | 93 | b = 0x80; |
96 | for (i = 0; i < 4; i++) { | 94 | for (i = 0; i < 4; i++) { |
97 | if (reg3 & a) /* LP7,5,3,1 --> ecc_code[1] */ | 95 | if (reg3 & a) /* LP7,5,3,1 --> ecc_code[1] */ |
98 | tmp2 |= b; | 96 | tmp2 |= b; |
99 | b >>= 1; | 97 | b >>= 1; |
100 | if (reg2 & a) /* LP6,4,2,0 --> ecc_code[1] */ | 98 | if (reg2 & a) /* LP6,4,2,0 --> ecc_code[1] */ |
101 | tmp2 |= b; | 99 | tmp2 |= b; |
102 | b >>= 1; | 100 | b >>= 1; |
103 | a >>= 1; | 101 | a >>= 1; |
@@ -124,7 +122,7 @@ int nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code | |||
124 | ecc_code[0] = ecc_code[1] = ecc_code[2] = 0; | 122 | ecc_code[0] = ecc_code[1] = ecc_code[2] = 0; |
125 | 123 | ||
126 | /* Build up column parity */ | 124 | /* Build up column parity */ |
127 | for(j = 0; j < 256; j++) { | 125 | for (j = 0; j < 256; j++) { |
128 | 126 | ||
129 | /* Get CP0 - CP5 from table */ | 127 | /* Get CP0 - CP5 from table */ |
130 | idx = nand_ecc_precalc_table[dat[j]]; | 128 | idx = nand_ecc_precalc_table[dat[j]]; |
@@ -168,8 +166,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha | |||
168 | if ((d1 | d2 | d3) == 0) { | 166 | if ((d1 | d2 | d3) == 0) { |
169 | /* No errors */ | 167 | /* No errors */ |
170 | return 0; | 168 | return 0; |
171 | } | 169 | } else { |
172 | else { | ||
173 | a = (d1 ^ (d1 >> 1)) & 0x55; | 170 | a = (d1 ^ (d1 >> 1)) & 0x55; |
174 | b = (d2 ^ (d2 >> 1)) & 0x55; | 171 | b = (d2 ^ (d2 >> 1)) & 0x55; |
175 | c = (d3 ^ (d3 >> 1)) & 0x54; | 172 | c = (d3 ^ (d3 >> 1)) & 0x54; |
@@ -179,14 +176,14 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha | |||
179 | c = 0x80; | 176 | c = 0x80; |
180 | add = 0; | 177 | add = 0; |
181 | a = 0x80; | 178 | a = 0x80; |
182 | for (i=0; i<4; i++) { | 179 | for (i = 0; i < 4; i++) { |
183 | if (d1 & c) | 180 | if (d1 & c) |
184 | add |= a; | 181 | add |= a; |
185 | c >>= 2; | 182 | c >>= 2; |
186 | a >>= 1; | 183 | a >>= 1; |
187 | } | 184 | } |
188 | c = 0x80; | 185 | c = 0x80; |
189 | for (i=0; i<4; i++) { | 186 | for (i = 0; i < 4; i++) { |
190 | if (d2 & c) | 187 | if (d2 & c) |
191 | add |= a; | 188 | add |= a; |
192 | c >>= 2; | 189 | c >>= 2; |
@@ -195,7 +192,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha | |||
195 | bit = 0; | 192 | bit = 0; |
196 | b = 0x04; | 193 | b = 0x04; |
197 | c = 0x80; | 194 | c = 0x80; |
198 | for (i=0; i<3; i++) { | 195 | for (i = 0; i < 3; i++) { |
199 | if (d3 & c) | 196 | if (d3 & c) |
200 | bit |= b; | 197 | bit |= b; |
201 | c >>= 2; | 198 | c >>= 2; |
@@ -206,8 +203,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha | |||
206 | a ^= (b << bit); | 203 | a ^= (b << bit); |
207 | dat[add] = a; | 204 | dat[add] = a; |
208 | return 1; | 205 | return 1; |
209 | } | 206 | } else { |
210 | else { | ||
211 | i = 0; | 207 | i = 0; |
212 | while (d1) { | 208 | while (d1) { |
213 | if (d1 & 0x01) | 209 | if (d1 & 0x01) |
@@ -230,8 +226,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha | |||
230 | read_ecc[1] = calc_ecc[1]; | 226 | read_ecc[1] = calc_ecc[1]; |
231 | read_ecc[2] = calc_ecc[2]; | 227 | read_ecc[2] = calc_ecc[2]; |
232 | return 2; | 228 | return 2; |
233 | } | 229 | } else { |
234 | else { | ||
235 | /* Uncorrectable Error */ | 230 | /* Uncorrectable Error */ |
236 | return -1; | 231 | return -1; |
237 | } | 232 | } |
diff --git a/drivers/mtd/nand/nand_ids.c b/drivers/mtd/nand/nand_ids.c index dbc7e55a4247..a9d52fc6e5d7 100644 --- a/drivers/mtd/nand/nand_ids.c +++ b/drivers/mtd/nand/nand_ids.c | |||
@@ -125,13 +125,13 @@ struct nand_manufacturers nand_manuf_ids[] = { | |||
125 | {NAND_MFR_NATIONAL, "National"}, | 125 | {NAND_MFR_NATIONAL, "National"}, |
126 | {NAND_MFR_RENESAS, "Renesas"}, | 126 | {NAND_MFR_RENESAS, "Renesas"}, |
127 | {NAND_MFR_STMICRO, "ST Micro"}, | 127 | {NAND_MFR_STMICRO, "ST Micro"}, |
128 | {NAND_MFR_HYNIX, "Hynix"}, | 128 | {NAND_MFR_HYNIX, "Hynix"}, |
129 | {0x0, "Unknown"} | 129 | {0x0, "Unknown"} |
130 | }; | 130 | }; |
131 | 131 | ||
132 | EXPORT_SYMBOL (nand_manuf_ids); | 132 | EXPORT_SYMBOL(nand_manuf_ids); |
133 | EXPORT_SYMBOL (nand_flash_ids); | 133 | EXPORT_SYMBOL(nand_flash_ids); |
134 | 134 | ||
135 | MODULE_LICENSE ("GPL"); | 135 | MODULE_LICENSE("GPL"); |
136 | MODULE_AUTHOR ("Thomas Gleixner <tglx@linutronix.de>"); | 136 | MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>"); |
137 | MODULE_DESCRIPTION ("Nand device & manufacturer ID's"); | 137 | MODULE_DESCRIPTION("Nand device & manufacturer IDs"); |
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index a0af92cc7efd..6903f5b903c6 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
@@ -1546,6 +1546,8 @@ static int __init ns_init_module(void) | |||
1546 | chip->options |= NAND_BUSWIDTH_16; | 1546 | chip->options |= NAND_BUSWIDTH_16; |
1547 | } | 1547 | } |
1548 | 1548 | ||
1549 | nsmtd->owner = THIS_MODULE; | ||
1550 | |||
1549 | if ((retval = nand_scan(nsmtd, 1)) != 0) { | 1551 | if ((retval = nand_scan(nsmtd, 1)) != 0) { |
1550 | NS_ERR("can't register NAND Simulator\n"); | 1552 | NS_ERR("can't register NAND Simulator\n"); |
1551 | if (retval > 0) | 1553 | if (retval > 0) |
diff --git a/drivers/mtd/nand/ppchameleonevb.c b/drivers/mtd/nand/ppchameleonevb.c index 91a95f34a6ee..5d4d16fb1df6 100644 --- a/drivers/mtd/nand/ppchameleonevb.c +++ b/drivers/mtd/nand/ppchameleonevb.c | |||
@@ -58,21 +58,21 @@ | |||
58 | /* | 58 | /* |
59 | * MTD structure for PPChameleonEVB board | 59 | * MTD structure for PPChameleonEVB board |
60 | */ | 60 | */ |
61 | static struct mtd_info *ppchameleon_mtd = NULL; | 61 | static struct mtd_info *ppchameleon_mtd = NULL; |
62 | static struct mtd_info *ppchameleonevb_mtd = NULL; | 62 | static struct mtd_info *ppchameleonevb_mtd = NULL; |
63 | 63 | ||
64 | /* | 64 | /* |
65 | * Module stuff | 65 | * Module stuff |
66 | */ | 66 | */ |
67 | static unsigned long ppchameleon_fio_pbase = CFG_NAND0_PADDR; | 67 | static unsigned long ppchameleon_fio_pbase = CFG_NAND0_PADDR; |
68 | static unsigned long ppchameleonevb_fio_pbase = CFG_NAND1_PADDR; | 68 | static unsigned long ppchameleonevb_fio_pbase = CFG_NAND1_PADDR; |
69 | 69 | ||
70 | #ifdef MODULE | 70 | #ifdef MODULE |
71 | module_param(ppchameleon_fio_pbase, ulong, 0); | 71 | module_param(ppchameleon_fio_pbase, ulong, 0); |
72 | module_param(ppchameleonevb_fio_pbase, ulong, 0); | 72 | module_param(ppchameleonevb_fio_pbase, ulong, 0); |
73 | #else | 73 | #else |
74 | __setup("ppchameleon_fio_pbase=",ppchameleon_fio_pbase); | 74 | __setup("ppchameleon_fio_pbase=", ppchameleon_fio_pbase); |
75 | __setup("ppchameleonevb_fio_pbase=",ppchameleonevb_fio_pbase); | 75 | __setup("ppchameleonevb_fio_pbase=", ppchameleonevb_fio_pbase); |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #ifdef CONFIG_MTD_PARTITIONS | 78 | #ifdef CONFIG_MTD_PARTITIONS |
@@ -80,80 +80,80 @@ __setup("ppchameleonevb_fio_pbase=",ppchameleonevb_fio_pbase); | |||
80 | * Define static partitions for flash devices | 80 | * Define static partitions for flash devices |
81 | */ | 81 | */ |
82 | static struct mtd_partition partition_info_hi[] = { | 82 | static struct mtd_partition partition_info_hi[] = { |
83 | { name: "PPChameleon HI Nand Flash", | 83 | { .name = "PPChameleon HI Nand Flash", |
84 | offset: 0, | 84 | offset = 0, |
85 | size: 128*1024*1024 } | 85 | .size = 128 * 1024 * 1024 |
86 | } | ||
86 | }; | 87 | }; |
87 | 88 | ||
88 | static struct mtd_partition partition_info_me[] = { | 89 | static struct mtd_partition partition_info_me[] = { |
89 | { name: "PPChameleon ME Nand Flash", | 90 | { .name = "PPChameleon ME Nand Flash", |
90 | offset: 0, | 91 | .offset = 0, |
91 | size: 32*1024*1024 } | 92 | .size = 32 * 1024 * 1024 |
93 | } | ||
92 | }; | 94 | }; |
93 | 95 | ||
94 | static struct mtd_partition partition_info_evb[] = { | 96 | static struct mtd_partition partition_info_evb[] = { |
95 | { name: "PPChameleonEVB Nand Flash", | 97 | { .name = "PPChameleonEVB Nand Flash", |
96 | offset: 0, | 98 | .offset = 0, |
97 | size: 32*1024*1024 } | 99 | .size = 32 * 1024 * 1024 |
100 | } | ||
98 | }; | 101 | }; |
99 | 102 | ||
100 | #define NUM_PARTITIONS 1 | 103 | #define NUM_PARTITIONS 1 |
101 | 104 | ||
102 | extern int parse_cmdline_partitions(struct mtd_info *master, | 105 | extern int parse_cmdline_partitions(struct mtd_info *master, struct mtd_partition **pparts, const char *mtd_id); |
103 | struct mtd_partition **pparts, | ||
104 | const char *mtd_id); | ||
105 | #endif | 106 | #endif |
106 | 107 | ||
107 | |||
108 | /* | 108 | /* |
109 | * hardware specific access to control-lines | 109 | * hardware specific access to control-lines |
110 | */ | 110 | */ |
111 | static void ppchameleon_hwcontrol(struct mtd_info *mtdinfo, int cmd) | 111 | static void ppchameleon_hwcontrol(struct mtd_info *mtdinfo, int cmd) |
112 | { | 112 | { |
113 | switch(cmd) { | 113 | switch (cmd) { |
114 | 114 | ||
115 | case NAND_CTL_SETCLE: | 115 | case NAND_CTL_SETCLE: |
116 | MACRO_NAND_CTL_SETCLE((unsigned long)CFG_NAND0_PADDR); | 116 | MACRO_NAND_CTL_SETCLE((unsigned long)CFG_NAND0_PADDR); |
117 | break; | 117 | break; |
118 | case NAND_CTL_CLRCLE: | 118 | case NAND_CTL_CLRCLE: |
119 | MACRO_NAND_CTL_CLRCLE((unsigned long)CFG_NAND0_PADDR); | 119 | MACRO_NAND_CTL_CLRCLE((unsigned long)CFG_NAND0_PADDR); |
120 | break; | 120 | break; |
121 | case NAND_CTL_SETALE: | 121 | case NAND_CTL_SETALE: |
122 | MACRO_NAND_CTL_SETALE((unsigned long)CFG_NAND0_PADDR); | 122 | MACRO_NAND_CTL_SETALE((unsigned long)CFG_NAND0_PADDR); |
123 | break; | 123 | break; |
124 | case NAND_CTL_CLRALE: | 124 | case NAND_CTL_CLRALE: |
125 | MACRO_NAND_CTL_CLRALE((unsigned long)CFG_NAND0_PADDR); | 125 | MACRO_NAND_CTL_CLRALE((unsigned long)CFG_NAND0_PADDR); |
126 | break; | 126 | break; |
127 | case NAND_CTL_SETNCE: | 127 | case NAND_CTL_SETNCE: |
128 | MACRO_NAND_ENABLE_CE((unsigned long)CFG_NAND0_PADDR); | 128 | MACRO_NAND_ENABLE_CE((unsigned long)CFG_NAND0_PADDR); |
129 | break; | 129 | break; |
130 | case NAND_CTL_CLRNCE: | 130 | case NAND_CTL_CLRNCE: |
131 | MACRO_NAND_DISABLE_CE((unsigned long)CFG_NAND0_PADDR); | 131 | MACRO_NAND_DISABLE_CE((unsigned long)CFG_NAND0_PADDR); |
132 | break; | 132 | break; |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | static void ppchameleonevb_hwcontrol(struct mtd_info *mtdinfo, int cmd) | 136 | static void ppchameleonevb_hwcontrol(struct mtd_info *mtdinfo, int cmd) |
137 | { | 137 | { |
138 | switch(cmd) { | 138 | switch (cmd) { |
139 | 139 | ||
140 | case NAND_CTL_SETCLE: | 140 | case NAND_CTL_SETCLE: |
141 | MACRO_NAND_CTL_SETCLE((unsigned long)CFG_NAND1_PADDR); | 141 | MACRO_NAND_CTL_SETCLE((unsigned long)CFG_NAND1_PADDR); |
142 | break; | 142 | break; |
143 | case NAND_CTL_CLRCLE: | 143 | case NAND_CTL_CLRCLE: |
144 | MACRO_NAND_CTL_CLRCLE((unsigned long)CFG_NAND1_PADDR); | 144 | MACRO_NAND_CTL_CLRCLE((unsigned long)CFG_NAND1_PADDR); |
145 | break; | 145 | break; |
146 | case NAND_CTL_SETALE: | 146 | case NAND_CTL_SETALE: |
147 | MACRO_NAND_CTL_SETALE((unsigned long)CFG_NAND1_PADDR); | 147 | MACRO_NAND_CTL_SETALE((unsigned long)CFG_NAND1_PADDR); |
148 | break; | 148 | break; |
149 | case NAND_CTL_CLRALE: | 149 | case NAND_CTL_CLRALE: |
150 | MACRO_NAND_CTL_CLRALE((unsigned long)CFG_NAND1_PADDR); | 150 | MACRO_NAND_CTL_CLRALE((unsigned long)CFG_NAND1_PADDR); |
151 | break; | 151 | break; |
152 | case NAND_CTL_SETNCE: | 152 | case NAND_CTL_SETNCE: |
153 | MACRO_NAND_ENABLE_CE((unsigned long)CFG_NAND1_PADDR); | 153 | MACRO_NAND_ENABLE_CE((unsigned long)CFG_NAND1_PADDR); |
154 | break; | 154 | break; |
155 | case NAND_CTL_CLRNCE: | 155 | case NAND_CTL_CLRNCE: |
156 | MACRO_NAND_DISABLE_CE((unsigned long)CFG_NAND1_PADDR); | 156 | MACRO_NAND_DISABLE_CE((unsigned long)CFG_NAND1_PADDR); |
157 | break; | 157 | break; |
158 | } | 158 | } |
159 | } | 159 | } |
@@ -164,15 +164,15 @@ static void ppchameleonevb_hwcontrol(struct mtd_info *mtdinfo, int cmd) | |||
164 | */ | 164 | */ |
165 | static int ppchameleon_device_ready(struct mtd_info *minfo) | 165 | static int ppchameleon_device_ready(struct mtd_info *minfo) |
166 | { | 166 | { |
167 | if (in_be32((volatile unsigned*)GPIO0_IR) & NAND_RB_GPIO_PIN) | 167 | if (in_be32((volatile unsigned *)GPIO0_IR) & NAND_RB_GPIO_PIN) |
168 | return 1; | 168 | return 1; |
169 | return 0; | 169 | return 0; |
170 | } | 170 | } |
171 | 171 | ||
172 | static int ppchameleonevb_device_ready(struct mtd_info *minfo) | 172 | static int ppchameleonevb_device_ready(struct mtd_info *minfo) |
173 | { | 173 | { |
174 | if (in_be32((volatile unsigned*)GPIO0_IR) & NAND_EVB_RB_GPIO_PIN) | 174 | if (in_be32((volatile unsigned *)GPIO0_IR) & NAND_EVB_RB_GPIO_PIN) |
175 | return 1; | 175 | return 1; |
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | #endif | 178 | #endif |
@@ -185,7 +185,7 @@ const char *part_probes_evb[] = { "cmdlinepart", NULL }; | |||
185 | /* | 185 | /* |
186 | * Main initialization routine | 186 | * Main initialization routine |
187 | */ | 187 | */ |
188 | static int __init ppchameleonevb_init (void) | 188 | static int __init ppchameleonevb_init(void) |
189 | { | 189 | { |
190 | struct nand_chip *this; | 190 | struct nand_chip *this; |
191 | const char *part_type = 0; | 191 | const char *part_type = 0; |
@@ -194,13 +194,11 @@ static int __init ppchameleonevb_init (void) | |||
194 | void __iomem *ppchameleon_fio_base; | 194 | void __iomem *ppchameleon_fio_base; |
195 | void __iomem *ppchameleonevb_fio_base; | 195 | void __iomem *ppchameleonevb_fio_base; |
196 | 196 | ||
197 | |||
198 | /********************************* | 197 | /********************************* |
199 | * Processor module NAND (if any) * | 198 | * Processor module NAND (if any) * |
200 | *********************************/ | 199 | *********************************/ |
201 | /* Allocate memory for MTD device structure and private data */ | 200 | /* Allocate memory for MTD device structure and private data */ |
202 | ppchameleon_mtd = kmalloc(sizeof(struct mtd_info) + | 201 | ppchameleon_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
203 | sizeof(struct nand_chip), GFP_KERNEL); | ||
204 | if (!ppchameleon_mtd) { | 202 | if (!ppchameleon_mtd) { |
205 | printk("Unable to allocate PPChameleon NAND MTD device structure.\n"); | 203 | printk("Unable to allocate PPChameleon NAND MTD device structure.\n"); |
206 | return -ENOMEM; | 204 | return -ENOMEM; |
@@ -208,43 +206,46 @@ static int __init ppchameleonevb_init (void) | |||
208 | 206 | ||
209 | /* map physical address */ | 207 | /* map physical address */ |
210 | ppchameleon_fio_base = ioremap(ppchameleon_fio_pbase, SZ_4M); | 208 | ppchameleon_fio_base = ioremap(ppchameleon_fio_pbase, SZ_4M); |
211 | if(!ppchameleon_fio_base) { | 209 | if (!ppchameleon_fio_base) { |
212 | printk("ioremap PPChameleon NAND flash failed\n"); | 210 | printk("ioremap PPChameleon NAND flash failed\n"); |
213 | kfree(ppchameleon_mtd); | 211 | kfree(ppchameleon_mtd); |
214 | return -EIO; | 212 | return -EIO; |
215 | } | 213 | } |
216 | 214 | ||
217 | /* Get pointer to private data */ | 215 | /* Get pointer to private data */ |
218 | this = (struct nand_chip *) (&ppchameleon_mtd[1]); | 216 | this = (struct nand_chip *)(&ppchameleon_mtd[1]); |
219 | 217 | ||
220 | /* Initialize structures */ | 218 | /* Initialize structures */ |
221 | memset((char *) ppchameleon_mtd, 0, sizeof(struct mtd_info)); | 219 | memset(ppchameleon_mtd, 0, sizeof(struct mtd_info)); |
222 | memset((char *) this, 0, sizeof(struct nand_chip)); | 220 | memset(this, 0, sizeof(struct nand_chip)); |
223 | 221 | ||
224 | /* Link the private data with the MTD structure */ | 222 | /* Link the private data with the MTD structure */ |
225 | ppchameleon_mtd->priv = this; | 223 | ppchameleon_mtd->priv = this; |
224 | ppchameleon_mtd->owner = THIS_MODULE; | ||
226 | 225 | ||
227 | /* Initialize GPIOs */ | 226 | /* Initialize GPIOs */ |
228 | /* Pin mapping for NAND chip */ | 227 | /* Pin mapping for NAND chip */ |
229 | /* | 228 | /* |
230 | CE GPIO_01 | 229 | CE GPIO_01 |
231 | CLE GPIO_02 | 230 | CLE GPIO_02 |
232 | ALE GPIO_03 | 231 | ALE GPIO_03 |
233 | R/B GPIO_04 | 232 | R/B GPIO_04 |
234 | */ | 233 | */ |
235 | /* output select */ | 234 | /* output select */ |
236 | out_be32((volatile unsigned*)GPIO0_OSRH, in_be32((volatile unsigned*)GPIO0_OSRH) & 0xC0FFFFFF); | 235 | out_be32((volatile unsigned *)GPIO0_OSRH, in_be32((volatile unsigned *)GPIO0_OSRH) & 0xC0FFFFFF); |
237 | /* three-state select */ | 236 | /* three-state select */ |
238 | out_be32((volatile unsigned*)GPIO0_TSRH, in_be32((volatile unsigned*)GPIO0_TSRH) & 0xC0FFFFFF); | 237 | out_be32((volatile unsigned *)GPIO0_TSRH, in_be32((volatile unsigned *)GPIO0_TSRH) & 0xC0FFFFFF); |
239 | /* enable output driver */ | 238 | /* enable output driver */ |
240 | out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) | NAND_nCE_GPIO_PIN | NAND_CLE_GPIO_PIN | NAND_ALE_GPIO_PIN); | 239 | out_be32((volatile unsigned *)GPIO0_TCR, |
240 | in_be32((volatile unsigned *)GPIO0_TCR) | NAND_nCE_GPIO_PIN | NAND_CLE_GPIO_PIN | NAND_ALE_GPIO_PIN); | ||
241 | #ifdef USE_READY_BUSY_PIN | 241 | #ifdef USE_READY_BUSY_PIN |
242 | /* three-state select */ | 242 | /* three-state select */ |
243 | out_be32((volatile unsigned*)GPIO0_TSRH, in_be32((volatile unsigned*)GPIO0_TSRH) & 0xFF3FFFFF); | 243 | out_be32((volatile unsigned *)GPIO0_TSRH, in_be32((volatile unsigned *)GPIO0_TSRH) & 0xFF3FFFFF); |
244 | /* high-impedecence */ | 244 | /* high-impedecence */ |
245 | out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) & (~NAND_RB_GPIO_PIN)); | 245 | out_be32((volatile unsigned *)GPIO0_TCR, in_be32((volatile unsigned *)GPIO0_TCR) & (~NAND_RB_GPIO_PIN)); |
246 | /* input select */ | 246 | /* input select */ |
247 | out_be32((volatile unsigned*)GPIO0_ISR1H, (in_be32((volatile unsigned*)GPIO0_ISR1H) & 0xFF3FFFFF) | 0x00400000); | 247 | out_be32((volatile unsigned *)GPIO0_ISR1H, |
248 | (in_be32((volatile unsigned *)GPIO0_ISR1H) & 0xFF3FFFFF) | 0x00400000); | ||
248 | #endif | 249 | #endif |
249 | 250 | ||
250 | /* insert callbacks */ | 251 | /* insert callbacks */ |
@@ -259,12 +260,11 @@ static int __init ppchameleonevb_init (void) | |||
259 | this->eccmode = NAND_ECC_SOFT; | 260 | this->eccmode = NAND_ECC_SOFT; |
260 | 261 | ||
261 | /* Scan to find existence of the device (it could not be mounted) */ | 262 | /* Scan to find existence of the device (it could not be mounted) */ |
262 | if (nand_scan (ppchameleon_mtd, 1)) { | 263 | if (nand_scan(ppchameleon_mtd, 1)) { |
263 | iounmap((void *)ppchameleon_fio_base); | 264 | iounmap((void *)ppchameleon_fio_base); |
264 | kfree (ppchameleon_mtd); | 265 | kfree(ppchameleon_mtd); |
265 | goto nand_evb_init; | 266 | goto nand_evb_init; |
266 | } | 267 | } |
267 | |||
268 | #ifndef USE_READY_BUSY_PIN | 268 | #ifndef USE_READY_BUSY_PIN |
269 | /* Adjust delay if necessary */ | 269 | /* Adjust delay if necessary */ |
270 | if (ppchameleon_mtd->size == NAND_SMALL_SIZE) | 270 | if (ppchameleon_mtd->size == NAND_SMALL_SIZE) |
@@ -275,12 +275,11 @@ static int __init ppchameleonevb_init (void) | |||
275 | ppchameleon_mtd->name = "ppchameleon-nand"; | 275 | ppchameleon_mtd->name = "ppchameleon-nand"; |
276 | mtd_parts_nb = parse_mtd_partitions(ppchameleon_mtd, part_probes, &mtd_parts, 0); | 276 | mtd_parts_nb = parse_mtd_partitions(ppchameleon_mtd, part_probes, &mtd_parts, 0); |
277 | if (mtd_parts_nb > 0) | 277 | if (mtd_parts_nb > 0) |
278 | part_type = "command line"; | 278 | part_type = "command line"; |
279 | else | 279 | else |
280 | mtd_parts_nb = 0; | 280 | mtd_parts_nb = 0; |
281 | #endif | 281 | #endif |
282 | if (mtd_parts_nb == 0) | 282 | if (mtd_parts_nb == 0) { |
283 | { | ||
284 | if (ppchameleon_mtd->size == NAND_SMALL_SIZE) | 283 | if (ppchameleon_mtd->size == NAND_SMALL_SIZE) |
285 | mtd_parts = partition_info_me; | 284 | mtd_parts = partition_info_me; |
286 | else | 285 | else |
@@ -293,13 +292,12 @@ static int __init ppchameleonevb_init (void) | |||
293 | printk(KERN_NOTICE "Using %s partition definition\n", part_type); | 292 | printk(KERN_NOTICE "Using %s partition definition\n", part_type); |
294 | add_mtd_partitions(ppchameleon_mtd, mtd_parts, mtd_parts_nb); | 293 | add_mtd_partitions(ppchameleon_mtd, mtd_parts, mtd_parts_nb); |
295 | 294 | ||
296 | nand_evb_init: | 295 | nand_evb_init: |
297 | /**************************** | 296 | /**************************** |
298 | * EVB NAND (always present) * | 297 | * EVB NAND (always present) * |
299 | ****************************/ | 298 | ****************************/ |
300 | /* Allocate memory for MTD device structure and private data */ | 299 | /* Allocate memory for MTD device structure and private data */ |
301 | ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) + | 300 | ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
302 | sizeof(struct nand_chip), GFP_KERNEL); | ||
303 | if (!ppchameleonevb_mtd) { | 301 | if (!ppchameleonevb_mtd) { |
304 | printk("Unable to allocate PPChameleonEVB NAND MTD device structure.\n"); | 302 | printk("Unable to allocate PPChameleonEVB NAND MTD device structure.\n"); |
305 | return -ENOMEM; | 303 | return -ENOMEM; |
@@ -307,46 +305,47 @@ nand_evb_init: | |||
307 | 305 | ||
308 | /* map physical address */ | 306 | /* map physical address */ |
309 | ppchameleonevb_fio_base = ioremap(ppchameleonevb_fio_pbase, SZ_4M); | 307 | ppchameleonevb_fio_base = ioremap(ppchameleonevb_fio_pbase, SZ_4M); |
310 | if(!ppchameleonevb_fio_base) { | 308 | if (!ppchameleonevb_fio_base) { |
311 | printk("ioremap PPChameleonEVB NAND flash failed\n"); | 309 | printk("ioremap PPChameleonEVB NAND flash failed\n"); |
312 | kfree(ppchameleonevb_mtd); | 310 | kfree(ppchameleonevb_mtd); |
313 | return -EIO; | 311 | return -EIO; |
314 | } | 312 | } |
315 | 313 | ||
316 | /* Get pointer to private data */ | 314 | /* Get pointer to private data */ |
317 | this = (struct nand_chip *) (&ppchameleonevb_mtd[1]); | 315 | this = (struct nand_chip *)(&ppchameleonevb_mtd[1]); |
318 | 316 | ||
319 | /* Initialize structures */ | 317 | /* Initialize structures */ |
320 | memset((char *) ppchameleonevb_mtd, 0, sizeof(struct mtd_info)); | 318 | memset(ppchameleonevb_mtd, 0, sizeof(struct mtd_info)); |
321 | memset((char *) this, 0, sizeof(struct nand_chip)); | 319 | memset(this, 0, sizeof(struct nand_chip)); |
322 | 320 | ||
323 | /* Link the private data with the MTD structure */ | 321 | /* Link the private data with the MTD structure */ |
324 | ppchameleonevb_mtd->priv = this; | 322 | ppchameleonevb_mtd->priv = this; |
325 | 323 | ||
326 | /* Initialize GPIOs */ | 324 | /* Initialize GPIOs */ |
327 | /* Pin mapping for NAND chip */ | 325 | /* Pin mapping for NAND chip */ |
328 | /* | 326 | /* |
329 | CE GPIO_14 | 327 | CE GPIO_14 |
330 | CLE GPIO_15 | 328 | CLE GPIO_15 |
331 | ALE GPIO_16 | 329 | ALE GPIO_16 |
332 | R/B GPIO_31 | 330 | R/B GPIO_31 |
333 | */ | 331 | */ |
334 | /* output select */ | 332 | /* output select */ |
335 | out_be32((volatile unsigned*)GPIO0_OSRH, in_be32((volatile unsigned*)GPIO0_OSRH) & 0xFFFFFFF0); | 333 | out_be32((volatile unsigned *)GPIO0_OSRH, in_be32((volatile unsigned *)GPIO0_OSRH) & 0xFFFFFFF0); |
336 | out_be32((volatile unsigned*)GPIO0_OSRL, in_be32((volatile unsigned*)GPIO0_OSRL) & 0x3FFFFFFF); | 334 | out_be32((volatile unsigned *)GPIO0_OSRL, in_be32((volatile unsigned *)GPIO0_OSRL) & 0x3FFFFFFF); |
337 | /* three-state select */ | 335 | /* three-state select */ |
338 | out_be32((volatile unsigned*)GPIO0_TSRH, in_be32((volatile unsigned*)GPIO0_TSRH) & 0xFFFFFFF0); | 336 | out_be32((volatile unsigned *)GPIO0_TSRH, in_be32((volatile unsigned *)GPIO0_TSRH) & 0xFFFFFFF0); |
339 | out_be32((volatile unsigned*)GPIO0_TSRL, in_be32((volatile unsigned*)GPIO0_TSRL) & 0x3FFFFFFF); | 337 | out_be32((volatile unsigned *)GPIO0_TSRL, in_be32((volatile unsigned *)GPIO0_TSRL) & 0x3FFFFFFF); |
340 | /* enable output driver */ | 338 | /* enable output driver */ |
341 | out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) | NAND_EVB_nCE_GPIO_PIN | | 339 | out_be32((volatile unsigned *)GPIO0_TCR, in_be32((volatile unsigned *)GPIO0_TCR) | NAND_EVB_nCE_GPIO_PIN | |
342 | NAND_EVB_CLE_GPIO_PIN | NAND_EVB_ALE_GPIO_PIN); | 340 | NAND_EVB_CLE_GPIO_PIN | NAND_EVB_ALE_GPIO_PIN); |
343 | #ifdef USE_READY_BUSY_PIN | 341 | #ifdef USE_READY_BUSY_PIN |
344 | /* three-state select */ | 342 | /* three-state select */ |
345 | out_be32((volatile unsigned*)GPIO0_TSRL, in_be32((volatile unsigned*)GPIO0_TSRL) & 0xFFFFFFFC); | 343 | out_be32((volatile unsigned *)GPIO0_TSRL, in_be32((volatile unsigned *)GPIO0_TSRL) & 0xFFFFFFFC); |
346 | /* high-impedecence */ | 344 | /* high-impedecence */ |
347 | out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) & (~NAND_EVB_RB_GPIO_PIN)); | 345 | out_be32((volatile unsigned *)GPIO0_TCR, in_be32((volatile unsigned *)GPIO0_TCR) & (~NAND_EVB_RB_GPIO_PIN)); |
348 | /* input select */ | 346 | /* input select */ |
349 | out_be32((volatile unsigned*)GPIO0_ISR1L, (in_be32((volatile unsigned*)GPIO0_ISR1L) & 0xFFFFFFFC) | 0x00000001); | 347 | out_be32((volatile unsigned *)GPIO0_ISR1L, |
348 | (in_be32((volatile unsigned *)GPIO0_ISR1L) & 0xFFFFFFFC) | 0x00000001); | ||
350 | #endif | 349 | #endif |
351 | 350 | ||
352 | /* insert callbacks */ | 351 | /* insert callbacks */ |
@@ -362,22 +361,20 @@ nand_evb_init: | |||
362 | this->eccmode = NAND_ECC_SOFT; | 361 | this->eccmode = NAND_ECC_SOFT; |
363 | 362 | ||
364 | /* Scan to find existence of the device */ | 363 | /* Scan to find existence of the device */ |
365 | if (nand_scan (ppchameleonevb_mtd, 1)) { | 364 | if (nand_scan(ppchameleonevb_mtd, 1)) { |
366 | iounmap((void *)ppchameleonevb_fio_base); | 365 | iounmap((void *)ppchameleonevb_fio_base); |
367 | kfree (ppchameleonevb_mtd); | 366 | kfree(ppchameleonevb_mtd); |
368 | return -ENXIO; | 367 | return -ENXIO; |
369 | } | 368 | } |
370 | |||
371 | #ifdef CONFIG_MTD_PARTITIONS | 369 | #ifdef CONFIG_MTD_PARTITIONS |
372 | ppchameleonevb_mtd->name = NAND_EVB_MTD_NAME; | 370 | ppchameleonevb_mtd->name = NAND_EVB_MTD_NAME; |
373 | mtd_parts_nb = parse_mtd_partitions(ppchameleonevb_mtd, part_probes_evb, &mtd_parts, 0); | 371 | mtd_parts_nb = parse_mtd_partitions(ppchameleonevb_mtd, part_probes_evb, &mtd_parts, 0); |
374 | if (mtd_parts_nb > 0) | 372 | if (mtd_parts_nb > 0) |
375 | part_type = "command line"; | 373 | part_type = "command line"; |
376 | else | 374 | else |
377 | mtd_parts_nb = 0; | 375 | mtd_parts_nb = 0; |
378 | #endif | 376 | #endif |
379 | if (mtd_parts_nb == 0) | 377 | if (mtd_parts_nb == 0) { |
380 | { | ||
381 | mtd_parts = partition_info_evb; | 378 | mtd_parts = partition_info_evb; |
382 | mtd_parts_nb = NUM_PARTITIONS; | 379 | mtd_parts_nb = NUM_PARTITIONS; |
383 | part_type = "static"; | 380 | part_type = "static"; |
@@ -390,18 +387,19 @@ nand_evb_init: | |||
390 | /* Return happy */ | 387 | /* Return happy */ |
391 | return 0; | 388 | return 0; |
392 | } | 389 | } |
390 | |||
393 | module_init(ppchameleonevb_init); | 391 | module_init(ppchameleonevb_init); |
394 | 392 | ||
395 | /* | 393 | /* |
396 | * Clean up routine | 394 | * Clean up routine |
397 | */ | 395 | */ |
398 | static void __exit ppchameleonevb_cleanup (void) | 396 | static void __exit ppchameleonevb_cleanup(void) |
399 | { | 397 | { |
400 | struct nand_chip *this; | 398 | struct nand_chip *this; |
401 | 399 | ||
402 | /* Release resources, unregister device(s) */ | 400 | /* Release resources, unregister device(s) */ |
403 | nand_release (ppchameleon_mtd); | 401 | nand_release(ppchameleon_mtd); |
404 | nand_release (ppchameleonevb_mtd); | 402 | nand_release(ppchameleonevb_mtd); |
405 | 403 | ||
406 | /* Release iomaps */ | 404 | /* Release iomaps */ |
407 | this = (struct nand_chip *) &ppchameleon_mtd[1]; | 405 | this = (struct nand_chip *) &ppchameleon_mtd[1]; |
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c index 4129c03dfd90..bc9d849fbd5d 100644 --- a/drivers/mtd/nand/rtc_from4.c +++ b/drivers/mtd/nand/rtc_from4.c | |||
@@ -97,12 +97,12 @@ static struct mtd_info *rtc_from4_mtd = NULL; | |||
97 | static void __iomem *rtc_from4_fio_base = (void *)P2SEGADDR(RTC_FROM4_FIO_BASE); | 97 | static void __iomem *rtc_from4_fio_base = (void *)P2SEGADDR(RTC_FROM4_FIO_BASE); |
98 | 98 | ||
99 | static const struct mtd_partition partition_info[] = { | 99 | static const struct mtd_partition partition_info[] = { |
100 | { | 100 | { |
101 | .name = "Renesas flash partition 1", | 101 | .name = "Renesas flash partition 1", |
102 | .offset = 0, | 102 | .offset = 0, |
103 | .size = MTDPART_SIZ_FULL | 103 | .size = MTDPART_SIZ_FULL}, |
104 | }, | ||
105 | }; | 104 | }; |
105 | |||
106 | #define NUM_PARTITIONS 1 | 106 | #define NUM_PARTITIONS 1 |
107 | 107 | ||
108 | /* | 108 | /* |
@@ -111,8 +111,8 @@ static const struct mtd_partition partition_info[] = { | |||
111 | * NAND_BBT_CREATE and/or NAND_BBT_WRITE | 111 | * NAND_BBT_CREATE and/or NAND_BBT_WRITE |
112 | * | 112 | * |
113 | */ | 113 | */ |
114 | static uint8_t bbt_pattern[] = {'B', 'b', 't', '0' }; | 114 | static uint8_t bbt_pattern[] = { 'B', 'b', 't', '0' }; |
115 | static uint8_t mirror_pattern[] = {'1', 't', 'b', 'B' }; | 115 | static uint8_t mirror_pattern[] = { '1', 't', 'b', 'B' }; |
116 | 116 | ||
117 | static struct nand_bbt_descr rtc_from4_bbt_main_descr = { | 117 | static struct nand_bbt_descr rtc_from4_bbt_main_descr = { |
118 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | 118 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE |
@@ -134,8 +134,6 @@ static struct nand_bbt_descr rtc_from4_bbt_mirror_descr = { | |||
134 | .pattern = mirror_pattern | 134 | .pattern = mirror_pattern |
135 | }; | 135 | }; |
136 | 136 | ||
137 | |||
138 | |||
139 | #ifdef RTC_FROM4_HWECC | 137 | #ifdef RTC_FROM4_HWECC |
140 | 138 | ||
141 | /* the Reed Solomon control structure */ | 139 | /* the Reed Solomon control structure */ |
@@ -148,11 +146,11 @@ static struct nand_oobinfo rtc_from4_nand_oobinfo = { | |||
148 | .useecc = MTD_NANDECC_AUTOPLACE, | 146 | .useecc = MTD_NANDECC_AUTOPLACE, |
149 | .eccbytes = 32, | 147 | .eccbytes = 32, |
150 | .eccpos = { | 148 | .eccpos = { |
151 | 0, 1, 2, 3, 4, 5, 6, 7, | 149 | 0, 1, 2, 3, 4, 5, 6, 7, |
152 | 8, 9, 10, 11, 12, 13, 14, 15, | 150 | 8, 9, 10, 11, 12, 13, 14, 15, |
153 | 16, 17, 18, 19, 20, 21, 22, 23, | 151 | 16, 17, 18, 19, 20, 21, 22, 23, |
154 | 24, 25, 26, 27, 28, 29, 30, 31}, | 152 | 24, 25, 26, 27, 28, 29, 30, 31}, |
155 | .oobfree = { {32, 32} } | 153 | .oobfree = {{32, 32}} |
156 | }; | 154 | }; |
157 | 155 | ||
158 | /* Aargh. I missed the reversed bit order, when I | 156 | /* Aargh. I missed the reversed bit order, when I |
@@ -162,44 +160,42 @@ static struct nand_oobinfo rtc_from4_nand_oobinfo = { | |||
162 | * of the ecc byte which we get from the FPGA | 160 | * of the ecc byte which we get from the FPGA |
163 | */ | 161 | */ |
164 | static uint8_t revbits[256] = { | 162 | static uint8_t revbits[256] = { |
165 | 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, | 163 | 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, |
166 | 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, | 164 | 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, |
167 | 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, | 165 | 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, |
168 | 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, | 166 | 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, |
169 | 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, | 167 | 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, |
170 | 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, | 168 | 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, |
171 | 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, | 169 | 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, |
172 | 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, | 170 | 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, |
173 | 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, | 171 | 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, |
174 | 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, | 172 | 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, |
175 | 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, | 173 | 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, |
176 | 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, | 174 | 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, |
177 | 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, | 175 | 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, |
178 | 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, | 176 | 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, |
179 | 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, | 177 | 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, |
180 | 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, | 178 | 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, |
181 | 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, | 179 | 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, |
182 | 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, | 180 | 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, |
183 | 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, | 181 | 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, |
184 | 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, | 182 | 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, |
185 | 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, | 183 | 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, |
186 | 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, | 184 | 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, |
187 | 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, | 185 | 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, |
188 | 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, | 186 | 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, |
189 | 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, | 187 | 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, |
190 | 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, | 188 | 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, |
191 | 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, | 189 | 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, |
192 | 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, | 190 | 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, |
193 | 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, | 191 | 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, |
194 | 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, | 192 | 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, |
195 | 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, | 193 | 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, |
196 | 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, | 194 | 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, |
197 | }; | 195 | }; |
198 | 196 | ||
199 | #endif | 197 | #endif |
200 | 198 | ||
201 | |||
202 | |||
203 | /* | 199 | /* |
204 | * rtc_from4_hwcontrol - hardware specific access to control-lines | 200 | * rtc_from4_hwcontrol - hardware specific access to control-lines |
205 | * @mtd: MTD device structure | 201 | * @mtd: MTD device structure |
@@ -214,9 +210,9 @@ static uint8_t revbits[256] = { | |||
214 | */ | 210 | */ |
215 | static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd) | 211 | static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd) |
216 | { | 212 | { |
217 | struct nand_chip* this = (struct nand_chip *) (mtd->priv); | 213 | struct nand_chip *this = (struct nand_chip *)(mtd->priv); |
218 | 214 | ||
219 | switch(cmd) { | 215 | switch (cmd) { |
220 | 216 | ||
221 | case NAND_CTL_SETCLE: | 217 | case NAND_CTL_SETCLE: |
222 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_CLE); | 218 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_CLE); |
@@ -240,7 +236,6 @@ static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd) | |||
240 | } | 236 | } |
241 | } | 237 | } |
242 | 238 | ||
243 | |||
244 | /* | 239 | /* |
245 | * rtc_from4_nand_select_chip - hardware specific chip select | 240 | * rtc_from4_nand_select_chip - hardware specific chip select |
246 | * @mtd: MTD device structure | 241 | * @mtd: MTD device structure |
@@ -252,26 +247,25 @@ static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd) | |||
252 | */ | 247 | */ |
253 | static void rtc_from4_nand_select_chip(struct mtd_info *mtd, int chip) | 248 | static void rtc_from4_nand_select_chip(struct mtd_info *mtd, int chip) |
254 | { | 249 | { |
255 | struct nand_chip *this = mtd->priv; | 250 | struct nand_chip *this = mtd->priv; |
256 | 251 | ||
257 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R & ~RTC_FROM4_NAND_ADDR_MASK); | 252 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R & ~RTC_FROM4_NAND_ADDR_MASK); |
258 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W & ~RTC_FROM4_NAND_ADDR_MASK); | 253 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W & ~RTC_FROM4_NAND_ADDR_MASK); |
259 | 254 | ||
260 | switch(chip) { | 255 | switch (chip) { |
261 | 256 | ||
262 | case 0: /* select slot 3 chip */ | 257 | case 0: /* select slot 3 chip */ |
263 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R | RTC_FROM4_NAND_ADDR_SLOT3); | 258 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R | RTC_FROM4_NAND_ADDR_SLOT3); |
264 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_NAND_ADDR_SLOT3); | 259 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_NAND_ADDR_SLOT3); |
265 | break; | 260 | break; |
266 | case 1: /* select slot 4 chip */ | 261 | case 1: /* select slot 4 chip */ |
267 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R | RTC_FROM4_NAND_ADDR_SLOT4); | 262 | this->IO_ADDR_R = (void __iomem *)((unsigned long)this->IO_ADDR_R | RTC_FROM4_NAND_ADDR_SLOT4); |
268 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_NAND_ADDR_SLOT4); | 263 | this->IO_ADDR_W = (void __iomem *)((unsigned long)this->IO_ADDR_W | RTC_FROM4_NAND_ADDR_SLOT4); |
269 | break; | 264 | break; |
270 | 265 | ||
271 | } | 266 | } |
272 | } | 267 | } |
273 | 268 | ||
274 | |||
275 | /* | 269 | /* |
276 | * rtc_from4_nand_device_ready - hardware specific ready/busy check | 270 | * rtc_from4_nand_device_ready - hardware specific ready/busy check |
277 | * @mtd: MTD device structure | 271 | * @mtd: MTD device structure |
@@ -290,7 +284,6 @@ static int rtc_from4_nand_device_ready(struct mtd_info *mtd) | |||
290 | 284 | ||
291 | } | 285 | } |
292 | 286 | ||
293 | |||
294 | /* | 287 | /* |
295 | * deplete - code to perform device recovery in case there was a power loss | 288 | * deplete - code to perform device recovery in case there was a power loss |
296 | * @mtd: MTD device structure | 289 | * @mtd: MTD device structure |
@@ -306,24 +299,23 @@ static int rtc_from4_nand_device_ready(struct mtd_info *mtd) | |||
306 | */ | 299 | */ |
307 | static void deplete(struct mtd_info *mtd, int chip) | 300 | static void deplete(struct mtd_info *mtd, int chip) |
308 | { | 301 | { |
309 | struct nand_chip *this = mtd->priv; | 302 | struct nand_chip *this = mtd->priv; |
310 | 303 | ||
311 | /* wait until device is ready */ | 304 | /* wait until device is ready */ |
312 | while (!this->dev_ready(mtd)); | 305 | while (!this->dev_ready(mtd)) ; |
313 | 306 | ||
314 | this->select_chip(mtd, chip); | 307 | this->select_chip(mtd, chip); |
315 | 308 | ||
316 | /* Send the commands for device recovery, phase 1 */ | 309 | /* Send the commands for device recovery, phase 1 */ |
317 | this->cmdfunc (mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0000); | 310 | this->cmdfunc(mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0000); |
318 | this->cmdfunc (mtd, NAND_CMD_DEPLETE2, -1, -1); | 311 | this->cmdfunc(mtd, NAND_CMD_DEPLETE2, -1, -1); |
319 | 312 | ||
320 | /* Send the commands for device recovery, phase 2 */ | 313 | /* Send the commands for device recovery, phase 2 */ |
321 | this->cmdfunc (mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0004); | 314 | this->cmdfunc(mtd, NAND_CMD_DEPLETE1, 0x0000, 0x0004); |
322 | this->cmdfunc (mtd, NAND_CMD_DEPLETE2, -1, -1); | 315 | this->cmdfunc(mtd, NAND_CMD_DEPLETE2, -1, -1); |
323 | 316 | ||
324 | } | 317 | } |
325 | 318 | ||
326 | |||
327 | #ifdef RTC_FROM4_HWECC | 319 | #ifdef RTC_FROM4_HWECC |
328 | /* | 320 | /* |
329 | * rtc_from4_enable_hwecc - hardware specific hardware ECC enable function | 321 | * rtc_from4_enable_hwecc - hardware specific hardware ECC enable function |
@@ -335,39 +327,35 @@ static void deplete(struct mtd_info *mtd, int chip) | |||
335 | */ | 327 | */ |
336 | static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode) | 328 | static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode) |
337 | { | 329 | { |
338 | volatile unsigned short * rs_ecc_ctl = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC_CTL); | 330 | volatile unsigned short *rs_ecc_ctl = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC_CTL); |
339 | unsigned short status; | 331 | unsigned short status; |
340 | 332 | ||
341 | switch (mode) { | 333 | switch (mode) { |
342 | case NAND_ECC_READ : | 334 | case NAND_ECC_READ: |
343 | status = RTC_FROM4_RS_ECC_CTL_CLR | 335 | status = RTC_FROM4_RS_ECC_CTL_CLR | RTC_FROM4_RS_ECC_CTL_FD_E; |
344 | | RTC_FROM4_RS_ECC_CTL_FD_E; | ||
345 | 336 | ||
346 | *rs_ecc_ctl = status; | 337 | *rs_ecc_ctl = status; |
347 | break; | 338 | break; |
348 | 339 | ||
349 | case NAND_ECC_READSYN : | 340 | case NAND_ECC_READSYN: |
350 | status = 0x00; | 341 | status = 0x00; |
351 | 342 | ||
352 | *rs_ecc_ctl = status; | 343 | *rs_ecc_ctl = status; |
353 | break; | 344 | break; |
354 | 345 | ||
355 | case NAND_ECC_WRITE : | 346 | case NAND_ECC_WRITE: |
356 | status = RTC_FROM4_RS_ECC_CTL_CLR | 347 | status = RTC_FROM4_RS_ECC_CTL_CLR | RTC_FROM4_RS_ECC_CTL_GEN | RTC_FROM4_RS_ECC_CTL_FD_E; |
357 | | RTC_FROM4_RS_ECC_CTL_GEN | ||
358 | | RTC_FROM4_RS_ECC_CTL_FD_E; | ||
359 | 348 | ||
360 | *rs_ecc_ctl = status; | 349 | *rs_ecc_ctl = status; |
361 | break; | 350 | break; |
362 | 351 | ||
363 | default: | 352 | default: |
364 | BUG(); | 353 | BUG(); |
365 | break; | 354 | break; |
366 | } | 355 | } |
367 | 356 | ||
368 | } | 357 | } |
369 | 358 | ||
370 | |||
371 | /* | 359 | /* |
372 | * rtc_from4_calculate_ecc - hardware specific code to read ECC code | 360 | * rtc_from4_calculate_ecc - hardware specific code to read ECC code |
373 | * @mtd: MTD device structure | 361 | * @mtd: MTD device structure |
@@ -383,7 +371,7 @@ static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode) | |||
383 | */ | 371 | */ |
384 | static void rtc_from4_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) | 372 | static void rtc_from4_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) |
385 | { | 373 | { |
386 | volatile unsigned short * rs_eccn = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECCN); | 374 | volatile unsigned short *rs_eccn = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECCN); |
387 | unsigned short value; | 375 | unsigned short value; |
388 | int i; | 376 | int i; |
389 | 377 | ||
@@ -395,7 +383,6 @@ static void rtc_from4_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_c | |||
395 | ecc_code[7] |= 0x0f; /* set the last four bits (not used) */ | 383 | ecc_code[7] |= 0x0f; /* set the last four bits (not used) */ |
396 | } | 384 | } |
397 | 385 | ||
398 | |||
399 | /* | 386 | /* |
400 | * rtc_from4_correct_data - hardware specific code to correct data using ECC code | 387 | * rtc_from4_correct_data - hardware specific code to correct data using ECC code |
401 | * @mtd: MTD device structure | 388 | * @mtd: MTD device structure |
@@ -414,7 +401,7 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha | |||
414 | unsigned short status; | 401 | unsigned short status; |
415 | uint16_t par[6], syn[6]; | 402 | uint16_t par[6], syn[6]; |
416 | uint8_t ecc[8]; | 403 | uint8_t ecc[8]; |
417 | volatile unsigned short *rs_ecc; | 404 | volatile unsigned short *rs_ecc; |
418 | 405 | ||
419 | status = *((volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC_CHK)); | 406 | status = *((volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC_CHK)); |
420 | 407 | ||
@@ -424,23 +411,18 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha | |||
424 | 411 | ||
425 | /* Read the syndrom pattern from the FPGA and correct the bitorder */ | 412 | /* Read the syndrom pattern from the FPGA and correct the bitorder */ |
426 | rs_ecc = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC); | 413 | rs_ecc = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC); |
427 | for (i = 0; i < 8; i++) { | 414 | for (i = 0; i < 8; i++) { |
428 | ecc[i] = revbits[(*rs_ecc) & 0xFF]; | 415 | ecc[i] = revbits[(*rs_ecc) & 0xFF]; |
429 | rs_ecc++; | 416 | rs_ecc++; |
430 | } | 417 | } |
431 | 418 | ||
432 | /* convert into 6 10bit syndrome fields */ | 419 | /* convert into 6 10bit syndrome fields */ |
433 | par[5] = rs_decoder->index_of[(((uint16_t)ecc[0] >> 0) & 0x0ff) | | 420 | par[5] = rs_decoder->index_of[(((uint16_t) ecc[0] >> 0) & 0x0ff) | (((uint16_t) ecc[1] << 8) & 0x300)]; |
434 | (((uint16_t)ecc[1] << 8) & 0x300)]; | 421 | par[4] = rs_decoder->index_of[(((uint16_t) ecc[1] >> 2) & 0x03f) | (((uint16_t) ecc[2] << 6) & 0x3c0)]; |
435 | par[4] = rs_decoder->index_of[(((uint16_t)ecc[1] >> 2) & 0x03f) | | 422 | par[3] = rs_decoder->index_of[(((uint16_t) ecc[2] >> 4) & 0x00f) | (((uint16_t) ecc[3] << 4) & 0x3f0)]; |
436 | (((uint16_t)ecc[2] << 6) & 0x3c0)]; | 423 | par[2] = rs_decoder->index_of[(((uint16_t) ecc[3] >> 6) & 0x003) | (((uint16_t) ecc[4] << 2) & 0x3fc)]; |
437 | par[3] = rs_decoder->index_of[(((uint16_t)ecc[2] >> 4) & 0x00f) | | 424 | par[1] = rs_decoder->index_of[(((uint16_t) ecc[5] >> 0) & 0x0ff) | (((uint16_t) ecc[6] << 8) & 0x300)]; |
438 | (((uint16_t)ecc[3] << 4) & 0x3f0)]; | 425 | par[0] = (((uint16_t) ecc[6] >> 2) & 0x03f) | (((uint16_t) ecc[7] << 6) & 0x3c0); |
439 | par[2] = rs_decoder->index_of[(((uint16_t)ecc[3] >> 6) & 0x003) | | ||
440 | (((uint16_t)ecc[4] << 2) & 0x3fc)]; | ||
441 | par[1] = rs_decoder->index_of[(((uint16_t)ecc[5] >> 0) & 0x0ff) | | ||
442 | (((uint16_t)ecc[6] << 8) & 0x300)]; | ||
443 | par[0] = (((uint16_t)ecc[6] >> 2) & 0x03f) | (((uint16_t)ecc[7] << 6) & 0x3c0); | ||
444 | 426 | ||
445 | /* Convert to computable syndrome */ | 427 | /* Convert to computable syndrome */ |
446 | for (i = 0; i < 6; i++) { | 428 | for (i = 0; i < 6; i++) { |
@@ -453,16 +435,14 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha | |||
453 | syn[i] = rs_decoder->index_of[syn[i]]; | 435 | syn[i] = rs_decoder->index_of[syn[i]]; |
454 | } | 436 | } |
455 | 437 | ||
456 | /* Let the library code do its magic.*/ | 438 | /* Let the library code do its magic. */ |
457 | res = decode_rs8(rs_decoder, (uint8_t *)buf, par, 512, syn, 0, NULL, 0xff, NULL); | 439 | res = decode_rs8(rs_decoder, (uint8_t *) buf, par, 512, syn, 0, NULL, 0xff, NULL); |
458 | if (res > 0) { | 440 | if (res > 0) { |
459 | DEBUG (MTD_DEBUG_LEVEL0, "rtc_from4_correct_data: " | 441 | DEBUG(MTD_DEBUG_LEVEL0, "rtc_from4_correct_data: " "ECC corrected %d errors on read\n", res); |
460 | "ECC corrected %d errors on read\n", res); | ||
461 | } | 442 | } |
462 | return res; | 443 | return res; |
463 | } | 444 | } |
464 | 445 | ||
465 | |||
466 | /** | 446 | /** |
467 | * rtc_from4_errstat - perform additional error status checks | 447 | * rtc_from4_errstat - perform additional error status checks |
468 | * @mtd: MTD device structure | 448 | * @mtd: MTD device structure |
@@ -480,44 +460,44 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha | |||
480 | */ | 460 | */ |
481 | static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page) | 461 | static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page) |
482 | { | 462 | { |
483 | int er_stat=0; | 463 | int er_stat = 0; |
484 | int rtn, retlen; | 464 | int rtn, retlen; |
485 | size_t len; | 465 | size_t len; |
486 | uint8_t *buf; | 466 | uint8_t *buf; |
487 | int i; | 467 | int i; |
488 | 468 | ||
489 | this->cmdfunc (mtd, NAND_CMD_STATUS_CLEAR, -1, -1); | 469 | this->cmdfunc(mtd, NAND_CMD_STATUS_CLEAR, -1, -1); |
490 | 470 | ||
491 | if (state == FL_ERASING) { | 471 | if (state == FL_ERASING) { |
492 | for (i=0; i<4; i++) { | 472 | for (i = 0; i < 4; i++) { |
493 | if (status & 1<<(i+1)) { | 473 | if (status & 1 << (i + 1)) { |
494 | this->cmdfunc (mtd, (NAND_CMD_STATUS_ERROR + i + 1), -1, -1); | 474 | this->cmdfunc(mtd, (NAND_CMD_STATUS_ERROR + i + 1), -1, -1); |
495 | rtn = this->read_byte(mtd); | 475 | rtn = this->read_byte(mtd); |
496 | this->cmdfunc (mtd, NAND_CMD_STATUS_RESET, -1, -1); | 476 | this->cmdfunc(mtd, NAND_CMD_STATUS_RESET, -1, -1); |
497 | if (!(rtn & ERR_STAT_ECC_AVAILABLE)) { | 477 | if (!(rtn & ERR_STAT_ECC_AVAILABLE)) { |
498 | er_stat |= 1<<(i+1); /* err_ecc_not_avail */ | 478 | er_stat |= 1 << (i + 1); /* err_ecc_not_avail */ |
499 | } | 479 | } |
500 | } | 480 | } |
501 | } | 481 | } |
502 | } else if (state == FL_WRITING) { | 482 | } else if (state == FL_WRITING) { |
503 | /* single bank write logic */ | 483 | /* single bank write logic */ |
504 | this->cmdfunc (mtd, NAND_CMD_STATUS_ERROR, -1, -1); | 484 | this->cmdfunc(mtd, NAND_CMD_STATUS_ERROR, -1, -1); |
505 | rtn = this->read_byte(mtd); | 485 | rtn = this->read_byte(mtd); |
506 | this->cmdfunc (mtd, NAND_CMD_STATUS_RESET, -1, -1); | 486 | this->cmdfunc(mtd, NAND_CMD_STATUS_RESET, -1, -1); |
507 | if (!(rtn & ERR_STAT_ECC_AVAILABLE)) { | 487 | if (!(rtn & ERR_STAT_ECC_AVAILABLE)) { |
508 | er_stat |= 1<<1; /* err_ecc_not_avail */ | 488 | er_stat |= 1 << 1; /* err_ecc_not_avail */ |
509 | } else { | 489 | } else { |
510 | len = mtd->oobblock; | 490 | len = mtd->oobblock; |
511 | buf = kmalloc (len, GFP_KERNEL); | 491 | buf = kmalloc(len, GFP_KERNEL); |
512 | if (!buf) { | 492 | if (!buf) { |
513 | printk (KERN_ERR "rtc_from4_errstat: Out of memory!\n"); | 493 | printk(KERN_ERR "rtc_from4_errstat: Out of memory!\n"); |
514 | er_stat = 1; /* if we can't check, assume failed */ | 494 | er_stat = 1; /* if we can't check, assume failed */ |
515 | } else { | 495 | } else { |
516 | /* recovery read */ | 496 | /* recovery read */ |
517 | /* page read */ | 497 | /* page read */ |
518 | rtn = nand_do_read_ecc (mtd, page, len, &retlen, buf, NULL, this->autooob, 1); | 498 | rtn = nand_do_read_ecc(mtd, page, len, &retlen, buf, NULL, this->autooob, 1); |
519 | if (rtn) { /* if read failed or > 1-bit error corrected */ | 499 | if (rtn) { /* if read failed or > 1-bit error corrected */ |
520 | er_stat |= 1<<1; /* ECC read failed */ | 500 | er_stat |= 1 << 1; /* ECC read failed */ |
521 | } | 501 | } |
522 | kfree(buf); | 502 | kfree(buf); |
523 | } | 503 | } |
@@ -525,7 +505,7 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int s | |||
525 | } | 505 | } |
526 | 506 | ||
527 | rtn = status; | 507 | rtn = status; |
528 | if (er_stat == 0) { /* if ECC is available */ | 508 | if (er_stat == 0) { /* if ECC is available */ |
529 | rtn = (status & ~NAND_STATUS_FAIL); /* clear the error bit */ | 509 | rtn = (status & ~NAND_STATUS_FAIL); /* clear the error bit */ |
530 | } | 510 | } |
531 | 511 | ||
@@ -533,33 +513,32 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int s | |||
533 | } | 513 | } |
534 | #endif | 514 | #endif |
535 | 515 | ||
536 | |||
537 | /* | 516 | /* |
538 | * Main initialization routine | 517 | * Main initialization routine |
539 | */ | 518 | */ |
540 | int __init rtc_from4_init (void) | 519 | static int __init rtc_from4_init(void) |
541 | { | 520 | { |
542 | struct nand_chip *this; | 521 | struct nand_chip *this; |
543 | unsigned short bcr1, bcr2, wcr2; | 522 | unsigned short bcr1, bcr2, wcr2; |
544 | int i; | 523 | int i; |
545 | 524 | ||
546 | /* Allocate memory for MTD device structure and private data */ | 525 | /* Allocate memory for MTD device structure and private data */ |
547 | rtc_from4_mtd = kmalloc(sizeof(struct mtd_info) + sizeof (struct nand_chip), | 526 | rtc_from4_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
548 | GFP_KERNEL); | ||
549 | if (!rtc_from4_mtd) { | 527 | if (!rtc_from4_mtd) { |
550 | printk ("Unable to allocate Renesas NAND MTD device structure.\n"); | 528 | printk("Unable to allocate Renesas NAND MTD device structure.\n"); |
551 | return -ENOMEM; | 529 | return -ENOMEM; |
552 | } | 530 | } |
553 | 531 | ||
554 | /* Get pointer to private data */ | 532 | /* Get pointer to private data */ |
555 | this = (struct nand_chip *) (&rtc_from4_mtd[1]); | 533 | this = (struct nand_chip *)(&rtc_from4_mtd[1]); |
556 | 534 | ||
557 | /* Initialize structures */ | 535 | /* Initialize structures */ |
558 | memset((char *) rtc_from4_mtd, 0, sizeof(struct mtd_info)); | 536 | memset(rtc_from4_mtd, 0, sizeof(struct mtd_info)); |
559 | memset((char *) this, 0, sizeof(struct nand_chip)); | 537 | memset(this, 0, sizeof(struct nand_chip)); |
560 | 538 | ||
561 | /* Link the private data with the MTD structure */ | 539 | /* Link the private data with the MTD structure */ |
562 | rtc_from4_mtd->priv = this; | 540 | rtc_from4_mtd->priv = this; |
541 | rtc_from4_mtd->owner = THIS_MODULE; | ||
563 | 542 | ||
564 | /* set area 5 as PCMCIA mode to clear the spec of tDH(Data hold time;9ns min) */ | 543 | /* set area 5 as PCMCIA mode to clear the spec of tDH(Data hold time;9ns min) */ |
565 | bcr1 = *SH77X9_BCR1 & ~0x0002; | 544 | bcr1 = *SH77X9_BCR1 & ~0x0002; |
@@ -582,7 +561,7 @@ int __init rtc_from4_init (void) | |||
582 | /* Set address of hardware control function */ | 561 | /* Set address of hardware control function */ |
583 | this->hwcontrol = rtc_from4_hwcontrol; | 562 | this->hwcontrol = rtc_from4_hwcontrol; |
584 | /* Set address of chip select function */ | 563 | /* Set address of chip select function */ |
585 | this->select_chip = rtc_from4_nand_select_chip; | 564 | this->select_chip = rtc_from4_nand_select_chip; |
586 | /* command delay time (in us) */ | 565 | /* command delay time (in us) */ |
587 | this->chip_delay = 100; | 566 | this->chip_delay = 100; |
588 | /* return the status of the Ready/Busy line */ | 567 | /* return the status of the Ready/Busy line */ |
@@ -591,7 +570,7 @@ int __init rtc_from4_init (void) | |||
591 | #ifdef RTC_FROM4_HWECC | 570 | #ifdef RTC_FROM4_HWECC |
592 | printk(KERN_INFO "rtc_from4_init: using hardware ECC detection.\n"); | 571 | printk(KERN_INFO "rtc_from4_init: using hardware ECC detection.\n"); |
593 | 572 | ||
594 | this->eccmode = NAND_ECC_HW8_512; | 573 | this->eccmode = NAND_ECC_HW8_512; |
595 | this->options |= NAND_HWECC_SYNDROME; | 574 | this->options |= NAND_HWECC_SYNDROME; |
596 | /* return the status of extra status and ECC checks */ | 575 | /* return the status of extra status and ECC checks */ |
597 | this->errstat = rtc_from4_errstat; | 576 | this->errstat = rtc_from4_errstat; |
@@ -617,7 +596,7 @@ int __init rtc_from4_init (void) | |||
617 | } | 596 | } |
618 | 597 | ||
619 | /* Perform 'device recovery' for each chip in case there was a power loss. */ | 598 | /* Perform 'device recovery' for each chip in case there was a power loss. */ |
620 | for (i=0; i < this->numchips; i++) { | 599 | for (i = 0; i < this->numchips; i++) { |
621 | deplete(rtc_from4_mtd, i); | 600 | deplete(rtc_from4_mtd, i); |
622 | } | 601 | } |
623 | 602 | ||
@@ -643,7 +622,7 @@ int __init rtc_from4_init (void) | |||
643 | */ | 622 | */ |
644 | rs_decoder = init_rs(10, 0x409, 0, 1, 6); | 623 | rs_decoder = init_rs(10, 0x409, 0, 1, 6); |
645 | if (!rs_decoder) { | 624 | if (!rs_decoder) { |
646 | printk (KERN_ERR "Could not create a RS decoder\n"); | 625 | printk(KERN_ERR "Could not create a RS decoder\n"); |
647 | nand_release(rtc_from4_mtd); | 626 | nand_release(rtc_from4_mtd); |
648 | kfree(rtc_from4_mtd); | 627 | kfree(rtc_from4_mtd); |
649 | return -ENOMEM; | 628 | return -ENOMEM; |
@@ -652,20 +631,19 @@ int __init rtc_from4_init (void) | |||
652 | /* Return happy */ | 631 | /* Return happy */ |
653 | return 0; | 632 | return 0; |
654 | } | 633 | } |
655 | module_init(rtc_from4_init); | ||
656 | 634 | ||
635 | module_init(rtc_from4_init); | ||
657 | 636 | ||
658 | /* | 637 | /* |
659 | * Clean up routine | 638 | * Clean up routine |
660 | */ | 639 | */ |
661 | #ifdef MODULE | 640 | static void __exit rtc_from4_cleanup(void) |
662 | static void __exit rtc_from4_cleanup (void) | ||
663 | { | 641 | { |
664 | /* Release resource, unregister partitions */ | 642 | /* Release resource, unregister partitions */ |
665 | nand_release(rtc_from4_mtd); | 643 | nand_release(rtc_from4_mtd); |
666 | 644 | ||
667 | /* Free the MTD device structure */ | 645 | /* Free the MTD device structure */ |
668 | kfree (rtc_from4_mtd); | 646 | kfree(rtc_from4_mtd); |
669 | 647 | ||
670 | #ifdef RTC_FROM4_HWECC | 648 | #ifdef RTC_FROM4_HWECC |
671 | /* Free the reed solomon resources */ | 649 | /* Free the reed solomon resources */ |
@@ -674,10 +652,9 @@ static void __exit rtc_from4_cleanup (void) | |||
674 | } | 652 | } |
675 | #endif | 653 | #endif |
676 | } | 654 | } |
655 | |||
677 | module_exit(rtc_from4_cleanup); | 656 | module_exit(rtc_from4_cleanup); |
678 | #endif | ||
679 | 657 | ||
680 | MODULE_LICENSE("GPL"); | 658 | MODULE_LICENSE("GPL"); |
681 | MODULE_AUTHOR("d.marlin <dmarlin@redhat.com"); | 659 | MODULE_AUTHOR("d.marlin <dmarlin@redhat.com"); |
682 | MODULE_DESCRIPTION("Board-specific glue layer for AG-AND flash on Renesas FROM_BOARD4"); | 660 | MODULE_DESCRIPTION("Board-specific glue layer for AG-AND flash on Renesas FROM_BOARD4"); |
683 | |||
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index 5b55599739f3..f8002596de8b 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c | |||
@@ -77,10 +77,10 @@ static int hardware_ecc = 0; | |||
77 | */ | 77 | */ |
78 | 78 | ||
79 | static struct nand_oobinfo nand_hw_eccoob = { | 79 | static struct nand_oobinfo nand_hw_eccoob = { |
80 | .useecc = MTD_NANDECC_AUTOPLACE, | 80 | .useecc = MTD_NANDECC_AUTOPLACE, |
81 | .eccbytes = 3, | 81 | .eccbytes = 3, |
82 | .eccpos = {0, 1, 2 }, | 82 | .eccpos = {0, 1, 2}, |
83 | .oobfree = { {8, 8} } | 83 | .oobfree = {{8, 8}} |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /* controller and mtd information */ | 86 | /* controller and mtd information */ |
@@ -149,8 +149,7 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max) | |||
149 | pr_debug("result %d from %ld, %d\n", result, clk, wanted); | 149 | pr_debug("result %d from %ld, %d\n", result, clk, wanted); |
150 | 150 | ||
151 | if (result > max) { | 151 | if (result > max) { |
152 | printk("%d ns is too big for current clock rate %ld\n", | 152 | printk("%d ns is too big for current clock rate %ld\n", wanted, clk); |
153 | wanted, clk); | ||
154 | return -1; | 153 | return -1; |
155 | } | 154 | } |
156 | 155 | ||
@@ -164,8 +163,7 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max) | |||
164 | 163 | ||
165 | /* controller setup */ | 164 | /* controller setup */ |
166 | 165 | ||
167 | static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, | 166 | static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, struct platform_device *pdev) |
168 | struct platform_device *pdev) | ||
169 | { | 167 | { |
170 | struct s3c2410_platform_nand *plat = to_nand_plat(pdev); | 168 | struct s3c2410_platform_nand *plat = to_nand_plat(pdev); |
171 | unsigned long clkrate = clk_get_rate(info->clk); | 169 | unsigned long clkrate = clk_get_rate(info->clk); |
@@ -177,7 +175,7 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, | |||
177 | clkrate /= 1000; /* turn clock into kHz for ease of use */ | 175 | clkrate /= 1000; /* turn clock into kHz for ease of use */ |
178 | 176 | ||
179 | if (plat != NULL) { | 177 | if (plat != NULL) { |
180 | tacls = s3c2410_nand_calc_rate(plat->tacls, clkrate, 4); | 178 | tacls = s3c2410_nand_calc_rate(plat->tacls, clkrate, 4); |
181 | twrph0 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8); | 179 | twrph0 = s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8); |
182 | twrph1 = s3c2410_nand_calc_rate(plat->twrph1, clkrate, 8); | 180 | twrph1 = s3c2410_nand_calc_rate(plat->twrph1, clkrate, 8); |
183 | } else { | 181 | } else { |
@@ -193,19 +191,17 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, | |||
193 | } | 191 | } |
194 | 192 | ||
195 | printk(KERN_INFO PFX "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n", | 193 | printk(KERN_INFO PFX "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n", |
196 | tacls, to_ns(tacls, clkrate), | 194 | tacls, to_ns(tacls, clkrate), twrph0, to_ns(twrph0, clkrate), twrph1, to_ns(twrph1, clkrate)); |
197 | twrph0, to_ns(twrph0, clkrate), | ||
198 | twrph1, to_ns(twrph1, clkrate)); | ||
199 | 195 | ||
200 | if (!info->is_s3c2440) { | 196 | if (!info->is_s3c2440) { |
201 | cfg = S3C2410_NFCONF_EN; | 197 | cfg = S3C2410_NFCONF_EN; |
202 | cfg |= S3C2410_NFCONF_TACLS(tacls-1); | 198 | cfg |= S3C2410_NFCONF_TACLS(tacls - 1); |
203 | cfg |= S3C2410_NFCONF_TWRPH0(twrph0-1); | 199 | cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1); |
204 | cfg |= S3C2410_NFCONF_TWRPH1(twrph1-1); | 200 | cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1); |
205 | } else { | 201 | } else { |
206 | cfg = S3C2440_NFCONF_TACLS(tacls-1); | 202 | cfg = S3C2440_NFCONF_TACLS(tacls - 1); |
207 | cfg |= S3C2440_NFCONF_TWRPH0(twrph0-1); | 203 | cfg |= S3C2440_NFCONF_TWRPH0(twrph0 - 1); |
208 | cfg |= S3C2440_NFCONF_TWRPH1(twrph1-1); | 204 | cfg |= S3C2440_NFCONF_TWRPH1(twrph1 - 1); |
209 | } | 205 | } |
210 | 206 | ||
211 | pr_debug(PFX "NF_CONF is 0x%lx\n", cfg); | 207 | pr_debug(PFX "NF_CONF is 0x%lx\n", cfg); |
@@ -229,7 +225,7 @@ static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip) | |||
229 | info = nmtd->info; | 225 | info = nmtd->info; |
230 | 226 | ||
231 | bit = (info->is_s3c2440) ? S3C2440_NFCONT_nFCE : S3C2410_NFCONF_nFCE; | 227 | bit = (info->is_s3c2440) ? S3C2440_NFCONT_nFCE : S3C2410_NFCONF_nFCE; |
232 | reg = info->regs+((info->is_s3c2440) ? S3C2440_NFCONT:S3C2410_NFCONF); | 228 | reg = info->regs + ((info->is_s3c2440) ? S3C2440_NFCONT : S3C2410_NFCONF); |
233 | 229 | ||
234 | cur = readl(reg); | 230 | cur = readl(reg); |
235 | 231 | ||
@@ -243,7 +239,7 @@ static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip) | |||
243 | 239 | ||
244 | if (info->platform != NULL) { | 240 | if (info->platform != NULL) { |
245 | if (info->platform->select_chip != NULL) | 241 | if (info->platform->select_chip != NULL) |
246 | (info->platform->select_chip)(nmtd->set, chip); | 242 | (info->platform->select_chip) (nmtd->set, chip); |
247 | } | 243 | } |
248 | 244 | ||
249 | cur &= ~bit; | 245 | cur &= ~bit; |
@@ -330,22 +326,16 @@ static int s3c2410_nand_devready(struct mtd_info *mtd) | |||
330 | return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY; | 326 | return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY; |
331 | } | 327 | } |
332 | 328 | ||
333 | |||
334 | /* ECC handling functions */ | 329 | /* ECC handling functions */ |
335 | 330 | ||
336 | static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat, | 331 | static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc) |
337 | u_char *read_ecc, u_char *calc_ecc) | ||
338 | { | 332 | { |
339 | pr_debug("s3c2410_nand_correct_data(%p,%p,%p,%p)\n", | 333 | pr_debug("s3c2410_nand_correct_data(%p,%p,%p,%p)\n", mtd, dat, read_ecc, calc_ecc); |
340 | mtd, dat, read_ecc, calc_ecc); | ||
341 | 334 | ||
342 | pr_debug("eccs: read %02x,%02x,%02x vs calc %02x,%02x,%02x\n", | 335 | pr_debug("eccs: read %02x,%02x,%02x vs calc %02x,%02x,%02x\n", |
343 | read_ecc[0], read_ecc[1], read_ecc[2], | 336 | read_ecc[0], read_ecc[1], read_ecc[2], calc_ecc[0], calc_ecc[1], calc_ecc[2]); |
344 | calc_ecc[0], calc_ecc[1], calc_ecc[2]); | ||
345 | 337 | ||
346 | if (read_ecc[0] == calc_ecc[0] && | 338 | if (read_ecc[0] == calc_ecc[0] && read_ecc[1] == calc_ecc[1] && read_ecc[2] == calc_ecc[2]) |
347 | read_ecc[1] == calc_ecc[1] && | ||
348 | read_ecc[2] == calc_ecc[2]) | ||
349 | return 0; | 339 | return 0; |
350 | 340 | ||
351 | /* we curently have no method for correcting the error */ | 341 | /* we curently have no method for correcting the error */ |
@@ -378,8 +368,7 @@ static void s3c2440_nand_enable_hwecc(struct mtd_info *mtd, int mode) | |||
378 | writel(ctrl | S3C2440_NFCONT_INITECC, info->regs + S3C2440_NFCONT); | 368 | writel(ctrl | S3C2440_NFCONT_INITECC, info->regs + S3C2440_NFCONT); |
379 | } | 369 | } |
380 | 370 | ||
381 | static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, | 371 | static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) |
382 | const u_char *dat, u_char *ecc_code) | ||
383 | { | 372 | { |
384 | struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); | 373 | struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); |
385 | 374 | ||
@@ -387,15 +376,12 @@ static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, | |||
387 | ecc_code[1] = readb(info->regs + S3C2410_NFECC + 1); | 376 | ecc_code[1] = readb(info->regs + S3C2410_NFECC + 1); |
388 | ecc_code[2] = readb(info->regs + S3C2410_NFECC + 2); | 377 | ecc_code[2] = readb(info->regs + S3C2410_NFECC + 2); |
389 | 378 | ||
390 | pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n", | 379 | pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n", ecc_code[0], ecc_code[1], ecc_code[2]); |
391 | ecc_code[0], ecc_code[1], ecc_code[2]); | ||
392 | 380 | ||
393 | return 0; | 381 | return 0; |
394 | } | 382 | } |
395 | 383 | ||
396 | 384 | static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) | |
397 | static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd, | ||
398 | const u_char *dat, u_char *ecc_code) | ||
399 | { | 385 | { |
400 | struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); | 386 | struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); |
401 | unsigned long ecc = readl(info->regs + S3C2440_NFMECC0); | 387 | unsigned long ecc = readl(info->regs + S3C2440_NFMECC0); |
@@ -404,13 +390,11 @@ static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd, | |||
404 | ecc_code[1] = ecc >> 8; | 390 | ecc_code[1] = ecc >> 8; |
405 | ecc_code[2] = ecc >> 16; | 391 | ecc_code[2] = ecc >> 16; |
406 | 392 | ||
407 | pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n", | 393 | pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n", ecc_code[0], ecc_code[1], ecc_code[2]); |
408 | ecc_code[0], ecc_code[1], ecc_code[2]); | ||
409 | 394 | ||
410 | return 0; | 395 | return 0; |
411 | } | 396 | } |
412 | 397 | ||
413 | |||
414 | /* over-ride the standard functions for a little more speed. We can | 398 | /* over-ride the standard functions for a little more speed. We can |
415 | * use read/write block to move the data buffers to/from the controller | 399 | * use read/write block to move the data buffers to/from the controller |
416 | */ | 400 | */ |
@@ -421,8 +405,7 @@ static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) | |||
421 | readsb(this->IO_ADDR_R, buf, len); | 405 | readsb(this->IO_ADDR_R, buf, len); |
422 | } | 406 | } |
423 | 407 | ||
424 | static void s3c2410_nand_write_buf(struct mtd_info *mtd, | 408 | static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) |
425 | const u_char *buf, int len) | ||
426 | { | 409 | { |
427 | struct nand_chip *this = mtd->priv; | 410 | struct nand_chip *this = mtd->priv; |
428 | writesb(this->IO_ADDR_W, buf, len); | 411 | writesb(this->IO_ADDR_W, buf, len); |
@@ -488,9 +471,7 @@ static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info, | |||
488 | return add_mtd_device(&mtd->mtd); | 471 | return add_mtd_device(&mtd->mtd); |
489 | 472 | ||
490 | if (set->nr_partitions > 0 && set->partitions != NULL) { | 473 | if (set->nr_partitions > 0 && set->partitions != NULL) { |
491 | return add_mtd_partitions(&mtd->mtd, | 474 | return add_mtd_partitions(&mtd->mtd, set->partitions, set->nr_partitions); |
492 | set->partitions, | ||
493 | set->nr_partitions); | ||
494 | } | 475 | } |
495 | 476 | ||
496 | return add_mtd_device(&mtd->mtd); | 477 | return add_mtd_device(&mtd->mtd); |
@@ -535,6 +516,7 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info, | |||
535 | 516 | ||
536 | nmtd->info = info; | 517 | nmtd->info = info; |
537 | nmtd->mtd.priv = chip; | 518 | nmtd->mtd.priv = chip; |
519 | nmtd->mtd.owner = THIS_MODULE; | ||
538 | nmtd->set = set; | 520 | nmtd->set = set; |
539 | 521 | ||
540 | if (hardware_ecc) { | 522 | if (hardware_ecc) { |
@@ -654,13 +636,11 @@ static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440) | |||
654 | nmtd = info->mtds; | 636 | nmtd = info->mtds; |
655 | 637 | ||
656 | for (setno = 0; setno < nr_sets; setno++, nmtd++) { | 638 | for (setno = 0; setno < nr_sets; setno++, nmtd++) { |
657 | pr_debug("initialising set %d (%p, info %p)\n", | 639 | pr_debug("initialising set %d (%p, info %p)\n", setno, nmtd, info); |
658 | setno, nmtd, info); | ||
659 | 640 | ||
660 | s3c2410_nand_init_chip(info, nmtd, sets); | 641 | s3c2410_nand_init_chip(info, nmtd, sets); |
661 | 642 | ||
662 | nmtd->scan_res = nand_scan(&nmtd->mtd, | 643 | nmtd->scan_res = nand_scan(&nmtd->mtd, (sets) ? sets->nr_chips : 1); |
663 | (sets) ? sets->nr_chips : 1); | ||
664 | 644 | ||
665 | if (nmtd->scan_res == 0) { | 645 | if (nmtd->scan_res == 0) { |
666 | s3c2410_nand_add_partition(info, nmtd, sets); | 646 | s3c2410_nand_add_partition(info, nmtd, sets); |
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c index c294374871a4..60e10c0d6980 100644 --- a/drivers/mtd/nand/sharpsl.c +++ b/drivers/mtd/nand/sharpsl.c | |||
@@ -46,7 +46,6 @@ static int sharpsl_phys_base = 0x0C000000; | |||
46 | #define FLCLE (1 << 1) | 46 | #define FLCLE (1 << 1) |
47 | #define FLCE0 (1 << 0) | 47 | #define FLCE0 (1 << 0) |
48 | 48 | ||
49 | |||
50 | /* | 49 | /* |
51 | * MTD structure for SharpSL | 50 | * MTD structure for SharpSL |
52 | */ | 51 | */ |
@@ -60,27 +59,26 @@ static struct mtd_info *sharpsl_mtd = NULL; | |||
60 | static int nr_partitions; | 59 | static int nr_partitions; |
61 | static struct mtd_partition sharpsl_nand_default_partition_info[] = { | 60 | static struct mtd_partition sharpsl_nand_default_partition_info[] = { |
62 | { | 61 | { |
63 | .name = "System Area", | 62 | .name = "System Area", |
64 | .offset = 0, | 63 | .offset = 0, |
65 | .size = 7 * 1024 * 1024, | 64 | .size = 7 * 1024 * 1024, |
66 | }, | 65 | }, |
67 | { | 66 | { |
68 | .name = "Root Filesystem", | 67 | .name = "Root Filesystem", |
69 | .offset = 7 * 1024 * 1024, | 68 | .offset = 7 * 1024 * 1024, |
70 | .size = 30 * 1024 * 1024, | 69 | .size = 30 * 1024 * 1024, |
71 | }, | 70 | }, |
72 | { | 71 | { |
73 | .name = "Home Filesystem", | 72 | .name = "Home Filesystem", |
74 | .offset = MTDPART_OFS_APPEND , | 73 | .offset = MTDPART_OFS_APPEND, |
75 | .size = MTDPART_SIZ_FULL , | 74 | .size = MTDPART_SIZ_FULL, |
76 | }, | 75 | }, |
77 | }; | 76 | }; |
78 | 77 | ||
79 | /* | 78 | /* |
80 | * hardware specific access to control-lines | 79 | * hardware specific access to control-lines |
81 | */ | 80 | */ |
82 | static void | 81 | static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd) |
83 | sharpsl_nand_hwcontrol(struct mtd_info* mtd, int cmd) | ||
84 | { | 82 | { |
85 | switch (cmd) { | 83 | switch (cmd) { |
86 | case NAND_CTL_SETCLE: | 84 | case NAND_CTL_SETCLE: |
@@ -98,10 +96,10 @@ sharpsl_nand_hwcontrol(struct mtd_info* mtd, int cmd) | |||
98 | break; | 96 | break; |
99 | 97 | ||
100 | case NAND_CTL_SETNCE: | 98 | case NAND_CTL_SETNCE: |
101 | writeb(readb(FLASHCTL) & ~(FLCE0|FLCE1), FLASHCTL); | 99 | writeb(readb(FLASHCTL) & ~(FLCE0 | FLCE1), FLASHCTL); |
102 | break; | 100 | break; |
103 | case NAND_CTL_CLRNCE: | 101 | case NAND_CTL_CLRNCE: |
104 | writeb(readb(FLASHCTL) | (FLCE0|FLCE1), FLASHCTL); | 102 | writeb(readb(FLASHCTL) | (FLCE0 | FLCE1), FLASHCTL); |
105 | break; | 103 | break; |
106 | } | 104 | } |
107 | } | 105 | } |
@@ -126,27 +124,23 @@ static struct nand_oobinfo akita_oobinfo = { | |||
126 | .useecc = MTD_NANDECC_AUTOPLACE, | 124 | .useecc = MTD_NANDECC_AUTOPLACE, |
127 | .eccbytes = 24, | 125 | .eccbytes = 24, |
128 | .eccpos = { | 126 | .eccpos = { |
129 | 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11, | 127 | 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11, |
130 | 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23, | 128 | 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23, |
131 | 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37}, | 129 | 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37}, |
132 | .oobfree = { {0x08, 0x09} } | 130 | .oobfree = {{0x08, 0x09}} |
133 | }; | 131 | }; |
134 | 132 | ||
135 | static int | 133 | static int sharpsl_nand_dev_ready(struct mtd_info *mtd) |
136 | sharpsl_nand_dev_ready(struct mtd_info* mtd) | ||
137 | { | 134 | { |
138 | return !((readb(FLASHCTL) & FLRYBY) == 0); | 135 | return !((readb(FLASHCTL) & FLRYBY) == 0); |
139 | } | 136 | } |
140 | 137 | ||
141 | static void | 138 | static void sharpsl_nand_enable_hwecc(struct mtd_info *mtd, int mode) |
142 | sharpsl_nand_enable_hwecc(struct mtd_info* mtd, int mode) | ||
143 | { | 139 | { |
144 | writeb(0 ,ECCCLRR); | 140 | writeb(0, ECCCLRR); |
145 | } | 141 | } |
146 | 142 | ||
147 | static int | 143 | static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat, u_char * ecc_code) |
148 | sharpsl_nand_calculate_ecc(struct mtd_info* mtd, const u_char* dat, | ||
149 | u_char* ecc_code) | ||
150 | { | 144 | { |
151 | ecc_code[0] = ~readb(ECCLPUB); | 145 | ecc_code[0] = ~readb(ECCLPUB); |
152 | ecc_code[1] = ~readb(ECCLPLB); | 146 | ecc_code[1] = ~readb(ECCLPLB); |
@@ -154,47 +148,44 @@ sharpsl_nand_calculate_ecc(struct mtd_info* mtd, const u_char* dat, | |||
154 | return readb(ECCCNTR) != 0; | 148 | return readb(ECCCNTR) != 0; |
155 | } | 149 | } |
156 | 150 | ||
157 | |||
158 | #ifdef CONFIG_MTD_PARTITIONS | 151 | #ifdef CONFIG_MTD_PARTITIONS |
159 | const char *part_probes[] = { "cmdlinepart", NULL }; | 152 | const char *part_probes[] = { "cmdlinepart", NULL }; |
160 | #endif | 153 | #endif |
161 | 154 | ||
162 | |||
163 | /* | 155 | /* |
164 | * Main initialization routine | 156 | * Main initialization routine |
165 | */ | 157 | */ |
166 | int __init | 158 | static int __init sharpsl_nand_init(void) |
167 | sharpsl_nand_init(void) | ||
168 | { | 159 | { |
169 | struct nand_chip *this; | 160 | struct nand_chip *this; |
170 | struct mtd_partition* sharpsl_partition_info; | 161 | struct mtd_partition *sharpsl_partition_info; |
171 | int err = 0; | 162 | int err = 0; |
172 | 163 | ||
173 | /* Allocate memory for MTD device structure and private data */ | 164 | /* Allocate memory for MTD device structure and private data */ |
174 | sharpsl_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), | 165 | sharpsl_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
175 | GFP_KERNEL); | ||
176 | if (!sharpsl_mtd) { | 166 | if (!sharpsl_mtd) { |
177 | printk ("Unable to allocate SharpSL NAND MTD device structure.\n"); | 167 | printk("Unable to allocate SharpSL NAND MTD device structure.\n"); |
178 | return -ENOMEM; | 168 | return -ENOMEM; |
179 | } | 169 | } |
180 | 170 | ||
181 | /* map physical adress */ | 171 | /* map physical adress */ |
182 | sharpsl_io_base = ioremap(sharpsl_phys_base, 0x1000); | 172 | sharpsl_io_base = ioremap(sharpsl_phys_base, 0x1000); |
183 | if(!sharpsl_io_base){ | 173 | if (!sharpsl_io_base) { |
184 | printk("ioremap to access Sharp SL NAND chip failed\n"); | 174 | printk("ioremap to access Sharp SL NAND chip failed\n"); |
185 | kfree(sharpsl_mtd); | 175 | kfree(sharpsl_mtd); |
186 | return -EIO; | 176 | return -EIO; |
187 | } | 177 | } |
188 | 178 | ||
189 | /* Get pointer to private data */ | 179 | /* Get pointer to private data */ |
190 | this = (struct nand_chip *) (&sharpsl_mtd[1]); | 180 | this = (struct nand_chip *)(&sharpsl_mtd[1]); |
191 | 181 | ||
192 | /* Initialize structures */ | 182 | /* Initialize structures */ |
193 | memset((char *) sharpsl_mtd, 0, sizeof(struct mtd_info)); | 183 | memset(sharpsl_mtd, 0, sizeof(struct mtd_info)); |
194 | memset((char *) this, 0, sizeof(struct nand_chip)); | 184 | memset(this, 0, sizeof(struct nand_chip)); |
195 | 185 | ||
196 | /* Link the private data with the MTD structure */ | 186 | /* Link the private data with the MTD structure */ |
197 | sharpsl_mtd->priv = this; | 187 | sharpsl_mtd->priv = this; |
188 | sharpsl_mtd->owner = THIS_MODULE; | ||
198 | 189 | ||
199 | /* | 190 | /* |
200 | * PXA initialize | 191 | * PXA initialize |
@@ -221,7 +212,7 @@ sharpsl_nand_init(void) | |||
221 | this->correct_data = nand_correct_data; | 212 | this->correct_data = nand_correct_data; |
222 | 213 | ||
223 | /* Scan to find existence of the device */ | 214 | /* Scan to find existence of the device */ |
224 | err=nand_scan(sharpsl_mtd,1); | 215 | err = nand_scan(sharpsl_mtd, 1); |
225 | if (err) { | 216 | if (err) { |
226 | iounmap(sharpsl_io_base); | 217 | iounmap(sharpsl_io_base); |
227 | kfree(sharpsl_mtd); | 218 | kfree(sharpsl_mtd); |
@@ -230,24 +221,23 @@ sharpsl_nand_init(void) | |||
230 | 221 | ||
231 | /* Register the partitions */ | 222 | /* Register the partitions */ |
232 | sharpsl_mtd->name = "sharpsl-nand"; | 223 | sharpsl_mtd->name = "sharpsl-nand"; |
233 | nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, | 224 | nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, &sharpsl_partition_info, 0); |
234 | &sharpsl_partition_info, 0); | ||
235 | 225 | ||
236 | if (nr_partitions <= 0) { | 226 | if (nr_partitions <= 0) { |
237 | nr_partitions = DEFAULT_NUM_PARTITIONS; | 227 | nr_partitions = DEFAULT_NUM_PARTITIONS; |
238 | sharpsl_partition_info = sharpsl_nand_default_partition_info; | 228 | sharpsl_partition_info = sharpsl_nand_default_partition_info; |
239 | if (machine_is_poodle()) { | 229 | if (machine_is_poodle()) { |
240 | sharpsl_partition_info[1].size=22 * 1024 * 1024; | 230 | sharpsl_partition_info[1].size = 22 * 1024 * 1024; |
241 | } else if (machine_is_corgi() || machine_is_shepherd()) { | 231 | } else if (machine_is_corgi() || machine_is_shepherd()) { |
242 | sharpsl_partition_info[1].size=25 * 1024 * 1024; | 232 | sharpsl_partition_info[1].size = 25 * 1024 * 1024; |
243 | } else if (machine_is_husky()) { | 233 | } else if (machine_is_husky()) { |
244 | sharpsl_partition_info[1].size=53 * 1024 * 1024; | 234 | sharpsl_partition_info[1].size = 53 * 1024 * 1024; |
245 | } else if (machine_is_spitz()) { | 235 | } else if (machine_is_spitz()) { |
246 | sharpsl_partition_info[1].size=5 * 1024 * 1024; | 236 | sharpsl_partition_info[1].size = 5 * 1024 * 1024; |
247 | } else if (machine_is_akita()) { | 237 | } else if (machine_is_akita()) { |
248 | sharpsl_partition_info[1].size=58 * 1024 * 1024; | 238 | sharpsl_partition_info[1].size = 58 * 1024 * 1024; |
249 | } else if (machine_is_borzoi()) { | 239 | } else if (machine_is_borzoi()) { |
250 | sharpsl_partition_info[1].size=32 * 1024 * 1024; | 240 | sharpsl_partition_info[1].size = 32 * 1024 * 1024; |
251 | } | 241 | } |
252 | } | 242 | } |
253 | 243 | ||
@@ -261,15 +251,15 @@ sharpsl_nand_init(void) | |||
261 | /* Return happy */ | 251 | /* Return happy */ |
262 | return 0; | 252 | return 0; |
263 | } | 253 | } |
254 | |||
264 | module_init(sharpsl_nand_init); | 255 | module_init(sharpsl_nand_init); |
265 | 256 | ||
266 | /* | 257 | /* |
267 | * Clean up routine | 258 | * Clean up routine |
268 | */ | 259 | */ |
269 | #ifdef MODULE | ||
270 | static void __exit sharpsl_nand_cleanup(void) | 260 | static void __exit sharpsl_nand_cleanup(void) |
271 | { | 261 | { |
272 | struct nand_chip *this = (struct nand_chip *) &sharpsl_mtd[1]; | 262 | struct nand_chip *this = (struct nand_chip *)&sharpsl_mtd[1]; |
273 | 263 | ||
274 | /* Release resources, unregister device */ | 264 | /* Release resources, unregister device */ |
275 | nand_release(sharpsl_mtd); | 265 | nand_release(sharpsl_mtd); |
@@ -279,8 +269,8 @@ static void __exit sharpsl_nand_cleanup(void) | |||
279 | /* Free the MTD device structure */ | 269 | /* Free the MTD device structure */ |
280 | kfree(sharpsl_mtd); | 270 | kfree(sharpsl_mtd); |
281 | } | 271 | } |
272 | |||
282 | module_exit(sharpsl_nand_cleanup); | 273 | module_exit(sharpsl_nand_cleanup); |
283 | #endif | ||
284 | 274 | ||
285 | MODULE_LICENSE("GPL"); | 275 | MODULE_LICENSE("GPL"); |
286 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); | 276 | MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); |
diff --git a/drivers/mtd/nand/spia.c b/drivers/mtd/nand/spia.c index 9cf1ce718ec1..9737f1d67c3c 100644 --- a/drivers/mtd/nand/spia.c +++ b/drivers/mtd/nand/spia.c | |||
@@ -39,16 +39,16 @@ static struct mtd_info *spia_mtd = NULL; | |||
39 | */ | 39 | */ |
40 | #define SPIA_IO_BASE 0xd0000000 /* Start of EP7212 IO address space */ | 40 | #define SPIA_IO_BASE 0xd0000000 /* Start of EP7212 IO address space */ |
41 | #define SPIA_FIO_BASE 0xf0000000 /* Address where flash is mapped */ | 41 | #define SPIA_FIO_BASE 0xf0000000 /* Address where flash is mapped */ |
42 | #define SPIA_PEDR 0x0080 /* | 42 | #define SPIA_PEDR 0x0080 /* |
43 | * IO offset to Port E data register | 43 | * IO offset to Port E data register |
44 | * where the CLE, ALE and NCE pins | 44 | * where the CLE, ALE and NCE pins |
45 | * are wired to. | 45 | * are wired to. |
46 | */ | 46 | */ |
47 | #define SPIA_PEDDR 0x00c0 /* | 47 | #define SPIA_PEDDR 0x00c0 /* |
48 | * IO offset to Port E data direction | 48 | * IO offset to Port E data direction |
49 | * register so we can control the IO | 49 | * register so we can control the IO |
50 | * lines. | 50 | * lines. |
51 | */ | 51 | */ |
52 | 52 | ||
53 | /* | 53 | /* |
54 | * Module stuff | 54 | * Module stuff |
@@ -69,25 +69,23 @@ module_param(spia_peddr, int, 0); | |||
69 | */ | 69 | */ |
70 | static const struct mtd_partition partition_info[] = { | 70 | static const struct mtd_partition partition_info[] = { |
71 | { | 71 | { |
72 | .name = "SPIA flash partition 1", | 72 | .name = "SPIA flash partition 1", |
73 | .offset = 0, | 73 | .offset = 0, |
74 | .size = 2*1024*1024 | 74 | .size = 2 * 1024 * 1024}, |
75 | }, | ||
76 | { | 75 | { |
77 | .name = "SPIA flash partition 2", | 76 | .name = "SPIA flash partition 2", |
78 | .offset = 2*1024*1024, | 77 | .offset = 2 * 1024 * 1024, |
79 | .size = 6*1024*1024 | 78 | .size = 6 * 1024 * 1024} |
80 | } | ||
81 | }; | 79 | }; |
82 | #define NUM_PARTITIONS 2 | ||
83 | 80 | ||
81 | #define NUM_PARTITIONS 2 | ||
84 | 82 | ||
85 | /* | 83 | /* |
86 | * hardware specific access to control-lines | 84 | * hardware specific access to control-lines |
87 | */ | 85 | */ |
88 | static void spia_hwcontrol(struct mtd_info *mtd, int cmd){ | 86 | static void spia_hwcontrol(struct mtd_info *mtd, int cmd) |
89 | 87 | { | |
90 | switch(cmd){ | 88 | switch (cmd) { |
91 | 89 | ||
92 | case NAND_CTL_SETCLE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |= 0x01; break; | 90 | case NAND_CTL_SETCLE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |= 0x01; break; |
93 | case NAND_CTL_CLRCLE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) &= ~0x01; break; | 91 | case NAND_CTL_CLRCLE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) &= ~0x01; break; |
@@ -97,51 +95,51 @@ static void spia_hwcontrol(struct mtd_info *mtd, int cmd){ | |||
97 | 95 | ||
98 | case NAND_CTL_SETNCE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) &= ~0x04; break; | 96 | case NAND_CTL_SETNCE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) &= ~0x04; break; |
99 | case NAND_CTL_CLRNCE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |= 0x04; break; | 97 | case NAND_CTL_CLRNCE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |= 0x04; break; |
100 | } | 98 | } |
101 | } | 99 | } |
102 | 100 | ||
103 | /* | 101 | /* |
104 | * Main initialization routine | 102 | * Main initialization routine |
105 | */ | 103 | */ |
106 | int __init spia_init (void) | 104 | static int __init spia_init(void) |
107 | { | 105 | { |
108 | struct nand_chip *this; | 106 | struct nand_chip *this; |
109 | 107 | ||
110 | /* Allocate memory for MTD device structure and private data */ | 108 | /* Allocate memory for MTD device structure and private data */ |
111 | spia_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), | 109 | spia_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
112 | GFP_KERNEL); | ||
113 | if (!spia_mtd) { | 110 | if (!spia_mtd) { |
114 | printk ("Unable to allocate SPIA NAND MTD device structure.\n"); | 111 | printk("Unable to allocate SPIA NAND MTD device structure.\n"); |
115 | return -ENOMEM; | 112 | return -ENOMEM; |
116 | } | 113 | } |
117 | 114 | ||
118 | /* Get pointer to private data */ | 115 | /* Get pointer to private data */ |
119 | this = (struct nand_chip *) (&spia_mtd[1]); | 116 | this = (struct nand_chip *)(&spia_mtd[1]); |
120 | 117 | ||
121 | /* Initialize structures */ | 118 | /* Initialize structures */ |
122 | memset((char *) spia_mtd, 0, sizeof(struct mtd_info)); | 119 | memset(spia_mtd, 0, sizeof(struct mtd_info)); |
123 | memset((char *) this, 0, sizeof(struct nand_chip)); | 120 | memset(this, 0, sizeof(struct nand_chip)); |
124 | 121 | ||
125 | /* Link the private data with the MTD structure */ | 122 | /* Link the private data with the MTD structure */ |
126 | spia_mtd->priv = this; | 123 | spia_mtd->priv = this; |
124 | spia_mtd->owner = THIS_MODULE; | ||
127 | 125 | ||
128 | /* | 126 | /* |
129 | * Set GPIO Port E control register so that the pins are configured | 127 | * Set GPIO Port E control register so that the pins are configured |
130 | * to be outputs for controlling the NAND flash. | 128 | * to be outputs for controlling the NAND flash. |
131 | */ | 129 | */ |
132 | (*(volatile unsigned char *) (spia_io_base + spia_peddr)) = 0x07; | 130 | (*(volatile unsigned char *)(spia_io_base + spia_peddr)) = 0x07; |
133 | 131 | ||
134 | /* Set address of NAND IO lines */ | 132 | /* Set address of NAND IO lines */ |
135 | this->IO_ADDR_R = (void __iomem *) spia_fio_base; | 133 | this->IO_ADDR_R = (void __iomem *)spia_fio_base; |
136 | this->IO_ADDR_W = (void __iomem *) spia_fio_base; | 134 | this->IO_ADDR_W = (void __iomem *)spia_fio_base; |
137 | /* Set address of hardware control function */ | 135 | /* Set address of hardware control function */ |
138 | this->hwcontrol = spia_hwcontrol; | 136 | this->hwcontrol = spia_hwcontrol; |
139 | /* 15 us command delay time */ | 137 | /* 15 us command delay time */ |
140 | this->chip_delay = 15; | 138 | this->chip_delay = 15; |
141 | 139 | ||
142 | /* Scan to find existence of the device */ | 140 | /* Scan to find existence of the device */ |
143 | if (nand_scan (spia_mtd, 1)) { | 141 | if (nand_scan(spia_mtd, 1)) { |
144 | kfree (spia_mtd); | 142 | kfree(spia_mtd); |
145 | return -ENXIO; | 143 | return -ENXIO; |
146 | } | 144 | } |
147 | 145 | ||
@@ -151,22 +149,22 @@ int __init spia_init (void) | |||
151 | /* Return happy */ | 149 | /* Return happy */ |
152 | return 0; | 150 | return 0; |
153 | } | 151 | } |
152 | |||
154 | module_init(spia_init); | 153 | module_init(spia_init); |
155 | 154 | ||
156 | /* | 155 | /* |
157 | * Clean up routine | 156 | * Clean up routine |
158 | */ | 157 | */ |
159 | #ifdef MODULE | 158 | static void __exit spia_cleanup(void) |
160 | static void __exit spia_cleanup (void) | ||
161 | { | 159 | { |
162 | /* Release resources, unregister device */ | 160 | /* Release resources, unregister device */ |
163 | nand_release (spia_mtd); | 161 | nand_release(spia_mtd); |
164 | 162 | ||
165 | /* Free the MTD device structure */ | 163 | /* Free the MTD device structure */ |
166 | kfree (spia_mtd); | 164 | kfree(spia_mtd); |
167 | } | 165 | } |
166 | |||
168 | module_exit(spia_cleanup); | 167 | module_exit(spia_cleanup); |
169 | #endif | ||
170 | 168 | ||
171 | MODULE_LICENSE("GPL"); | 169 | MODULE_LICENSE("GPL"); |
172 | MODULE_AUTHOR("Steven J. Hill <sjhill@realitydiluted.com"); | 170 | MODULE_AUTHOR("Steven J. Hill <sjhill@realitydiluted.com"); |
diff --git a/drivers/mtd/nand/toto.c b/drivers/mtd/nand/toto.c index 7609c43cb3ec..c51c89559514 100644 --- a/drivers/mtd/nand/toto.c +++ b/drivers/mtd/nand/toto.c | |||
@@ -48,7 +48,7 @@ static unsigned long toto_io_base = OMAP_FLASH_1_BASE; | |||
48 | 48 | ||
49 | #define T_NAND_CTL_CLRALE(iob) gpiosetout(NAND_ALE, 0) | 49 | #define T_NAND_CTL_CLRALE(iob) gpiosetout(NAND_ALE, 0) |
50 | #define T_NAND_CTL_SETALE(iob) gpiosetout(NAND_ALE, NAND_ALE) | 50 | #define T_NAND_CTL_SETALE(iob) gpiosetout(NAND_ALE, NAND_ALE) |
51 | #ifdef CONFIG_NAND_WORKAROUND /* "some" dev boards busted, blue wired to rts2 :( */ | 51 | #ifdef CONFIG_NAND_WORKAROUND /* "some" dev boards busted, blue wired to rts2 :( */ |
52 | #define T_NAND_CTL_CLRCLE(iob) gpiosetout(NAND_CLE, 0); rts2setout(2, 2) | 52 | #define T_NAND_CTL_CLRCLE(iob) gpiosetout(NAND_CLE, 0); rts2setout(2, 2) |
53 | #define T_NAND_CTL_SETCLE(iob) gpiosetout(NAND_CLE, NAND_CLE); rts2setout(2, 0) | 53 | #define T_NAND_CTL_SETCLE(iob) gpiosetout(NAND_CLE, NAND_CLE); rts2setout(2, 0) |
54 | #else | 54 | #else |
@@ -98,9 +98,8 @@ static struct mtd_partition partition_info32M[] = { | |||
98 | static void toto_hwcontrol(struct mtd_info *mtd, int cmd) | 98 | static void toto_hwcontrol(struct mtd_info *mtd, int cmd) |
99 | { | 99 | { |
100 | 100 | ||
101 | udelay(1); /* hopefully enough time for tc make proceding write to clear */ | 101 | udelay(1); /* hopefully enough time for tc make proceding write to clear */ |
102 | switch(cmd){ | 102 | switch (cmd) { |
103 | |||
104 | case NAND_CTL_SETCLE: T_NAND_CTL_SETCLE(cmd); break; | 103 | case NAND_CTL_SETCLE: T_NAND_CTL_SETCLE(cmd); break; |
105 | case NAND_CTL_CLRCLE: T_NAND_CTL_CLRCLE(cmd); break; | 104 | case NAND_CTL_CLRCLE: T_NAND_CTL_CLRCLE(cmd); break; |
106 | 105 | ||
@@ -110,35 +109,35 @@ static void toto_hwcontrol(struct mtd_info *mtd, int cmd) | |||
110 | case NAND_CTL_SETNCE: T_NAND_CTL_SETNCE(cmd); break; | 109 | case NAND_CTL_SETNCE: T_NAND_CTL_SETNCE(cmd); break; |
111 | case NAND_CTL_CLRNCE: T_NAND_CTL_CLRNCE(cmd); break; | 110 | case NAND_CTL_CLRNCE: T_NAND_CTL_CLRNCE(cmd); break; |
112 | } | 111 | } |
113 | udelay(1); /* allow time to ensure gpio state to over take memory write */ | 112 | udelay(1); /* allow time to ensure gpio state to over take memory write */ |
114 | } | 113 | } |
115 | 114 | ||
116 | /* | 115 | /* |
117 | * Main initialization routine | 116 | * Main initialization routine |
118 | */ | 117 | */ |
119 | int __init toto_init (void) | 118 | static int __init toto_init(void) |
120 | { | 119 | { |
121 | struct nand_chip *this; | 120 | struct nand_chip *this; |
122 | int err = 0; | 121 | int err = 0; |
123 | 122 | ||
124 | /* Allocate memory for MTD device structure and private data */ | 123 | /* Allocate memory for MTD device structure and private data */ |
125 | toto_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), | 124 | toto_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
126 | GFP_KERNEL); | ||
127 | if (!toto_mtd) { | 125 | if (!toto_mtd) { |
128 | printk (KERN_WARNING "Unable to allocate toto NAND MTD device structure.\n"); | 126 | printk(KERN_WARNING "Unable to allocate toto NAND MTD device structure.\n"); |
129 | err = -ENOMEM; | 127 | err = -ENOMEM; |
130 | goto out; | 128 | goto out; |
131 | } | 129 | } |
132 | 130 | ||
133 | /* Get pointer to private data */ | 131 | /* Get pointer to private data */ |
134 | this = (struct nand_chip *) (&toto_mtd[1]); | 132 | this = (struct nand_chip *)(&toto_mtd[1]); |
135 | 133 | ||
136 | /* Initialize structures */ | 134 | /* Initialize structures */ |
137 | memset((char *) toto_mtd, 0, sizeof(struct mtd_info)); | 135 | memset(toto_mtd, 0, sizeof(struct mtd_info)); |
138 | memset((char *) this, 0, sizeof(struct nand_chip)); | 136 | memset(this, 0, sizeof(struct nand_chip)); |
139 | 137 | ||
140 | /* Link the private data with the MTD structure */ | 138 | /* Link the private data with the MTD structure */ |
141 | toto_mtd->priv = this; | 139 | toto_mtd->priv = this; |
140 | toto_mtd->owner = THIS_MODULE; | ||
142 | 141 | ||
143 | /* Set address of NAND IO lines */ | 142 | /* Set address of NAND IO lines */ |
144 | this->IO_ADDR_R = toto_io_base; | 143 | this->IO_ADDR_R = toto_io_base; |
@@ -149,33 +148,37 @@ int __init toto_init (void) | |||
149 | this->chip_delay = 30; | 148 | this->chip_delay = 30; |
150 | this->eccmode = NAND_ECC_SOFT; | 149 | this->eccmode = NAND_ECC_SOFT; |
151 | 150 | ||
152 | /* Scan to find existance of the device */ | 151 | /* Scan to find existance of the device */ |
153 | if (nand_scan (toto_mtd, 1)) { | 152 | if (nand_scan(toto_mtd, 1)) { |
154 | err = -ENXIO; | 153 | err = -ENXIO; |
155 | goto out_mtd; | 154 | goto out_mtd; |
156 | } | 155 | } |
157 | 156 | ||
158 | /* Register the partitions */ | 157 | /* Register the partitions */ |
159 | switch(toto_mtd->size){ | 158 | switch (toto_mtd->size) { |
160 | case SZ_64M: add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M); break; | 159 | case SZ_64M: |
161 | case SZ_32M: add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M); break; | 160 | add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M); |
162 | default: { | 161 | break; |
163 | printk (KERN_WARNING "Unsupported Nand device\n"); | 162 | case SZ_32M: |
163 | add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M); | ||
164 | break; | ||
165 | default:{ | ||
166 | printk(KERN_WARNING "Unsupported Nand device\n"); | ||
164 | err = -ENXIO; | 167 | err = -ENXIO; |
165 | goto out_buf; | 168 | goto out_buf; |
166 | } | 169 | } |
167 | } | 170 | } |
168 | 171 | ||
169 | gpioreserve(NAND_MASK); /* claim our gpios */ | 172 | gpioreserve(NAND_MASK); /* claim our gpios */ |
170 | archflashwp(0,0); /* open up flash for writing */ | 173 | archflashwp(0, 0); /* open up flash for writing */ |
171 | 174 | ||
172 | goto out; | 175 | goto out; |
173 | 176 | ||
174 | out_buf: | 177 | out_buf: |
175 | kfree (this->data_buf); | 178 | kfree(this->data_buf); |
176 | out_mtd: | 179 | out_mtd: |
177 | kfree (toto_mtd); | 180 | kfree(toto_mtd); |
178 | out: | 181 | out: |
179 | return err; | 182 | return err; |
180 | } | 183 | } |
181 | 184 | ||
@@ -184,20 +187,21 @@ module_init(toto_init); | |||
184 | /* | 187 | /* |
185 | * Clean up routine | 188 | * Clean up routine |
186 | */ | 189 | */ |
187 | static void __exit toto_cleanup (void) | 190 | static void __exit toto_cleanup(void) |
188 | { | 191 | { |
189 | /* Release resources, unregister device */ | 192 | /* Release resources, unregister device */ |
190 | nand_release (toto_mtd); | 193 | nand_release(toto_mtd); |
191 | 194 | ||
192 | /* Free the MTD device structure */ | 195 | /* Free the MTD device structure */ |
193 | kfree (toto_mtd); | 196 | kfree(toto_mtd); |
194 | 197 | ||
195 | /* stop flash writes */ | 198 | /* stop flash writes */ |
196 | archflashwp(0,1); | 199 | archflashwp(0, 1); |
197 | 200 | ||
198 | /* release gpios to system */ | 201 | /* release gpios to system */ |
199 | gpiorelease(NAND_MASK); | 202 | gpiorelease(NAND_MASK); |
200 | } | 203 | } |
204 | |||
201 | module_exit(toto_cleanup); | 205 | module_exit(toto_cleanup); |
202 | 206 | ||
203 | MODULE_LICENSE("GPL"); | 207 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mtd/nand/ts7250.c b/drivers/mtd/nand/ts7250.c index 643633d91a8b..622db3127f7c 100644 --- a/drivers/mtd/nand/ts7250.c +++ b/drivers/mtd/nand/ts7250.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Copyright (C) 2004 Technologic Systems (support@embeddedARM.com) | 4 | * Copyright (C) 2004 Technologic Systems (support@embeddedARM.com) |
5 | * | 5 | * |
6 | * Derived from drivers/mtd/nand/edb7312.c | 6 | * Derived from drivers/mtd/nand/edb7312.c |
7 | * Copyright (C) 2004 Marius Gröger (mag@sysgo.de) | 7 | * Copyright (C) 2004 Marius Gröger (mag@sysgo.de) |
8 | * | 8 | * |
9 | * Derived from drivers/mtd/nand/autcpu12.c | 9 | * Derived from drivers/mtd/nand/autcpu12.c |
10 | * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) | 10 | * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de) |
@@ -88,7 +88,7 @@ static void ts7250_hwcontrol(struct mtd_info *mtd, int cmd) | |||
88 | { | 88 | { |
89 | unsigned long ctrl = TS72XX_NAND_CONTROL_VIRT_BASE; | 89 | unsigned long ctrl = TS72XX_NAND_CONTROL_VIRT_BASE; |
90 | 90 | ||
91 | switch(cmd) { | 91 | switch (cmd) { |
92 | case NAND_CTL_SETCLE: | 92 | case NAND_CTL_SETCLE: |
93 | __raw_writeb(__raw_readb(ctrl) | 0x2, ctrl); | 93 | __raw_writeb(__raw_readb(ctrl) | 0x2, ctrl); |
94 | break; | 94 | break; |
@@ -132,8 +132,7 @@ static int __init ts7250_init(void) | |||
132 | return -ENXIO; | 132 | return -ENXIO; |
133 | 133 | ||
134 | /* Allocate memory for MTD device structure and private data */ | 134 | /* Allocate memory for MTD device structure and private data */ |
135 | ts7250_mtd = kmalloc(sizeof(struct mtd_info) + | 135 | ts7250_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
136 | sizeof(struct nand_chip), GFP_KERNEL); | ||
137 | if (!ts7250_mtd) { | 136 | if (!ts7250_mtd) { |
138 | printk("Unable to allocate TS7250 NAND MTD device structure.\n"); | 137 | printk("Unable to allocate TS7250 NAND MTD device structure.\n"); |
139 | return -ENOMEM; | 138 | return -ENOMEM; |
@@ -148,6 +147,7 @@ static int __init ts7250_init(void) | |||
148 | 147 | ||
149 | /* Link the private data with the MTD structure */ | 148 | /* Link the private data with the MTD structure */ |
150 | ts7250_mtd->priv = this; | 149 | ts7250_mtd->priv = this; |
150 | ts7250_mtd->owner = THIS_MODULE; | ||
151 | 151 | ||
152 | /* insert callbacks */ | 152 | /* insert callbacks */ |
153 | this->IO_ADDR_R = (void *)TS72XX_NAND_DATA_VIRT_BASE; | 153 | this->IO_ADDR_R = (void *)TS72XX_NAND_DATA_VIRT_BASE; |
@@ -163,11 +163,9 @@ static int __init ts7250_init(void) | |||
163 | kfree(ts7250_mtd); | 163 | kfree(ts7250_mtd); |
164 | return -ENXIO; | 164 | return -ENXIO; |
165 | } | 165 | } |
166 | |||
167 | #ifdef CONFIG_MTD_PARTITIONS | 166 | #ifdef CONFIG_MTD_PARTITIONS |
168 | ts7250_mtd->name = "ts7250-nand"; | 167 | ts7250_mtd->name = "ts7250-nand"; |
169 | mtd_parts_nb = parse_mtd_partitions(ts7250_mtd, part_probes, | 168 | mtd_parts_nb = parse_mtd_partitions(ts7250_mtd, part_probes, &mtd_parts, 0); |
170 | &mtd_parts, 0); | ||
171 | if (mtd_parts_nb > 0) | 169 | if (mtd_parts_nb > 0) |
172 | part_type = "command line"; | 170 | part_type = "command line"; |
173 | else | 171 | else |
@@ -188,6 +186,7 @@ static int __init ts7250_init(void) | |||
188 | /* Return happy */ | 186 | /* Return happy */ |
189 | return 0; | 187 | return 0; |
190 | } | 188 | } |
189 | |||
191 | module_init(ts7250_init); | 190 | module_init(ts7250_init); |
192 | 191 | ||
193 | /* | 192 | /* |
@@ -201,6 +200,7 @@ static void __exit ts7250_cleanup(void) | |||
201 | /* Free the MTD device structure */ | 200 | /* Free the MTD device structure */ |
202 | kfree(ts7250_mtd); | 201 | kfree(ts7250_mtd); |
203 | } | 202 | } |
203 | |||
204 | module_exit(ts7250_cleanup); | 204 | module_exit(ts7250_cleanup); |
205 | 205 | ||
206 | MODULE_LICENSE("GPL"); | 206 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c index c077d2ec9cdd..5b58523e4d4e 100644 --- a/drivers/mtd/redboot.c +++ b/drivers/mtd/redboot.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: redboot.c,v 1.19 2005/12/01 10:03:51 dwmw2 Exp $ | 2 | * $Id: redboot.c,v 1.21 2006/03/30 18:34:37 bjd Exp $ |
3 | * | 3 | * |
4 | * Parse RedBoot-style Flash Image System (FIS) tables and | 4 | * Parse RedBoot-style Flash Image System (FIS) tables and |
5 | * produce a Linux partition array to match. | 5 | * produce a Linux partition array to match. |
@@ -15,14 +15,14 @@ | |||
15 | 15 | ||
16 | struct fis_image_desc { | 16 | struct fis_image_desc { |
17 | unsigned char name[16]; // Null terminated name | 17 | unsigned char name[16]; // Null terminated name |
18 | unsigned long flash_base; // Address within FLASH of image | 18 | uint32_t flash_base; // Address within FLASH of image |
19 | unsigned long mem_base; // Address in memory where it executes | 19 | uint32_t mem_base; // Address in memory where it executes |
20 | unsigned long size; // Length of image | 20 | uint32_t size; // Length of image |
21 | unsigned long entry_point; // Execution entry point | 21 | uint32_t entry_point; // Execution entry point |
22 | unsigned long data_length; // Length of actual data | 22 | uint32_t data_length; // Length of actual data |
23 | unsigned char _pad[256-(16+7*sizeof(unsigned long))]; | 23 | unsigned char _pad[256-(16+7*sizeof(uint32_t))]; |
24 | unsigned long desc_cksum; // Checksum over image descriptor | 24 | uint32_t desc_cksum; // Checksum over image descriptor |
25 | unsigned long file_cksum; // Checksum over image data | 25 | uint32_t file_cksum; // Checksum over image data |
26 | }; | 26 | }; |
27 | 27 | ||
28 | struct fis_list { | 28 | struct fis_list { |
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index a3e00a4635a5..fa4362fb4dd8 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2005 Sean Young <sean@mess.org> | 4 | * Copyright (C) 2005 Sean Young <sean@mess.org> |
5 | * | 5 | * |
6 | * $Id: rfd_ftl.c,v 1.5 2005/11/07 11:14:21 gleixner Exp $ | 6 | * $Id: rfd_ftl.c,v 1.8 2006/01/15 12:51:44 sean Exp $ |
7 | * | 7 | * |
8 | * This type of flash translation layer (FTL) is used by the Embedded BIOS | 8 | * This type of flash translation layer (FTL) is used by the Embedded BIOS |
9 | * by General Software. It is known as the Resident Flash Disk (RFD), see: | 9 | * by General Software. It is known as the Resident Flash Disk (RFD), see: |
@@ -61,6 +61,7 @@ struct block { | |||
61 | BLOCK_OK, | 61 | BLOCK_OK, |
62 | BLOCK_ERASING, | 62 | BLOCK_ERASING, |
63 | BLOCK_ERASED, | 63 | BLOCK_ERASED, |
64 | BLOCK_UNUSED, | ||
64 | BLOCK_FAILED | 65 | BLOCK_FAILED |
65 | } state; | 66 | } state; |
66 | int free_sectors; | 67 | int free_sectors; |
@@ -99,10 +100,8 @@ static int build_block_map(struct partition *part, int block_no) | |||
99 | block->offset = part->block_size * block_no; | 100 | block->offset = part->block_size * block_no; |
100 | 101 | ||
101 | if (le16_to_cpu(part->header_cache[0]) != RFD_MAGIC) { | 102 | if (le16_to_cpu(part->header_cache[0]) != RFD_MAGIC) { |
102 | block->state = BLOCK_ERASED; /* assumption */ | 103 | block->state = BLOCK_UNUSED; |
103 | block->free_sectors = part->data_sectors_per_block; | 104 | return -ENOENT; |
104 | part->reserved_block = block_no; | ||
105 | return 1; | ||
106 | } | 105 | } |
107 | 106 | ||
108 | block->state = BLOCK_OK; | 107 | block->state = BLOCK_OK; |
@@ -124,7 +123,7 @@ static int build_block_map(struct partition *part, int block_no) | |||
124 | entry = 0; | 123 | entry = 0; |
125 | 124 | ||
126 | if (entry >= part->sector_count) { | 125 | if (entry >= part->sector_count) { |
127 | printk(KERN_NOTICE PREFIX | 126 | printk(KERN_WARNING PREFIX |
128 | "'%s': unit #%d: entry %d corrupt, " | 127 | "'%s': unit #%d: entry %d corrupt, " |
129 | "sector %d out of range\n", | 128 | "sector %d out of range\n", |
130 | part->mbd.mtd->name, block_no, i, entry); | 129 | part->mbd.mtd->name, block_no, i, entry); |
@@ -132,7 +131,7 @@ static int build_block_map(struct partition *part, int block_no) | |||
132 | } | 131 | } |
133 | 132 | ||
134 | if (part->sector_map[entry] != -1) { | 133 | if (part->sector_map[entry] != -1) { |
135 | printk(KERN_NOTICE PREFIX | 134 | printk(KERN_WARNING PREFIX |
136 | "'%s': more than one entry for sector %d\n", | 135 | "'%s': more than one entry for sector %d\n", |
137 | part->mbd.mtd->name, entry); | 136 | part->mbd.mtd->name, entry); |
138 | part->errors = 1; | 137 | part->errors = 1; |
@@ -167,7 +166,7 @@ static int scan_header(struct partition *part) | |||
167 | /* each erase block has three bytes header, followed by the map */ | 166 | /* each erase block has three bytes header, followed by the map */ |
168 | part->header_sectors_per_block = | 167 | part->header_sectors_per_block = |
169 | ((HEADER_MAP_OFFSET + sectors_per_block) * | 168 | ((HEADER_MAP_OFFSET + sectors_per_block) * |
170 | sizeof(u16) + SECTOR_SIZE - 1) / SECTOR_SIZE; | 169 | sizeof(u16) + SECTOR_SIZE - 1) / SECTOR_SIZE; |
171 | 170 | ||
172 | part->data_sectors_per_block = sectors_per_block - | 171 | part->data_sectors_per_block = sectors_per_block - |
173 | part->header_sectors_per_block; | 172 | part->header_sectors_per_block; |
@@ -226,7 +225,7 @@ static int scan_header(struct partition *part) | |||
226 | } | 225 | } |
227 | 226 | ||
228 | if (part->reserved_block == -1) { | 227 | if (part->reserved_block == -1) { |
229 | printk(KERN_NOTICE PREFIX "'%s': no empty erase unit found\n", | 228 | printk(KERN_WARNING PREFIX "'%s': no empty erase unit found\n", |
230 | part->mbd.mtd->name); | 229 | part->mbd.mtd->name); |
231 | 230 | ||
232 | part->errors = 1; | 231 | part->errors = 1; |
@@ -315,7 +314,7 @@ static void erase_callback(struct erase_info *erase) | |||
315 | rc = -EIO; | 314 | rc = -EIO; |
316 | 315 | ||
317 | if (rc) { | 316 | if (rc) { |
318 | printk(KERN_NOTICE PREFIX "'%s': unable to write RFD " | 317 | printk(KERN_ERR PREFIX "'%s': unable to write RFD " |
319 | "header at 0x%lx\n", | 318 | "header at 0x%lx\n", |
320 | part->mbd.mtd->name, | 319 | part->mbd.mtd->name, |
321 | part->blocks[i].offset); | 320 | part->blocks[i].offset); |
@@ -348,7 +347,7 @@ static int erase_block(struct partition *part, int block) | |||
348 | rc = part->mbd.mtd->erase(part->mbd.mtd, erase); | 347 | rc = part->mbd.mtd->erase(part->mbd.mtd, erase); |
349 | 348 | ||
350 | if (rc) { | 349 | if (rc) { |
351 | printk(KERN_WARNING PREFIX "erase of region %x,%x on '%s' " | 350 | printk(KERN_ERR PREFIX "erase of region %x,%x on '%s' " |
352 | "failed\n", erase->addr, erase->len, | 351 | "failed\n", erase->addr, erase->len, |
353 | part->mbd.mtd->name); | 352 | part->mbd.mtd->name); |
354 | kfree(erase); | 353 | kfree(erase); |
@@ -383,7 +382,7 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old | |||
383 | rc = -EIO; | 382 | rc = -EIO; |
384 | 383 | ||
385 | if (rc) { | 384 | if (rc) { |
386 | printk(KERN_NOTICE PREFIX "error reading '%s' at " | 385 | printk(KERN_ERR PREFIX "error reading '%s' at " |
387 | "0x%lx\n", part->mbd.mtd->name, | 386 | "0x%lx\n", part->mbd.mtd->name, |
388 | part->blocks[block_no].offset); | 387 | part->blocks[block_no].offset); |
389 | 388 | ||
@@ -423,7 +422,7 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old | |||
423 | rc = -EIO; | 422 | rc = -EIO; |
424 | 423 | ||
425 | if (rc) { | 424 | if (rc) { |
426 | printk(KERN_NOTICE PREFIX "'%s': Unable to " | 425 | printk(KERN_ERR PREFIX "'%s': Unable to " |
427 | "read sector for relocation\n", | 426 | "read sector for relocation\n", |
428 | part->mbd.mtd->name); | 427 | part->mbd.mtd->name); |
429 | 428 | ||
@@ -520,7 +519,7 @@ static int reclaim_block(struct partition *part, u_long *old_sector) | |||
520 | * because if we fill that one up first it'll have the most chance of having | 519 | * because if we fill that one up first it'll have the most chance of having |
521 | * the least live sectors at reclaim. | 520 | * the least live sectors at reclaim. |
522 | */ | 521 | */ |
523 | static int find_free_block(const struct partition *part) | 522 | static int find_free_block(struct partition *part) |
524 | { | 523 | { |
525 | int block, stop; | 524 | int block, stop; |
526 | 525 | ||
@@ -533,6 +532,9 @@ static int find_free_block(const struct partition *part) | |||
533 | block != part->reserved_block) | 532 | block != part->reserved_block) |
534 | return block; | 533 | return block; |
535 | 534 | ||
535 | if (part->blocks[block].state == BLOCK_UNUSED) | ||
536 | erase_block(part, block); | ||
537 | |||
536 | if (++block >= part->total_blocks) | 538 | if (++block >= part->total_blocks) |
537 | block = 0; | 539 | block = 0; |
538 | 540 | ||
@@ -541,7 +543,7 @@ static int find_free_block(const struct partition *part) | |||
541 | return -1; | 543 | return -1; |
542 | } | 544 | } |
543 | 545 | ||
544 | static int find_writeable_block(struct partition *part, u_long *old_sector) | 546 | static int find_writable_block(struct partition *part, u_long *old_sector) |
545 | { | 547 | { |
546 | int rc, block; | 548 | int rc, block; |
547 | size_t retlen; | 549 | size_t retlen; |
@@ -570,7 +572,7 @@ static int find_writeable_block(struct partition *part, u_long *old_sector) | |||
570 | rc = -EIO; | 572 | rc = -EIO; |
571 | 573 | ||
572 | if (rc) { | 574 | if (rc) { |
573 | printk(KERN_NOTICE PREFIX "'%s': unable to read header at " | 575 | printk(KERN_ERR PREFIX "'%s': unable to read header at " |
574 | "0x%lx\n", part->mbd.mtd->name, | 576 | "0x%lx\n", part->mbd.mtd->name, |
575 | part->blocks[block].offset); | 577 | part->blocks[block].offset); |
576 | goto err; | 578 | goto err; |
@@ -602,7 +604,7 @@ static int mark_sector_deleted(struct partition *part, u_long old_addr) | |||
602 | rc = -EIO; | 604 | rc = -EIO; |
603 | 605 | ||
604 | if (rc) { | 606 | if (rc) { |
605 | printk(KERN_WARNING PREFIX "error writing '%s' at " | 607 | printk(KERN_ERR PREFIX "error writing '%s' at " |
606 | "0x%lx\n", part->mbd.mtd->name, addr); | 608 | "0x%lx\n", part->mbd.mtd->name, addr); |
607 | if (rc) | 609 | if (rc) |
608 | goto err; | 610 | goto err; |
@@ -652,7 +654,7 @@ static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf, | |||
652 | if (part->current_block == -1 || | 654 | if (part->current_block == -1 || |
653 | !part->blocks[part->current_block].free_sectors) { | 655 | !part->blocks[part->current_block].free_sectors) { |
654 | 656 | ||
655 | rc = find_writeable_block(part, old_addr); | 657 | rc = find_writable_block(part, old_addr); |
656 | if (rc) | 658 | if (rc) |
657 | goto err; | 659 | goto err; |
658 | } | 660 | } |
@@ -675,7 +677,7 @@ static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf, | |||
675 | rc = -EIO; | 677 | rc = -EIO; |
676 | 678 | ||
677 | if (rc) { | 679 | if (rc) { |
678 | printk(KERN_WARNING PREFIX "error writing '%s' at 0x%lx\n", | 680 | printk(KERN_ERR PREFIX "error writing '%s' at 0x%lx\n", |
679 | part->mbd.mtd->name, addr); | 681 | part->mbd.mtd->name, addr); |
680 | if (rc) | 682 | if (rc) |
681 | goto err; | 683 | goto err; |
@@ -695,7 +697,7 @@ static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf, | |||
695 | rc = -EIO; | 697 | rc = -EIO; |
696 | 698 | ||
697 | if (rc) { | 699 | if (rc) { |
698 | printk(KERN_WARNING PREFIX "error writing '%s' at 0x%lx\n", | 700 | printk(KERN_ERR PREFIX "error writing '%s' at 0x%lx\n", |
699 | part->mbd.mtd->name, addr); | 701 | part->mbd.mtd->name, addr); |
700 | if (rc) | 702 | if (rc) |
701 | goto err; | 703 | goto err; |
@@ -776,7 +778,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
776 | part->block_size = block_size; | 778 | part->block_size = block_size; |
777 | else { | 779 | else { |
778 | if (!mtd->erasesize) { | 780 | if (!mtd->erasesize) { |
779 | printk(KERN_NOTICE PREFIX "please provide block_size"); | 781 | printk(KERN_WARNING PREFIX "please provide block_size"); |
780 | return; | 782 | return; |
781 | } | 783 | } |
782 | else | 784 | else |
@@ -791,8 +793,8 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
791 | if (!(mtd->flags & MTD_WRITEABLE)) | 793 | if (!(mtd->flags & MTD_WRITEABLE)) |
792 | part->mbd.readonly = 1; | 794 | part->mbd.readonly = 1; |
793 | else if (part->errors) { | 795 | else if (part->errors) { |
794 | printk(KERN_NOTICE PREFIX "'%s': errors found, " | 796 | printk(KERN_WARNING PREFIX "'%s': errors found, " |
795 | "setting read-only", mtd->name); | 797 | "setting read-only\n", mtd->name); |
796 | part->mbd.readonly = 1; | 798 | part->mbd.readonly = 1; |
797 | } | 799 | } |
798 | 800 | ||
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c index 1363083b4d83..14dbad14afb6 100644 --- a/drivers/net/au1000_eth.c +++ b/drivers/net/au1000_eth.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include <linux/mii.h> | 52 | #include <linux/mii.h> |
53 | #include <linux/skbuff.h> | 53 | #include <linux/skbuff.h> |
54 | #include <linux/delay.h> | 54 | #include <linux/delay.h> |
55 | #include <linux/crc32.h> | ||
55 | #include <asm/mipsregs.h> | 56 | #include <asm/mipsregs.h> |
56 | #include <asm/irq.h> | 57 | #include <asm/irq.h> |
57 | #include <asm/io.h> | 58 | #include <asm/io.h> |
@@ -2070,23 +2071,6 @@ static void au1000_tx_timeout(struct net_device *dev) | |||
2070 | netif_wake_queue(dev); | 2071 | netif_wake_queue(dev); |
2071 | } | 2072 | } |
2072 | 2073 | ||
2073 | |||
2074 | static unsigned const ethernet_polynomial = 0x04c11db7U; | ||
2075 | static inline u32 ether_crc(int length, unsigned char *data) | ||
2076 | { | ||
2077 | int crc = -1; | ||
2078 | |||
2079 | while(--length >= 0) { | ||
2080 | unsigned char current_octet = *data++; | ||
2081 | int bit; | ||
2082 | for (bit = 0; bit < 8; bit++, current_octet >>= 1) | ||
2083 | crc = (crc << 1) ^ | ||
2084 | ((crc < 0) ^ (current_octet & 1) ? | ||
2085 | ethernet_polynomial : 0); | ||
2086 | } | ||
2087 | return crc; | ||
2088 | } | ||
2089 | |||
2090 | static void set_rx_mode(struct net_device *dev) | 2074 | static void set_rx_mode(struct net_device *dev) |
2091 | { | 2075 | { |
2092 | struct au1000_private *aup = (struct au1000_private *) dev->priv; | 2076 | struct au1000_private *aup = (struct au1000_private *) dev->priv; |
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c index 1f3627470c95..038447fb5c5e 100644 --- a/drivers/net/dl2k.c +++ b/drivers/net/dl2k.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #define DRV_VERSION "v1.17b" | 53 | #define DRV_VERSION "v1.17b" |
54 | #define DRV_RELDATE "2006/03/10" | 54 | #define DRV_RELDATE "2006/03/10" |
55 | #include "dl2k.h" | 55 | #include "dl2k.h" |
56 | #include <linux/dma-mapping.h> | ||
56 | 57 | ||
57 | static char version[] __devinitdata = | 58 | static char version[] __devinitdata = |
58 | KERN_INFO DRV_NAME " " DRV_VERSION " " DRV_RELDATE "\n"; | 59 | KERN_INFO DRV_NAME " " DRV_VERSION " " DRV_RELDATE "\n"; |
@@ -765,7 +766,7 @@ rio_free_tx (struct net_device *dev, int irq) | |||
765 | break; | 766 | break; |
766 | skb = np->tx_skbuff[entry]; | 767 | skb = np->tx_skbuff[entry]; |
767 | pci_unmap_single (np->pdev, | 768 | pci_unmap_single (np->pdev, |
768 | np->tx_ring[entry].fraginfo & 0xffffffffffff, | 769 | np->tx_ring[entry].fraginfo & DMA_48BIT_MASK, |
769 | skb->len, PCI_DMA_TODEVICE); | 770 | skb->len, PCI_DMA_TODEVICE); |
770 | if (irq) | 771 | if (irq) |
771 | dev_kfree_skb_irq (skb); | 772 | dev_kfree_skb_irq (skb); |
@@ -893,7 +894,7 @@ receive_packet (struct net_device *dev) | |||
893 | /* Small skbuffs for short packets */ | 894 | /* Small skbuffs for short packets */ |
894 | if (pkt_len > copy_thresh) { | 895 | if (pkt_len > copy_thresh) { |
895 | pci_unmap_single (np->pdev, | 896 | pci_unmap_single (np->pdev, |
896 | desc->fraginfo & 0xffffffffffff, | 897 | desc->fraginfo & DMA_48BIT_MASK, |
897 | np->rx_buf_sz, | 898 | np->rx_buf_sz, |
898 | PCI_DMA_FROMDEVICE); | 899 | PCI_DMA_FROMDEVICE); |
899 | skb_put (skb = np->rx_skbuff[entry], pkt_len); | 900 | skb_put (skb = np->rx_skbuff[entry], pkt_len); |
@@ -901,7 +902,7 @@ receive_packet (struct net_device *dev) | |||
901 | } else if ((skb = dev_alloc_skb (pkt_len + 2)) != NULL) { | 902 | } else if ((skb = dev_alloc_skb (pkt_len + 2)) != NULL) { |
902 | pci_dma_sync_single_for_cpu(np->pdev, | 903 | pci_dma_sync_single_for_cpu(np->pdev, |
903 | desc->fraginfo & | 904 | desc->fraginfo & |
904 | 0xffffffffffff, | 905 | DMA_48BIT_MASK, |
905 | np->rx_buf_sz, | 906 | np->rx_buf_sz, |
906 | PCI_DMA_FROMDEVICE); | 907 | PCI_DMA_FROMDEVICE); |
907 | skb->dev = dev; | 908 | skb->dev = dev; |
@@ -913,7 +914,7 @@ receive_packet (struct net_device *dev) | |||
913 | skb_put (skb, pkt_len); | 914 | skb_put (skb, pkt_len); |
914 | pci_dma_sync_single_for_device(np->pdev, | 915 | pci_dma_sync_single_for_device(np->pdev, |
915 | desc->fraginfo & | 916 | desc->fraginfo & |
916 | 0xffffffffffff, | 917 | DMA_48BIT_MASK, |
917 | np->rx_buf_sz, | 918 | np->rx_buf_sz, |
918 | PCI_DMA_FROMDEVICE); | 919 | PCI_DMA_FROMDEVICE); |
919 | } | 920 | } |
@@ -1800,7 +1801,7 @@ rio_close (struct net_device *dev) | |||
1800 | skb = np->rx_skbuff[i]; | 1801 | skb = np->rx_skbuff[i]; |
1801 | if (skb) { | 1802 | if (skb) { |
1802 | pci_unmap_single(np->pdev, | 1803 | pci_unmap_single(np->pdev, |
1803 | np->rx_ring[i].fraginfo & 0xffffffffffff, | 1804 | np->rx_ring[i].fraginfo & DMA_48BIT_MASK, |
1804 | skb->len, PCI_DMA_FROMDEVICE); | 1805 | skb->len, PCI_DMA_FROMDEVICE); |
1805 | dev_kfree_skb (skb); | 1806 | dev_kfree_skb (skb); |
1806 | np->rx_skbuff[i] = NULL; | 1807 | np->rx_skbuff[i] = NULL; |
@@ -1810,7 +1811,7 @@ rio_close (struct net_device *dev) | |||
1810 | skb = np->tx_skbuff[i]; | 1811 | skb = np->tx_skbuff[i]; |
1811 | if (skb) { | 1812 | if (skb) { |
1812 | pci_unmap_single(np->pdev, | 1813 | pci_unmap_single(np->pdev, |
1813 | np->tx_ring[i].fraginfo & 0xffffffffffff, | 1814 | np->tx_ring[i].fraginfo & DMA_48BIT_MASK, |
1814 | skb->len, PCI_DMA_TODEVICE); | 1815 | skb->len, PCI_DMA_TODEVICE); |
1815 | dev_kfree_skb (skb); | 1816 | dev_kfree_skb (skb); |
1816 | np->tx_skbuff[i] = NULL; | 1817 | np->tx_skbuff[i] = NULL; |
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c index 79a8fbcf5f93..0d5fccc984bb 100644 --- a/drivers/net/hamradio/dmascc.c +++ b/drivers/net/hamradio/dmascc.c | |||
@@ -582,7 +582,6 @@ static int __init setup_adapter(int card_base, int type, int n) | |||
582 | INIT_WORK(&priv->rx_work, rx_bh, priv); | 582 | INIT_WORK(&priv->rx_work, rx_bh, priv); |
583 | dev->priv = priv; | 583 | dev->priv = priv; |
584 | sprintf(dev->name, "dmascc%i", 2 * n + i); | 584 | sprintf(dev->name, "dmascc%i", 2 * n + i); |
585 | SET_MODULE_OWNER(dev); | ||
586 | dev->base_addr = card_base; | 585 | dev->base_addr = card_base; |
587 | dev->irq = irq; | 586 | dev->irq = irq; |
588 | dev->open = scc_open; | 587 | dev->open = scc_open; |
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c index 6ace0e914fd1..5927784df3f9 100644 --- a/drivers/net/hamradio/scc.c +++ b/drivers/net/hamradio/scc.c | |||
@@ -1550,7 +1550,6 @@ static unsigned char ax25_nocall[AX25_ADDR_LEN] = | |||
1550 | 1550 | ||
1551 | static void scc_net_setup(struct net_device *dev) | 1551 | static void scc_net_setup(struct net_device *dev) |
1552 | { | 1552 | { |
1553 | SET_MODULE_OWNER(dev); | ||
1554 | dev->tx_queue_len = 16; /* should be enough... */ | 1553 | dev->tx_queue_len = 16; /* should be enough... */ |
1555 | 1554 | ||
1556 | dev->open = scc_net_open; | 1555 | dev->open = scc_net_open; |
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c index fe22479eb202..b49884048caa 100644 --- a/drivers/net/hamradio/yam.c +++ b/drivers/net/hamradio/yam.c | |||
@@ -1098,7 +1098,6 @@ static void yam_setup(struct net_device *dev) | |||
1098 | 1098 | ||
1099 | dev->base_addr = yp->iobase; | 1099 | dev->base_addr = yp->iobase; |
1100 | dev->irq = yp->irq; | 1100 | dev->irq = yp->irq; |
1101 | SET_MODULE_OWNER(dev); | ||
1102 | 1101 | ||
1103 | dev->open = yam_open; | 1102 | dev->open = yam_open; |
1104 | dev->stop = yam_close; | 1103 | dev->stop = yam_close; |
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile index 27ab75f20799..c1ce2398efea 100644 --- a/drivers/net/irda/Makefile +++ b/drivers/net/irda/Makefile | |||
@@ -46,4 +46,4 @@ obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o | |||
46 | obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o | 46 | obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o |
47 | 47 | ||
48 | # The SIR helper module | 48 | # The SIR helper module |
49 | sir-dev-objs := sir_dev.o sir_dongle.o sir_kthread.o | 49 | sir-dev-objs := sir_dev.o sir_dongle.o |
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index 96bdb73c2283..cd87593e4e8a 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c | |||
@@ -1778,7 +1778,7 @@ static int irda_usb_probe(struct usb_interface *intf, | |||
1778 | 1778 | ||
1779 | if (self->needspatch) { | 1779 | if (self->needspatch) { |
1780 | ret = usb_control_msg (self->usbdev, usb_sndctrlpipe (self->usbdev, 0), | 1780 | ret = usb_control_msg (self->usbdev, usb_sndctrlpipe (self->usbdev, 0), |
1781 | 0x02, 0x40, 0, 0, 0, 0, msecs_to_jiffies(500)); | 1781 | 0x02, 0x40, 0, 0, NULL, 0, 500); |
1782 | if (ret < 0) { | 1782 | if (ret < 0) { |
1783 | IRDA_DEBUG (0, "usb_control_msg failed %d\n", ret); | 1783 | IRDA_DEBUG (0, "usb_control_msg failed %d\n", ret); |
1784 | goto err_out_3; | 1784 | goto err_out_3; |
diff --git a/drivers/net/irda/sir-dev.h b/drivers/net/irda/sir-dev.h index f69fb4cec76f..9fa294a546d6 100644 --- a/drivers/net/irda/sir-dev.h +++ b/drivers/net/irda/sir-dev.h | |||
@@ -15,23 +15,14 @@ | |||
15 | #define IRDA_SIR_H | 15 | #define IRDA_SIR_H |
16 | 16 | ||
17 | #include <linux/netdevice.h> | 17 | #include <linux/netdevice.h> |
18 | #include <linux/workqueue.h> | ||
18 | 19 | ||
19 | #include <net/irda/irda.h> | 20 | #include <net/irda/irda.h> |
20 | #include <net/irda/irda_device.h> // iobuff_t | 21 | #include <net/irda/irda_device.h> // iobuff_t |
21 | 22 | ||
22 | /* FIXME: unify irda_request with sir_fsm! */ | ||
23 | |||
24 | struct irda_request { | ||
25 | struct list_head lh_request; | ||
26 | unsigned long pending; | ||
27 | void (*func)(void *); | ||
28 | void *data; | ||
29 | struct timer_list timer; | ||
30 | }; | ||
31 | |||
32 | struct sir_fsm { | 23 | struct sir_fsm { |
33 | struct semaphore sem; | 24 | struct semaphore sem; |
34 | struct irda_request rq; | 25 | struct work_struct work; |
35 | unsigned state, substate; | 26 | unsigned state, substate; |
36 | int param; | 27 | int param; |
37 | int result; | 28 | int result; |
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c index ea7c9464d46a..3b5854d10c17 100644 --- a/drivers/net/irda/sir_dev.c +++ b/drivers/net/irda/sir_dev.c | |||
@@ -23,6 +23,298 @@ | |||
23 | 23 | ||
24 | #include "sir-dev.h" | 24 | #include "sir-dev.h" |
25 | 25 | ||
26 | |||
27 | static struct workqueue_struct *irda_sir_wq; | ||
28 | |||
29 | /* STATE MACHINE */ | ||
30 | |||
31 | /* substate handler of the config-fsm to handle the cases where we want | ||
32 | * to wait for transmit completion before changing the port configuration | ||
33 | */ | ||
34 | |||
35 | static int sirdev_tx_complete_fsm(struct sir_dev *dev) | ||
36 | { | ||
37 | struct sir_fsm *fsm = &dev->fsm; | ||
38 | unsigned next_state, delay; | ||
39 | unsigned bytes_left; | ||
40 | |||
41 | do { | ||
42 | next_state = fsm->substate; /* default: stay in current substate */ | ||
43 | delay = 0; | ||
44 | |||
45 | switch(fsm->substate) { | ||
46 | |||
47 | case SIRDEV_STATE_WAIT_XMIT: | ||
48 | if (dev->drv->chars_in_buffer) | ||
49 | bytes_left = dev->drv->chars_in_buffer(dev); | ||
50 | else | ||
51 | bytes_left = 0; | ||
52 | if (!bytes_left) { | ||
53 | next_state = SIRDEV_STATE_WAIT_UNTIL_SENT; | ||
54 | break; | ||
55 | } | ||
56 | |||
57 | if (dev->speed > 115200) | ||
58 | delay = (bytes_left*8*10000) / (dev->speed/100); | ||
59 | else if (dev->speed > 0) | ||
60 | delay = (bytes_left*10*10000) / (dev->speed/100); | ||
61 | else | ||
62 | delay = 0; | ||
63 | /* expected delay (usec) until remaining bytes are sent */ | ||
64 | if (delay < 100) { | ||
65 | udelay(delay); | ||
66 | delay = 0; | ||
67 | break; | ||
68 | } | ||
69 | /* sleep some longer delay (msec) */ | ||
70 | delay = (delay+999) / 1000; | ||
71 | break; | ||
72 | |||
73 | case SIRDEV_STATE_WAIT_UNTIL_SENT: | ||
74 | /* block until underlaying hardware buffer are empty */ | ||
75 | if (dev->drv->wait_until_sent) | ||
76 | dev->drv->wait_until_sent(dev); | ||
77 | next_state = SIRDEV_STATE_TX_DONE; | ||
78 | break; | ||
79 | |||
80 | case SIRDEV_STATE_TX_DONE: | ||
81 | return 0; | ||
82 | |||
83 | default: | ||
84 | IRDA_ERROR("%s - undefined state\n", __FUNCTION__); | ||
85 | return -EINVAL; | ||
86 | } | ||
87 | fsm->substate = next_state; | ||
88 | } while (delay == 0); | ||
89 | return delay; | ||
90 | } | ||
91 | |||
92 | /* | ||
93 | * Function sirdev_config_fsm | ||
94 | * | ||
95 | * State machine to handle the configuration of the device (and attached dongle, if any). | ||
96 | * This handler is scheduled for execution in kIrDAd context, so we can sleep. | ||
97 | * however, kIrDAd is shared by all sir_dev devices so we better don't sleep there too | ||
98 | * long. Instead, for longer delays we start a timer to reschedule us later. | ||
99 | * On entry, fsm->sem is always locked and the netdev xmit queue stopped. | ||
100 | * Both must be unlocked/restarted on completion - but only on final exit. | ||
101 | */ | ||
102 | |||
103 | static void sirdev_config_fsm(void *data) | ||
104 | { | ||
105 | struct sir_dev *dev = data; | ||
106 | struct sir_fsm *fsm = &dev->fsm; | ||
107 | int next_state; | ||
108 | int ret = -1; | ||
109 | unsigned delay; | ||
110 | |||
111 | IRDA_DEBUG(2, "%s(), <%ld>\n", __FUNCTION__, jiffies); | ||
112 | |||
113 | do { | ||
114 | IRDA_DEBUG(3, "%s - state=0x%04x / substate=0x%04x\n", | ||
115 | __FUNCTION__, fsm->state, fsm->substate); | ||
116 | |||
117 | next_state = fsm->state; | ||
118 | delay = 0; | ||
119 | |||
120 | switch(fsm->state) { | ||
121 | |||
122 | case SIRDEV_STATE_DONGLE_OPEN: | ||
123 | if (dev->dongle_drv != NULL) { | ||
124 | ret = sirdev_put_dongle(dev); | ||
125 | if (ret) { | ||
126 | fsm->result = -EINVAL; | ||
127 | next_state = SIRDEV_STATE_ERROR; | ||
128 | break; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | /* Initialize dongle */ | ||
133 | ret = sirdev_get_dongle(dev, fsm->param); | ||
134 | if (ret) { | ||
135 | fsm->result = ret; | ||
136 | next_state = SIRDEV_STATE_ERROR; | ||
137 | break; | ||
138 | } | ||
139 | |||
140 | /* Dongles are powered through the modem control lines which | ||
141 | * were just set during open. Before resetting, let's wait for | ||
142 | * the power to stabilize. This is what some dongle drivers did | ||
143 | * in open before, while others didn't - should be safe anyway. | ||
144 | */ | ||
145 | |||
146 | delay = 50; | ||
147 | fsm->substate = SIRDEV_STATE_DONGLE_RESET; | ||
148 | next_state = SIRDEV_STATE_DONGLE_RESET; | ||
149 | |||
150 | fsm->param = 9600; | ||
151 | |||
152 | break; | ||
153 | |||
154 | case SIRDEV_STATE_DONGLE_CLOSE: | ||
155 | /* shouldn't we just treat this as success=? */ | ||
156 | if (dev->dongle_drv == NULL) { | ||
157 | fsm->result = -EINVAL; | ||
158 | next_state = SIRDEV_STATE_ERROR; | ||
159 | break; | ||
160 | } | ||
161 | |||
162 | ret = sirdev_put_dongle(dev); | ||
163 | if (ret) { | ||
164 | fsm->result = ret; | ||
165 | next_state = SIRDEV_STATE_ERROR; | ||
166 | break; | ||
167 | } | ||
168 | next_state = SIRDEV_STATE_DONE; | ||
169 | break; | ||
170 | |||
171 | case SIRDEV_STATE_SET_DTR_RTS: | ||
172 | ret = sirdev_set_dtr_rts(dev, | ||
173 | (fsm->param&0x02) ? TRUE : FALSE, | ||
174 | (fsm->param&0x01) ? TRUE : FALSE); | ||
175 | next_state = SIRDEV_STATE_DONE; | ||
176 | break; | ||
177 | |||
178 | case SIRDEV_STATE_SET_SPEED: | ||
179 | fsm->substate = SIRDEV_STATE_WAIT_XMIT; | ||
180 | next_state = SIRDEV_STATE_DONGLE_CHECK; | ||
181 | break; | ||
182 | |||
183 | case SIRDEV_STATE_DONGLE_CHECK: | ||
184 | ret = sirdev_tx_complete_fsm(dev); | ||
185 | if (ret < 0) { | ||
186 | fsm->result = ret; | ||
187 | next_state = SIRDEV_STATE_ERROR; | ||
188 | break; | ||
189 | } | ||
190 | if ((delay=ret) != 0) | ||
191 | break; | ||
192 | |||
193 | if (dev->dongle_drv) { | ||
194 | fsm->substate = SIRDEV_STATE_DONGLE_RESET; | ||
195 | next_state = SIRDEV_STATE_DONGLE_RESET; | ||
196 | } | ||
197 | else { | ||
198 | dev->speed = fsm->param; | ||
199 | next_state = SIRDEV_STATE_PORT_SPEED; | ||
200 | } | ||
201 | break; | ||
202 | |||
203 | case SIRDEV_STATE_DONGLE_RESET: | ||
204 | if (dev->dongle_drv->reset) { | ||
205 | ret = dev->dongle_drv->reset(dev); | ||
206 | if (ret < 0) { | ||
207 | fsm->result = ret; | ||
208 | next_state = SIRDEV_STATE_ERROR; | ||
209 | break; | ||
210 | } | ||
211 | } | ||
212 | else | ||
213 | ret = 0; | ||
214 | if ((delay=ret) == 0) { | ||
215 | /* set serial port according to dongle default speed */ | ||
216 | if (dev->drv->set_speed) | ||
217 | dev->drv->set_speed(dev, dev->speed); | ||
218 | fsm->substate = SIRDEV_STATE_DONGLE_SPEED; | ||
219 | next_state = SIRDEV_STATE_DONGLE_SPEED; | ||
220 | } | ||
221 | break; | ||
222 | |||
223 | case SIRDEV_STATE_DONGLE_SPEED: | ||
224 | if (dev->dongle_drv->reset) { | ||
225 | ret = dev->dongle_drv->set_speed(dev, fsm->param); | ||
226 | if (ret < 0) { | ||
227 | fsm->result = ret; | ||
228 | next_state = SIRDEV_STATE_ERROR; | ||
229 | break; | ||
230 | } | ||
231 | } | ||
232 | else | ||
233 | ret = 0; | ||
234 | if ((delay=ret) == 0) | ||
235 | next_state = SIRDEV_STATE_PORT_SPEED; | ||
236 | break; | ||
237 | |||
238 | case SIRDEV_STATE_PORT_SPEED: | ||
239 | /* Finally we are ready to change the serial port speed */ | ||
240 | if (dev->drv->set_speed) | ||
241 | dev->drv->set_speed(dev, dev->speed); | ||
242 | dev->new_speed = 0; | ||
243 | next_state = SIRDEV_STATE_DONE; | ||
244 | break; | ||
245 | |||
246 | case SIRDEV_STATE_DONE: | ||
247 | /* Signal network layer so it can send more frames */ | ||
248 | netif_wake_queue(dev->netdev); | ||
249 | next_state = SIRDEV_STATE_COMPLETE; | ||
250 | break; | ||
251 | |||
252 | default: | ||
253 | IRDA_ERROR("%s - undefined state\n", __FUNCTION__); | ||
254 | fsm->result = -EINVAL; | ||
255 | /* fall thru */ | ||
256 | |||
257 | case SIRDEV_STATE_ERROR: | ||
258 | IRDA_ERROR("%s - error: %d\n", __FUNCTION__, fsm->result); | ||
259 | |||
260 | #if 0 /* don't enable this before we have netdev->tx_timeout to recover */ | ||
261 | netif_stop_queue(dev->netdev); | ||
262 | #else | ||
263 | netif_wake_queue(dev->netdev); | ||
264 | #endif | ||
265 | /* fall thru */ | ||
266 | |||
267 | case SIRDEV_STATE_COMPLETE: | ||
268 | /* config change finished, so we are not busy any longer */ | ||
269 | sirdev_enable_rx(dev); | ||
270 | up(&fsm->sem); | ||
271 | return; | ||
272 | } | ||
273 | fsm->state = next_state; | ||
274 | } while(!delay); | ||
275 | |||
276 | queue_delayed_work(irda_sir_wq, &fsm->work, msecs_to_jiffies(delay)); | ||
277 | } | ||
278 | |||
279 | /* schedule some device configuration task for execution by kIrDAd | ||
280 | * on behalf of the above state machine. | ||
281 | * can be called from process or interrupt/tasklet context. | ||
282 | */ | ||
283 | |||
284 | int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned param) | ||
285 | { | ||
286 | struct sir_fsm *fsm = &dev->fsm; | ||
287 | |||
288 | IRDA_DEBUG(2, "%s - state=0x%04x / param=%u\n", __FUNCTION__, initial_state, param); | ||
289 | |||
290 | if (down_trylock(&fsm->sem)) { | ||
291 | if (in_interrupt() || in_atomic() || irqs_disabled()) { | ||
292 | IRDA_DEBUG(1, "%s(), state machine busy!\n", __FUNCTION__); | ||
293 | return -EWOULDBLOCK; | ||
294 | } else | ||
295 | down(&fsm->sem); | ||
296 | } | ||
297 | |||
298 | if (fsm->state == SIRDEV_STATE_DEAD) { | ||
299 | /* race with sirdev_close should never happen */ | ||
300 | IRDA_ERROR("%s(), instance staled!\n", __FUNCTION__); | ||
301 | up(&fsm->sem); | ||
302 | return -ESTALE; /* or better EPIPE? */ | ||
303 | } | ||
304 | |||
305 | netif_stop_queue(dev->netdev); | ||
306 | atomic_set(&dev->enable_rx, 0); | ||
307 | |||
308 | fsm->state = initial_state; | ||
309 | fsm->param = param; | ||
310 | fsm->result = 0; | ||
311 | |||
312 | INIT_WORK(&fsm->work, sirdev_config_fsm, dev); | ||
313 | queue_work(irda_sir_wq, &fsm->work); | ||
314 | return 0; | ||
315 | } | ||
316 | |||
317 | |||
26 | /***************************************************************************/ | 318 | /***************************************************************************/ |
27 | 319 | ||
28 | void sirdev_enable_rx(struct sir_dev *dev) | 320 | void sirdev_enable_rx(struct sir_dev *dev) |
@@ -619,10 +911,6 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n | |||
619 | spin_lock_init(&dev->tx_lock); | 911 | spin_lock_init(&dev->tx_lock); |
620 | init_MUTEX(&dev->fsm.sem); | 912 | init_MUTEX(&dev->fsm.sem); |
621 | 913 | ||
622 | INIT_LIST_HEAD(&dev->fsm.rq.lh_request); | ||
623 | dev->fsm.rq.pending = 0; | ||
624 | init_timer(&dev->fsm.rq.timer); | ||
625 | |||
626 | dev->drv = drv; | 914 | dev->drv = drv; |
627 | dev->netdev = ndev; | 915 | dev->netdev = ndev; |
628 | 916 | ||
@@ -682,3 +970,22 @@ int sirdev_put_instance(struct sir_dev *dev) | |||
682 | } | 970 | } |
683 | EXPORT_SYMBOL(sirdev_put_instance); | 971 | EXPORT_SYMBOL(sirdev_put_instance); |
684 | 972 | ||
973 | static int __init sir_wq_init(void) | ||
974 | { | ||
975 | irda_sir_wq = create_singlethread_workqueue("irda_sir_wq"); | ||
976 | if (!irda_sir_wq) | ||
977 | return -ENOMEM; | ||
978 | return 0; | ||
979 | } | ||
980 | |||
981 | static void __exit sir_wq_exit(void) | ||
982 | { | ||
983 | destroy_workqueue(irda_sir_wq); | ||
984 | } | ||
985 | |||
986 | module_init(sir_wq_init); | ||
987 | module_exit(sir_wq_exit); | ||
988 | |||
989 | MODULE_AUTHOR("Martin Diehl <info@mdiehl.de>"); | ||
990 | MODULE_DESCRIPTION("IrDA SIR core"); | ||
991 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/net/irda/sir_kthread.c b/drivers/net/irda/sir_kthread.c deleted file mode 100644 index e3904d6bfecd..000000000000 --- a/drivers/net/irda/sir_kthread.c +++ /dev/null | |||
@@ -1,508 +0,0 @@ | |||
1 | /********************************************************************* | ||
2 | * | ||
3 | * sir_kthread.c: dedicated thread to process scheduled | ||
4 | * sir device setup requests | ||
5 | * | ||
6 | * Copyright (c) 2002 Martin Diehl | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License as | ||
10 | * published by the Free Software Foundation; either version 2 of | ||
11 | * the License, or (at your option) any later version. | ||
12 | * | ||
13 | ********************************************************************/ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/version.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/smp_lock.h> | ||
20 | #include <linux/completion.h> | ||
21 | #include <linux/delay.h> | ||
22 | |||
23 | #include <net/irda/irda.h> | ||
24 | |||
25 | #include "sir-dev.h" | ||
26 | |||
27 | /************************************************************************** | ||
28 | * | ||
29 | * kIrDAd kernel thread and config state machine | ||
30 | * | ||
31 | */ | ||
32 | |||
33 | struct irda_request_queue { | ||
34 | struct list_head request_list; | ||
35 | spinlock_t lock; | ||
36 | task_t *thread; | ||
37 | struct completion exit; | ||
38 | wait_queue_head_t kick, done; | ||
39 | atomic_t num_pending; | ||
40 | }; | ||
41 | |||
42 | static struct irda_request_queue irda_rq_queue; | ||
43 | |||
44 | static int irda_queue_request(struct irda_request *rq) | ||
45 | { | ||
46 | int ret = 0; | ||
47 | unsigned long flags; | ||
48 | |||
49 | if (!test_and_set_bit(0, &rq->pending)) { | ||
50 | spin_lock_irqsave(&irda_rq_queue.lock, flags); | ||
51 | list_add_tail(&rq->lh_request, &irda_rq_queue.request_list); | ||
52 | wake_up(&irda_rq_queue.kick); | ||
53 | atomic_inc(&irda_rq_queue.num_pending); | ||
54 | spin_unlock_irqrestore(&irda_rq_queue.lock, flags); | ||
55 | ret = 1; | ||
56 | } | ||
57 | return ret; | ||
58 | } | ||
59 | |||
60 | static void irda_request_timer(unsigned long data) | ||
61 | { | ||
62 | struct irda_request *rq = (struct irda_request *)data; | ||
63 | unsigned long flags; | ||
64 | |||
65 | spin_lock_irqsave(&irda_rq_queue.lock, flags); | ||
66 | list_add_tail(&rq->lh_request, &irda_rq_queue.request_list); | ||
67 | wake_up(&irda_rq_queue.kick); | ||
68 | spin_unlock_irqrestore(&irda_rq_queue.lock, flags); | ||
69 | } | ||
70 | |||
71 | static int irda_queue_delayed_request(struct irda_request *rq, unsigned long delay) | ||
72 | { | ||
73 | int ret = 0; | ||
74 | struct timer_list *timer = &rq->timer; | ||
75 | |||
76 | if (!test_and_set_bit(0, &rq->pending)) { | ||
77 | timer->expires = jiffies + delay; | ||
78 | timer->function = irda_request_timer; | ||
79 | timer->data = (unsigned long)rq; | ||
80 | atomic_inc(&irda_rq_queue.num_pending); | ||
81 | add_timer(timer); | ||
82 | ret = 1; | ||
83 | } | ||
84 | return ret; | ||
85 | } | ||
86 | |||
87 | static void run_irda_queue(void) | ||
88 | { | ||
89 | unsigned long flags; | ||
90 | struct list_head *entry, *tmp; | ||
91 | struct irda_request *rq; | ||
92 | |||
93 | spin_lock_irqsave(&irda_rq_queue.lock, flags); | ||
94 | list_for_each_safe(entry, tmp, &irda_rq_queue.request_list) { | ||
95 | rq = list_entry(entry, struct irda_request, lh_request); | ||
96 | list_del_init(entry); | ||
97 | spin_unlock_irqrestore(&irda_rq_queue.lock, flags); | ||
98 | |||
99 | clear_bit(0, &rq->pending); | ||
100 | rq->func(rq->data); | ||
101 | |||
102 | if (atomic_dec_and_test(&irda_rq_queue.num_pending)) | ||
103 | wake_up(&irda_rq_queue.done); | ||
104 | |||
105 | spin_lock_irqsave(&irda_rq_queue.lock, flags); | ||
106 | } | ||
107 | spin_unlock_irqrestore(&irda_rq_queue.lock, flags); | ||
108 | } | ||
109 | |||
110 | static int irda_thread(void *startup) | ||
111 | { | ||
112 | DECLARE_WAITQUEUE(wait, current); | ||
113 | |||
114 | daemonize("kIrDAd"); | ||
115 | |||
116 | irda_rq_queue.thread = current; | ||
117 | |||
118 | complete((struct completion *)startup); | ||
119 | |||
120 | while (irda_rq_queue.thread != NULL) { | ||
121 | |||
122 | /* We use TASK_INTERRUPTIBLE, rather than | ||
123 | * TASK_UNINTERRUPTIBLE. Andrew Morton made this | ||
124 | * change ; he told me that it is safe, because "signal | ||
125 | * blocking is now handled in daemonize()", he added | ||
126 | * that the problem is that "uninterruptible sleep | ||
127 | * contributes to load average", making user worry. | ||
128 | * Jean II */ | ||
129 | set_task_state(current, TASK_INTERRUPTIBLE); | ||
130 | add_wait_queue(&irda_rq_queue.kick, &wait); | ||
131 | if (list_empty(&irda_rq_queue.request_list)) | ||
132 | schedule(); | ||
133 | else | ||
134 | __set_task_state(current, TASK_RUNNING); | ||
135 | remove_wait_queue(&irda_rq_queue.kick, &wait); | ||
136 | |||
137 | /* make swsusp happy with our thread */ | ||
138 | try_to_freeze(); | ||
139 | |||
140 | run_irda_queue(); | ||
141 | } | ||
142 | |||
143 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,35) | ||
144 | reparent_to_init(); | ||
145 | #endif | ||
146 | complete_and_exit(&irda_rq_queue.exit, 0); | ||
147 | /* never reached */ | ||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | |||
152 | static void flush_irda_queue(void) | ||
153 | { | ||
154 | if (atomic_read(&irda_rq_queue.num_pending)) { | ||
155 | |||
156 | DECLARE_WAITQUEUE(wait, current); | ||
157 | |||
158 | if (!list_empty(&irda_rq_queue.request_list)) | ||
159 | run_irda_queue(); | ||
160 | |||
161 | set_task_state(current, TASK_UNINTERRUPTIBLE); | ||
162 | add_wait_queue(&irda_rq_queue.done, &wait); | ||
163 | if (atomic_read(&irda_rq_queue.num_pending)) | ||
164 | schedule(); | ||
165 | else | ||
166 | __set_task_state(current, TASK_RUNNING); | ||
167 | remove_wait_queue(&irda_rq_queue.done, &wait); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | /* substate handler of the config-fsm to handle the cases where we want | ||
172 | * to wait for transmit completion before changing the port configuration | ||
173 | */ | ||
174 | |||
175 | static int irda_tx_complete_fsm(struct sir_dev *dev) | ||
176 | { | ||
177 | struct sir_fsm *fsm = &dev->fsm; | ||
178 | unsigned next_state, delay; | ||
179 | unsigned bytes_left; | ||
180 | |||
181 | do { | ||
182 | next_state = fsm->substate; /* default: stay in current substate */ | ||
183 | delay = 0; | ||
184 | |||
185 | switch(fsm->substate) { | ||
186 | |||
187 | case SIRDEV_STATE_WAIT_XMIT: | ||
188 | if (dev->drv->chars_in_buffer) | ||
189 | bytes_left = dev->drv->chars_in_buffer(dev); | ||
190 | else | ||
191 | bytes_left = 0; | ||
192 | if (!bytes_left) { | ||
193 | next_state = SIRDEV_STATE_WAIT_UNTIL_SENT; | ||
194 | break; | ||
195 | } | ||
196 | |||
197 | if (dev->speed > 115200) | ||
198 | delay = (bytes_left*8*10000) / (dev->speed/100); | ||
199 | else if (dev->speed > 0) | ||
200 | delay = (bytes_left*10*10000) / (dev->speed/100); | ||
201 | else | ||
202 | delay = 0; | ||
203 | /* expected delay (usec) until remaining bytes are sent */ | ||
204 | if (delay < 100) { | ||
205 | udelay(delay); | ||
206 | delay = 0; | ||
207 | break; | ||
208 | } | ||
209 | /* sleep some longer delay (msec) */ | ||
210 | delay = (delay+999) / 1000; | ||
211 | break; | ||
212 | |||
213 | case SIRDEV_STATE_WAIT_UNTIL_SENT: | ||
214 | /* block until underlaying hardware buffer are empty */ | ||
215 | if (dev->drv->wait_until_sent) | ||
216 | dev->drv->wait_until_sent(dev); | ||
217 | next_state = SIRDEV_STATE_TX_DONE; | ||
218 | break; | ||
219 | |||
220 | case SIRDEV_STATE_TX_DONE: | ||
221 | return 0; | ||
222 | |||
223 | default: | ||
224 | IRDA_ERROR("%s - undefined state\n", __FUNCTION__); | ||
225 | return -EINVAL; | ||
226 | } | ||
227 | fsm->substate = next_state; | ||
228 | } while (delay == 0); | ||
229 | return delay; | ||
230 | } | ||
231 | |||
232 | /* | ||
233 | * Function irda_config_fsm | ||
234 | * | ||
235 | * State machine to handle the configuration of the device (and attached dongle, if any). | ||
236 | * This handler is scheduled for execution in kIrDAd context, so we can sleep. | ||
237 | * however, kIrDAd is shared by all sir_dev devices so we better don't sleep there too | ||
238 | * long. Instead, for longer delays we start a timer to reschedule us later. | ||
239 | * On entry, fsm->sem is always locked and the netdev xmit queue stopped. | ||
240 | * Both must be unlocked/restarted on completion - but only on final exit. | ||
241 | */ | ||
242 | |||
243 | static void irda_config_fsm(void *data) | ||
244 | { | ||
245 | struct sir_dev *dev = data; | ||
246 | struct sir_fsm *fsm = &dev->fsm; | ||
247 | int next_state; | ||
248 | int ret = -1; | ||
249 | unsigned delay; | ||
250 | |||
251 | IRDA_DEBUG(2, "%s(), <%ld>\n", __FUNCTION__, jiffies); | ||
252 | |||
253 | do { | ||
254 | IRDA_DEBUG(3, "%s - state=0x%04x / substate=0x%04x\n", | ||
255 | __FUNCTION__, fsm->state, fsm->substate); | ||
256 | |||
257 | next_state = fsm->state; | ||
258 | delay = 0; | ||
259 | |||
260 | switch(fsm->state) { | ||
261 | |||
262 | case SIRDEV_STATE_DONGLE_OPEN: | ||
263 | if (dev->dongle_drv != NULL) { | ||
264 | ret = sirdev_put_dongle(dev); | ||
265 | if (ret) { | ||
266 | fsm->result = -EINVAL; | ||
267 | next_state = SIRDEV_STATE_ERROR; | ||
268 | break; | ||
269 | } | ||
270 | } | ||
271 | |||
272 | /* Initialize dongle */ | ||
273 | ret = sirdev_get_dongle(dev, fsm->param); | ||
274 | if (ret) { | ||
275 | fsm->result = ret; | ||
276 | next_state = SIRDEV_STATE_ERROR; | ||
277 | break; | ||
278 | } | ||
279 | |||
280 | /* Dongles are powered through the modem control lines which | ||
281 | * were just set during open. Before resetting, let's wait for | ||
282 | * the power to stabilize. This is what some dongle drivers did | ||
283 | * in open before, while others didn't - should be safe anyway. | ||
284 | */ | ||
285 | |||
286 | delay = 50; | ||
287 | fsm->substate = SIRDEV_STATE_DONGLE_RESET; | ||
288 | next_state = SIRDEV_STATE_DONGLE_RESET; | ||
289 | |||
290 | fsm->param = 9600; | ||
291 | |||
292 | break; | ||
293 | |||
294 | case SIRDEV_STATE_DONGLE_CLOSE: | ||
295 | /* shouldn't we just treat this as success=? */ | ||
296 | if (dev->dongle_drv == NULL) { | ||
297 | fsm->result = -EINVAL; | ||
298 | next_state = SIRDEV_STATE_ERROR; | ||
299 | break; | ||
300 | } | ||
301 | |||
302 | ret = sirdev_put_dongle(dev); | ||
303 | if (ret) { | ||
304 | fsm->result = ret; | ||
305 | next_state = SIRDEV_STATE_ERROR; | ||
306 | break; | ||
307 | } | ||
308 | next_state = SIRDEV_STATE_DONE; | ||
309 | break; | ||
310 | |||
311 | case SIRDEV_STATE_SET_DTR_RTS: | ||
312 | ret = sirdev_set_dtr_rts(dev, | ||
313 | (fsm->param&0x02) ? TRUE : FALSE, | ||
314 | (fsm->param&0x01) ? TRUE : FALSE); | ||
315 | next_state = SIRDEV_STATE_DONE; | ||
316 | break; | ||
317 | |||
318 | case SIRDEV_STATE_SET_SPEED: | ||
319 | fsm->substate = SIRDEV_STATE_WAIT_XMIT; | ||
320 | next_state = SIRDEV_STATE_DONGLE_CHECK; | ||
321 | break; | ||
322 | |||
323 | case SIRDEV_STATE_DONGLE_CHECK: | ||
324 | ret = irda_tx_complete_fsm(dev); | ||
325 | if (ret < 0) { | ||
326 | fsm->result = ret; | ||
327 | next_state = SIRDEV_STATE_ERROR; | ||
328 | break; | ||
329 | } | ||
330 | if ((delay=ret) != 0) | ||
331 | break; | ||
332 | |||
333 | if (dev->dongle_drv) { | ||
334 | fsm->substate = SIRDEV_STATE_DONGLE_RESET; | ||
335 | next_state = SIRDEV_STATE_DONGLE_RESET; | ||
336 | } | ||
337 | else { | ||
338 | dev->speed = fsm->param; | ||
339 | next_state = SIRDEV_STATE_PORT_SPEED; | ||
340 | } | ||
341 | break; | ||
342 | |||
343 | case SIRDEV_STATE_DONGLE_RESET: | ||
344 | if (dev->dongle_drv->reset) { | ||
345 | ret = dev->dongle_drv->reset(dev); | ||
346 | if (ret < 0) { | ||
347 | fsm->result = ret; | ||
348 | next_state = SIRDEV_STATE_ERROR; | ||
349 | break; | ||
350 | } | ||
351 | } | ||
352 | else | ||
353 | ret = 0; | ||
354 | if ((delay=ret) == 0) { | ||
355 | /* set serial port according to dongle default speed */ | ||
356 | if (dev->drv->set_speed) | ||
357 | dev->drv->set_speed(dev, dev->speed); | ||
358 | fsm->substate = SIRDEV_STATE_DONGLE_SPEED; | ||
359 | next_state = SIRDEV_STATE_DONGLE_SPEED; | ||
360 | } | ||
361 | break; | ||
362 | |||
363 | case SIRDEV_STATE_DONGLE_SPEED: | ||
364 | if (dev->dongle_drv->reset) { | ||
365 | ret = dev->dongle_drv->set_speed(dev, fsm->param); | ||
366 | if (ret < 0) { | ||
367 | fsm->result = ret; | ||
368 | next_state = SIRDEV_STATE_ERROR; | ||
369 | break; | ||
370 | } | ||
371 | } | ||
372 | else | ||
373 | ret = 0; | ||
374 | if ((delay=ret) == 0) | ||
375 | next_state = SIRDEV_STATE_PORT_SPEED; | ||
376 | break; | ||
377 | |||
378 | case SIRDEV_STATE_PORT_SPEED: | ||
379 | /* Finally we are ready to change the serial port speed */ | ||
380 | if (dev->drv->set_speed) | ||
381 | dev->drv->set_speed(dev, dev->speed); | ||
382 | dev->new_speed = 0; | ||
383 | next_state = SIRDEV_STATE_DONE; | ||
384 | break; | ||
385 | |||
386 | case SIRDEV_STATE_DONE: | ||
387 | /* Signal network layer so it can send more frames */ | ||
388 | netif_wake_queue(dev->netdev); | ||
389 | next_state = SIRDEV_STATE_COMPLETE; | ||
390 | break; | ||
391 | |||
392 | default: | ||
393 | IRDA_ERROR("%s - undefined state\n", __FUNCTION__); | ||
394 | fsm->result = -EINVAL; | ||
395 | /* fall thru */ | ||
396 | |||
397 | case SIRDEV_STATE_ERROR: | ||
398 | IRDA_ERROR("%s - error: %d\n", __FUNCTION__, fsm->result); | ||
399 | |||
400 | #if 0 /* don't enable this before we have netdev->tx_timeout to recover */ | ||
401 | netif_stop_queue(dev->netdev); | ||
402 | #else | ||
403 | netif_wake_queue(dev->netdev); | ||
404 | #endif | ||
405 | /* fall thru */ | ||
406 | |||
407 | case SIRDEV_STATE_COMPLETE: | ||
408 | /* config change finished, so we are not busy any longer */ | ||
409 | sirdev_enable_rx(dev); | ||
410 | up(&fsm->sem); | ||
411 | return; | ||
412 | } | ||
413 | fsm->state = next_state; | ||
414 | } while(!delay); | ||
415 | |||
416 | irda_queue_delayed_request(&fsm->rq, msecs_to_jiffies(delay)); | ||
417 | } | ||
418 | |||
419 | /* schedule some device configuration task for execution by kIrDAd | ||
420 | * on behalf of the above state machine. | ||
421 | * can be called from process or interrupt/tasklet context. | ||
422 | */ | ||
423 | |||
424 | int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned param) | ||
425 | { | ||
426 | struct sir_fsm *fsm = &dev->fsm; | ||
427 | int xmit_was_down; | ||
428 | |||
429 | IRDA_DEBUG(2, "%s - state=0x%04x / param=%u\n", __FUNCTION__, initial_state, param); | ||
430 | |||
431 | if (down_trylock(&fsm->sem)) { | ||
432 | if (in_interrupt() || in_atomic() || irqs_disabled()) { | ||
433 | IRDA_DEBUG(1, "%s(), state machine busy!\n", __FUNCTION__); | ||
434 | return -EWOULDBLOCK; | ||
435 | } else | ||
436 | down(&fsm->sem); | ||
437 | } | ||
438 | |||
439 | if (fsm->state == SIRDEV_STATE_DEAD) { | ||
440 | /* race with sirdev_close should never happen */ | ||
441 | IRDA_ERROR("%s(), instance staled!\n", __FUNCTION__); | ||
442 | up(&fsm->sem); | ||
443 | return -ESTALE; /* or better EPIPE? */ | ||
444 | } | ||
445 | |||
446 | xmit_was_down = netif_queue_stopped(dev->netdev); | ||
447 | netif_stop_queue(dev->netdev); | ||
448 | atomic_set(&dev->enable_rx, 0); | ||
449 | |||
450 | fsm->state = initial_state; | ||
451 | fsm->param = param; | ||
452 | fsm->result = 0; | ||
453 | |||
454 | INIT_LIST_HEAD(&fsm->rq.lh_request); | ||
455 | fsm->rq.pending = 0; | ||
456 | fsm->rq.func = irda_config_fsm; | ||
457 | fsm->rq.data = dev; | ||
458 | |||
459 | if (!irda_queue_request(&fsm->rq)) { /* returns 0 on error! */ | ||
460 | atomic_set(&dev->enable_rx, 1); | ||
461 | if (!xmit_was_down) | ||
462 | netif_wake_queue(dev->netdev); | ||
463 | up(&fsm->sem); | ||
464 | return -EAGAIN; | ||
465 | } | ||
466 | return 0; | ||
467 | } | ||
468 | |||
469 | static int __init irda_thread_create(void) | ||
470 | { | ||
471 | struct completion startup; | ||
472 | int pid; | ||
473 | |||
474 | spin_lock_init(&irda_rq_queue.lock); | ||
475 | irda_rq_queue.thread = NULL; | ||
476 | INIT_LIST_HEAD(&irda_rq_queue.request_list); | ||
477 | init_waitqueue_head(&irda_rq_queue.kick); | ||
478 | init_waitqueue_head(&irda_rq_queue.done); | ||
479 | atomic_set(&irda_rq_queue.num_pending, 0); | ||
480 | |||
481 | init_completion(&startup); | ||
482 | pid = kernel_thread(irda_thread, &startup, CLONE_FS|CLONE_FILES); | ||
483 | if (pid <= 0) | ||
484 | return -EAGAIN; | ||
485 | else | ||
486 | wait_for_completion(&startup); | ||
487 | |||
488 | return 0; | ||
489 | } | ||
490 | |||
491 | static void __exit irda_thread_join(void) | ||
492 | { | ||
493 | if (irda_rq_queue.thread) { | ||
494 | flush_irda_queue(); | ||
495 | init_completion(&irda_rq_queue.exit); | ||
496 | irda_rq_queue.thread = NULL; | ||
497 | wake_up(&irda_rq_queue.kick); | ||
498 | wait_for_completion(&irda_rq_queue.exit); | ||
499 | } | ||
500 | } | ||
501 | |||
502 | module_init(irda_thread_create); | ||
503 | module_exit(irda_thread_join); | ||
504 | |||
505 | MODULE_AUTHOR("Martin Diehl <info@mdiehl.de>"); | ||
506 | MODULE_DESCRIPTION("IrDA SIR core"); | ||
507 | MODULE_LICENSE("GPL"); | ||
508 | |||
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c index 58f76cefbc83..a4674044bd6f 100644 --- a/drivers/net/irda/smsc-ircc2.c +++ b/drivers/net/irda/smsc-ircc2.c | |||
@@ -54,6 +54,7 @@ | |||
54 | #include <linux/rtnetlink.h> | 54 | #include <linux/rtnetlink.h> |
55 | #include <linux/serial_reg.h> | 55 | #include <linux/serial_reg.h> |
56 | #include <linux/dma-mapping.h> | 56 | #include <linux/dma-mapping.h> |
57 | #include <linux/pnp.h> | ||
57 | #include <linux/platform_device.h> | 58 | #include <linux/platform_device.h> |
58 | 59 | ||
59 | #include <asm/io.h> | 60 | #include <asm/io.h> |
@@ -358,6 +359,16 @@ static inline void register_bank(int iobase, int bank) | |||
358 | iobase + IRCC_MASTER); | 359 | iobase + IRCC_MASTER); |
359 | } | 360 | } |
360 | 361 | ||
362 | #ifdef CONFIG_PNP | ||
363 | /* PNP hotplug support */ | ||
364 | static const struct pnp_device_id smsc_ircc_pnp_table[] = { | ||
365 | { .id = "SMCf010", .driver_data = 0 }, | ||
366 | /* and presumably others */ | ||
367 | { } | ||
368 | }; | ||
369 | MODULE_DEVICE_TABLE(pnp, smsc_ircc_pnp_table); | ||
370 | #endif | ||
371 | |||
361 | 372 | ||
362 | /******************************************************************************* | 373 | /******************************************************************************* |
363 | * | 374 | * |
@@ -2072,7 +2083,8 @@ static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self) | |||
2072 | 2083 | ||
2073 | /* PROBING | 2084 | /* PROBING |
2074 | * | 2085 | * |
2075 | * | 2086 | * REVISIT we can be told about the device by PNP, and should use that info |
2087 | * instead of probing hardware and creating a platform_device ... | ||
2076 | */ | 2088 | */ |
2077 | 2089 | ||
2078 | static int __init smsc_ircc_look_for_chips(void) | 2090 | static int __init smsc_ircc_look_for_chips(void) |
diff --git a/drivers/net/ne.c b/drivers/net/ne.c index 93c494bcd18d..b32765215f75 100644 --- a/drivers/net/ne.c +++ b/drivers/net/ne.c | |||
@@ -139,8 +139,9 @@ bad_clone_list[] __initdata = { | |||
139 | 139 | ||
140 | #if defined(CONFIG_PLAT_MAPPI) | 140 | #if defined(CONFIG_PLAT_MAPPI) |
141 | # define DCR_VAL 0x4b | 141 | # define DCR_VAL 0x4b |
142 | #elif defined(CONFIG_PLAT_OAKS32R) | 142 | #elif defined(CONFIG_PLAT_OAKS32R) || \ |
143 | # define DCR_VAL 0x48 | 143 | defined(CONFIG_TOSHIBA_RBTX4927) || defined(CONFIG_TOSHIBA_RBTX4938) |
144 | # define DCR_VAL 0x48 /* 8-bit mode */ | ||
144 | #else | 145 | #else |
145 | # define DCR_VAL 0x49 | 146 | # define DCR_VAL 0x49 |
146 | #endif | 147 | #endif |
@@ -396,10 +397,22 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr) | |||
396 | /* We must set the 8390 for word mode. */ | 397 | /* We must set the 8390 for word mode. */ |
397 | outb_p(DCR_VAL, ioaddr + EN0_DCFG); | 398 | outb_p(DCR_VAL, ioaddr + EN0_DCFG); |
398 | start_page = NESM_START_PG; | 399 | start_page = NESM_START_PG; |
399 | stop_page = NESM_STOP_PG; | 400 | |
401 | /* | ||
402 | * Realtek RTL8019AS datasheet says that the PSTOP register | ||
403 | * shouldn't exceed 0x60 in 8-bit mode. | ||
404 | * This chip can be identified by reading the signature from | ||
405 | * the remote byte count registers (otherwise write-only)... | ||
406 | */ | ||
407 | if ((DCR_VAL & 0x01) == 0 && /* 8-bit mode */ | ||
408 | inb(ioaddr + EN0_RCNTLO) == 0x50 && | ||
409 | inb(ioaddr + EN0_RCNTHI) == 0x70) | ||
410 | stop_page = 0x60; | ||
411 | else | ||
412 | stop_page = NESM_STOP_PG; | ||
400 | } else { | 413 | } else { |
401 | start_page = NE1SM_START_PG; | 414 | start_page = NE1SM_START_PG; |
402 | stop_page = NE1SM_STOP_PG; | 415 | stop_page = NE1SM_STOP_PG; |
403 | } | 416 | } |
404 | 417 | ||
405 | #if defined(CONFIG_PLAT_MAPPI) || defined(CONFIG_PLAT_OAKS32R) | 418 | #if defined(CONFIG_PLAT_MAPPI) || defined(CONFIG_PLAT_OAKS32R) |
@@ -509,15 +522,9 @@ static int __init ne_probe1(struct net_device *dev, int ioaddr) | |||
509 | ei_status.name = name; | 522 | ei_status.name = name; |
510 | ei_status.tx_start_page = start_page; | 523 | ei_status.tx_start_page = start_page; |
511 | ei_status.stop_page = stop_page; | 524 | ei_status.stop_page = stop_page; |
512 | #if defined(CONFIG_TOSHIBA_RBTX4927) || defined(CONFIG_TOSHIBA_RBTX4938) | ||
513 | wordlength = 1; | ||
514 | #endif | ||
515 | 525 | ||
516 | #ifdef CONFIG_PLAT_OAKS32R | 526 | /* Use 16-bit mode only if this wasn't overridden by DCR_VAL */ |
517 | ei_status.word16 = 0; | 527 | ei_status.word16 = (wordlength == 2 && (DCR_VAL & 0x01)); |
518 | #else | ||
519 | ei_status.word16 = (wordlength == 2); | ||
520 | #endif | ||
521 | 528 | ||
522 | ei_status.rx_start_page = start_page + TX_PAGES; | 529 | ei_status.rx_start_page = start_page + TX_PAGES; |
523 | #ifdef PACKETBUF_MEMSIZE | 530 | #ifdef PACKETBUF_MEMSIZE |
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 459443b572ce..1b236bdf6b92 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c | |||
@@ -60,8 +60,10 @@ int mdiobus_register(struct mii_bus *bus) | |||
60 | for (i = 0; i < PHY_MAX_ADDR; i++) { | 60 | for (i = 0; i < PHY_MAX_ADDR; i++) { |
61 | struct phy_device *phydev; | 61 | struct phy_device *phydev; |
62 | 62 | ||
63 | if (bus->phy_mask & (1 << i)) | 63 | if (bus->phy_mask & (1 << i)) { |
64 | bus->phy_map[i] = NULL; | ||
64 | continue; | 65 | continue; |
66 | } | ||
65 | 67 | ||
66 | phydev = get_phy_device(bus, i); | 68 | phydev = get_phy_device(bus, i); |
67 | 69 | ||
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c index b82191d2bee1..f5a3bf4d959a 100644 --- a/drivers/net/sis900.c +++ b/drivers/net/sis900.c | |||
@@ -127,6 +127,7 @@ static const struct mii_chip_info { | |||
127 | } mii_chip_table[] = { | 127 | } mii_chip_table[] = { |
128 | { "SiS 900 Internal MII PHY", 0x001d, 0x8000, LAN }, | 128 | { "SiS 900 Internal MII PHY", 0x001d, 0x8000, LAN }, |
129 | { "SiS 7014 Physical Layer Solution", 0x0016, 0xf830, LAN }, | 129 | { "SiS 7014 Physical Layer Solution", 0x0016, 0xf830, LAN }, |
130 | { "SiS 900 on Foxconn 661 7MI", 0x0143, 0xBC70, LAN }, | ||
130 | { "Altimata AC101LF PHY", 0x0022, 0x5520, LAN }, | 131 | { "Altimata AC101LF PHY", 0x0022, 0x5520, LAN }, |
131 | { "ADM 7001 LAN PHY", 0x002e, 0xcc60, LAN }, | 132 | { "ADM 7001 LAN PHY", 0x002e, 0xcc60, LAN }, |
132 | { "AMD 79C901 10BASE-T PHY", 0x0000, 0x6B70, LAN }, | 133 | { "AMD 79C901 10BASE-T PHY", 0x0000, 0x6B70, LAN }, |
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 227df9876a2c..ffd267fab21d 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -51,7 +51,7 @@ | |||
51 | #include "sky2.h" | 51 | #include "sky2.h" |
52 | 52 | ||
53 | #define DRV_NAME "sky2" | 53 | #define DRV_NAME "sky2" |
54 | #define DRV_VERSION "1.2" | 54 | #define DRV_VERSION "1.3" |
55 | #define PFX DRV_NAME " " | 55 | #define PFX DRV_NAME " " |
56 | 56 | ||
57 | /* | 57 | /* |
@@ -79,6 +79,8 @@ | |||
79 | #define NAPI_WEIGHT 64 | 79 | #define NAPI_WEIGHT 64 |
80 | #define PHY_RETRIES 1000 | 80 | #define PHY_RETRIES 1000 |
81 | 81 | ||
82 | #define RING_NEXT(x,s) (((x)+1) & ((s)-1)) | ||
83 | |||
82 | static const u32 default_msg = | 84 | static const u32 default_msg = |
83 | NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | 85 | NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK |
84 | | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR | 86 | | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR |
@@ -96,6 +98,10 @@ static int disable_msi = 0; | |||
96 | module_param(disable_msi, int, 0); | 98 | module_param(disable_msi, int, 0); |
97 | MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)"); | 99 | MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)"); |
98 | 100 | ||
101 | static int idle_timeout = 100; | ||
102 | module_param(idle_timeout, int, 0); | ||
103 | MODULE_PARM_DESC(idle_timeout, "Idle timeout workaround for lost interrupts (ms)"); | ||
104 | |||
99 | static const struct pci_device_id sky2_id_table[] = { | 105 | static const struct pci_device_id sky2_id_table[] = { |
100 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, | 106 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, |
101 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, | 107 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, |
@@ -122,6 +128,7 @@ MODULE_DEVICE_TABLE(pci, sky2_id_table); | |||
122 | /* Avoid conditionals by using array */ | 128 | /* Avoid conditionals by using array */ |
123 | static const unsigned txqaddr[] = { Q_XA1, Q_XA2 }; | 129 | static const unsigned txqaddr[] = { Q_XA1, Q_XA2 }; |
124 | static const unsigned rxqaddr[] = { Q_R1, Q_R2 }; | 130 | static const unsigned rxqaddr[] = { Q_R1, Q_R2 }; |
131 | static const u32 portirq_msk[] = { Y2_IS_PORT_1, Y2_IS_PORT_2 }; | ||
125 | 132 | ||
126 | /* This driver supports yukon2 chipset only */ | 133 | /* This driver supports yukon2 chipset only */ |
127 | static const char *yukon2_name[] = { | 134 | static const char *yukon2_name[] = { |
@@ -298,7 +305,8 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
298 | struct sky2_port *sky2 = netdev_priv(hw->dev[port]); | 305 | struct sky2_port *sky2 = netdev_priv(hw->dev[port]); |
299 | u16 ctrl, ct1000, adv, pg, ledctrl, ledover; | 306 | u16 ctrl, ct1000, adv, pg, ledctrl, ledover; |
300 | 307 | ||
301 | if (sky2->autoneg == AUTONEG_ENABLE && hw->chip_id != CHIP_ID_YUKON_XL) { | 308 | if (sky2->autoneg == AUTONEG_ENABLE && |
309 | (hw->chip_id != CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U)) { | ||
302 | u16 ectrl = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL); | 310 | u16 ectrl = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL); |
303 | 311 | ||
304 | ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK | | 312 | ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK | |
@@ -326,7 +334,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
326 | ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO); | 334 | ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO); |
327 | 335 | ||
328 | if (sky2->autoneg == AUTONEG_ENABLE && | 336 | if (sky2->autoneg == AUTONEG_ENABLE && |
329 | hw->chip_id == CHIP_ID_YUKON_XL) { | 337 | (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U)) { |
330 | ctrl &= ~PHY_M_PC_DSC_MSK; | 338 | ctrl &= ~PHY_M_PC_DSC_MSK; |
331 | ctrl |= PHY_M_PC_DSC(2) | PHY_M_PC_DOWN_S_ENA; | 339 | ctrl |= PHY_M_PC_DSC(2) | PHY_M_PC_DOWN_S_ENA; |
332 | } | 340 | } |
@@ -442,10 +450,11 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
442 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); | 450 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); |
443 | 451 | ||
444 | /* set LED Function Control register */ | 452 | /* set LED Function Control register */ |
445 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ | 453 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, |
446 | PHY_M_LEDC_INIT_CTRL(7) | /* 10 Mbps */ | 454 | (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ |
447 | PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */ | 455 | PHY_M_LEDC_INIT_CTRL(7) | /* 10 Mbps */ |
448 | PHY_M_LEDC_STA0_CTRL(7))); /* 1000 Mbps */ | 456 | PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */ |
457 | PHY_M_LEDC_STA0_CTRL(7))); /* 1000 Mbps */ | ||
449 | 458 | ||
450 | /* set Polarity Control register */ | 459 | /* set Polarity Control register */ |
451 | gm_phy_write(hw, port, PHY_MARV_PHY_STAT, | 460 | gm_phy_write(hw, port, PHY_MARV_PHY_STAT, |
@@ -459,6 +468,25 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
459 | /* restore page register */ | 468 | /* restore page register */ |
460 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); | 469 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); |
461 | break; | 470 | break; |
471 | case CHIP_ID_YUKON_EC_U: | ||
472 | pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); | ||
473 | |||
474 | /* select page 3 to access LED control register */ | ||
475 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); | ||
476 | |||
477 | /* set LED Function Control register */ | ||
478 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, | ||
479 | (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ | ||
480 | PHY_M_LEDC_INIT_CTRL(8) | /* 10 Mbps */ | ||
481 | PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */ | ||
482 | PHY_M_LEDC_STA0_CTRL(7)));/* 1000 Mbps */ | ||
483 | |||
484 | /* set Blink Rate in LED Timer Control Register */ | ||
485 | gm_phy_write(hw, port, PHY_MARV_INT_MASK, | ||
486 | ledctrl | PHY_M_LED_BLINK_RT(BLINK_84MS)); | ||
487 | /* restore page register */ | ||
488 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); | ||
489 | break; | ||
462 | 490 | ||
463 | default: | 491 | default: |
464 | /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */ | 492 | /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */ |
@@ -467,19 +495,21 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
467 | ledover |= PHY_M_LED_MO_RX(MO_LED_OFF); | 495 | ledover |= PHY_M_LED_MO_RX(MO_LED_OFF); |
468 | } | 496 | } |
469 | 497 | ||
470 | if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev >= 2) { | 498 | if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == CHIP_REV_YU_EC_A1) { |
471 | /* apply fixes in PHY AFE */ | 499 | /* apply fixes in PHY AFE */ |
472 | gm_phy_write(hw, port, 22, 255); | 500 | pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); |
501 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 255); | ||
502 | |||
473 | /* increase differential signal amplitude in 10BASE-T */ | 503 | /* increase differential signal amplitude in 10BASE-T */ |
474 | gm_phy_write(hw, port, 24, 0xaa99); | 504 | gm_phy_write(hw, port, 0x18, 0xaa99); |
475 | gm_phy_write(hw, port, 23, 0x2011); | 505 | gm_phy_write(hw, port, 0x17, 0x2011); |
476 | 506 | ||
477 | /* fix for IEEE A/B Symmetry failure in 1000BASE-T */ | 507 | /* fix for IEEE A/B Symmetry failure in 1000BASE-T */ |
478 | gm_phy_write(hw, port, 24, 0xa204); | 508 | gm_phy_write(hw, port, 0x18, 0xa204); |
479 | gm_phy_write(hw, port, 23, 0x2002); | 509 | gm_phy_write(hw, port, 0x17, 0x2002); |
480 | 510 | ||
481 | /* set page register to 0 */ | 511 | /* set page register to 0 */ |
482 | gm_phy_write(hw, port, 22, 0); | 512 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); |
483 | } else { | 513 | } else { |
484 | gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); | 514 | gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); |
485 | 515 | ||
@@ -553,6 +583,11 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) | |||
553 | 583 | ||
554 | if (sky2->duplex == DUPLEX_FULL) | 584 | if (sky2->duplex == DUPLEX_FULL) |
555 | reg |= GM_GPCR_DUP_FULL; | 585 | reg |= GM_GPCR_DUP_FULL; |
586 | |||
587 | /* turn off pause in 10/100mbps half duplex */ | ||
588 | else if (sky2->speed != SPEED_1000 && | ||
589 | hw->chip_id != CHIP_ID_YUKON_EC_U) | ||
590 | sky2->tx_pause = sky2->rx_pause = 0; | ||
556 | } else | 591 | } else |
557 | reg = GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100 | GM_GPCR_DUP_FULL; | 592 | reg = GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100 | GM_GPCR_DUP_FULL; |
558 | 593 | ||
@@ -719,7 +754,7 @@ static inline struct sky2_tx_le *get_tx_le(struct sky2_port *sky2) | |||
719 | { | 754 | { |
720 | struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod; | 755 | struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod; |
721 | 756 | ||
722 | sky2->tx_prod = (sky2->tx_prod + 1) % TX_RING_SIZE; | 757 | sky2->tx_prod = RING_NEXT(sky2->tx_prod, TX_RING_SIZE); |
723 | return le; | 758 | return le; |
724 | } | 759 | } |
725 | 760 | ||
@@ -735,7 +770,7 @@ static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx) | |||
735 | static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) | 770 | static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) |
736 | { | 771 | { |
737 | struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put; | 772 | struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put; |
738 | sky2->rx_put = (sky2->rx_put + 1) % RX_LE_SIZE; | 773 | sky2->rx_put = RING_NEXT(sky2->rx_put, RX_LE_SIZE); |
739 | return le; | 774 | return le; |
740 | } | 775 | } |
741 | 776 | ||
@@ -1050,7 +1085,7 @@ static int sky2_up(struct net_device *dev) | |||
1050 | 1085 | ||
1051 | /* Enable interrupts from phy/mac for port */ | 1086 | /* Enable interrupts from phy/mac for port */ |
1052 | imask = sky2_read32(hw, B0_IMSK); | 1087 | imask = sky2_read32(hw, B0_IMSK); |
1053 | imask |= (port == 0) ? Y2_IS_PORT_1 : Y2_IS_PORT_2; | 1088 | imask |= portirq_msk[port]; |
1054 | sky2_write32(hw, B0_IMSK, imask); | 1089 | sky2_write32(hw, B0_IMSK, imask); |
1055 | 1090 | ||
1056 | return 0; | 1091 | return 0; |
@@ -1078,7 +1113,7 @@ err_out: | |||
1078 | /* Modular subtraction in ring */ | 1113 | /* Modular subtraction in ring */ |
1079 | static inline int tx_dist(unsigned tail, unsigned head) | 1114 | static inline int tx_dist(unsigned tail, unsigned head) |
1080 | { | 1115 | { |
1081 | return (head - tail) % TX_RING_SIZE; | 1116 | return (head - tail) & (TX_RING_SIZE - 1); |
1082 | } | 1117 | } |
1083 | 1118 | ||
1084 | /* Number of list elements available for next tx */ | 1119 | /* Number of list elements available for next tx */ |
@@ -1255,7 +1290,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) | |||
1255 | le->opcode = OP_BUFFER | HW_OWNER; | 1290 | le->opcode = OP_BUFFER | HW_OWNER; |
1256 | 1291 | ||
1257 | fre = sky2->tx_ring | 1292 | fre = sky2->tx_ring |
1258 | + ((re - sky2->tx_ring) + i + 1) % TX_RING_SIZE; | 1293 | + RING_NEXT((re - sky2->tx_ring) + i, TX_RING_SIZE); |
1259 | pci_unmap_addr_set(fre, mapaddr, mapping); | 1294 | pci_unmap_addr_set(fre, mapaddr, mapping); |
1260 | } | 1295 | } |
1261 | 1296 | ||
@@ -1315,7 +1350,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) | |||
1315 | 1350 | ||
1316 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 1351 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
1317 | struct tx_ring_info *fre; | 1352 | struct tx_ring_info *fre; |
1318 | fre = sky2->tx_ring + (put + i + 1) % TX_RING_SIZE; | 1353 | fre = sky2->tx_ring + RING_NEXT(put + i, TX_RING_SIZE); |
1319 | pci_unmap_page(pdev, pci_unmap_addr(fre, mapaddr), | 1354 | pci_unmap_page(pdev, pci_unmap_addr(fre, mapaddr), |
1320 | skb_shinfo(skb)->frags[i].size, | 1355 | skb_shinfo(skb)->frags[i].size, |
1321 | PCI_DMA_TODEVICE); | 1356 | PCI_DMA_TODEVICE); |
@@ -1401,7 +1436,7 @@ static int sky2_down(struct net_device *dev) | |||
1401 | 1436 | ||
1402 | /* Disable port IRQ */ | 1437 | /* Disable port IRQ */ |
1403 | imask = sky2_read32(hw, B0_IMSK); | 1438 | imask = sky2_read32(hw, B0_IMSK); |
1404 | imask &= ~(sky2->port == 0) ? Y2_IS_PORT_1 : Y2_IS_PORT_2; | 1439 | imask &= ~portirq_msk[port]; |
1405 | sky2_write32(hw, B0_IMSK, imask); | 1440 | sky2_write32(hw, B0_IMSK, imask); |
1406 | 1441 | ||
1407 | /* turn off LED's */ | 1442 | /* turn off LED's */ |
@@ -1498,17 +1533,26 @@ static void sky2_link_up(struct sky2_port *sky2) | |||
1498 | sky2_write8(hw, SK_REG(port, LNK_LED_REG), | 1533 | sky2_write8(hw, SK_REG(port, LNK_LED_REG), |
1499 | LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF); | 1534 | LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF); |
1500 | 1535 | ||
1501 | if (hw->chip_id == CHIP_ID_YUKON_XL) { | 1536 | if (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U) { |
1502 | u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); | 1537 | u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); |
1538 | u16 led = PHY_M_LEDC_LOS_CTRL(1); /* link active */ | ||
1539 | |||
1540 | switch(sky2->speed) { | ||
1541 | case SPEED_10: | ||
1542 | led |= PHY_M_LEDC_INIT_CTRL(7); | ||
1543 | break; | ||
1544 | |||
1545 | case SPEED_100: | ||
1546 | led |= PHY_M_LEDC_STA1_CTRL(7); | ||
1547 | break; | ||
1548 | |||
1549 | case SPEED_1000: | ||
1550 | led |= PHY_M_LEDC_STA0_CTRL(7); | ||
1551 | break; | ||
1552 | } | ||
1503 | 1553 | ||
1504 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); | 1554 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); |
1505 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ | 1555 | gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, led); |
1506 | PHY_M_LEDC_INIT_CTRL(sky2->speed == | ||
1507 | SPEED_10 ? 7 : 0) | | ||
1508 | PHY_M_LEDC_STA1_CTRL(sky2->speed == | ||
1509 | SPEED_100 ? 7 : 0) | | ||
1510 | PHY_M_LEDC_STA0_CTRL(sky2->speed == | ||
1511 | SPEED_1000 ? 7 : 0)); | ||
1512 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); | 1556 | gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); |
1513 | } | 1557 | } |
1514 | 1558 | ||
@@ -1583,7 +1627,7 @@ static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux) | |||
1583 | sky2->speed = sky2_phy_speed(hw, aux); | 1627 | sky2->speed = sky2_phy_speed(hw, aux); |
1584 | 1628 | ||
1585 | /* Pause bits are offset (9..8) */ | 1629 | /* Pause bits are offset (9..8) */ |
1586 | if (hw->chip_id == CHIP_ID_YUKON_XL) | 1630 | if (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U) |
1587 | aux >>= 6; | 1631 | aux >>= 6; |
1588 | 1632 | ||
1589 | sky2->rx_pause = (aux & PHY_M_PS_RX_P_EN) != 0; | 1633 | sky2->rx_pause = (aux & PHY_M_PS_RX_P_EN) != 0; |
@@ -1859,35 +1903,28 @@ static inline void sky2_tx_done(struct net_device *dev, u16 last) | |||
1859 | static int sky2_status_intr(struct sky2_hw *hw, int to_do) | 1903 | static int sky2_status_intr(struct sky2_hw *hw, int to_do) |
1860 | { | 1904 | { |
1861 | int work_done = 0; | 1905 | int work_done = 0; |
1906 | u16 hwidx = sky2_read16(hw, STAT_PUT_IDX); | ||
1862 | 1907 | ||
1863 | rmb(); | 1908 | rmb(); |
1864 | 1909 | ||
1865 | for(;;) { | 1910 | while (hw->st_idx != hwidx) { |
1866 | struct sky2_status_le *le = hw->st_le + hw->st_idx; | 1911 | struct sky2_status_le *le = hw->st_le + hw->st_idx; |
1867 | struct net_device *dev; | 1912 | struct net_device *dev; |
1868 | struct sky2_port *sky2; | 1913 | struct sky2_port *sky2; |
1869 | struct sk_buff *skb; | 1914 | struct sk_buff *skb; |
1870 | u32 status; | 1915 | u32 status; |
1871 | u16 length; | 1916 | u16 length; |
1872 | u8 link, opcode; | ||
1873 | 1917 | ||
1874 | opcode = le->opcode; | 1918 | hw->st_idx = RING_NEXT(hw->st_idx, STATUS_RING_SIZE); |
1875 | if (!opcode) | ||
1876 | break; | ||
1877 | opcode &= ~HW_OWNER; | ||
1878 | |||
1879 | hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE; | ||
1880 | le->opcode = 0; | ||
1881 | 1919 | ||
1882 | link = le->link; | 1920 | BUG_ON(le->link >= 2); |
1883 | BUG_ON(link >= 2); | 1921 | dev = hw->dev[le->link]; |
1884 | dev = hw->dev[link]; | ||
1885 | 1922 | ||
1886 | sky2 = netdev_priv(dev); | 1923 | sky2 = netdev_priv(dev); |
1887 | length = le->length; | 1924 | length = le->length; |
1888 | status = le->status; | 1925 | status = le->status; |
1889 | 1926 | ||
1890 | switch (opcode) { | 1927 | switch (le->opcode & ~HW_OWNER) { |
1891 | case OP_RXSTAT: | 1928 | case OP_RXSTAT: |
1892 | skb = sky2_receive(sky2, length, status); | 1929 | skb = sky2_receive(sky2, length, status); |
1893 | if (!skb) | 1930 | if (!skb) |
@@ -1927,7 +1964,8 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do) | |||
1927 | 1964 | ||
1928 | case OP_TXINDEXLE: | 1965 | case OP_TXINDEXLE: |
1929 | /* TX index reports status for both ports */ | 1966 | /* TX index reports status for both ports */ |
1930 | sky2_tx_done(hw->dev[0], status & 0xffff); | 1967 | BUILD_BUG_ON(TX_RING_SIZE > 0x1000); |
1968 | sky2_tx_done(hw->dev[0], status & 0xfff); | ||
1931 | if (hw->dev[1]) | 1969 | if (hw->dev[1]) |
1932 | sky2_tx_done(hw->dev[1], | 1970 | sky2_tx_done(hw->dev[1], |
1933 | ((status >> 24) & 0xff) | 1971 | ((status >> 24) & 0xff) |
@@ -1937,8 +1975,8 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do) | |||
1937 | default: | 1975 | default: |
1938 | if (net_ratelimit()) | 1976 | if (net_ratelimit()) |
1939 | printk(KERN_WARNING PFX | 1977 | printk(KERN_WARNING PFX |
1940 | "unknown status opcode 0x%x\n", opcode); | 1978 | "unknown status opcode 0x%x\n", le->opcode); |
1941 | break; | 1979 | goto exit_loop; |
1942 | } | 1980 | } |
1943 | } | 1981 | } |
1944 | 1982 | ||
@@ -2089,12 +2127,13 @@ static void sky2_descriptor_error(struct sky2_hw *hw, unsigned port, | |||
2089 | */ | 2127 | */ |
2090 | static void sky2_idle(unsigned long arg) | 2128 | static void sky2_idle(unsigned long arg) |
2091 | { | 2129 | { |
2092 | struct net_device *dev = (struct net_device *) arg; | 2130 | struct sky2_hw *hw = (struct sky2_hw *) arg; |
2131 | struct net_device *dev = hw->dev[0]; | ||
2093 | 2132 | ||
2094 | local_irq_disable(); | ||
2095 | if (__netif_rx_schedule_prep(dev)) | 2133 | if (__netif_rx_schedule_prep(dev)) |
2096 | __netif_rx_schedule(dev); | 2134 | __netif_rx_schedule(dev); |
2097 | local_irq_enable(); | 2135 | |
2136 | mod_timer(&hw->idle_timer, jiffies + msecs_to_jiffies(idle_timeout)); | ||
2098 | } | 2137 | } |
2099 | 2138 | ||
2100 | 2139 | ||
@@ -2105,65 +2144,46 @@ static int sky2_poll(struct net_device *dev0, int *budget) | |||
2105 | int work_done = 0; | 2144 | int work_done = 0; |
2106 | u32 status = sky2_read32(hw, B0_Y2_SP_EISR); | 2145 | u32 status = sky2_read32(hw, B0_Y2_SP_EISR); |
2107 | 2146 | ||
2108 | restart_poll: | 2147 | if (status & Y2_IS_HW_ERR) |
2109 | if (unlikely(status & ~Y2_IS_STAT_BMU)) { | 2148 | sky2_hw_intr(hw); |
2110 | if (status & Y2_IS_HW_ERR) | ||
2111 | sky2_hw_intr(hw); | ||
2112 | |||
2113 | if (status & Y2_IS_IRQ_PHY1) | ||
2114 | sky2_phy_intr(hw, 0); | ||
2115 | |||
2116 | if (status & Y2_IS_IRQ_PHY2) | ||
2117 | sky2_phy_intr(hw, 1); | ||
2118 | 2149 | ||
2119 | if (status & Y2_IS_IRQ_MAC1) | 2150 | if (status & Y2_IS_IRQ_PHY1) |
2120 | sky2_mac_intr(hw, 0); | 2151 | sky2_phy_intr(hw, 0); |
2121 | 2152 | ||
2122 | if (status & Y2_IS_IRQ_MAC2) | 2153 | if (status & Y2_IS_IRQ_PHY2) |
2123 | sky2_mac_intr(hw, 1); | 2154 | sky2_phy_intr(hw, 1); |
2124 | 2155 | ||
2125 | if (status & Y2_IS_CHK_RX1) | 2156 | if (status & Y2_IS_IRQ_MAC1) |
2126 | sky2_descriptor_error(hw, 0, "receive", Y2_IS_CHK_RX1); | 2157 | sky2_mac_intr(hw, 0); |
2127 | 2158 | ||
2128 | if (status & Y2_IS_CHK_RX2) | 2159 | if (status & Y2_IS_IRQ_MAC2) |
2129 | sky2_descriptor_error(hw, 1, "receive", Y2_IS_CHK_RX2); | 2160 | sky2_mac_intr(hw, 1); |
2130 | 2161 | ||
2131 | if (status & Y2_IS_CHK_TXA1) | 2162 | if (status & Y2_IS_CHK_RX1) |
2132 | sky2_descriptor_error(hw, 0, "transmit", Y2_IS_CHK_TXA1); | 2163 | sky2_descriptor_error(hw, 0, "receive", Y2_IS_CHK_RX1); |
2133 | 2164 | ||
2134 | if (status & Y2_IS_CHK_TXA2) | 2165 | if (status & Y2_IS_CHK_RX2) |
2135 | sky2_descriptor_error(hw, 1, "transmit", Y2_IS_CHK_TXA2); | 2166 | sky2_descriptor_error(hw, 1, "receive", Y2_IS_CHK_RX2); |
2136 | } | ||
2137 | 2167 | ||
2138 | if (status & Y2_IS_STAT_BMU) { | 2168 | if (status & Y2_IS_CHK_TXA1) |
2139 | work_done += sky2_status_intr(hw, work_limit - work_done); | 2169 | sky2_descriptor_error(hw, 0, "transmit", Y2_IS_CHK_TXA1); |
2140 | *budget -= work_done; | ||
2141 | dev0->quota -= work_done; | ||
2142 | 2170 | ||
2143 | if (work_done >= work_limit) | 2171 | if (status & Y2_IS_CHK_TXA2) |
2144 | return 1; | 2172 | sky2_descriptor_error(hw, 1, "transmit", Y2_IS_CHK_TXA2); |
2145 | 2173 | ||
2174 | if (status & Y2_IS_STAT_BMU) | ||
2146 | sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); | 2175 | sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); |
2147 | } | ||
2148 | |||
2149 | mod_timer(&hw->idle_timer, jiffies + HZ); | ||
2150 | 2176 | ||
2151 | local_irq_disable(); | 2177 | work_done = sky2_status_intr(hw, work_limit); |
2152 | __netif_rx_complete(dev0); | 2178 | *budget -= work_done; |
2179 | dev0->quota -= work_done; | ||
2153 | 2180 | ||
2154 | status = sky2_read32(hw, B0_Y2_SP_LISR); | 2181 | if (work_done >= work_limit) |
2182 | return 1; | ||
2155 | 2183 | ||
2156 | if (unlikely(status)) { | 2184 | netif_rx_complete(dev0); |
2157 | /* More work pending, try and keep going */ | ||
2158 | if (__netif_rx_schedule_prep(dev0)) { | ||
2159 | __netif_rx_reschedule(dev0, work_done); | ||
2160 | status = sky2_read32(hw, B0_Y2_SP_EISR); | ||
2161 | local_irq_enable(); | ||
2162 | goto restart_poll; | ||
2163 | } | ||
2164 | } | ||
2165 | 2185 | ||
2166 | local_irq_enable(); | 2186 | status = sky2_read32(hw, B0_Y2_SP_LISR); |
2167 | return 0; | 2187 | return 0; |
2168 | } | 2188 | } |
2169 | 2189 | ||
@@ -2244,13 +2264,6 @@ static int __devinit sky2_reset(struct sky2_hw *hw) | |||
2244 | return -EOPNOTSUPP; | 2264 | return -EOPNOTSUPP; |
2245 | } | 2265 | } |
2246 | 2266 | ||
2247 | /* This chip is new and not tested yet */ | ||
2248 | if (hw->chip_id == CHIP_ID_YUKON_EC_U) { | ||
2249 | pr_info(PFX "%s: is a version of Yukon 2 chipset that has not been tested yet.\n", | ||
2250 | pci_name(hw->pdev)); | ||
2251 | pr_info("Please report success/failure to maintainer <shemminger@osdl.org>\n"); | ||
2252 | } | ||
2253 | |||
2254 | /* disable ASF */ | 2267 | /* disable ASF */ |
2255 | if (hw->chip_id <= CHIP_ID_YUKON_EC) { | 2268 | if (hw->chip_id <= CHIP_ID_YUKON_EC) { |
2256 | sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); | 2269 | sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); |
@@ -3302,7 +3315,10 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3302 | 3315 | ||
3303 | sky2_write32(hw, B0_IMSK, Y2_IS_BASE); | 3316 | sky2_write32(hw, B0_IMSK, Y2_IS_BASE); |
3304 | 3317 | ||
3305 | setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) dev); | 3318 | setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) hw); |
3319 | if (idle_timeout > 0) | ||
3320 | mod_timer(&hw->idle_timer, | ||
3321 | jiffies + msecs_to_jiffies(idle_timeout)); | ||
3306 | 3322 | ||
3307 | pci_set_drvdata(pdev, hw); | 3323 | pci_set_drvdata(pdev, hw); |
3308 | 3324 | ||
@@ -3342,6 +3358,8 @@ static void __devexit sky2_remove(struct pci_dev *pdev) | |||
3342 | del_timer_sync(&hw->idle_timer); | 3358 | del_timer_sync(&hw->idle_timer); |
3343 | 3359 | ||
3344 | sky2_write32(hw, B0_IMSK, 0); | 3360 | sky2_write32(hw, B0_IMSK, 0); |
3361 | synchronize_irq(hw->pdev->irq); | ||
3362 | |||
3345 | dev0 = hw->dev[0]; | 3363 | dev0 = hw->dev[0]; |
3346 | dev1 = hw->dev[1]; | 3364 | dev1 = hw->dev[1]; |
3347 | if (dev1) | 3365 | if (dev1) |
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index b026f5653f04..8012994c9b93 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h | |||
@@ -378,6 +378,9 @@ enum { | |||
378 | CHIP_REV_YU_EC_A1 = 0, /* Chip Rev. for Yukon-EC A1/A0 */ | 378 | CHIP_REV_YU_EC_A1 = 0, /* Chip Rev. for Yukon-EC A1/A0 */ |
379 | CHIP_REV_YU_EC_A2 = 1, /* Chip Rev. for Yukon-EC A2 */ | 379 | CHIP_REV_YU_EC_A2 = 1, /* Chip Rev. for Yukon-EC A2 */ |
380 | CHIP_REV_YU_EC_A3 = 2, /* Chip Rev. for Yukon-EC A3 */ | 380 | CHIP_REV_YU_EC_A3 = 2, /* Chip Rev. for Yukon-EC A3 */ |
381 | |||
382 | CHIP_REV_YU_EC_U_A0 = 0, | ||
383 | CHIP_REV_YU_EC_U_A1 = 1, | ||
381 | }; | 384 | }; |
382 | 385 | ||
383 | /* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */ | 386 | /* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */ |
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c index 43f5e86fc559..394339d5e87c 100644 --- a/drivers/net/spider_net.c +++ b/drivers/net/spider_net.c | |||
@@ -1652,6 +1652,8 @@ spider_net_enable_card(struct spider_net_card *card) | |||
1652 | { SPIDER_NET_GFTRESTRT, SPIDER_NET_RESTART_VALUE }, | 1652 | { SPIDER_NET_GFTRESTRT, SPIDER_NET_RESTART_VALUE }, |
1653 | 1653 | ||
1654 | { SPIDER_NET_GMRWOLCTRL, 0 }, | 1654 | { SPIDER_NET_GMRWOLCTRL, 0 }, |
1655 | { SPIDER_NET_GTESTMD, 0x10000000 }, | ||
1656 | { SPIDER_NET_GTTQMSK, 0x00400040 }, | ||
1655 | { SPIDER_NET_GTESTMD, 0 }, | 1657 | { SPIDER_NET_GTESTMD, 0 }, |
1656 | 1658 | ||
1657 | { SPIDER_NET_GMACINTEN, 0 }, | 1659 | { SPIDER_NET_GMACINTEN, 0 }, |
@@ -1792,15 +1794,7 @@ spider_net_setup_phy(struct spider_net_card *card) | |||
1792 | if (phy->def->ops->setup_forced) | 1794 | if (phy->def->ops->setup_forced) |
1793 | phy->def->ops->setup_forced(phy, SPEED_1000, DUPLEX_FULL); | 1795 | phy->def->ops->setup_forced(phy, SPEED_1000, DUPLEX_FULL); |
1794 | 1796 | ||
1795 | /* the following two writes could be moved to sungem_phy.c */ | 1797 | phy->def->ops->enable_fiber(phy); |
1796 | /* enable fiber mode */ | ||
1797 | spider_net_write_phy(card->netdev, 1, MII_NCONFIG, 0x9020); | ||
1798 | /* LEDs active in both modes, autosense prio = fiber */ | ||
1799 | spider_net_write_phy(card->netdev, 1, MII_NCONFIG, 0x945f); | ||
1800 | |||
1801 | /* switch off fibre autoneg */ | ||
1802 | spider_net_write_phy(card->netdev, 1, MII_NCONFIG, 0xfc01); | ||
1803 | spider_net_write_phy(card->netdev, 1, 0x0b, 0x0004); | ||
1804 | 1798 | ||
1805 | phy->def->ops->read_link(phy); | 1799 | phy->def->ops->read_link(phy); |
1806 | pr_info("Found %s with %i Mbps, %s-duplex.\n", phy->def->name, | 1800 | pr_info("Found %s with %i Mbps, %s-duplex.\n", phy->def->name, |
diff --git a/drivers/net/spider_net.h b/drivers/net/spider_net.h index 5922b529a048..3b8d951cf73c 100644 --- a/drivers/net/spider_net.h +++ b/drivers/net/spider_net.h | |||
@@ -120,6 +120,8 @@ extern char spider_net_driver_name[]; | |||
120 | #define SPIDER_NET_GMRUAFILnR 0x00000500 | 120 | #define SPIDER_NET_GMRUAFILnR 0x00000500 |
121 | #define SPIDER_NET_GMRUA0FIL15R 0x00000578 | 121 | #define SPIDER_NET_GMRUA0FIL15R 0x00000578 |
122 | 122 | ||
123 | #define SPIDER_NET_GTTQMSK 0x00000934 | ||
124 | |||
123 | /* RX DMA controller registers, all 0x00000a.. are for DMA controller A, | 125 | /* RX DMA controller registers, all 0x00000a.. are for DMA controller A, |
124 | * 0x00000b.. for DMA controller B, etc. */ | 126 | * 0x00000b.. for DMA controller B, etc. */ |
125 | #define SPIDER_NET_GDADCHA 0x00000a00 | 127 | #define SPIDER_NET_GDADCHA 0x00000a00 |
diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c index 046371ee5bbe..b2ddd5e79303 100644 --- a/drivers/net/sungem_phy.c +++ b/drivers/net/sungem_phy.c | |||
@@ -329,6 +329,30 @@ static int bcm5421_init(struct mii_phy* phy) | |||
329 | return 0; | 329 | return 0; |
330 | } | 330 | } |
331 | 331 | ||
332 | static int bcm5421_enable_fiber(struct mii_phy* phy) | ||
333 | { | ||
334 | /* enable fiber mode */ | ||
335 | phy_write(phy, MII_NCONFIG, 0x9020); | ||
336 | /* LEDs active in both modes, autosense prio = fiber */ | ||
337 | phy_write(phy, MII_NCONFIG, 0x945f); | ||
338 | |||
339 | /* switch off fibre autoneg */ | ||
340 | phy_write(phy, MII_NCONFIG, 0xfc01); | ||
341 | phy_write(phy, 0x0b, 0x0004); | ||
342 | |||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | static int bcm5461_enable_fiber(struct mii_phy* phy) | ||
347 | { | ||
348 | phy_write(phy, MII_NCONFIG, 0xfc0c); | ||
349 | phy_write(phy, MII_BMCR, 0x4140); | ||
350 | phy_write(phy, MII_NCONFIG, 0xfc0b); | ||
351 | phy_write(phy, MII_BMCR, 0x0140); | ||
352 | |||
353 | return 0; | ||
354 | } | ||
355 | |||
332 | static int bcm54xx_setup_aneg(struct mii_phy *phy, u32 advertise) | 356 | static int bcm54xx_setup_aneg(struct mii_phy *phy, u32 advertise) |
333 | { | 357 | { |
334 | u16 ctl, adv; | 358 | u16 ctl, adv; |
@@ -762,6 +786,7 @@ static struct mii_phy_ops bcm5421_phy_ops = { | |||
762 | .setup_forced = bcm54xx_setup_forced, | 786 | .setup_forced = bcm54xx_setup_forced, |
763 | .poll_link = genmii_poll_link, | 787 | .poll_link = genmii_poll_link, |
764 | .read_link = bcm54xx_read_link, | 788 | .read_link = bcm54xx_read_link, |
789 | .enable_fiber = bcm5421_enable_fiber, | ||
765 | }; | 790 | }; |
766 | 791 | ||
767 | static struct mii_phy_def bcm5421_phy_def = { | 792 | static struct mii_phy_def bcm5421_phy_def = { |
@@ -792,6 +817,25 @@ static struct mii_phy_def bcm5421k2_phy_def = { | |||
792 | .ops = &bcm5421k2_phy_ops | 817 | .ops = &bcm5421k2_phy_ops |
793 | }; | 818 | }; |
794 | 819 | ||
820 | static struct mii_phy_ops bcm5461_phy_ops = { | ||
821 | .init = bcm5421_init, | ||
822 | .suspend = generic_suspend, | ||
823 | .setup_aneg = bcm54xx_setup_aneg, | ||
824 | .setup_forced = bcm54xx_setup_forced, | ||
825 | .poll_link = genmii_poll_link, | ||
826 | .read_link = bcm54xx_read_link, | ||
827 | .enable_fiber = bcm5461_enable_fiber, | ||
828 | }; | ||
829 | |||
830 | static struct mii_phy_def bcm5461_phy_def = { | ||
831 | .phy_id = 0x002060c0, | ||
832 | .phy_id_mask = 0xfffffff0, | ||
833 | .name = "BCM5461", | ||
834 | .features = MII_GBIT_FEATURES, | ||
835 | .magic_aneg = 1, | ||
836 | .ops = &bcm5461_phy_ops | ||
837 | }; | ||
838 | |||
795 | /* Broadcom BCM 5462 built-in Vesta */ | 839 | /* Broadcom BCM 5462 built-in Vesta */ |
796 | static struct mii_phy_ops bcm5462V_phy_ops = { | 840 | static struct mii_phy_ops bcm5462V_phy_ops = { |
797 | .init = bcm5421_init, | 841 | .init = bcm5421_init, |
@@ -857,6 +901,7 @@ static struct mii_phy_def* mii_phy_table[] = { | |||
857 | &bcm5411_phy_def, | 901 | &bcm5411_phy_def, |
858 | &bcm5421_phy_def, | 902 | &bcm5421_phy_def, |
859 | &bcm5421k2_phy_def, | 903 | &bcm5421k2_phy_def, |
904 | &bcm5461_phy_def, | ||
860 | &bcm5462V_phy_def, | 905 | &bcm5462V_phy_def, |
861 | &marvell_phy_def, | 906 | &marvell_phy_def, |
862 | &genmii_phy_def, | 907 | &genmii_phy_def, |
diff --git a/drivers/net/sungem_phy.h b/drivers/net/sungem_phy.h index 430544496c52..69e125197fcf 100644 --- a/drivers/net/sungem_phy.h +++ b/drivers/net/sungem_phy.h | |||
@@ -12,6 +12,7 @@ struct mii_phy_ops | |||
12 | int (*setup_forced)(struct mii_phy *phy, int speed, int fd); | 12 | int (*setup_forced)(struct mii_phy *phy, int speed, int fd); |
13 | int (*poll_link)(struct mii_phy *phy); | 13 | int (*poll_link)(struct mii_phy *phy); |
14 | int (*read_link)(struct mii_phy *phy); | 14 | int (*read_link)(struct mii_phy *phy); |
15 | int (*enable_fiber)(struct mii_phy *phy); | ||
15 | }; | 16 | }; |
16 | 17 | ||
17 | /* Structure used to statically define an mii/gii based PHY */ | 18 | /* Structure used to statically define an mii/gii based PHY */ |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index beeb612be98f..e1b33a25a25f 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -7653,21 +7653,23 @@ static int tg3_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
7653 | cmd->supported |= (SUPPORTED_1000baseT_Half | | 7653 | cmd->supported |= (SUPPORTED_1000baseT_Half | |
7654 | SUPPORTED_1000baseT_Full); | 7654 | SUPPORTED_1000baseT_Full); |
7655 | 7655 | ||
7656 | if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES)) | 7656 | if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES)) { |
7657 | cmd->supported |= (SUPPORTED_100baseT_Half | | 7657 | cmd->supported |= (SUPPORTED_100baseT_Half | |
7658 | SUPPORTED_100baseT_Full | | 7658 | SUPPORTED_100baseT_Full | |
7659 | SUPPORTED_10baseT_Half | | 7659 | SUPPORTED_10baseT_Half | |
7660 | SUPPORTED_10baseT_Full | | 7660 | SUPPORTED_10baseT_Full | |
7661 | SUPPORTED_MII); | 7661 | SUPPORTED_MII); |
7662 | else | 7662 | cmd->port = PORT_TP; |
7663 | } else { | ||
7663 | cmd->supported |= SUPPORTED_FIBRE; | 7664 | cmd->supported |= SUPPORTED_FIBRE; |
7665 | cmd->port = PORT_FIBRE; | ||
7666 | } | ||
7664 | 7667 | ||
7665 | cmd->advertising = tp->link_config.advertising; | 7668 | cmd->advertising = tp->link_config.advertising; |
7666 | if (netif_running(dev)) { | 7669 | if (netif_running(dev)) { |
7667 | cmd->speed = tp->link_config.active_speed; | 7670 | cmd->speed = tp->link_config.active_speed; |
7668 | cmd->duplex = tp->link_config.active_duplex; | 7671 | cmd->duplex = tp->link_config.active_duplex; |
7669 | } | 7672 | } |
7670 | cmd->port = 0; | ||
7671 | cmd->phy_address = PHY_ADDR; | 7673 | cmd->phy_address = PHY_ADDR; |
7672 | cmd->transceiver = 0; | 7674 | cmd->transceiver = 0; |
7673 | cmd->autoneg = tp->link_config.autoneg; | 7675 | cmd->autoneg = tp->link_config.autoneg; |
@@ -8454,6 +8456,9 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode) | |||
8454 | 8456 | ||
8455 | tx_len = 1514; | 8457 | tx_len = 1514; |
8456 | skb = dev_alloc_skb(tx_len); | 8458 | skb = dev_alloc_skb(tx_len); |
8459 | if (!skb) | ||
8460 | return -ENOMEM; | ||
8461 | |||
8457 | tx_data = skb_put(skb, tx_len); | 8462 | tx_data = skb_put(skb, tx_len); |
8458 | memcpy(tx_data, tp->dev->dev_addr, 6); | 8463 | memcpy(tx_data, tp->dev->dev_addr, 6); |
8459 | memset(tx_data + 6, 0x0, 8); | 8464 | memset(tx_data + 6, 0x0, 8); |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c index 9a06e61df0a2..e2982a83ae42 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c | |||
@@ -939,9 +939,9 @@ static int bcm43xx_sprom_extract(struct bcm43xx_private *bcm) | |||
939 | return 0; | 939 | return 0; |
940 | } | 940 | } |
941 | 941 | ||
942 | static void bcm43xx_geo_init(struct bcm43xx_private *bcm) | 942 | static int bcm43xx_geo_init(struct bcm43xx_private *bcm) |
943 | { | 943 | { |
944 | struct ieee80211_geo geo; | 944 | struct ieee80211_geo *geo; |
945 | struct ieee80211_channel *chan; | 945 | struct ieee80211_channel *chan; |
946 | int have_a = 0, have_bg = 0; | 946 | int have_a = 0, have_bg = 0; |
947 | int i; | 947 | int i; |
@@ -949,7 +949,10 @@ static void bcm43xx_geo_init(struct bcm43xx_private *bcm) | |||
949 | struct bcm43xx_phyinfo *phy; | 949 | struct bcm43xx_phyinfo *phy; |
950 | const char *iso_country; | 950 | const char *iso_country; |
951 | 951 | ||
952 | memset(&geo, 0, sizeof(geo)); | 952 | geo = kzalloc(sizeof(*geo), GFP_KERNEL); |
953 | if (!geo) | ||
954 | return -ENOMEM; | ||
955 | |||
953 | for (i = 0; i < bcm->nr_80211_available; i++) { | 956 | for (i = 0; i < bcm->nr_80211_available; i++) { |
954 | phy = &(bcm->core_80211_ext[i].phy); | 957 | phy = &(bcm->core_80211_ext[i].phy); |
955 | switch (phy->type) { | 958 | switch (phy->type) { |
@@ -967,31 +970,36 @@ static void bcm43xx_geo_init(struct bcm43xx_private *bcm) | |||
967 | iso_country = bcm43xx_locale_iso(bcm->sprom.locale); | 970 | iso_country = bcm43xx_locale_iso(bcm->sprom.locale); |
968 | 971 | ||
969 | if (have_a) { | 972 | if (have_a) { |
970 | for (i = 0, channel = 0; channel < 201; channel++) { | 973 | for (i = 0, channel = IEEE80211_52GHZ_MIN_CHANNEL; |
971 | chan = &geo.a[i++]; | 974 | channel <= IEEE80211_52GHZ_MAX_CHANNEL; channel++) { |
975 | chan = &geo->a[i++]; | ||
972 | chan->freq = bcm43xx_channel_to_freq_a(channel); | 976 | chan->freq = bcm43xx_channel_to_freq_a(channel); |
973 | chan->channel = channel; | 977 | chan->channel = channel; |
974 | } | 978 | } |
975 | geo.a_channels = i; | 979 | geo->a_channels = i; |
976 | } | 980 | } |
977 | if (have_bg) { | 981 | if (have_bg) { |
978 | for (i = 0, channel = 1; channel < 15; channel++) { | 982 | for (i = 0, channel = IEEE80211_24GHZ_MIN_CHANNEL; |
979 | chan = &geo.bg[i++]; | 983 | channel <= IEEE80211_24GHZ_MAX_CHANNEL; channel++) { |
984 | chan = &geo->bg[i++]; | ||
980 | chan->freq = bcm43xx_channel_to_freq_bg(channel); | 985 | chan->freq = bcm43xx_channel_to_freq_bg(channel); |
981 | chan->channel = channel; | 986 | chan->channel = channel; |
982 | } | 987 | } |
983 | geo.bg_channels = i; | 988 | geo->bg_channels = i; |
984 | } | 989 | } |
985 | memcpy(geo.name, iso_country, 2); | 990 | memcpy(geo->name, iso_country, 2); |
986 | if (0 /*TODO: Outdoor use only */) | 991 | if (0 /*TODO: Outdoor use only */) |
987 | geo.name[2] = 'O'; | 992 | geo->name[2] = 'O'; |
988 | else if (0 /*TODO: Indoor use only */) | 993 | else if (0 /*TODO: Indoor use only */) |
989 | geo.name[2] = 'I'; | 994 | geo->name[2] = 'I'; |
990 | else | 995 | else |
991 | geo.name[2] = ' '; | 996 | geo->name[2] = ' '; |
992 | geo.name[3] = '\0'; | 997 | geo->name[3] = '\0'; |
998 | |||
999 | ieee80211_set_geo(bcm->ieee, geo); | ||
1000 | kfree(geo); | ||
993 | 1001 | ||
994 | ieee80211_set_geo(bcm->ieee, &geo); | 1002 | return 0; |
995 | } | 1003 | } |
996 | 1004 | ||
997 | /* DummyTransmission function, as documented on | 1005 | /* DummyTransmission function, as documented on |
@@ -3479,16 +3487,17 @@ static int bcm43xx_attach_board(struct bcm43xx_private *bcm) | |||
3479 | goto err_80211_unwind; | 3487 | goto err_80211_unwind; |
3480 | bcm43xx_wireless_core_disable(bcm); | 3488 | bcm43xx_wireless_core_disable(bcm); |
3481 | } | 3489 | } |
3490 | err = bcm43xx_geo_init(bcm); | ||
3491 | if (err) | ||
3492 | goto err_80211_unwind; | ||
3482 | bcm43xx_pctl_set_crystal(bcm, 0); | 3493 | bcm43xx_pctl_set_crystal(bcm, 0); |
3483 | 3494 | ||
3484 | /* Set the MAC address in the networking subsystem */ | 3495 | /* Set the MAC address in the networking subsystem */ |
3485 | if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A) | 3496 | if (is_valid_ether_addr(bcm->sprom.et1macaddr)) |
3486 | memcpy(bcm->net_dev->dev_addr, bcm->sprom.et1macaddr, 6); | 3497 | memcpy(bcm->net_dev->dev_addr, bcm->sprom.et1macaddr, 6); |
3487 | else | 3498 | else |
3488 | memcpy(bcm->net_dev->dev_addr, bcm->sprom.il0macaddr, 6); | 3499 | memcpy(bcm->net_dev->dev_addr, bcm->sprom.il0macaddr, 6); |
3489 | 3500 | ||
3490 | bcm43xx_geo_init(bcm); | ||
3491 | |||
3492 | snprintf(bcm->nick, IW_ESSID_MAX_SIZE, | 3501 | snprintf(bcm->nick, IW_ESSID_MAX_SIZE, |
3493 | "Broadcom %04X", bcm->chip_id); | 3502 | "Broadcom %04X", bcm->chip_id); |
3494 | 3503 | ||
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.h b/drivers/net/wireless/bcm43xx/bcm43xx_main.h index eca79a38594a..30a202b258b5 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_main.h +++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.h | |||
@@ -118,12 +118,14 @@ int bcm43xx_channel_to_freq(struct bcm43xx_private *bcm, | |||
118 | static inline | 118 | static inline |
119 | int bcm43xx_is_valid_channel_a(u8 channel) | 119 | int bcm43xx_is_valid_channel_a(u8 channel) |
120 | { | 120 | { |
121 | return (channel <= 200); | 121 | return (channel >= IEEE80211_52GHZ_MIN_CHANNEL |
122 | && channel <= IEEE80211_52GHZ_MAX_CHANNEL); | ||
122 | } | 123 | } |
123 | static inline | 124 | static inline |
124 | int bcm43xx_is_valid_channel_bg(u8 channel) | 125 | int bcm43xx_is_valid_channel_bg(u8 channel) |
125 | { | 126 | { |
126 | return (channel >= 1 && channel <= 14); | 127 | return (channel >= IEEE80211_24GHZ_MIN_CHANNEL |
128 | && channel <= IEEE80211_24GHZ_MAX_CHANNEL); | ||
127 | } | 129 | } |
128 | static inline | 130 | static inline |
129 | int bcm43xx_is_valid_channel(struct bcm43xx_private *bcm, | 131 | int bcm43xx_is_valid_channel(struct bcm43xx_private *bcm, |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c index 33137165727f..b0abac515530 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c | |||
@@ -1287,7 +1287,7 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm) | |||
1287 | if (radio->revision == 8) | 1287 | if (radio->revision == 8) |
1288 | bcm43xx_phy_write(bcm, 0x0805, 0x3230); | 1288 | bcm43xx_phy_write(bcm, 0x0805, 0x3230); |
1289 | bcm43xx_phy_init_pctl(bcm); | 1289 | bcm43xx_phy_init_pctl(bcm); |
1290 | if (bcm->chip_id == 0x4306 && bcm->chip_package != 2) { | 1290 | if (bcm->chip_id == 0x4306 && bcm->chip_package == 2) { |
1291 | bcm43xx_phy_write(bcm, 0x0429, | 1291 | bcm43xx_phy_write(bcm, 0x0429, |
1292 | bcm43xx_phy_read(bcm, 0x0429) & 0xBFFF); | 1292 | bcm43xx_phy_read(bcm, 0x0429) & 0xBFFF); |
1293 | bcm43xx_phy_write(bcm, 0x04C3, | 1293 | bcm43xx_phy_write(bcm, 0x04C3, |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c index 3edbb481a0a0..b45063974ae9 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c | |||
@@ -182,8 +182,11 @@ static int bcm43xx_wx_set_mode(struct net_device *net_dev, | |||
182 | mode = BCM43xx_INITIAL_IWMODE; | 182 | mode = BCM43xx_INITIAL_IWMODE; |
183 | 183 | ||
184 | bcm43xx_lock_mmio(bcm, flags); | 184 | bcm43xx_lock_mmio(bcm, flags); |
185 | if (bcm->ieee->iw_mode != mode) | 185 | if (bcm->initialized) { |
186 | bcm43xx_set_iwmode(bcm, mode); | 186 | if (bcm->ieee->iw_mode != mode) |
187 | bcm43xx_set_iwmode(bcm, mode); | ||
188 | } else | ||
189 | bcm->ieee->iw_mode = mode; | ||
187 | bcm43xx_unlock_mmio(bcm, flags); | 190 | bcm43xx_unlock_mmio(bcm, flags); |
188 | 191 | ||
189 | return 0; | 192 | return 0; |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 19e2b174d33c..d378478612fb 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -634,6 +634,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_vi | |||
634 | * non-x86 architectures (yes Via exists on PPC among other places), | 634 | * non-x86 architectures (yes Via exists on PPC among other places), |
635 | * we must mask the PCI_INTERRUPT_LINE value versus 0xf to get | 635 | * we must mask the PCI_INTERRUPT_LINE value versus 0xf to get |
636 | * interrupts delivered properly. | 636 | * interrupts delivered properly. |
637 | * | ||
638 | * Some of the on-chip devices are actually '586 devices' so they are | ||
639 | * listed here. | ||
637 | */ | 640 | */ |
638 | static void quirk_via_irq(struct pci_dev *dev) | 641 | static void quirk_via_irq(struct pci_dev *dev) |
639 | { | 642 | { |
@@ -648,6 +651,10 @@ static void quirk_via_irq(struct pci_dev *dev) | |||
648 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); | 651 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); |
649 | } | 652 | } |
650 | } | 653 | } |
654 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_0, quirk_via_irq); | ||
655 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, quirk_via_irq); | ||
656 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_2, quirk_via_irq); | ||
657 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_via_irq); | ||
651 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_irq); | 658 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_irq); |
652 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_irq); | 659 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_irq); |
653 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_5, quirk_via_irq); | 660 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_5, quirk_via_irq); |
@@ -895,6 +902,7 @@ static void __init k8t_sound_hostbridge(struct pci_dev *dev) | |||
895 | } | 902 | } |
896 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, k8t_sound_hostbridge); | 903 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, k8t_sound_hostbridge); |
897 | 904 | ||
905 | #ifndef CONFIG_ACPI_SLEEP | ||
898 | /* | 906 | /* |
899 | * On ASUS P4B boards, the SMBus PCI Device within the ICH2/4 southbridge | 907 | * On ASUS P4B boards, the SMBus PCI Device within the ICH2/4 southbridge |
900 | * is not activated. The myth is that Asus said that they do not want the | 908 | * is not activated. The myth is that Asus said that they do not want the |
@@ -906,8 +914,12 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, k8t_sound_ho | |||
906 | * bridge. Unfortunately, this device has no subvendor/subdevice ID. So it | 914 | * bridge. Unfortunately, this device has no subvendor/subdevice ID. So it |
907 | * becomes necessary to do this tweak in two steps -- I've chosen the Host | 915 | * becomes necessary to do this tweak in two steps -- I've chosen the Host |
908 | * bridge as trigger. | 916 | * bridge as trigger. |
917 | * | ||
918 | * Actually, leaving it unhidden and not redoing the quirk over suspend2ram | ||
919 | * will cause thermal management to break down, and causing machine to | ||
920 | * overheat. | ||
909 | */ | 921 | */ |
910 | static int __initdata asus_hides_smbus = 0; | 922 | static int __initdata asus_hides_smbus; |
911 | 923 | ||
912 | static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev) | 924 | static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev) |
913 | { | 925 | { |
@@ -1050,6 +1062,8 @@ static void __init asus_hides_smbus_lpc_ich6(struct pci_dev *dev) | |||
1050 | } | 1062 | } |
1051 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6 ); | 1063 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6 ); |
1052 | 1064 | ||
1065 | #endif | ||
1066 | |||
1053 | /* | 1067 | /* |
1054 | * SiS 96x south bridge: BIOS typically hides SMBus device... | 1068 | * SiS 96x south bridge: BIOS typically hides SMBus device... |
1055 | */ | 1069 | */ |
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index c53db7ceda5e..738b1ef595a3 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c | |||
@@ -426,7 +426,7 @@ static int ds_open(struct inode *inode, struct file *file) | |||
426 | 426 | ||
427 | if (!warning_printed) { | 427 | if (!warning_printed) { |
428 | printk(KERN_INFO "pcmcia: Detected deprecated PCMCIA ioctl " | 428 | printk(KERN_INFO "pcmcia: Detected deprecated PCMCIA ioctl " |
429 | "usage.\n"); | 429 | "usage from process: %s.\n", current->comm); |
430 | printk(KERN_INFO "pcmcia: This interface will soon be removed from " | 430 | printk(KERN_INFO "pcmcia: This interface will soon be removed from " |
431 | "the kernel; please expect breakage unless you upgrade " | 431 | "the kernel; please expect breakage unless you upgrade " |
432 | "to new tools.\n"); | 432 | "to new tools.\n"); |
@@ -601,8 +601,12 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
601 | ret = CS_BAD_ARGS; | 601 | ret = CS_BAD_ARGS; |
602 | else { | 602 | else { |
603 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function); | 603 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function); |
604 | ret = pccard_get_configuration_info(s, p_dev, &buf->config); | 604 | if (p_dev == NULL) |
605 | pcmcia_put_dev(p_dev); | 605 | ret = CS_BAD_ARGS; |
606 | else { | ||
607 | ret = pccard_get_configuration_info(s, p_dev, &buf->config); | ||
608 | pcmcia_put_dev(p_dev); | ||
609 | } | ||
606 | } | 610 | } |
607 | break; | 611 | break; |
608 | case DS_GET_FIRST_TUPLE: | 612 | case DS_GET_FIRST_TUPLE: |
@@ -632,8 +636,12 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
632 | ret = CS_BAD_ARGS; | 636 | ret = CS_BAD_ARGS; |
633 | else { | 637 | else { |
634 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function); | 638 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function); |
635 | ret = pccard_get_status(s, p_dev, &buf->status); | 639 | if (p_dev == NULL) |
636 | pcmcia_put_dev(p_dev); | 640 | ret = CS_BAD_ARGS; |
641 | else { | ||
642 | ret = pccard_get_status(s, p_dev, &buf->status); | ||
643 | pcmcia_put_dev(p_dev); | ||
644 | } | ||
637 | } | 645 | } |
638 | break; | 646 | break; |
639 | case DS_VALIDATE_CIS: | 647 | case DS_VALIDATE_CIS: |
@@ -665,9 +673,10 @@ static int ds_ioctl(struct inode * inode, struct file * file, | |||
665 | if (!(buf->conf_reg.Function && | 673 | if (!(buf->conf_reg.Function && |
666 | (buf->conf_reg.Function >= s->functions))) { | 674 | (buf->conf_reg.Function >= s->functions))) { |
667 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->conf_reg.Function); | 675 | struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->conf_reg.Function); |
668 | if (p_dev) | 676 | if (p_dev) { |
669 | ret = pcmcia_access_configuration_register(p_dev, &buf->conf_reg); | 677 | ret = pcmcia_access_configuration_register(p_dev, &buf->conf_reg); |
670 | pcmcia_put_dev(p_dev); | 678 | pcmcia_put_dev(p_dev); |
679 | } | ||
671 | } | 680 | } |
672 | break; | 681 | break; |
673 | case DS_GET_FIRST_REGION: | 682 | case DS_GET_FIRST_REGION: |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index a23ec54989f6..2bc8aad47219 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -178,9 +178,9 @@ static int sa1100_rtc_open(struct device *dev) | |||
178 | return 0; | 178 | return 0; |
179 | 179 | ||
180 | fail_pi: | 180 | fail_pi: |
181 | free_irq(IRQ_RTCAlrm, NULL); | 181 | free_irq(IRQ_RTCAlrm, dev); |
182 | fail_ai: | 182 | fail_ai: |
183 | free_irq(IRQ_RTC1Hz, NULL); | 183 | free_irq(IRQ_RTC1Hz, dev); |
184 | fail_ui: | 184 | fail_ui: |
185 | return ret; | 185 | return ret; |
186 | } | 186 | } |
@@ -295,7 +295,7 @@ static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
295 | 295 | ||
296 | static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) | 296 | static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) |
297 | { | 297 | { |
298 | seq_printf(seq, "trim/divider\t: 0x%08x\n", RTTR); | 298 | seq_printf(seq, "trim/divider\t: 0x%08lx\n", RTTR); |
299 | seq_printf(seq, "alarm_IRQ\t: %s\n", | 299 | seq_printf(seq, "alarm_IRQ\t: %s\n", |
300 | (RTSR & RTSR_ALE) ? "yes" : "no" ); | 300 | (RTSR & RTSR_ALE) ? "yes" : "no" ); |
301 | seq_printf(seq, "update_IRQ\t: %s\n", | 301 | seq_printf(seq, "update_IRQ\t: %s\n", |
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c index 5d6b7a57b02f..e65da921a827 100644 --- a/drivers/s390/net/lcs.c +++ b/drivers/s390/net/lcs.c | |||
@@ -1348,7 +1348,7 @@ lcs_irq(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) | |||
1348 | index = (struct ccw1 *) __va((addr_t) irb->scsw.cpa) | 1348 | index = (struct ccw1 *) __va((addr_t) irb->scsw.cpa) |
1349 | - channel->ccws; | 1349 | - channel->ccws; |
1350 | if ((irb->scsw.actl & SCSW_ACTL_SUSPENDED) || | 1350 | if ((irb->scsw.actl & SCSW_ACTL_SUSPENDED) || |
1351 | (irb->scsw.cstat | SCHN_STAT_PCI)) | 1351 | (irb->scsw.cstat & SCHN_STAT_PCI)) |
1352 | /* Bloody io subsystem tells us lies about cpa... */ | 1352 | /* Bloody io subsystem tells us lies about cpa... */ |
1353 | index = (index - 1) & (LCS_NUM_BUFFS - 1); | 1353 | index = (index - 1) & (LCS_NUM_BUFFS - 1); |
1354 | while (channel->io_idx != index) { | 1354 | while (channel->io_idx != index) { |
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c index 383a95f34a0d..239e108b8ed1 100644 --- a/drivers/sbus/char/openprom.c +++ b/drivers/sbus/char/openprom.c | |||
@@ -392,13 +392,16 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file, | |||
392 | return -ENOMEM; | 392 | return -ENOMEM; |
393 | } | 393 | } |
394 | 394 | ||
395 | prom_getproperty(op.op_nodeid, str, tmp, len); | 395 | cnt = prom_getproperty(op.op_nodeid, str, tmp, len); |
396 | 396 | if (cnt <= 0) { | |
397 | tmp[len] = '\0'; | 397 | error = -EINVAL; |
398 | } else { | ||
399 | tmp[len] = '\0'; | ||
398 | 400 | ||
399 | if (__copy_to_user(argp, &op, sizeof(op)) != 0 | 401 | if (__copy_to_user(argp, &op, sizeof(op)) != 0 || |
400 | || copy_to_user(op.op_buf, tmp, len) != 0) | 402 | copy_to_user(op.op_buf, tmp, len) != 0) |
401 | error = -EFAULT; | 403 | error = -EFAULT; |
404 | } | ||
402 | 405 | ||
403 | kfree(tmp); | 406 | kfree(tmp); |
404 | kfree(str); | 407 | kfree(str); |
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c index cb30d9c1153d..0c9c2f400bf6 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | |||
@@ -219,6 +219,7 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
219 | ahc->flags |= AHC_39BIT_ADDRESSING; | 219 | ahc->flags |= AHC_39BIT_ADDRESSING; |
220 | } else { | 220 | } else { |
221 | if (dma_set_mask(dev, DMA_32BIT_MASK)) { | 221 | if (dma_set_mask(dev, DMA_32BIT_MASK)) { |
222 | ahc_free(ahc); | ||
222 | printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); | 223 | printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n"); |
223 | return (-ENODEV); | 224 | return (-ENODEV); |
224 | } | 225 | } |
diff --git a/drivers/scsi/aic7xxx/aic7xxx_pci.c b/drivers/scsi/aic7xxx/aic7xxx_pci.c index 5f586140e057..3adecef21783 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_pci.c | |||
@@ -2036,12 +2036,12 @@ ahc_pci_resume(struct ahc_softc *ahc) | |||
2036 | * that the OS doesn't know about and rely on our chip | 2036 | * that the OS doesn't know about and rely on our chip |
2037 | * reset handler to handle the rest. | 2037 | * reset handler to handle the rest. |
2038 | */ | 2038 | */ |
2039 | ahc_pci_write_config(ahc->dev_softc, DEVCONFIG, /*bytes*/4, | 2039 | ahc_pci_write_config(ahc->dev_softc, DEVCONFIG, |
2040 | ahc->bus_softc.pci_softc.devconfig); | 2040 | ahc->bus_softc.pci_softc.devconfig, /*bytes*/4); |
2041 | ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/1, | 2041 | ahc_pci_write_config(ahc->dev_softc, PCIR_COMMAND, |
2042 | ahc->bus_softc.pci_softc.command); | 2042 | ahc->bus_softc.pci_softc.command, /*bytes*/1); |
2043 | ahc_pci_write_config(ahc->dev_softc, CSIZE_LATTIME, /*bytes*/1, | 2043 | ahc_pci_write_config(ahc->dev_softc, CSIZE_LATTIME, |
2044 | ahc->bus_softc.pci_softc.csize_lattime); | 2044 | ahc->bus_softc.pci_softc.csize_lattime, /*bytes*/1); |
2045 | if ((ahc->flags & AHC_HAS_TERM_LOGIC) != 0) { | 2045 | if ((ahc->flags & AHC_HAS_TERM_LOGIC) != 0) { |
2046 | struct seeprom_descriptor sd; | 2046 | struct seeprom_descriptor sd; |
2047 | u_int sxfrctl1; | 2047 | u_int sxfrctl1; |
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 0a8ad37ae899..2e9be83a697f 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c | |||
@@ -739,7 +739,8 @@ static void send_mad_adapter_info(struct ibmvscsi_host_data *hostdata) | |||
739 | { | 739 | { |
740 | struct viosrp_adapter_info *req; | 740 | struct viosrp_adapter_info *req; |
741 | struct srp_event_struct *evt_struct; | 741 | struct srp_event_struct *evt_struct; |
742 | 742 | dma_addr_t addr; | |
743 | |||
743 | evt_struct = get_event_struct(&hostdata->pool); | 744 | evt_struct = get_event_struct(&hostdata->pool); |
744 | if (!evt_struct) { | 745 | if (!evt_struct) { |
745 | printk(KERN_ERR "ibmvscsi: couldn't allocate an event " | 746 | printk(KERN_ERR "ibmvscsi: couldn't allocate an event " |
@@ -757,10 +758,10 @@ static void send_mad_adapter_info(struct ibmvscsi_host_data *hostdata) | |||
757 | 758 | ||
758 | req->common.type = VIOSRP_ADAPTER_INFO_TYPE; | 759 | req->common.type = VIOSRP_ADAPTER_INFO_TYPE; |
759 | req->common.length = sizeof(hostdata->madapter_info); | 760 | req->common.length = sizeof(hostdata->madapter_info); |
760 | req->buffer = dma_map_single(hostdata->dev, | 761 | req->buffer = addr = dma_map_single(hostdata->dev, |
761 | &hostdata->madapter_info, | 762 | &hostdata->madapter_info, |
762 | sizeof(hostdata->madapter_info), | 763 | sizeof(hostdata->madapter_info), |
763 | DMA_BIDIRECTIONAL); | 764 | DMA_BIDIRECTIONAL); |
764 | 765 | ||
765 | if (dma_mapping_error(req->buffer)) { | 766 | if (dma_mapping_error(req->buffer)) { |
766 | printk(KERN_ERR | 767 | printk(KERN_ERR |
@@ -770,8 +771,13 @@ static void send_mad_adapter_info(struct ibmvscsi_host_data *hostdata) | |||
770 | return; | 771 | return; |
771 | } | 772 | } |
772 | 773 | ||
773 | if (ibmvscsi_send_srp_event(evt_struct, hostdata)) | 774 | if (ibmvscsi_send_srp_event(evt_struct, hostdata)) { |
774 | printk(KERN_ERR "ibmvscsi: couldn't send ADAPTER_INFO_REQ!\n"); | 775 | printk(KERN_ERR "ibmvscsi: couldn't send ADAPTER_INFO_REQ!\n"); |
776 | dma_unmap_single(hostdata->dev, | ||
777 | addr, | ||
778 | sizeof(hostdata->madapter_info), | ||
779 | DMA_BIDIRECTIONAL); | ||
780 | } | ||
775 | }; | 781 | }; |
776 | 782 | ||
777 | /** | 783 | /** |
@@ -1259,6 +1265,7 @@ static int ibmvscsi_do_host_config(struct ibmvscsi_host_data *hostdata, | |||
1259 | { | 1265 | { |
1260 | struct viosrp_host_config *host_config; | 1266 | struct viosrp_host_config *host_config; |
1261 | struct srp_event_struct *evt_struct; | 1267 | struct srp_event_struct *evt_struct; |
1268 | dma_addr_t addr; | ||
1262 | int rc; | 1269 | int rc; |
1263 | 1270 | ||
1264 | evt_struct = get_event_struct(&hostdata->pool); | 1271 | evt_struct = get_event_struct(&hostdata->pool); |
@@ -1279,8 +1286,9 @@ static int ibmvscsi_do_host_config(struct ibmvscsi_host_data *hostdata, | |||
1279 | memset(host_config, 0x00, sizeof(*host_config)); | 1286 | memset(host_config, 0x00, sizeof(*host_config)); |
1280 | host_config->common.type = VIOSRP_HOST_CONFIG_TYPE; | 1287 | host_config->common.type = VIOSRP_HOST_CONFIG_TYPE; |
1281 | host_config->common.length = length; | 1288 | host_config->common.length = length; |
1282 | host_config->buffer = dma_map_single(hostdata->dev, buffer, length, | 1289 | host_config->buffer = addr = dma_map_single(hostdata->dev, buffer, |
1283 | DMA_BIDIRECTIONAL); | 1290 | length, |
1291 | DMA_BIDIRECTIONAL); | ||
1284 | 1292 | ||
1285 | if (dma_mapping_error(host_config->buffer)) { | 1293 | if (dma_mapping_error(host_config->buffer)) { |
1286 | printk(KERN_ERR | 1294 | printk(KERN_ERR |
@@ -1291,11 +1299,9 @@ static int ibmvscsi_do_host_config(struct ibmvscsi_host_data *hostdata, | |||
1291 | 1299 | ||
1292 | init_completion(&evt_struct->comp); | 1300 | init_completion(&evt_struct->comp); |
1293 | rc = ibmvscsi_send_srp_event(evt_struct, hostdata); | 1301 | rc = ibmvscsi_send_srp_event(evt_struct, hostdata); |
1294 | if (rc == 0) { | 1302 | if (rc == 0) |
1295 | wait_for_completion(&evt_struct->comp); | 1303 | wait_for_completion(&evt_struct->comp); |
1296 | dma_unmap_single(hostdata->dev, host_config->buffer, | 1304 | dma_unmap_single(hostdata->dev, addr, length, DMA_BIDIRECTIONAL); |
1297 | length, DMA_BIDIRECTIONAL); | ||
1298 | } | ||
1299 | 1305 | ||
1300 | return rc; | 1306 | return rc; |
1301 | } | 1307 | } |
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h index fad607b2e6f4..ee22173fce43 100644 --- a/drivers/scsi/lpfc/lpfc_crtn.h +++ b/drivers/scsi/lpfc/lpfc_crtn.h | |||
@@ -27,7 +27,6 @@ void lpfc_config_link(struct lpfc_hba *, LPFC_MBOXQ_t *); | |||
27 | int lpfc_read_sparam(struct lpfc_hba *, LPFC_MBOXQ_t *); | 27 | int lpfc_read_sparam(struct lpfc_hba *, LPFC_MBOXQ_t *); |
28 | void lpfc_read_config(struct lpfc_hba *, LPFC_MBOXQ_t *); | 28 | void lpfc_read_config(struct lpfc_hba *, LPFC_MBOXQ_t *); |
29 | void lpfc_read_lnk_stat(struct lpfc_hba *, LPFC_MBOXQ_t *); | 29 | void lpfc_read_lnk_stat(struct lpfc_hba *, LPFC_MBOXQ_t *); |
30 | void lpfc_set_slim(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t, uint32_t); | ||
31 | int lpfc_reg_login(struct lpfc_hba *, uint32_t, uint8_t *, LPFC_MBOXQ_t *, | 30 | int lpfc_reg_login(struct lpfc_hba *, uint32_t, uint8_t *, LPFC_MBOXQ_t *, |
32 | uint32_t); | 31 | uint32_t); |
33 | void lpfc_unreg_login(struct lpfc_hba *, uint32_t, LPFC_MBOXQ_t *); | 32 | void lpfc_unreg_login(struct lpfc_hba *, uint32_t, LPFC_MBOXQ_t *); |
diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h index 8932b1be2b60..41cf5d3ea6ce 100644 --- a/drivers/scsi/lpfc/lpfc_disc.h +++ b/drivers/scsi/lpfc/lpfc_disc.h | |||
@@ -113,6 +113,7 @@ struct lpfc_nodelist { | |||
113 | #define NLP_NPR_ADISC 0x2000000 /* Issue ADISC when dq'ed from | 113 | #define NLP_NPR_ADISC 0x2000000 /* Issue ADISC when dq'ed from |
114 | NPR list */ | 114 | NPR list */ |
115 | #define NLP_DELAY_REMOVE 0x4000000 /* Defer removal till end of DSM */ | 115 | #define NLP_DELAY_REMOVE 0x4000000 /* Defer removal till end of DSM */ |
116 | #define NLP_NODEV_REMOVE 0x8000000 /* Defer removal till discovery ends */ | ||
116 | 117 | ||
117 | /* Defines for list searchs */ | 118 | /* Defines for list searchs */ |
118 | #define NLP_SEARCH_MAPPED 0x1 /* search mapped */ | 119 | #define NLP_SEARCH_MAPPED 0x1 /* search mapped */ |
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 4813beaaca8f..283b7d824c34 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c | |||
@@ -302,10 +302,6 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp, | |||
302 | if (lpfc_reg_login(phba, Fabric_DID, (uint8_t *) sp, mbox, 0)) | 302 | if (lpfc_reg_login(phba, Fabric_DID, (uint8_t *) sp, mbox, 0)) |
303 | goto fail_free_mbox; | 303 | goto fail_free_mbox; |
304 | 304 | ||
305 | /* | ||
306 | * set_slim mailbox command needs to execute first, | ||
307 | * queue this command to be processed later. | ||
308 | */ | ||
309 | mbox->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login; | 305 | mbox->mbox_cmpl = lpfc_mbx_cmpl_fabric_reg_login; |
310 | mbox->context2 = ndlp; | 306 | mbox->context2 = ndlp; |
311 | 307 | ||
@@ -781,25 +777,26 @@ lpfc_cmpl_els_plogi(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, | |||
781 | if (disc && phba->num_disc_nodes) { | 777 | if (disc && phba->num_disc_nodes) { |
782 | /* Check to see if there are more PLOGIs to be sent */ | 778 | /* Check to see if there are more PLOGIs to be sent */ |
783 | lpfc_more_plogi(phba); | 779 | lpfc_more_plogi(phba); |
784 | } | ||
785 | 780 | ||
786 | if (phba->num_disc_nodes == 0) { | 781 | if (phba->num_disc_nodes == 0) { |
787 | spin_lock_irq(phba->host->host_lock); | 782 | spin_lock_irq(phba->host->host_lock); |
788 | phba->fc_flag &= ~FC_NDISC_ACTIVE; | 783 | phba->fc_flag &= ~FC_NDISC_ACTIVE; |
789 | spin_unlock_irq(phba->host->host_lock); | 784 | spin_unlock_irq(phba->host->host_lock); |
790 | 785 | ||
791 | lpfc_can_disctmo(phba); | 786 | lpfc_can_disctmo(phba); |
792 | if (phba->fc_flag & FC_RSCN_MODE) { | 787 | if (phba->fc_flag & FC_RSCN_MODE) { |
793 | /* Check to see if more RSCNs came in while we were | 788 | /* |
794 | * processing this one. | 789 | * Check to see if more RSCNs came in while |
795 | */ | 790 | * we were processing this one. |
796 | if ((phba->fc_rscn_id_cnt == 0) && | 791 | */ |
797 | (!(phba->fc_flag & FC_RSCN_DISCOVERY))) { | 792 | if ((phba->fc_rscn_id_cnt == 0) && |
798 | spin_lock_irq(phba->host->host_lock); | 793 | (!(phba->fc_flag & FC_RSCN_DISCOVERY))) { |
799 | phba->fc_flag &= ~FC_RSCN_MODE; | 794 | spin_lock_irq(phba->host->host_lock); |
800 | spin_unlock_irq(phba->host->host_lock); | 795 | phba->fc_flag &= ~FC_RSCN_MODE; |
801 | } else { | 796 | spin_unlock_irq(phba->host->host_lock); |
802 | lpfc_els_handle_rscn(phba); | 797 | } else { |
798 | lpfc_els_handle_rscn(phba); | ||
799 | } | ||
803 | } | 800 | } |
804 | } | 801 | } |
805 | } | 802 | } |
@@ -1263,7 +1260,7 @@ lpfc_issue_els_logo(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, | |||
1263 | psli = &phba->sli; | 1260 | psli = &phba->sli; |
1264 | pring = &psli->ring[LPFC_ELS_RING]; | 1261 | pring = &psli->ring[LPFC_ELS_RING]; |
1265 | 1262 | ||
1266 | cmdsize = 2 * (sizeof (uint32_t) + sizeof (struct lpfc_name)); | 1263 | cmdsize = (2 * sizeof (uint32_t)) + sizeof (struct lpfc_name); |
1267 | elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, ndlp, | 1264 | elsiocb = lpfc_prep_els_iocb(phba, 1, cmdsize, retry, ndlp, |
1268 | ndlp->nlp_DID, ELS_CMD_LOGO); | 1265 | ndlp->nlp_DID, ELS_CMD_LOGO); |
1269 | if (!elsiocb) | 1266 | if (!elsiocb) |
@@ -1451,22 +1448,23 @@ lpfc_cancel_retry_delay_tmo(struct lpfc_hba *phba, struct lpfc_nodelist * nlp) | |||
1451 | * PLOGIs to be sent | 1448 | * PLOGIs to be sent |
1452 | */ | 1449 | */ |
1453 | lpfc_more_plogi(phba); | 1450 | lpfc_more_plogi(phba); |
1454 | } | ||
1455 | 1451 | ||
1456 | if (phba->num_disc_nodes == 0) { | 1452 | if (phba->num_disc_nodes == 0) { |
1457 | phba->fc_flag &= ~FC_NDISC_ACTIVE; | 1453 | phba->fc_flag &= ~FC_NDISC_ACTIVE; |
1458 | lpfc_can_disctmo(phba); | 1454 | lpfc_can_disctmo(phba); |
1459 | if (phba->fc_flag & FC_RSCN_MODE) { | 1455 | if (phba->fc_flag & FC_RSCN_MODE) { |
1460 | /* Check to see if more RSCNs | 1456 | /* |
1461 | * came in while we were | 1457 | * Check to see if more RSCNs |
1462 | * processing this one. | 1458 | * came in while we were |
1463 | */ | 1459 | * processing this one. |
1464 | if((phba->fc_rscn_id_cnt==0) && | 1460 | */ |
1465 | (!(phba->fc_flag & FC_RSCN_DISCOVERY))) { | 1461 | if((phba->fc_rscn_id_cnt==0) && |
1466 | phba->fc_flag &= ~FC_RSCN_MODE; | 1462 | !(phba->fc_flag & FC_RSCN_DISCOVERY)) { |
1467 | } | 1463 | phba->fc_flag &= ~FC_RSCN_MODE; |
1468 | else { | 1464 | } |
1469 | lpfc_els_handle_rscn(phba); | 1465 | else { |
1466 | lpfc_els_handle_rscn(phba); | ||
1467 | } | ||
1470 | } | 1468 | } |
1471 | } | 1469 | } |
1472 | } | 1470 | } |
@@ -1872,9 +1870,6 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, | |||
1872 | if (mbox) { | 1870 | if (mbox) { |
1873 | if ((rspiocb->iocb.ulpStatus == 0) | 1871 | if ((rspiocb->iocb.ulpStatus == 0) |
1874 | && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { | 1872 | && (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) { |
1875 | /* set_slim mailbox command needs to execute first, | ||
1876 | * queue this command to be processed later. | ||
1877 | */ | ||
1878 | lpfc_unreg_rpi(phba, ndlp); | 1873 | lpfc_unreg_rpi(phba, ndlp); |
1879 | mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; | 1874 | mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login; |
1880 | mbox->context2 = ndlp; | 1875 | mbox->context2 = ndlp; |
@@ -1920,6 +1915,7 @@ lpfc_els_rsp_acc(struct lpfc_hba * phba, uint32_t flag, | |||
1920 | uint8_t *pcmd; | 1915 | uint8_t *pcmd; |
1921 | uint16_t cmdsize; | 1916 | uint16_t cmdsize; |
1922 | int rc; | 1917 | int rc; |
1918 | ELS_PKT *els_pkt_ptr; | ||
1923 | 1919 | ||
1924 | psli = &phba->sli; | 1920 | psli = &phba->sli; |
1925 | pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ | 1921 | pring = &psli->ring[LPFC_ELS_RING]; /* ELS ring */ |
@@ -1958,6 +1954,23 @@ lpfc_els_rsp_acc(struct lpfc_hba * phba, uint32_t flag, | |||
1958 | pcmd += sizeof (uint32_t); | 1954 | pcmd += sizeof (uint32_t); |
1959 | memcpy(pcmd, &phba->fc_sparam, sizeof (struct serv_parm)); | 1955 | memcpy(pcmd, &phba->fc_sparam, sizeof (struct serv_parm)); |
1960 | break; | 1956 | break; |
1957 | case ELS_CMD_PRLO: | ||
1958 | cmdsize = sizeof (uint32_t) + sizeof (PRLO); | ||
1959 | elsiocb = lpfc_prep_els_iocb(phba, 0, cmdsize, oldiocb->retry, | ||
1960 | ndlp, ndlp->nlp_DID, ELS_CMD_PRLO); | ||
1961 | if (!elsiocb) | ||
1962 | return 1; | ||
1963 | |||
1964 | icmd = &elsiocb->iocb; | ||
1965 | icmd->ulpContext = oldcmd->ulpContext; /* Xri */ | ||
1966 | pcmd = (((struct lpfc_dmabuf *) elsiocb->context2)->virt); | ||
1967 | |||
1968 | memcpy(pcmd, ((struct lpfc_dmabuf *) oldiocb->context2)->virt, | ||
1969 | sizeof (uint32_t) + sizeof (PRLO)); | ||
1970 | *((uint32_t *) (pcmd)) = ELS_CMD_PRLO_ACC; | ||
1971 | els_pkt_ptr = (ELS_PKT *) pcmd; | ||
1972 | els_pkt_ptr->un.prlo.acceptRspCode = PRLO_REQ_EXECUTED; | ||
1973 | break; | ||
1961 | default: | 1974 | default: |
1962 | return 1; | 1975 | return 1; |
1963 | } | 1976 | } |
@@ -2498,7 +2511,7 @@ lpfc_els_rcv_rscn(struct lpfc_hba * phba, | |||
2498 | /* If we are about to begin discovery, just ACC the RSCN. | 2511 | /* If we are about to begin discovery, just ACC the RSCN. |
2499 | * Discovery processing will satisfy it. | 2512 | * Discovery processing will satisfy it. |
2500 | */ | 2513 | */ |
2501 | if (phba->hba_state < LPFC_NS_QRY) { | 2514 | if (phba->hba_state <= LPFC_NS_QRY) { |
2502 | lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, | 2515 | lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, |
2503 | newnode); | 2516 | newnode); |
2504 | return 0; | 2517 | return 0; |
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 6721e679df62..adb086009ae0 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c | |||
@@ -311,8 +311,8 @@ lpfc_workq_post_event(struct lpfc_hba * phba, void *arg1, void *arg2, | |||
311 | evtp->evt_arg2 = arg2; | 311 | evtp->evt_arg2 = arg2; |
312 | evtp->evt = evt; | 312 | evtp->evt = evt; |
313 | 313 | ||
314 | list_add_tail(&evtp->evt_listp, &phba->work_list); | ||
315 | spin_lock_irq(phba->host->host_lock); | 314 | spin_lock_irq(phba->host->host_lock); |
315 | list_add_tail(&evtp->evt_listp, &phba->work_list); | ||
316 | if (phba->work_wait) | 316 | if (phba->work_wait) |
317 | wake_up(phba->work_wait); | 317 | wake_up(phba->work_wait); |
318 | spin_unlock_irq(phba->host->host_lock); | 318 | spin_unlock_irq(phba->host->host_lock); |
@@ -1071,10 +1071,6 @@ lpfc_register_remote_port(struct lpfc_hba * phba, | |||
1071 | /* initialize static port data */ | 1071 | /* initialize static port data */ |
1072 | rport->maxframe_size = ndlp->nlp_maxframe; | 1072 | rport->maxframe_size = ndlp->nlp_maxframe; |
1073 | rport->supported_classes = ndlp->nlp_class_sup; | 1073 | rport->supported_classes = ndlp->nlp_class_sup; |
1074 | if ((rport->scsi_target_id != -1) && | ||
1075 | (rport->scsi_target_id < MAX_FCP_TARGET)) { | ||
1076 | ndlp->nlp_sid = rport->scsi_target_id; | ||
1077 | } | ||
1078 | rdata = rport->dd_data; | 1074 | rdata = rport->dd_data; |
1079 | rdata->pnode = ndlp; | 1075 | rdata->pnode = ndlp; |
1080 | 1076 | ||
@@ -1087,6 +1083,10 @@ lpfc_register_remote_port(struct lpfc_hba * phba, | |||
1087 | if (rport_ids.roles != FC_RPORT_ROLE_UNKNOWN) | 1083 | if (rport_ids.roles != FC_RPORT_ROLE_UNKNOWN) |
1088 | fc_remote_port_rolechg(rport, rport_ids.roles); | 1084 | fc_remote_port_rolechg(rport, rport_ids.roles); |
1089 | 1085 | ||
1086 | if ((rport->scsi_target_id != -1) && | ||
1087 | (rport->scsi_target_id < MAX_FCP_TARGET)) { | ||
1088 | ndlp->nlp_sid = rport->scsi_target_id; | ||
1089 | } | ||
1090 | 1090 | ||
1091 | return; | 1091 | return; |
1092 | } | 1092 | } |
@@ -1238,6 +1238,7 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list) | |||
1238 | evt_listp); | 1238 | evt_listp); |
1239 | 1239 | ||
1240 | } | 1240 | } |
1241 | nlp->nlp_flag &= ~NLP_NODEV_REMOVE; | ||
1241 | nlp->nlp_type |= NLP_FC_NODE; | 1242 | nlp->nlp_type |= NLP_FC_NODE; |
1242 | break; | 1243 | break; |
1243 | case NLP_MAPPED_LIST: | 1244 | case NLP_MAPPED_LIST: |
@@ -1258,6 +1259,7 @@ lpfc_nlp_list(struct lpfc_hba * phba, struct lpfc_nodelist * nlp, int list) | |||
1258 | evt_listp); | 1259 | evt_listp); |
1259 | 1260 | ||
1260 | } | 1261 | } |
1262 | nlp->nlp_flag &= ~NLP_NODEV_REMOVE; | ||
1261 | break; | 1263 | break; |
1262 | case NLP_NPR_LIST: | 1264 | case NLP_NPR_LIST: |
1263 | nlp->nlp_flag |= list; | 1265 | nlp->nlp_flag |= list; |
@@ -1402,6 +1404,8 @@ lpfc_check_sli_ndlp(struct lpfc_hba * phba, | |||
1402 | if (icmd->ulpContext == (volatile ushort)ndlp->nlp_rpi) | 1404 | if (icmd->ulpContext == (volatile ushort)ndlp->nlp_rpi) |
1403 | return 1; | 1405 | return 1; |
1404 | case CMD_ELS_REQUEST64_CR: | 1406 | case CMD_ELS_REQUEST64_CR: |
1407 | if (icmd->un.elsreq64.remoteID == ndlp->nlp_DID) | ||
1408 | return 1; | ||
1405 | case CMD_XMIT_ELS_RSP64_CX: | 1409 | case CMD_XMIT_ELS_RSP64_CX: |
1406 | if (iocb->context1 == (uint8_t *) ndlp) | 1410 | if (iocb->context1 == (uint8_t *) ndlp) |
1407 | return 1; | 1411 | return 1; |
@@ -1901,10 +1905,8 @@ lpfc_setup_disc_node(struct lpfc_hba * phba, uint32_t did) | |||
1901 | */ | 1905 | */ |
1902 | if (ndlp->nlp_flag & NLP_DELAY_TMO) | 1906 | if (ndlp->nlp_flag & NLP_DELAY_TMO) |
1903 | lpfc_cancel_retry_delay_tmo(phba, ndlp); | 1907 | lpfc_cancel_retry_delay_tmo(phba, ndlp); |
1904 | } else { | 1908 | } else |
1905 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; | ||
1906 | ndlp = NULL; | 1909 | ndlp = NULL; |
1907 | } | ||
1908 | } else { | 1910 | } else { |
1909 | flg = ndlp->nlp_flag & NLP_LIST_MASK; | 1911 | flg = ndlp->nlp_flag & NLP_LIST_MASK; |
1910 | if ((flg == NLP_ADISC_LIST) || (flg == NLP_PLOGI_LIST)) | 1912 | if ((flg == NLP_ADISC_LIST) || (flg == NLP_PLOGI_LIST)) |
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index 54d04188f7cc..eedf98801366 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h | |||
@@ -449,6 +449,7 @@ struct serv_parm { /* Structure is in Big Endian format */ | |||
449 | #define ELS_CMD_RRQ 0x12000000 | 449 | #define ELS_CMD_RRQ 0x12000000 |
450 | #define ELS_CMD_PRLI 0x20100014 | 450 | #define ELS_CMD_PRLI 0x20100014 |
451 | #define ELS_CMD_PRLO 0x21100014 | 451 | #define ELS_CMD_PRLO 0x21100014 |
452 | #define ELS_CMD_PRLO_ACC 0x02100014 | ||
452 | #define ELS_CMD_PDISC 0x50000000 | 453 | #define ELS_CMD_PDISC 0x50000000 |
453 | #define ELS_CMD_FDISC 0x51000000 | 454 | #define ELS_CMD_FDISC 0x51000000 |
454 | #define ELS_CMD_ADISC 0x52000000 | 455 | #define ELS_CMD_ADISC 0x52000000 |
@@ -484,6 +485,7 @@ struct serv_parm { /* Structure is in Big Endian format */ | |||
484 | #define ELS_CMD_RRQ 0x12 | 485 | #define ELS_CMD_RRQ 0x12 |
485 | #define ELS_CMD_PRLI 0x14001020 | 486 | #define ELS_CMD_PRLI 0x14001020 |
486 | #define ELS_CMD_PRLO 0x14001021 | 487 | #define ELS_CMD_PRLO 0x14001021 |
488 | #define ELS_CMD_PRLO_ACC 0x14001002 | ||
487 | #define ELS_CMD_PDISC 0x50 | 489 | #define ELS_CMD_PDISC 0x50 |
488 | #define ELS_CMD_FDISC 0x51 | 490 | #define ELS_CMD_FDISC 0x51 |
489 | #define ELS_CMD_ADISC 0x52 | 491 | #define ELS_CMD_ADISC 0x52 |
@@ -1539,6 +1541,7 @@ typedef struct { | |||
1539 | 1541 | ||
1540 | #define FLAGS_TOPOLOGY_FAILOVER 0x0400 /* Bit 10 */ | 1542 | #define FLAGS_TOPOLOGY_FAILOVER 0x0400 /* Bit 10 */ |
1541 | #define FLAGS_LINK_SPEED 0x0800 /* Bit 11 */ | 1543 | #define FLAGS_LINK_SPEED 0x0800 /* Bit 11 */ |
1544 | #define FLAGS_IMED_ABORT 0x04000 /* Bit 14 */ | ||
1542 | 1545 | ||
1543 | uint32_t link_speed; | 1546 | uint32_t link_speed; |
1544 | #define LINK_SPEED_AUTO 0 /* Auto selection */ | 1547 | #define LINK_SPEED_AUTO 0 /* Auto selection */ |
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 66d5d003555d..908d0f27706f 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c | |||
@@ -294,15 +294,6 @@ lpfc_config_port_post(struct lpfc_hba * phba) | |||
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | ||
297 | /* This should turn on DELAYED ABTS for ELS timeouts */ | ||
298 | lpfc_set_slim(phba, pmb, 0x052198, 0x1); | ||
299 | if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { | ||
300 | phba->hba_state = LPFC_HBA_ERROR; | ||
301 | mempool_free( pmb, phba->mbox_mem_pool); | ||
302 | return -EIO; | ||
303 | } | ||
304 | |||
305 | |||
306 | lpfc_read_config(phba, pmb); | 297 | lpfc_read_config(phba, pmb); |
307 | if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { | 298 | if (lpfc_sli_issue_mbox(phba, pmb, MBX_POLL) != MBX_SUCCESS) { |
308 | lpfc_printf_log(phba, | 299 | lpfc_printf_log(phba, |
@@ -804,7 +795,7 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) | |||
804 | int max_speed; | 795 | int max_speed; |
805 | char * ports; | 796 | char * ports; |
806 | char * bus; | 797 | char * bus; |
807 | } m; | 798 | } m = {"<Unknown>", 0, "", ""}; |
808 | 799 | ||
809 | pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype); | 800 | pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype); |
810 | ports = (hdrtype == 0x80) ? "2-port " : ""; | 801 | ports = (hdrtype == 0x80) ? "2-port " : ""; |
@@ -1627,7 +1618,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |||
1627 | 1618 | ||
1628 | error = lpfc_alloc_sysfs_attr(phba); | 1619 | error = lpfc_alloc_sysfs_attr(phba); |
1629 | if (error) | 1620 | if (error) |
1630 | goto out_kthread_stop; | 1621 | goto out_remove_host; |
1631 | 1622 | ||
1632 | error = request_irq(phba->pcidev->irq, lpfc_intr_handler, SA_SHIRQ, | 1623 | error = request_irq(phba->pcidev->irq, lpfc_intr_handler, SA_SHIRQ, |
1633 | LPFC_DRIVER_NAME, phba); | 1624 | LPFC_DRIVER_NAME, phba); |
@@ -1644,8 +1635,10 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) | |||
1644 | phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; | 1635 | phba->HCregaddr = phba->ctrl_regs_memmap_p + HC_REG_OFFSET; |
1645 | 1636 | ||
1646 | error = lpfc_sli_hba_setup(phba); | 1637 | error = lpfc_sli_hba_setup(phba); |
1647 | if (error) | 1638 | if (error) { |
1639 | error = -ENODEV; | ||
1648 | goto out_free_irq; | 1640 | goto out_free_irq; |
1641 | } | ||
1649 | 1642 | ||
1650 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) { | 1643 | if (phba->cfg_poll & DISABLE_FCP_RING_INT) { |
1651 | spin_lock_irq(phba->host->host_lock); | 1644 | spin_lock_irq(phba->host->host_lock); |
@@ -1700,6 +1693,9 @@ out_free_irq: | |||
1700 | free_irq(phba->pcidev->irq, phba); | 1693 | free_irq(phba->pcidev->irq, phba); |
1701 | out_free_sysfs_attr: | 1694 | out_free_sysfs_attr: |
1702 | lpfc_free_sysfs_attr(phba); | 1695 | lpfc_free_sysfs_attr(phba); |
1696 | out_remove_host: | ||
1697 | fc_remove_host(phba->host); | ||
1698 | scsi_remove_host(phba->host); | ||
1703 | out_kthread_stop: | 1699 | out_kthread_stop: |
1704 | kthread_stop(phba->worker_thread); | 1700 | kthread_stop(phba->worker_thread); |
1705 | out_free_iocbq: | 1701 | out_free_iocbq: |
@@ -1721,12 +1717,14 @@ out_iounmap_slim: | |||
1721 | out_idr_remove: | 1717 | out_idr_remove: |
1722 | idr_remove(&lpfc_hba_index, phba->brd_no); | 1718 | idr_remove(&lpfc_hba_index, phba->brd_no); |
1723 | out_put_host: | 1719 | out_put_host: |
1720 | phba->host = NULL; | ||
1724 | scsi_host_put(host); | 1721 | scsi_host_put(host); |
1725 | out_release_regions: | 1722 | out_release_regions: |
1726 | pci_release_regions(pdev); | 1723 | pci_release_regions(pdev); |
1727 | out_disable_device: | 1724 | out_disable_device: |
1728 | pci_disable_device(pdev); | 1725 | pci_disable_device(pdev); |
1729 | out: | 1726 | out: |
1727 | pci_set_drvdata(pdev, NULL); | ||
1730 | return error; | 1728 | return error; |
1731 | } | 1729 | } |
1732 | 1730 | ||
diff --git a/drivers/scsi/lpfc/lpfc_mbox.c b/drivers/scsi/lpfc/lpfc_mbox.c index c585e2b2e589..e42f22aaf71b 100644 --- a/drivers/scsi/lpfc/lpfc_mbox.c +++ b/drivers/scsi/lpfc/lpfc_mbox.c | |||
@@ -200,6 +200,9 @@ lpfc_init_link(struct lpfc_hba * phba, | |||
200 | break; | 200 | break; |
201 | } | 201 | } |
202 | 202 | ||
203 | /* Enable asynchronous ABTS responses from firmware */ | ||
204 | mb->un.varInitLnk.link_flags |= FLAGS_IMED_ABORT; | ||
205 | |||
203 | /* NEW_FEATURE | 206 | /* NEW_FEATURE |
204 | * Setting up the link speed | 207 | * Setting up the link speed |
205 | */ | 208 | */ |
@@ -292,36 +295,6 @@ lpfc_unreg_did(struct lpfc_hba * phba, uint32_t did, LPFC_MBOXQ_t * pmb) | |||
292 | return; | 295 | return; |
293 | } | 296 | } |
294 | 297 | ||
295 | /***********************************************/ | ||
296 | |||
297 | /* command to write slim */ | ||
298 | /***********************************************/ | ||
299 | void | ||
300 | lpfc_set_slim(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb, uint32_t addr, | ||
301 | uint32_t value) | ||
302 | { | ||
303 | MAILBOX_t *mb; | ||
304 | |||
305 | mb = &pmb->mb; | ||
306 | memset(pmb, 0, sizeof (LPFC_MBOXQ_t)); | ||
307 | |||
308 | /* addr = 0x090597 is AUTO ABTS disable for ELS commands */ | ||
309 | /* addr = 0x052198 is DELAYED ABTS enable for ELS commands */ | ||
310 | |||
311 | /* | ||
312 | * Always turn on DELAYED ABTS for ELS timeouts | ||
313 | */ | ||
314 | if ((addr == 0x052198) && (value == 0)) | ||
315 | value = 1; | ||
316 | |||
317 | mb->un.varWords[0] = addr; | ||
318 | mb->un.varWords[1] = value; | ||
319 | |||
320 | mb->mbxCommand = MBX_SET_SLIM; | ||
321 | mb->mbxOwner = OWN_HOST; | ||
322 | return; | ||
323 | } | ||
324 | |||
325 | /**********************************************/ | 298 | /**********************************************/ |
326 | /* lpfc_read_nv Issue a READ CONFIG */ | 299 | /* lpfc_read_nv Issue a READ CONFIG */ |
327 | /* mailbox command */ | 300 | /* mailbox command */ |
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index 3d77bd999b70..27d60ad897cd 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c | |||
@@ -465,14 +465,18 @@ lpfc_rcv_padisc(struct lpfc_hba * phba, | |||
465 | static int | 465 | static int |
466 | lpfc_rcv_logo(struct lpfc_hba * phba, | 466 | lpfc_rcv_logo(struct lpfc_hba * phba, |
467 | struct lpfc_nodelist * ndlp, | 467 | struct lpfc_nodelist * ndlp, |
468 | struct lpfc_iocbq *cmdiocb) | 468 | struct lpfc_iocbq *cmdiocb, |
469 | uint32_t els_cmd) | ||
469 | { | 470 | { |
470 | /* Put ndlp on NPR list with 1 sec timeout for plogi, ACC logo */ | 471 | /* Put ndlp on NPR list with 1 sec timeout for plogi, ACC logo */ |
471 | /* Only call LOGO ACC for first LOGO, this avoids sending unnecessary | 472 | /* Only call LOGO ACC for first LOGO, this avoids sending unnecessary |
472 | * PLOGIs during LOGO storms from a device. | 473 | * PLOGIs during LOGO storms from a device. |
473 | */ | 474 | */ |
474 | ndlp->nlp_flag |= NLP_LOGO_ACC; | 475 | ndlp->nlp_flag |= NLP_LOGO_ACC; |
475 | lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); | 476 | if (els_cmd == ELS_CMD_PRLO) |
477 | lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0); | ||
478 | else | ||
479 | lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); | ||
476 | 480 | ||
477 | if (!(ndlp->nlp_type & NLP_FABRIC) || | 481 | if (!(ndlp->nlp_type & NLP_FABRIC) || |
478 | (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) { | 482 | (ndlp->nlp_state == NLP_STE_ADISC_ISSUE)) { |
@@ -681,7 +685,7 @@ lpfc_rcv_logo_plogi_issue(struct lpfc_hba * phba, | |||
681 | /* software abort outstanding PLOGI */ | 685 | /* software abort outstanding PLOGI */ |
682 | lpfc_els_abort(phba, ndlp, 1); | 686 | lpfc_els_abort(phba, ndlp, 1); |
683 | 687 | ||
684 | lpfc_rcv_logo(phba, ndlp, cmdiocb); | 688 | lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); |
685 | return ndlp->nlp_state; | 689 | return ndlp->nlp_state; |
686 | } | 690 | } |
687 | 691 | ||
@@ -788,10 +792,6 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba, | |||
788 | if (lpfc_reg_login | 792 | if (lpfc_reg_login |
789 | (phba, irsp->un.elsreq64.remoteID, | 793 | (phba, irsp->un.elsreq64.remoteID, |
790 | (uint8_t *) sp, mbox, 0) == 0) { | 794 | (uint8_t *) sp, mbox, 0) == 0) { |
791 | /* set_slim mailbox command needs to | ||
792 | * execute first, queue this command to | ||
793 | * be processed later. | ||
794 | */ | ||
795 | switch (ndlp->nlp_DID) { | 795 | switch (ndlp->nlp_DID) { |
796 | case NameServer_DID: | 796 | case NameServer_DID: |
797 | mbox->mbox_cmpl = | 797 | mbox->mbox_cmpl = |
@@ -832,11 +832,17 @@ static uint32_t | |||
832 | lpfc_device_rm_plogi_issue(struct lpfc_hba * phba, | 832 | lpfc_device_rm_plogi_issue(struct lpfc_hba * phba, |
833 | struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) | 833 | struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) |
834 | { | 834 | { |
835 | /* software abort outstanding PLOGI */ | 835 | if(ndlp->nlp_flag & NLP_NPR_2B_DISC) { |
836 | lpfc_els_abort(phba, ndlp, 1); | 836 | ndlp->nlp_flag |= NLP_NODEV_REMOVE; |
837 | return ndlp->nlp_state; | ||
838 | } | ||
839 | else { | ||
840 | /* software abort outstanding PLOGI */ | ||
841 | lpfc_els_abort(phba, ndlp, 1); | ||
837 | 842 | ||
838 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | 843 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); |
839 | return NLP_STE_FREED_NODE; | 844 | return NLP_STE_FREED_NODE; |
845 | } | ||
840 | } | 846 | } |
841 | 847 | ||
842 | static uint32_t | 848 | static uint32_t |
@@ -851,7 +857,7 @@ lpfc_device_recov_plogi_issue(struct lpfc_hba * phba, | |||
851 | ndlp->nlp_state = NLP_STE_NPR_NODE; | 857 | ndlp->nlp_state = NLP_STE_NPR_NODE; |
852 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); | 858 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); |
853 | spin_lock_irq(phba->host->host_lock); | 859 | spin_lock_irq(phba->host->host_lock); |
854 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; | 860 | ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); |
855 | spin_unlock_irq(phba->host->host_lock); | 861 | spin_unlock_irq(phba->host->host_lock); |
856 | 862 | ||
857 | return ndlp->nlp_state; | 863 | return ndlp->nlp_state; |
@@ -905,7 +911,7 @@ lpfc_rcv_logo_adisc_issue(struct lpfc_hba * phba, | |||
905 | /* software abort outstanding ADISC */ | 911 | /* software abort outstanding ADISC */ |
906 | lpfc_els_abort(phba, ndlp, 0); | 912 | lpfc_els_abort(phba, ndlp, 0); |
907 | 913 | ||
908 | lpfc_rcv_logo(phba, ndlp, cmdiocb); | 914 | lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); |
909 | return ndlp->nlp_state; | 915 | return ndlp->nlp_state; |
910 | } | 916 | } |
911 | 917 | ||
@@ -932,7 +938,7 @@ lpfc_rcv_prlo_adisc_issue(struct lpfc_hba * phba, | |||
932 | cmdiocb = (struct lpfc_iocbq *) arg; | 938 | cmdiocb = (struct lpfc_iocbq *) arg; |
933 | 939 | ||
934 | /* Treat like rcv logo */ | 940 | /* Treat like rcv logo */ |
935 | lpfc_rcv_logo(phba, ndlp, cmdiocb); | 941 | lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_PRLO); |
936 | return ndlp->nlp_state; | 942 | return ndlp->nlp_state; |
937 | } | 943 | } |
938 | 944 | ||
@@ -987,11 +993,17 @@ lpfc_device_rm_adisc_issue(struct lpfc_hba * phba, | |||
987 | struct lpfc_nodelist * ndlp, void *arg, | 993 | struct lpfc_nodelist * ndlp, void *arg, |
988 | uint32_t evt) | 994 | uint32_t evt) |
989 | { | 995 | { |
990 | /* software abort outstanding ADISC */ | 996 | if(ndlp->nlp_flag & NLP_NPR_2B_DISC) { |
991 | lpfc_els_abort(phba, ndlp, 1); | 997 | ndlp->nlp_flag |= NLP_NODEV_REMOVE; |
998 | return ndlp->nlp_state; | ||
999 | } | ||
1000 | else { | ||
1001 | /* software abort outstanding ADISC */ | ||
1002 | lpfc_els_abort(phba, ndlp, 1); | ||
992 | 1003 | ||
993 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | 1004 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); |
994 | return NLP_STE_FREED_NODE; | 1005 | return NLP_STE_FREED_NODE; |
1006 | } | ||
995 | } | 1007 | } |
996 | 1008 | ||
997 | static uint32_t | 1009 | static uint32_t |
@@ -1006,7 +1018,7 @@ lpfc_device_recov_adisc_issue(struct lpfc_hba * phba, | |||
1006 | ndlp->nlp_state = NLP_STE_NPR_NODE; | 1018 | ndlp->nlp_state = NLP_STE_NPR_NODE; |
1007 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); | 1019 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); |
1008 | spin_lock_irq(phba->host->host_lock); | 1020 | spin_lock_irq(phba->host->host_lock); |
1009 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; | 1021 | ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); |
1010 | ndlp->nlp_flag |= NLP_NPR_ADISC; | 1022 | ndlp->nlp_flag |= NLP_NPR_ADISC; |
1011 | spin_unlock_irq(phba->host->host_lock); | 1023 | spin_unlock_irq(phba->host->host_lock); |
1012 | 1024 | ||
@@ -1048,7 +1060,7 @@ lpfc_rcv_logo_reglogin_issue(struct lpfc_hba * phba, | |||
1048 | 1060 | ||
1049 | cmdiocb = (struct lpfc_iocbq *) arg; | 1061 | cmdiocb = (struct lpfc_iocbq *) arg; |
1050 | 1062 | ||
1051 | lpfc_rcv_logo(phba, ndlp, cmdiocb); | 1063 | lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); |
1052 | return ndlp->nlp_state; | 1064 | return ndlp->nlp_state; |
1053 | } | 1065 | } |
1054 | 1066 | ||
@@ -1073,7 +1085,7 @@ lpfc_rcv_prlo_reglogin_issue(struct lpfc_hba * phba, | |||
1073 | struct lpfc_iocbq *cmdiocb; | 1085 | struct lpfc_iocbq *cmdiocb; |
1074 | 1086 | ||
1075 | cmdiocb = (struct lpfc_iocbq *) arg; | 1087 | cmdiocb = (struct lpfc_iocbq *) arg; |
1076 | lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); | 1088 | lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0); |
1077 | return ndlp->nlp_state; | 1089 | return ndlp->nlp_state; |
1078 | } | 1090 | } |
1079 | 1091 | ||
@@ -1133,8 +1145,14 @@ lpfc_device_rm_reglogin_issue(struct lpfc_hba * phba, | |||
1133 | struct lpfc_nodelist * ndlp, void *arg, | 1145 | struct lpfc_nodelist * ndlp, void *arg, |
1134 | uint32_t evt) | 1146 | uint32_t evt) |
1135 | { | 1147 | { |
1136 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | 1148 | if(ndlp->nlp_flag & NLP_NPR_2B_DISC) { |
1137 | return NLP_STE_FREED_NODE; | 1149 | ndlp->nlp_flag |= NLP_NODEV_REMOVE; |
1150 | return ndlp->nlp_state; | ||
1151 | } | ||
1152 | else { | ||
1153 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | ||
1154 | return NLP_STE_FREED_NODE; | ||
1155 | } | ||
1138 | } | 1156 | } |
1139 | 1157 | ||
1140 | static uint32_t | 1158 | static uint32_t |
@@ -1146,7 +1164,7 @@ lpfc_device_recov_reglogin_issue(struct lpfc_hba * phba, | |||
1146 | ndlp->nlp_state = NLP_STE_NPR_NODE; | 1164 | ndlp->nlp_state = NLP_STE_NPR_NODE; |
1147 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); | 1165 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); |
1148 | spin_lock_irq(phba->host->host_lock); | 1166 | spin_lock_irq(phba->host->host_lock); |
1149 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; | 1167 | ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); |
1150 | spin_unlock_irq(phba->host->host_lock); | 1168 | spin_unlock_irq(phba->host->host_lock); |
1151 | return ndlp->nlp_state; | 1169 | return ndlp->nlp_state; |
1152 | } | 1170 | } |
@@ -1186,7 +1204,7 @@ lpfc_rcv_logo_prli_issue(struct lpfc_hba * phba, | |||
1186 | /* Software abort outstanding PRLI before sending acc */ | 1204 | /* Software abort outstanding PRLI before sending acc */ |
1187 | lpfc_els_abort(phba, ndlp, 1); | 1205 | lpfc_els_abort(phba, ndlp, 1); |
1188 | 1206 | ||
1189 | lpfc_rcv_logo(phba, ndlp, cmdiocb); | 1207 | lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); |
1190 | return ndlp->nlp_state; | 1208 | return ndlp->nlp_state; |
1191 | } | 1209 | } |
1192 | 1210 | ||
@@ -1214,7 +1232,7 @@ lpfc_rcv_prlo_prli_issue(struct lpfc_hba * phba, | |||
1214 | struct lpfc_iocbq *cmdiocb; | 1232 | struct lpfc_iocbq *cmdiocb; |
1215 | 1233 | ||
1216 | cmdiocb = (struct lpfc_iocbq *) arg; | 1234 | cmdiocb = (struct lpfc_iocbq *) arg; |
1217 | lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); | 1235 | lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0); |
1218 | return ndlp->nlp_state; | 1236 | return ndlp->nlp_state; |
1219 | } | 1237 | } |
1220 | 1238 | ||
@@ -1278,11 +1296,17 @@ static uint32_t | |||
1278 | lpfc_device_rm_prli_issue(struct lpfc_hba * phba, | 1296 | lpfc_device_rm_prli_issue(struct lpfc_hba * phba, |
1279 | struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) | 1297 | struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) |
1280 | { | 1298 | { |
1281 | /* software abort outstanding PRLI */ | 1299 | if(ndlp->nlp_flag & NLP_NPR_2B_DISC) { |
1282 | lpfc_els_abort(phba, ndlp, 1); | 1300 | ndlp->nlp_flag |= NLP_NODEV_REMOVE; |
1301 | return ndlp->nlp_state; | ||
1302 | } | ||
1303 | else { | ||
1304 | /* software abort outstanding PLOGI */ | ||
1305 | lpfc_els_abort(phba, ndlp, 1); | ||
1283 | 1306 | ||
1284 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | 1307 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); |
1285 | return NLP_STE_FREED_NODE; | 1308 | return NLP_STE_FREED_NODE; |
1309 | } | ||
1286 | } | 1310 | } |
1287 | 1311 | ||
1288 | 1312 | ||
@@ -1313,7 +1337,7 @@ lpfc_device_recov_prli_issue(struct lpfc_hba * phba, | |||
1313 | ndlp->nlp_state = NLP_STE_NPR_NODE; | 1337 | ndlp->nlp_state = NLP_STE_NPR_NODE; |
1314 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); | 1338 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); |
1315 | spin_lock_irq(phba->host->host_lock); | 1339 | spin_lock_irq(phba->host->host_lock); |
1316 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; | 1340 | ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); |
1317 | spin_unlock_irq(phba->host->host_lock); | 1341 | spin_unlock_irq(phba->host->host_lock); |
1318 | return ndlp->nlp_state; | 1342 | return ndlp->nlp_state; |
1319 | } | 1343 | } |
@@ -1351,7 +1375,7 @@ lpfc_rcv_logo_unmap_node(struct lpfc_hba * phba, | |||
1351 | 1375 | ||
1352 | cmdiocb = (struct lpfc_iocbq *) arg; | 1376 | cmdiocb = (struct lpfc_iocbq *) arg; |
1353 | 1377 | ||
1354 | lpfc_rcv_logo(phba, ndlp, cmdiocb); | 1378 | lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); |
1355 | return ndlp->nlp_state; | 1379 | return ndlp->nlp_state; |
1356 | } | 1380 | } |
1357 | 1381 | ||
@@ -1375,7 +1399,7 @@ lpfc_rcv_prlo_unmap_node(struct lpfc_hba * phba, | |||
1375 | 1399 | ||
1376 | cmdiocb = (struct lpfc_iocbq *) arg; | 1400 | cmdiocb = (struct lpfc_iocbq *) arg; |
1377 | 1401 | ||
1378 | lpfc_els_rsp_acc(phba, ELS_CMD_ACC, cmdiocb, ndlp, NULL, 0); | 1402 | lpfc_els_rsp_acc(phba, ELS_CMD_PRLO, cmdiocb, ndlp, NULL, 0); |
1379 | return ndlp->nlp_state; | 1403 | return ndlp->nlp_state; |
1380 | } | 1404 | } |
1381 | 1405 | ||
@@ -1386,7 +1410,7 @@ lpfc_device_recov_unmap_node(struct lpfc_hba * phba, | |||
1386 | ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE; | 1410 | ndlp->nlp_prev_state = NLP_STE_UNMAPPED_NODE; |
1387 | ndlp->nlp_state = NLP_STE_NPR_NODE; | 1411 | ndlp->nlp_state = NLP_STE_NPR_NODE; |
1388 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); | 1412 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); |
1389 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; | 1413 | ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); |
1390 | lpfc_disc_set_adisc(phba, ndlp); | 1414 | lpfc_disc_set_adisc(phba, ndlp); |
1391 | 1415 | ||
1392 | return ndlp->nlp_state; | 1416 | return ndlp->nlp_state; |
@@ -1424,7 +1448,7 @@ lpfc_rcv_logo_mapped_node(struct lpfc_hba * phba, | |||
1424 | 1448 | ||
1425 | cmdiocb = (struct lpfc_iocbq *) arg; | 1449 | cmdiocb = (struct lpfc_iocbq *) arg; |
1426 | 1450 | ||
1427 | lpfc_rcv_logo(phba, ndlp, cmdiocb); | 1451 | lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); |
1428 | return ndlp->nlp_state; | 1452 | return ndlp->nlp_state; |
1429 | } | 1453 | } |
1430 | 1454 | ||
@@ -1456,7 +1480,7 @@ lpfc_rcv_prlo_mapped_node(struct lpfc_hba * phba, | |||
1456 | spin_unlock_irq(phba->host->host_lock); | 1480 | spin_unlock_irq(phba->host->host_lock); |
1457 | 1481 | ||
1458 | /* Treat like rcv logo */ | 1482 | /* Treat like rcv logo */ |
1459 | lpfc_rcv_logo(phba, ndlp, cmdiocb); | 1483 | lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_PRLO); |
1460 | return ndlp->nlp_state; | 1484 | return ndlp->nlp_state; |
1461 | } | 1485 | } |
1462 | 1486 | ||
@@ -1469,7 +1493,7 @@ lpfc_device_recov_mapped_node(struct lpfc_hba * phba, | |||
1469 | ndlp->nlp_state = NLP_STE_NPR_NODE; | 1493 | ndlp->nlp_state = NLP_STE_NPR_NODE; |
1470 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); | 1494 | lpfc_nlp_list(phba, ndlp, NLP_NPR_LIST); |
1471 | spin_lock_irq(phba->host->host_lock); | 1495 | spin_lock_irq(phba->host->host_lock); |
1472 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; | 1496 | ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); |
1473 | spin_unlock_irq(phba->host->host_lock); | 1497 | spin_unlock_irq(phba->host->host_lock); |
1474 | lpfc_disc_set_adisc(phba, ndlp); | 1498 | lpfc_disc_set_adisc(phba, ndlp); |
1475 | return ndlp->nlp_state; | 1499 | return ndlp->nlp_state; |
@@ -1551,7 +1575,7 @@ lpfc_rcv_logo_npr_node(struct lpfc_hba * phba, | |||
1551 | 1575 | ||
1552 | cmdiocb = (struct lpfc_iocbq *) arg; | 1576 | cmdiocb = (struct lpfc_iocbq *) arg; |
1553 | 1577 | ||
1554 | lpfc_rcv_logo(phba, ndlp, cmdiocb); | 1578 | lpfc_rcv_logo(phba, ndlp, cmdiocb, ELS_CMD_LOGO); |
1555 | return ndlp->nlp_state; | 1579 | return ndlp->nlp_state; |
1556 | } | 1580 | } |
1557 | 1581 | ||
@@ -1617,9 +1641,16 @@ lpfc_cmpl_plogi_npr_node(struct lpfc_hba * phba, | |||
1617 | struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) | 1641 | struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) |
1618 | { | 1642 | { |
1619 | struct lpfc_iocbq *cmdiocb, *rspiocb; | 1643 | struct lpfc_iocbq *cmdiocb, *rspiocb; |
1644 | IOCB_t *irsp; | ||
1620 | 1645 | ||
1621 | cmdiocb = (struct lpfc_iocbq *) arg; | 1646 | cmdiocb = (struct lpfc_iocbq *) arg; |
1622 | rspiocb = cmdiocb->context_un.rsp_iocb; | 1647 | rspiocb = cmdiocb->context_un.rsp_iocb; |
1648 | |||
1649 | irsp = &rspiocb->iocb; | ||
1650 | if (irsp->ulpStatus) { | ||
1651 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | ||
1652 | return NLP_STE_FREED_NODE; | ||
1653 | } | ||
1623 | return ndlp->nlp_state; | 1654 | return ndlp->nlp_state; |
1624 | } | 1655 | } |
1625 | 1656 | ||
@@ -1628,9 +1659,16 @@ lpfc_cmpl_prli_npr_node(struct lpfc_hba * phba, | |||
1628 | struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) | 1659 | struct lpfc_nodelist * ndlp, void *arg, uint32_t evt) |
1629 | { | 1660 | { |
1630 | struct lpfc_iocbq *cmdiocb, *rspiocb; | 1661 | struct lpfc_iocbq *cmdiocb, *rspiocb; |
1662 | IOCB_t *irsp; | ||
1631 | 1663 | ||
1632 | cmdiocb = (struct lpfc_iocbq *) arg; | 1664 | cmdiocb = (struct lpfc_iocbq *) arg; |
1633 | rspiocb = cmdiocb->context_un.rsp_iocb; | 1665 | rspiocb = cmdiocb->context_un.rsp_iocb; |
1666 | |||
1667 | irsp = &rspiocb->iocb; | ||
1668 | if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) { | ||
1669 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | ||
1670 | return NLP_STE_FREED_NODE; | ||
1671 | } | ||
1634 | return ndlp->nlp_state; | 1672 | return ndlp->nlp_state; |
1635 | } | 1673 | } |
1636 | 1674 | ||
@@ -1649,9 +1687,16 @@ lpfc_cmpl_adisc_npr_node(struct lpfc_hba * phba, | |||
1649 | uint32_t evt) | 1687 | uint32_t evt) |
1650 | { | 1688 | { |
1651 | struct lpfc_iocbq *cmdiocb, *rspiocb; | 1689 | struct lpfc_iocbq *cmdiocb, *rspiocb; |
1690 | IOCB_t *irsp; | ||
1652 | 1691 | ||
1653 | cmdiocb = (struct lpfc_iocbq *) arg; | 1692 | cmdiocb = (struct lpfc_iocbq *) arg; |
1654 | rspiocb = cmdiocb->context_un.rsp_iocb; | 1693 | rspiocb = cmdiocb->context_un.rsp_iocb; |
1694 | |||
1695 | irsp = &rspiocb->iocb; | ||
1696 | if (irsp->ulpStatus && (ndlp->nlp_flag & NLP_NODEV_REMOVE)) { | ||
1697 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | ||
1698 | return NLP_STE_FREED_NODE; | ||
1699 | } | ||
1655 | return ndlp->nlp_state; | 1700 | return ndlp->nlp_state; |
1656 | } | 1701 | } |
1657 | 1702 | ||
@@ -1668,7 +1713,12 @@ lpfc_cmpl_reglogin_npr_node(struct lpfc_hba * phba, | |||
1668 | 1713 | ||
1669 | if (!mb->mbxStatus) | 1714 | if (!mb->mbxStatus) |
1670 | ndlp->nlp_rpi = mb->un.varWords[0]; | 1715 | ndlp->nlp_rpi = mb->un.varWords[0]; |
1671 | 1716 | else { | |
1717 | if (ndlp->nlp_flag & NLP_NODEV_REMOVE) { | ||
1718 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | ||
1719 | return NLP_STE_FREED_NODE; | ||
1720 | } | ||
1721 | } | ||
1672 | return ndlp->nlp_state; | 1722 | return ndlp->nlp_state; |
1673 | } | 1723 | } |
1674 | 1724 | ||
@@ -1677,6 +1727,10 @@ lpfc_device_rm_npr_node(struct lpfc_hba * phba, | |||
1677 | struct lpfc_nodelist * ndlp, void *arg, | 1727 | struct lpfc_nodelist * ndlp, void *arg, |
1678 | uint32_t evt) | 1728 | uint32_t evt) |
1679 | { | 1729 | { |
1730 | if (ndlp->nlp_flag & NLP_NPR_2B_DISC) { | ||
1731 | ndlp->nlp_flag |= NLP_NODEV_REMOVE; | ||
1732 | return ndlp->nlp_state; | ||
1733 | } | ||
1680 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); | 1734 | lpfc_nlp_list(phba, ndlp, NLP_NO_LIST); |
1681 | return NLP_STE_FREED_NODE; | 1735 | return NLP_STE_FREED_NODE; |
1682 | } | 1736 | } |
@@ -1687,7 +1741,7 @@ lpfc_device_recov_npr_node(struct lpfc_hba * phba, | |||
1687 | uint32_t evt) | 1741 | uint32_t evt) |
1688 | { | 1742 | { |
1689 | spin_lock_irq(phba->host->host_lock); | 1743 | spin_lock_irq(phba->host->host_lock); |
1690 | ndlp->nlp_flag &= ~NLP_NPR_2B_DISC; | 1744 | ndlp->nlp_flag &= ~(NLP_NODEV_REMOVE | NLP_NPR_2B_DISC); |
1691 | spin_unlock_irq(phba->host->host_lock); | 1745 | spin_unlock_irq(phba->host->host_lock); |
1692 | if (ndlp->nlp_flag & NLP_DELAY_TMO) { | 1746 | if (ndlp->nlp_flag & NLP_DELAY_TMO) { |
1693 | lpfc_cancel_retry_delay_tmo(phba, ndlp); | 1747 | lpfc_cancel_retry_delay_tmo(phba, ndlp); |
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index f93799873721..7dc4c2e6bed2 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c | |||
@@ -629,8 +629,7 @@ lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_hba *phba, | |||
629 | struct lpfc_iocbq *piocbq; | 629 | struct lpfc_iocbq *piocbq; |
630 | IOCB_t *piocb; | 630 | IOCB_t *piocb; |
631 | struct fcp_cmnd *fcp_cmnd; | 631 | struct fcp_cmnd *fcp_cmnd; |
632 | struct scsi_device *scsi_dev = lpfc_cmd->pCmd->device; | 632 | struct lpfc_rport_data *rdata = lpfc_cmd->rdata; |
633 | struct lpfc_rport_data *rdata = scsi_dev->hostdata; | ||
634 | struct lpfc_nodelist *ndlp = rdata->pnode; | 633 | struct lpfc_nodelist *ndlp = rdata->pnode; |
635 | 634 | ||
636 | if ((ndlp == NULL) || (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) { | 635 | if ((ndlp == NULL) || (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) { |
@@ -665,56 +664,18 @@ lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_hba *phba, | |||
665 | piocb->ulpTimeout = lpfc_cmd->timeout; | 664 | piocb->ulpTimeout = lpfc_cmd->timeout; |
666 | } | 665 | } |
667 | 666 | ||
668 | lpfc_cmd->rdata = rdata; | ||
669 | |||
670 | switch (task_mgmt_cmd) { | ||
671 | case FCP_LUN_RESET: | ||
672 | /* Issue LUN Reset to TGT <num> LUN <num> */ | ||
673 | lpfc_printf_log(phba, | ||
674 | KERN_INFO, | ||
675 | LOG_FCP, | ||
676 | "%d:0703 Issue LUN Reset to TGT %d LUN %d " | ||
677 | "Data: x%x x%x\n", | ||
678 | phba->brd_no, | ||
679 | scsi_dev->id, scsi_dev->lun, | ||
680 | ndlp->nlp_rpi, ndlp->nlp_flag); | ||
681 | |||
682 | break; | ||
683 | case FCP_ABORT_TASK_SET: | ||
684 | /* Issue Abort Task Set to TGT <num> LUN <num> */ | ||
685 | lpfc_printf_log(phba, | ||
686 | KERN_INFO, | ||
687 | LOG_FCP, | ||
688 | "%d:0701 Issue Abort Task Set to TGT %d LUN %d " | ||
689 | "Data: x%x x%x\n", | ||
690 | phba->brd_no, | ||
691 | scsi_dev->id, scsi_dev->lun, | ||
692 | ndlp->nlp_rpi, ndlp->nlp_flag); | ||
693 | |||
694 | break; | ||
695 | case FCP_TARGET_RESET: | ||
696 | /* Issue Target Reset to TGT <num> */ | ||
697 | lpfc_printf_log(phba, | ||
698 | KERN_INFO, | ||
699 | LOG_FCP, | ||
700 | "%d:0702 Issue Target Reset to TGT %d " | ||
701 | "Data: x%x x%x\n", | ||
702 | phba->brd_no, | ||
703 | scsi_dev->id, ndlp->nlp_rpi, | ||
704 | ndlp->nlp_flag); | ||
705 | break; | ||
706 | } | ||
707 | |||
708 | return (1); | 667 | return (1); |
709 | } | 668 | } |
710 | 669 | ||
711 | static int | 670 | static int |
712 | lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba) | 671 | lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba, |
672 | unsigned tgt_id, struct lpfc_rport_data *rdata) | ||
713 | { | 673 | { |
714 | struct lpfc_iocbq *iocbq; | 674 | struct lpfc_iocbq *iocbq; |
715 | struct lpfc_iocbq *iocbqrsp; | 675 | struct lpfc_iocbq *iocbqrsp; |
716 | int ret; | 676 | int ret; |
717 | 677 | ||
678 | lpfc_cmd->rdata = rdata; | ||
718 | ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, FCP_TARGET_RESET); | 679 | ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, FCP_TARGET_RESET); |
719 | if (!ret) | 680 | if (!ret) |
720 | return FAILED; | 681 | return FAILED; |
@@ -726,6 +687,13 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba) | |||
726 | if (!iocbqrsp) | 687 | if (!iocbqrsp) |
727 | return FAILED; | 688 | return FAILED; |
728 | 689 | ||
690 | /* Issue Target Reset to TGT <num> */ | ||
691 | lpfc_printf_log(phba, KERN_INFO, LOG_FCP, | ||
692 | "%d:0702 Issue Target Reset to TGT %d " | ||
693 | "Data: x%x x%x\n", | ||
694 | phba->brd_no, tgt_id, rdata->pnode->nlp_rpi, | ||
695 | rdata->pnode->nlp_flag); | ||
696 | |||
729 | ret = lpfc_sli_issue_iocb_wait(phba, | 697 | ret = lpfc_sli_issue_iocb_wait(phba, |
730 | &phba->sli.ring[phba->sli.fcp_ring], | 698 | &phba->sli.ring[phba->sli.fcp_ring], |
731 | iocbq, iocbqrsp, lpfc_cmd->timeout); | 699 | iocbq, iocbqrsp, lpfc_cmd->timeout); |
@@ -1021,6 +989,7 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) | |||
1021 | lpfc_cmd->pCmd = cmnd; | 989 | lpfc_cmd->pCmd = cmnd; |
1022 | lpfc_cmd->timeout = 60; | 990 | lpfc_cmd->timeout = 60; |
1023 | lpfc_cmd->scsi_hba = phba; | 991 | lpfc_cmd->scsi_hba = phba; |
992 | lpfc_cmd->rdata = rdata; | ||
1024 | 993 | ||
1025 | ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, FCP_LUN_RESET); | 994 | ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, FCP_LUN_RESET); |
1026 | if (!ret) | 995 | if (!ret) |
@@ -1033,6 +1002,11 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) | |||
1033 | if (iocbqrsp == NULL) | 1002 | if (iocbqrsp == NULL) |
1034 | goto out_free_scsi_buf; | 1003 | goto out_free_scsi_buf; |
1035 | 1004 | ||
1005 | lpfc_printf_log(phba, KERN_INFO, LOG_FCP, | ||
1006 | "%d:0703 Issue LUN Reset to TGT %d LUN %d " | ||
1007 | "Data: x%x x%x\n", phba->brd_no, cmnd->device->id, | ||
1008 | cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag); | ||
1009 | |||
1036 | ret = lpfc_sli_issue_iocb_wait(phba, | 1010 | ret = lpfc_sli_issue_iocb_wait(phba, |
1037 | &phba->sli.ring[phba->sli.fcp_ring], | 1011 | &phba->sli.ring[phba->sli.fcp_ring], |
1038 | iocbq, iocbqrsp, lpfc_cmd->timeout); | 1012 | iocbq, iocbqrsp, lpfc_cmd->timeout); |
@@ -1104,7 +1078,6 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) | |||
1104 | int match; | 1078 | int match; |
1105 | int ret = FAILED, i, err_count = 0; | 1079 | int ret = FAILED, i, err_count = 0; |
1106 | int cnt, loopcnt; | 1080 | int cnt, loopcnt; |
1107 | unsigned int midlayer_id = 0; | ||
1108 | struct lpfc_scsi_buf * lpfc_cmd; | 1081 | struct lpfc_scsi_buf * lpfc_cmd; |
1109 | 1082 | ||
1110 | lpfc_block_requests(phba); | 1083 | lpfc_block_requests(phba); |
@@ -1124,7 +1097,6 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) | |||
1124 | * targets known to the driver. Should any target reset | 1097 | * targets known to the driver. Should any target reset |
1125 | * fail, this routine returns failure to the midlayer. | 1098 | * fail, this routine returns failure to the midlayer. |
1126 | */ | 1099 | */ |
1127 | midlayer_id = cmnd->device->id; | ||
1128 | for (i = 0; i < MAX_FCP_TARGET; i++) { | 1100 | for (i = 0; i < MAX_FCP_TARGET; i++) { |
1129 | /* Search the mapped list for this target ID */ | 1101 | /* Search the mapped list for this target ID */ |
1130 | match = 0; | 1102 | match = 0; |
@@ -1137,9 +1109,8 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) | |||
1137 | if (!match) | 1109 | if (!match) |
1138 | continue; | 1110 | continue; |
1139 | 1111 | ||
1140 | lpfc_cmd->pCmd->device->id = i; | 1112 | ret = lpfc_scsi_tgt_reset(lpfc_cmd, phba, |
1141 | lpfc_cmd->pCmd->device->hostdata = ndlp->rport->dd_data; | 1113 | i, ndlp->rport->dd_data); |
1142 | ret = lpfc_scsi_tgt_reset(lpfc_cmd, phba); | ||
1143 | if (ret != SUCCESS) { | 1114 | if (ret != SUCCESS) { |
1144 | lpfc_printf_log(phba, KERN_ERR, LOG_FCP, | 1115 | lpfc_printf_log(phba, KERN_ERR, LOG_FCP, |
1145 | "%d:0713 Bus Reset on target %d failed\n", | 1116 | "%d:0713 Bus Reset on target %d failed\n", |
@@ -1158,7 +1129,6 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) | |||
1158 | * the targets. Unfortunately, some targets do not abide by | 1129 | * the targets. Unfortunately, some targets do not abide by |
1159 | * this forcing the driver to double check. | 1130 | * this forcing the driver to double check. |
1160 | */ | 1131 | */ |
1161 | cmnd->device->id = midlayer_id; | ||
1162 | cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], | 1132 | cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], |
1163 | 0, 0, LPFC_CTX_HOST); | 1133 | 0, 0, LPFC_CTX_HOST); |
1164 | if (cnt) | 1134 | if (cnt) |
diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h index 4cf1366108b7..6b737568b831 100644 --- a/drivers/scsi/lpfc/lpfc_version.h +++ b/drivers/scsi/lpfc/lpfc_version.h | |||
@@ -18,7 +18,7 @@ | |||
18 | * included with this package. * | 18 | * included with this package. * |
19 | *******************************************************************/ | 19 | *******************************************************************/ |
20 | 20 | ||
21 | #define LPFC_DRIVER_VERSION "8.1.4" | 21 | #define LPFC_DRIVER_VERSION "8.1.6" |
22 | 22 | ||
23 | #define LPFC_DRIVER_NAME "lpfc" | 23 | #define LPFC_DRIVER_NAME "lpfc" |
24 | 24 | ||
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 80b68a2481b3..de35ffe2f79d 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -4471,7 +4471,6 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) | |||
4471 | { | 4471 | { |
4472 | Scsi_Cmnd *scmd; | 4472 | Scsi_Cmnd *scmd; |
4473 | struct scsi_device *sdev; | 4473 | struct scsi_device *sdev; |
4474 | unsigned long flags = 0; | ||
4475 | scb_t *scb; | 4474 | scb_t *scb; |
4476 | int rval; | 4475 | int rval; |
4477 | 4476 | ||
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index c11e5ce6865e..bec1424eda85 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * 2 of the License, or (at your option) any later version. | 10 | * 2 of the License, or (at your option) any later version. |
11 | * | 11 | * |
12 | * FILE : megaraid_mbox.c | 12 | * FILE : megaraid_mbox.c |
13 | * Version : v2.20.4.7 (Nov 14 2005) | 13 | * Version : v2.20.4.8 (Apr 11 2006) |
14 | * | 14 | * |
15 | * Authors: | 15 | * Authors: |
16 | * Atul Mukker <Atul.Mukker@lsil.com> | 16 | * Atul Mukker <Atul.Mukker@lsil.com> |
@@ -2278,6 +2278,7 @@ megaraid_mbox_dpc(unsigned long devp) | |||
2278 | unsigned long flags; | 2278 | unsigned long flags; |
2279 | uint8_t c; | 2279 | uint8_t c; |
2280 | int status; | 2280 | int status; |
2281 | uioc_t *kioc; | ||
2281 | 2282 | ||
2282 | 2283 | ||
2283 | if (!adapter) return; | 2284 | if (!adapter) return; |
@@ -2320,6 +2321,9 @@ megaraid_mbox_dpc(unsigned long devp) | |||
2320 | // remove from local clist | 2321 | // remove from local clist |
2321 | list_del_init(&scb->list); | 2322 | list_del_init(&scb->list); |
2322 | 2323 | ||
2324 | kioc = (uioc_t *)scb->gp; | ||
2325 | kioc->status = 0; | ||
2326 | |||
2323 | megaraid_mbox_mm_done(adapter, scb); | 2327 | megaraid_mbox_mm_done(adapter, scb); |
2324 | 2328 | ||
2325 | continue; | 2329 | continue; |
@@ -2636,6 +2640,7 @@ megaraid_reset_handler(struct scsi_cmnd *scp) | |||
2636 | int recovery_window; | 2640 | int recovery_window; |
2637 | int recovering; | 2641 | int recovering; |
2638 | int i; | 2642 | int i; |
2643 | uioc_t *kioc; | ||
2639 | 2644 | ||
2640 | adapter = SCP2ADAPTER(scp); | 2645 | adapter = SCP2ADAPTER(scp); |
2641 | raid_dev = ADAP2RAIDDEV(adapter); | 2646 | raid_dev = ADAP2RAIDDEV(adapter); |
@@ -2655,32 +2660,51 @@ megaraid_reset_handler(struct scsi_cmnd *scp) | |||
2655 | // Also, reset all the commands currently owned by the driver | 2660 | // Also, reset all the commands currently owned by the driver |
2656 | spin_lock_irqsave(PENDING_LIST_LOCK(adapter), flags); | 2661 | spin_lock_irqsave(PENDING_LIST_LOCK(adapter), flags); |
2657 | list_for_each_entry_safe(scb, tmp, &adapter->pend_list, list) { | 2662 | list_for_each_entry_safe(scb, tmp, &adapter->pend_list, list) { |
2658 | |||
2659 | list_del_init(&scb->list); // from pending list | 2663 | list_del_init(&scb->list); // from pending list |
2660 | 2664 | ||
2661 | con_log(CL_ANN, (KERN_WARNING | 2665 | if (scb->sno >= MBOX_MAX_SCSI_CMDS) { |
2662 | "megaraid: %ld:%d[%d:%d], reset from pending list\n", | 2666 | con_log(CL_ANN, (KERN_WARNING |
2663 | scp->serial_number, scb->sno, | 2667 | "megaraid: IOCTL packet with %d[%d:%d] being reset\n", |
2664 | scb->dev_channel, scb->dev_target)); | 2668 | scb->sno, scb->dev_channel, scb->dev_target)); |
2665 | 2669 | ||
2666 | scp->result = (DID_RESET << 16); | 2670 | scb->status = -1; |
2667 | scp->scsi_done(scp); | ||
2668 | 2671 | ||
2669 | megaraid_dealloc_scb(adapter, scb); | 2672 | kioc = (uioc_t *)scb->gp; |
2673 | kioc->status = -EFAULT; | ||
2674 | |||
2675 | megaraid_mbox_mm_done(adapter, scb); | ||
2676 | } else { | ||
2677 | if (scb->scp == scp) { // Found command | ||
2678 | con_log(CL_ANN, (KERN_WARNING | ||
2679 | "megaraid: %ld:%d[%d:%d], reset from pending list\n", | ||
2680 | scp->serial_number, scb->sno, | ||
2681 | scb->dev_channel, scb->dev_target)); | ||
2682 | } else { | ||
2683 | con_log(CL_ANN, (KERN_WARNING | ||
2684 | "megaraid: IO packet with %d[%d:%d] being reset\n", | ||
2685 | scb->sno, scb->dev_channel, scb->dev_target)); | ||
2686 | } | ||
2687 | |||
2688 | scb->scp->result = (DID_RESET << 16); | ||
2689 | scb->scp->scsi_done(scb->scp); | ||
2690 | |||
2691 | megaraid_dealloc_scb(adapter, scb); | ||
2692 | } | ||
2670 | } | 2693 | } |
2671 | spin_unlock_irqrestore(PENDING_LIST_LOCK(adapter), flags); | 2694 | spin_unlock_irqrestore(PENDING_LIST_LOCK(adapter), flags); |
2672 | 2695 | ||
2673 | if (adapter->outstanding_cmds) { | 2696 | if (adapter->outstanding_cmds) { |
2674 | con_log(CL_ANN, (KERN_NOTICE | 2697 | con_log(CL_ANN, (KERN_NOTICE |
2675 | "megaraid: %d outstanding commands. Max wait %d sec\n", | 2698 | "megaraid: %d outstanding commands. Max wait %d sec\n", |
2676 | adapter->outstanding_cmds, MBOX_RESET_WAIT)); | 2699 | adapter->outstanding_cmds, |
2700 | (MBOX_RESET_WAIT + MBOX_RESET_EXT_WAIT))); | ||
2677 | } | 2701 | } |
2678 | 2702 | ||
2679 | recovery_window = MBOX_RESET_WAIT + MBOX_RESET_EXT_WAIT; | 2703 | recovery_window = MBOX_RESET_WAIT + MBOX_RESET_EXT_WAIT; |
2680 | 2704 | ||
2681 | recovering = adapter->outstanding_cmds; | 2705 | recovering = adapter->outstanding_cmds; |
2682 | 2706 | ||
2683 | for (i = 0; i < recovery_window && adapter->outstanding_cmds; i++) { | 2707 | for (i = 0; i < recovery_window; i++) { |
2684 | 2708 | ||
2685 | megaraid_ack_sequence(adapter); | 2709 | megaraid_ack_sequence(adapter); |
2686 | 2710 | ||
@@ -2689,12 +2713,11 @@ megaraid_reset_handler(struct scsi_cmnd *scp) | |||
2689 | con_log(CL_ANN, ( | 2713 | con_log(CL_ANN, ( |
2690 | "megaraid mbox: Wait for %d commands to complete:%d\n", | 2714 | "megaraid mbox: Wait for %d commands to complete:%d\n", |
2691 | adapter->outstanding_cmds, | 2715 | adapter->outstanding_cmds, |
2692 | MBOX_RESET_WAIT - i)); | 2716 | (MBOX_RESET_WAIT + MBOX_RESET_EXT_WAIT) - i)); |
2693 | } | 2717 | } |
2694 | 2718 | ||
2695 | // bailout if no recovery happended in reset time | 2719 | // bailout if no recovery happended in reset time |
2696 | if ((i == MBOX_RESET_WAIT) && | 2720 | if (adapter->outstanding_cmds == 0) { |
2697 | (recovering == adapter->outstanding_cmds)) { | ||
2698 | break; | 2721 | break; |
2699 | } | 2722 | } |
2700 | 2723 | ||
@@ -2918,12 +2941,13 @@ mbox_post_sync_cmd_fast(adapter_t *adapter, uint8_t raw_mbox[]) | |||
2918 | wmb(); | 2941 | wmb(); |
2919 | WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1); | 2942 | WRINDOOR(raid_dev, raid_dev->mbox_dma | 0x1); |
2920 | 2943 | ||
2921 | for (i = 0; i < 0xFFFFF; i++) { | 2944 | for (i = 0; i < MBOX_SYNC_WAIT_CNT; i++) { |
2922 | if (mbox->numstatus != 0xFF) break; | 2945 | if (mbox->numstatus != 0xFF) break; |
2923 | rmb(); | 2946 | rmb(); |
2947 | udelay(MBOX_SYNC_DELAY_200); | ||
2924 | } | 2948 | } |
2925 | 2949 | ||
2926 | if (i == 0xFFFFF) { | 2950 | if (i == MBOX_SYNC_WAIT_CNT) { |
2927 | // We may need to re-calibrate the counter | 2951 | // We may need to re-calibrate the counter |
2928 | con_log(CL_ANN, (KERN_CRIT | 2952 | con_log(CL_ANN, (KERN_CRIT |
2929 | "megaraid: fast sync command timed out\n")); | 2953 | "megaraid: fast sync command timed out\n")); |
@@ -3475,7 +3499,7 @@ megaraid_cmm_register(adapter_t *adapter) | |||
3475 | adp.drvr_data = (unsigned long)adapter; | 3499 | adp.drvr_data = (unsigned long)adapter; |
3476 | adp.pdev = adapter->pdev; | 3500 | adp.pdev = adapter->pdev; |
3477 | adp.issue_uioc = megaraid_mbox_mm_handler; | 3501 | adp.issue_uioc = megaraid_mbox_mm_handler; |
3478 | adp.timeout = 300; | 3502 | adp.timeout = MBOX_RESET_WAIT + MBOX_RESET_EXT_WAIT; |
3479 | adp.max_kioc = MBOX_MAX_USER_CMDS; | 3503 | adp.max_kioc = MBOX_MAX_USER_CMDS; |
3480 | 3504 | ||
3481 | if ((rval = mraid_mm_register_adp(&adp)) != 0) { | 3505 | if ((rval = mraid_mm_register_adp(&adp)) != 0) { |
@@ -3702,7 +3726,6 @@ megaraid_mbox_mm_done(adapter_t *adapter, scb_t *scb) | |||
3702 | unsigned long flags; | 3726 | unsigned long flags; |
3703 | 3727 | ||
3704 | kioc = (uioc_t *)scb->gp; | 3728 | kioc = (uioc_t *)scb->gp; |
3705 | kioc->status = 0; | ||
3706 | mbox64 = (mbox64_t *)(unsigned long)kioc->cmdbuf; | 3729 | mbox64 = (mbox64_t *)(unsigned long)kioc->cmdbuf; |
3707 | mbox64->mbox32.status = scb->status; | 3730 | mbox64->mbox32.status = scb->status; |
3708 | raw_mbox = (uint8_t *)&mbox64->mbox32; | 3731 | raw_mbox = (uint8_t *)&mbox64->mbox32; |
diff --git a/drivers/scsi/megaraid/megaraid_mbox.h b/drivers/scsi/megaraid/megaraid_mbox.h index 882fb1a0b575..868fb0ec93e7 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.h +++ b/drivers/scsi/megaraid/megaraid_mbox.h | |||
@@ -21,8 +21,8 @@ | |||
21 | #include "megaraid_ioctl.h" | 21 | #include "megaraid_ioctl.h" |
22 | 22 | ||
23 | 23 | ||
24 | #define MEGARAID_VERSION "2.20.4.7" | 24 | #define MEGARAID_VERSION "2.20.4.8" |
25 | #define MEGARAID_EXT_VERSION "(Release Date: Mon Nov 14 12:27:22 EST 2005)" | 25 | #define MEGARAID_EXT_VERSION "(Release Date: Mon Apr 11 12:27:22 EST 2006)" |
26 | 26 | ||
27 | 27 | ||
28 | /* | 28 | /* |
@@ -100,6 +100,9 @@ | |||
100 | #define MBOX_BUSY_WAIT 10 // max usec to wait for busy mailbox | 100 | #define MBOX_BUSY_WAIT 10 // max usec to wait for busy mailbox |
101 | #define MBOX_RESET_WAIT 180 // wait these many seconds in reset | 101 | #define MBOX_RESET_WAIT 180 // wait these many seconds in reset |
102 | #define MBOX_RESET_EXT_WAIT 120 // extended wait reset | 102 | #define MBOX_RESET_EXT_WAIT 120 // extended wait reset |
103 | #define MBOX_SYNC_WAIT_CNT 0xFFFF // wait loop index for synchronous mode | ||
104 | |||
105 | #define MBOX_SYNC_DELAY_200 200 // 200 micro-seconds | ||
103 | 106 | ||
104 | /* | 107 | /* |
105 | * maximum transfer that can happen through the firmware commands issued | 108 | * maximum transfer that can happen through the firmware commands issued |
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c index 8f3ce0432295..e8f534fb336b 100644 --- a/drivers/scsi/megaraid/megaraid_mm.c +++ b/drivers/scsi/megaraid/megaraid_mm.c | |||
@@ -898,10 +898,8 @@ mraid_mm_register_adp(mraid_mmadp_t *lld_adp) | |||
898 | 898 | ||
899 | adapter = kmalloc(sizeof(mraid_mmadp_t), GFP_KERNEL); | 899 | adapter = kmalloc(sizeof(mraid_mmadp_t), GFP_KERNEL); |
900 | 900 | ||
901 | if (!adapter) { | 901 | if (!adapter) |
902 | rval = -ENOMEM; | 902 | return -ENOMEM; |
903 | goto memalloc_error; | ||
904 | } | ||
905 | 903 | ||
906 | memset(adapter, 0, sizeof(mraid_mmadp_t)); | 904 | memset(adapter, 0, sizeof(mraid_mmadp_t)); |
907 | 905 | ||
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 017729c59a49..584fe5d8e507 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
@@ -599,6 +599,7 @@ qla2x00_wait_for_loop_ready(scsi_qla_host_t *ha) | |||
599 | * Either SUCCESS or FAILED. | 599 | * Either SUCCESS or FAILED. |
600 | * | 600 | * |
601 | * Note: | 601 | * Note: |
602 | * Only return FAILED if command not returned by firmware. | ||
602 | **************************************************************************/ | 603 | **************************************************************************/ |
603 | int | 604 | int |
604 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) | 605 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
@@ -609,11 +610,12 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
609 | unsigned int id, lun; | 610 | unsigned int id, lun; |
610 | unsigned long serial; | 611 | unsigned long serial; |
611 | unsigned long flags; | 612 | unsigned long flags; |
613 | int wait = 0; | ||
612 | 614 | ||
613 | if (!CMD_SP(cmd)) | 615 | if (!CMD_SP(cmd)) |
614 | return FAILED; | 616 | return SUCCESS; |
615 | 617 | ||
616 | ret = FAILED; | 618 | ret = SUCCESS; |
617 | 619 | ||
618 | id = cmd->device->id; | 620 | id = cmd->device->id; |
619 | lun = cmd->device->lun; | 621 | lun = cmd->device->lun; |
@@ -642,7 +644,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
642 | } else { | 644 | } else { |
643 | DEBUG3(printk("%s(%ld): abort_command " | 645 | DEBUG3(printk("%s(%ld): abort_command " |
644 | "mbx success.\n", __func__, ha->host_no)); | 646 | "mbx success.\n", __func__, ha->host_no)); |
645 | ret = SUCCESS; | 647 | wait = 1; |
646 | } | 648 | } |
647 | spin_lock_irqsave(&ha->hardware_lock, flags); | 649 | spin_lock_irqsave(&ha->hardware_lock, flags); |
648 | 650 | ||
@@ -651,17 +653,18 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd) | |||
651 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 653 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
652 | 654 | ||
653 | /* Wait for the command to be returned. */ | 655 | /* Wait for the command to be returned. */ |
654 | if (ret == SUCCESS) { | 656 | if (wait) { |
655 | if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) { | 657 | if (qla2x00_eh_wait_on_command(ha, cmd) != QLA_SUCCESS) { |
656 | qla_printk(KERN_ERR, ha, | 658 | qla_printk(KERN_ERR, ha, |
657 | "scsi(%ld:%d:%d): Abort handler timed out -- %lx " | 659 | "scsi(%ld:%d:%d): Abort handler timed out -- %lx " |
658 | "%x.\n", ha->host_no, id, lun, serial, ret); | 660 | "%x.\n", ha->host_no, id, lun, serial, ret); |
661 | ret = FAILED; | ||
659 | } | 662 | } |
660 | } | 663 | } |
661 | 664 | ||
662 | qla_printk(KERN_INFO, ha, | 665 | qla_printk(KERN_INFO, ha, |
663 | "scsi(%ld:%d:%d): Abort command issued -- %lx %x.\n", ha->host_no, | 666 | "scsi(%ld:%d:%d): Abort command issued -- %d %lx %x.\n", |
664 | id, lun, serial, ret); | 667 | ha->host_no, id, lun, wait, serial, ret); |
665 | 668 | ||
666 | return ret; | 669 | return ret; |
667 | } | 670 | } |
@@ -1700,8 +1703,8 @@ qla2x00_free_device(scsi_qla_host_t *ha) | |||
1700 | ha->flags.online = 0; | 1703 | ha->flags.online = 0; |
1701 | 1704 | ||
1702 | /* Detach interrupts */ | 1705 | /* Detach interrupts */ |
1703 | if (ha->pdev->irq) | 1706 | if (ha->host->irq) |
1704 | free_irq(ha->pdev->irq, ha); | 1707 | free_irq(ha->host->irq, ha); |
1705 | 1708 | ||
1706 | /* release io space registers */ | 1709 | /* release io space registers */ |
1707 | if (ha->iobase) | 1710 | if (ha->iobase) |
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index c750d3399a97..941c1e15c899 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c | |||
@@ -56,6 +56,8 @@ static struct { | |||
56 | {"DENON", "DRD-25X", "V", BLIST_NOLUN}, /* locks up */ | 56 | {"DENON", "DRD-25X", "V", BLIST_NOLUN}, /* locks up */ |
57 | {"HITACHI", "DK312C", "CM81", BLIST_NOLUN}, /* responds to all lun */ | 57 | {"HITACHI", "DK312C", "CM81", BLIST_NOLUN}, /* responds to all lun */ |
58 | {"HITACHI", "DK314C", "CR21", BLIST_NOLUN}, /* responds to all lun */ | 58 | {"HITACHI", "DK314C", "CR21", BLIST_NOLUN}, /* responds to all lun */ |
59 | {"IBM", "2104-DU3", NULL, BLIST_NOLUN}, /* locks up */ | ||
60 | {"IBM", "2104-TU3", NULL, BLIST_NOLUN}, /* locks up */ | ||
59 | {"IMS", "CDD521/10", "2.06", BLIST_NOLUN}, /* locks up */ | 61 | {"IMS", "CDD521/10", "2.06", BLIST_NOLUN}, /* locks up */ |
60 | {"MAXTOR", "XT-3280", "PR02", BLIST_NOLUN}, /* locks up */ | 62 | {"MAXTOR", "XT-3280", "PR02", BLIST_NOLUN}, /* locks up */ |
61 | {"MAXTOR", "XT-4380S", "B3C", BLIST_NOLUN}, /* locks up */ | 63 | {"MAXTOR", "XT-4380S", "B3C", BLIST_NOLUN}, /* locks up */ |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 7b0f9a3810d2..764a8b375ead 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -1067,16 +1067,29 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, | |||
1067 | break; | 1067 | break; |
1068 | case NOT_READY: | 1068 | case NOT_READY: |
1069 | /* | 1069 | /* |
1070 | * If the device is in the process of becoming ready, | 1070 | * If the device is in the process of becoming |
1071 | * retry. | 1071 | * ready, or has a temporary blockage, retry. |
1072 | */ | 1072 | */ |
1073 | if (sshdr.asc == 0x04 && sshdr.ascq == 0x01) { | 1073 | if (sshdr.asc == 0x04) { |
1074 | scsi_requeue_command(q, cmd); | 1074 | switch (sshdr.ascq) { |
1075 | return; | 1075 | case 0x01: /* becoming ready */ |
1076 | case 0x04: /* format in progress */ | ||
1077 | case 0x05: /* rebuild in progress */ | ||
1078 | case 0x06: /* recalculation in progress */ | ||
1079 | case 0x07: /* operation in progress */ | ||
1080 | case 0x08: /* Long write in progress */ | ||
1081 | case 0x09: /* self test in progress */ | ||
1082 | scsi_requeue_command(q, cmd); | ||
1083 | return; | ||
1084 | default: | ||
1085 | break; | ||
1086 | } | ||
1076 | } | 1087 | } |
1077 | if (!(req->flags & REQ_QUIET)) | 1088 | if (!(req->flags & REQ_QUIET)) { |
1078 | scmd_printk(KERN_INFO, cmd, | 1089 | scmd_printk(KERN_INFO, cmd, |
1079 | "Device not ready.\n"); | 1090 | "Device not ready: "); |
1091 | scsi_print_sense_hdr("", &sshdr); | ||
1092 | } | ||
1080 | scsi_end_request(cmd, 0, this_count, 1); | 1093 | scsi_end_request(cmd, 0, this_count, 1); |
1081 | return; | 1094 | return; |
1082 | case VOLUME_OVERFLOW: | 1095 | case VOLUME_OVERFLOW: |
diff --git a/drivers/scsi/sim710.c b/drivers/scsi/sim710.c index 3274ab76c8d3..255886a9ac55 100644 --- a/drivers/scsi/sim710.c +++ b/drivers/scsi/sim710.c | |||
@@ -75,7 +75,7 @@ param_setup(char *str) | |||
75 | else if(!strncmp(pos, "id:", 3)) { | 75 | else if(!strncmp(pos, "id:", 3)) { |
76 | if(slot == -1) { | 76 | if(slot == -1) { |
77 | printk(KERN_WARNING "sim710: Must specify slot for id parameter\n"); | 77 | printk(KERN_WARNING "sim710: Must specify slot for id parameter\n"); |
78 | } else if(slot > MAX_SLOTS) { | 78 | } else if(slot >= MAX_SLOTS) { |
79 | printk(KERN_WARNING "sim710: Illegal slot %d for id %d\n", slot, val); | 79 | printk(KERN_WARNING "sim710: Illegal slot %d for id %d\n", slot, val); |
80 | } else { | 80 | } else { |
81 | id_array[slot] = val; | 81 | id_array[slot] = val; |
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c index 674b15c78f68..bbf78aaf9e01 100644 --- a/drivers/serial/8250.c +++ b/drivers/serial/8250.c | |||
@@ -362,6 +362,40 @@ serial_out(struct uart_8250_port *up, int offset, int value) | |||
362 | #define serial_inp(up, offset) serial_in(up, offset) | 362 | #define serial_inp(up, offset) serial_in(up, offset) |
363 | #define serial_outp(up, offset, value) serial_out(up, offset, value) | 363 | #define serial_outp(up, offset, value) serial_out(up, offset, value) |
364 | 364 | ||
365 | /* Uart divisor latch read */ | ||
366 | static inline int _serial_dl_read(struct uart_8250_port *up) | ||
367 | { | ||
368 | return serial_inp(up, UART_DLL) | serial_inp(up, UART_DLM) << 8; | ||
369 | } | ||
370 | |||
371 | /* Uart divisor latch write */ | ||
372 | static inline void _serial_dl_write(struct uart_8250_port *up, int value) | ||
373 | { | ||
374 | serial_outp(up, UART_DLL, value & 0xff); | ||
375 | serial_outp(up, UART_DLM, value >> 8 & 0xff); | ||
376 | } | ||
377 | |||
378 | #ifdef CONFIG_SERIAL_8250_AU1X00 | ||
379 | /* Au1x00 haven't got a standard divisor latch */ | ||
380 | static int serial_dl_read(struct uart_8250_port *up) | ||
381 | { | ||
382 | if (up->port.iotype == UPIO_AU) | ||
383 | return __raw_readl(up->port.membase + 0x28); | ||
384 | else | ||
385 | return _serial_dl_read(up); | ||
386 | } | ||
387 | |||
388 | static void serial_dl_write(struct uart_8250_port *up, int value) | ||
389 | { | ||
390 | if (up->port.iotype == UPIO_AU) | ||
391 | __raw_writel(value, up->port.membase + 0x28); | ||
392 | else | ||
393 | _serial_dl_write(up, value); | ||
394 | } | ||
395 | #else | ||
396 | #define serial_dl_read(up) _serial_dl_read(up) | ||
397 | #define serial_dl_write(up, value) _serial_dl_write(up, value) | ||
398 | #endif | ||
365 | 399 | ||
366 | /* | 400 | /* |
367 | * For the 16C950 | 401 | * For the 16C950 |
@@ -494,7 +528,8 @@ static void disable_rsa(struct uart_8250_port *up) | |||
494 | */ | 528 | */ |
495 | static int size_fifo(struct uart_8250_port *up) | 529 | static int size_fifo(struct uart_8250_port *up) |
496 | { | 530 | { |
497 | unsigned char old_fcr, old_mcr, old_dll, old_dlm, old_lcr; | 531 | unsigned char old_fcr, old_mcr, old_lcr; |
532 | unsigned short old_dl; | ||
498 | int count; | 533 | int count; |
499 | 534 | ||
500 | old_lcr = serial_inp(up, UART_LCR); | 535 | old_lcr = serial_inp(up, UART_LCR); |
@@ -505,10 +540,8 @@ static int size_fifo(struct uart_8250_port *up) | |||
505 | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); | 540 | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); |
506 | serial_outp(up, UART_MCR, UART_MCR_LOOP); | 541 | serial_outp(up, UART_MCR, UART_MCR_LOOP); |
507 | serial_outp(up, UART_LCR, UART_LCR_DLAB); | 542 | serial_outp(up, UART_LCR, UART_LCR_DLAB); |
508 | old_dll = serial_inp(up, UART_DLL); | 543 | old_dl = serial_dl_read(up); |
509 | old_dlm = serial_inp(up, UART_DLM); | 544 | serial_dl_write(up, 0x0001); |
510 | serial_outp(up, UART_DLL, 0x01); | ||
511 | serial_outp(up, UART_DLM, 0x00); | ||
512 | serial_outp(up, UART_LCR, 0x03); | 545 | serial_outp(up, UART_LCR, 0x03); |
513 | for (count = 0; count < 256; count++) | 546 | for (count = 0; count < 256; count++) |
514 | serial_outp(up, UART_TX, count); | 547 | serial_outp(up, UART_TX, count); |
@@ -519,8 +552,7 @@ static int size_fifo(struct uart_8250_port *up) | |||
519 | serial_outp(up, UART_FCR, old_fcr); | 552 | serial_outp(up, UART_FCR, old_fcr); |
520 | serial_outp(up, UART_MCR, old_mcr); | 553 | serial_outp(up, UART_MCR, old_mcr); |
521 | serial_outp(up, UART_LCR, UART_LCR_DLAB); | 554 | serial_outp(up, UART_LCR, UART_LCR_DLAB); |
522 | serial_outp(up, UART_DLL, old_dll); | 555 | serial_dl_write(up, old_dl); |
523 | serial_outp(up, UART_DLM, old_dlm); | ||
524 | serial_outp(up, UART_LCR, old_lcr); | 556 | serial_outp(up, UART_LCR, old_lcr); |
525 | 557 | ||
526 | return count; | 558 | return count; |
@@ -750,8 +782,7 @@ static void autoconfig_16550a(struct uart_8250_port *up) | |||
750 | 782 | ||
751 | serial_outp(up, UART_LCR, 0xE0); | 783 | serial_outp(up, UART_LCR, 0xE0); |
752 | 784 | ||
753 | quot = serial_inp(up, UART_DLM) << 8; | 785 | quot = serial_dl_read(up); |
754 | quot += serial_inp(up, UART_DLL); | ||
755 | quot <<= 3; | 786 | quot <<= 3; |
756 | 787 | ||
757 | status1 = serial_in(up, 0x04); /* EXCR1 */ | 788 | status1 = serial_in(up, 0x04); /* EXCR1 */ |
@@ -759,8 +790,7 @@ static void autoconfig_16550a(struct uart_8250_port *up) | |||
759 | status1 |= 0x10; /* 1.625 divisor for baud_base --> 921600 */ | 790 | status1 |= 0x10; /* 1.625 divisor for baud_base --> 921600 */ |
760 | serial_outp(up, 0x04, status1); | 791 | serial_outp(up, 0x04, status1); |
761 | 792 | ||
762 | serial_outp(up, UART_DLL, quot & 0xff); | 793 | serial_dl_write(up, quot); |
763 | serial_outp(up, UART_DLM, quot >> 8); | ||
764 | 794 | ||
765 | serial_outp(up, UART_LCR, 0); | 795 | serial_outp(up, UART_LCR, 0); |
766 | 796 | ||
@@ -1862,8 +1892,7 @@ serial8250_set_termios(struct uart_port *port, struct termios *termios, | |||
1862 | serial_outp(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ | 1892 | serial_outp(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ |
1863 | } | 1893 | } |
1864 | 1894 | ||
1865 | serial_outp(up, UART_DLL, quot & 0xff); /* LS of divisor */ | 1895 | serial_dl_write(up, quot); |
1866 | serial_outp(up, UART_DLM, quot >> 8); /* MS of divisor */ | ||
1867 | 1896 | ||
1868 | /* | 1897 | /* |
1869 | * LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR | 1898 | * LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR |
@@ -1906,6 +1935,9 @@ static int serial8250_request_std_resource(struct uart_8250_port *up) | |||
1906 | int ret = 0; | 1935 | int ret = 0; |
1907 | 1936 | ||
1908 | switch (up->port.iotype) { | 1937 | switch (up->port.iotype) { |
1938 | case UPIO_AU: | ||
1939 | size = 0x100000; | ||
1940 | /* fall thru */ | ||
1909 | case UPIO_MEM: | 1941 | case UPIO_MEM: |
1910 | if (!up->port.mapbase) | 1942 | if (!up->port.mapbase) |
1911 | break; | 1943 | break; |
@@ -1938,6 +1970,9 @@ static void serial8250_release_std_resource(struct uart_8250_port *up) | |||
1938 | unsigned int size = 8 << up->port.regshift; | 1970 | unsigned int size = 8 << up->port.regshift; |
1939 | 1971 | ||
1940 | switch (up->port.iotype) { | 1972 | switch (up->port.iotype) { |
1973 | case UPIO_AU: | ||
1974 | size = 0x100000; | ||
1975 | /* fall thru */ | ||
1941 | case UPIO_MEM: | 1976 | case UPIO_MEM: |
1942 | if (!up->port.mapbase) | 1977 | if (!up->port.mapbase) |
1943 | break; | 1978 | break; |
@@ -2200,10 +2235,17 @@ static void | |||
2200 | serial8250_console_write(struct console *co, const char *s, unsigned int count) | 2235 | serial8250_console_write(struct console *co, const char *s, unsigned int count) |
2201 | { | 2236 | { |
2202 | struct uart_8250_port *up = &serial8250_ports[co->index]; | 2237 | struct uart_8250_port *up = &serial8250_ports[co->index]; |
2238 | unsigned long flags; | ||
2203 | unsigned int ier; | 2239 | unsigned int ier; |
2240 | int locked = 1; | ||
2204 | 2241 | ||
2205 | touch_nmi_watchdog(); | 2242 | touch_nmi_watchdog(); |
2206 | 2243 | ||
2244 | if (oops_in_progress) { | ||
2245 | locked = spin_trylock_irqsave(&up->port.lock, flags); | ||
2246 | } else | ||
2247 | spin_lock_irqsave(&up->port.lock, flags); | ||
2248 | |||
2207 | /* | 2249 | /* |
2208 | * First save the IER then disable the interrupts | 2250 | * First save the IER then disable the interrupts |
2209 | */ | 2251 | */ |
@@ -2221,8 +2263,10 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count) | |||
2221 | * and restore the IER | 2263 | * and restore the IER |
2222 | */ | 2264 | */ |
2223 | wait_for_xmitr(up, BOTH_EMPTY); | 2265 | wait_for_xmitr(up, BOTH_EMPTY); |
2224 | up->ier |= UART_IER_THRI; | 2266 | serial_out(up, UART_IER, ier); |
2225 | serial_out(up, UART_IER, ier | UART_IER_THRI); | 2267 | |
2268 | if (locked) | ||
2269 | spin_unlock_irqrestore(&up->port.lock, flags); | ||
2226 | } | 2270 | } |
2227 | 2271 | ||
2228 | static int serial8250_console_setup(struct console *co, char *options) | 2272 | static int serial8250_console_setup(struct console *co, char *options) |
diff --git a/drivers/serial/8250_au1x00.c b/drivers/serial/8250_au1x00.c index 3d1bfd07208d..58015fd14be9 100644 --- a/drivers/serial/8250_au1x00.c +++ b/drivers/serial/8250_au1x00.c | |||
@@ -30,13 +30,12 @@ | |||
30 | { \ | 30 | { \ |
31 | .iobase = _base, \ | 31 | .iobase = _base, \ |
32 | .membase = (void __iomem *)_base,\ | 32 | .membase = (void __iomem *)_base,\ |
33 | .mapbase = _base, \ | 33 | .mapbase = CPHYSADDR(_base), \ |
34 | .irq = _irq, \ | 34 | .irq = _irq, \ |
35 | .uartclk = 0, /* filled */ \ | 35 | .uartclk = 0, /* filled */ \ |
36 | .regshift = 2, \ | 36 | .regshift = 2, \ |
37 | .iotype = UPIO_AU, \ | 37 | .iotype = UPIO_AU, \ |
38 | .flags = UPF_SKIP_TEST | \ | 38 | .flags = UPF_SKIP_TEST \ |
39 | UPF_IOREMAP, \ | ||
40 | } | 39 | } |
41 | 40 | ||
42 | static struct plat_serial8250_port au1x00_data[] = { | 41 | static struct plat_serial8250_port au1x00_data[] = { |
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h index aa5eb7ddeda9..3b35cb779539 100644 --- a/drivers/serial/cpm_uart/cpm_uart.h +++ b/drivers/serial/cpm_uart/cpm_uart.h | |||
@@ -5,6 +5,13 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 6 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
7 | * | 7 | * |
8 | * 2006 (c) MontaVista Software, Inc. | ||
9 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
10 | * | ||
11 | * This file is licensed under the terms of the GNU General Public License | ||
12 | * version 2. This program is licensed "as is" without any warranty of any | ||
13 | * kind, whether express or implied. | ||
14 | * | ||
8 | */ | 15 | */ |
9 | #ifndef CPM_UART_H | 16 | #ifndef CPM_UART_H |
10 | #define CPM_UART_H | 17 | #define CPM_UART_H |
@@ -101,12 +108,13 @@ static inline unsigned long cpu2cpm_addr(void* addr, struct uart_cpm_port *pinfo | |||
101 | int offset; | 108 | int offset; |
102 | u32 val = (u32)addr; | 109 | u32 val = (u32)addr; |
103 | /* sane check */ | 110 | /* sane check */ |
104 | if ((val >= (u32)pinfo->mem_addr) && | 111 | if (likely((val >= (u32)pinfo->mem_addr)) && |
105 | (val<((u32)pinfo->mem_addr + pinfo->mem_size))) { | 112 | (val<((u32)pinfo->mem_addr + pinfo->mem_size))) { |
106 | offset = val - (u32)pinfo->mem_addr; | 113 | offset = val - (u32)pinfo->mem_addr; |
107 | return pinfo->dma_addr+offset; | 114 | return pinfo->dma_addr+offset; |
108 | } | 115 | } |
109 | printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val); | 116 | /* something nasty happened */ |
117 | BUG(); | ||
110 | return 0; | 118 | return 0; |
111 | } | 119 | } |
112 | 120 | ||
@@ -115,12 +123,13 @@ static inline void *cpm2cpu_addr(unsigned long addr, struct uart_cpm_port *pinfo | |||
115 | int offset; | 123 | int offset; |
116 | u32 val = addr; | 124 | u32 val = addr; |
117 | /* sane check */ | 125 | /* sane check */ |
118 | if ((val >= pinfo->dma_addr) && | 126 | if (likely((val >= pinfo->dma_addr) && |
119 | (val<(pinfo->dma_addr + pinfo->mem_size))) { | 127 | (val<(pinfo->dma_addr + pinfo->mem_size)))) { |
120 | offset = val - (u32)pinfo->dma_addr; | 128 | offset = val - (u32)pinfo->dma_addr; |
121 | return (void*)(pinfo->mem_addr+offset); | 129 | return (void*)(pinfo->mem_addr+offset); |
122 | } | 130 | } |
123 | printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val); | 131 | /* something nasty happened */ |
132 | BUG(); | ||
124 | return 0; | 133 | return 0; |
125 | } | 134 | } |
126 | 135 | ||
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c index ced193bf9e1e..969f94900431 100644 --- a/drivers/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/serial/cpm_uart/cpm_uart_core.c | |||
@@ -12,7 +12,8 @@ | |||
12 | * | 12 | * |
13 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 13 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
14 | * (C) 2004 Intracom, S.A. | 14 | * (C) 2004 Intracom, S.A. |
15 | * (C) 2005 MontaVista Software, Inc. by Vitaly Bordug <vbordug@ru.mvista.com> | 15 | * (C) 2005-2006 MontaVista Software, Inc. |
16 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
16 | * | 17 | * |
17 | * This program is free software; you can redistribute it and/or modify | 18 | * This program is free software; you can redistribute it and/or modify |
18 | * it under the terms of the GNU General Public License as published by | 19 | * it under the terms of the GNU General Public License as published by |
@@ -81,7 +82,7 @@ early_uart_get_pdev(int index) | |||
81 | } | 82 | } |
82 | 83 | ||
83 | 84 | ||
84 | void cpm_uart_count(void) | 85 | static void cpm_uart_count(void) |
85 | { | 86 | { |
86 | cpm_uart_nr = 0; | 87 | cpm_uart_nr = 0; |
87 | #ifdef CONFIG_SERIAL_CPM_SMC1 | 88 | #ifdef CONFIG_SERIAL_CPM_SMC1 |
@@ -104,6 +105,21 @@ void cpm_uart_count(void) | |||
104 | #endif | 105 | #endif |
105 | } | 106 | } |
106 | 107 | ||
108 | /* Get UART number by its id */ | ||
109 | static int cpm_uart_id2nr(int id) | ||
110 | { | ||
111 | int i; | ||
112 | if (id < UART_NR) { | ||
113 | for (i=0; i<UART_NR; i++) { | ||
114 | if (cpm_uart_port_map[i] == id) | ||
115 | return i; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | /* not found or invalid argument */ | ||
120 | return -1; | ||
121 | } | ||
122 | |||
107 | /* | 123 | /* |
108 | * Check, if transmit buffers are processed | 124 | * Check, if transmit buffers are processed |
109 | */ | 125 | */ |
@@ -457,7 +473,11 @@ static void cpm_uart_shutdown(struct uart_port *port) | |||
457 | } | 473 | } |
458 | 474 | ||
459 | /* Shut them really down and reinit buffer descriptors */ | 475 | /* Shut them really down and reinit buffer descriptors */ |
460 | cpm_line_cr_cmd(line, CPM_CR_STOP_TX); | 476 | if (IS_SMC(pinfo)) |
477 | cpm_line_cr_cmd(line, CPM_CR_STOP_TX); | ||
478 | else | ||
479 | cpm_line_cr_cmd(line, CPM_CR_GRA_STOP_TX); | ||
480 | |||
461 | cpm_uart_initbd(pinfo); | 481 | cpm_uart_initbd(pinfo); |
462 | } | 482 | } |
463 | } | 483 | } |
@@ -1008,7 +1028,11 @@ int cpm_uart_drv_get_platform_data(struct platform_device *pdev, int is_con) | |||
1008 | int line; | 1028 | int line; |
1009 | u32 mem, pram; | 1029 | u32 mem, pram; |
1010 | 1030 | ||
1011 | for (line=0; line<UART_NR && cpm_uart_port_map[line]!=pdata->fs_no; line++); | 1031 | line = cpm_uart_id2nr(idx); |
1032 | if(line < 0) { | ||
1033 | printk(KERN_ERR"%s(): port %d is not registered", __FUNCTION__, idx); | ||
1034 | return -1; | ||
1035 | } | ||
1012 | 1036 | ||
1013 | pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx]; | 1037 | pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx]; |
1014 | 1038 | ||
@@ -1241,8 +1265,7 @@ static int cpm_uart_drv_probe(struct device *dev) | |||
1241 | } | 1265 | } |
1242 | 1266 | ||
1243 | pdata = pdev->dev.platform_data; | 1267 | pdata = pdev->dev.platform_data; |
1244 | pr_debug("cpm_uart_drv_probe: Adding CPM UART %d\n", | 1268 | pr_debug("cpm_uart_drv_probe: Adding CPM UART %d\n", cpm_uart_id2nr(pdata->fs_no)); |
1245 | cpm_uart_port_map[pdata->fs_no]); | ||
1246 | 1269 | ||
1247 | if ((ret = cpm_uart_drv_get_platform_data(pdev, 0))) | 1270 | if ((ret = cpm_uart_drv_get_platform_data(pdev, 0))) |
1248 | return ret; | 1271 | return ret; |
@@ -1261,7 +1284,7 @@ static int cpm_uart_drv_remove(struct device *dev) | |||
1261 | struct fs_uart_platform_info *pdata = pdev->dev.platform_data; | 1284 | struct fs_uart_platform_info *pdata = pdev->dev.platform_data; |
1262 | 1285 | ||
1263 | pr_debug("cpm_uart_drv_remove: Removing CPM UART %d\n", | 1286 | pr_debug("cpm_uart_drv_remove: Removing CPM UART %d\n", |
1264 | cpm_uart_port_map[pdata->fs_no]); | 1287 | cpm_uart_id2nr(pdata->fs_no)); |
1265 | 1288 | ||
1266 | uart_remove_one_port(&cpm_reg, &cpm_uart_ports[pdata->fs_no].port); | 1289 | uart_remove_one_port(&cpm_reg, &cpm_uart_ports[pdata->fs_no].port); |
1267 | return 0; | 1290 | return 0; |
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c index a5a30622637a..17406a05ce1f 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * | 8 | * |
9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
10 | * (C) 2004 Intracom, S.A. | 10 | * (C) 2004 Intracom, S.A. |
11 | * (C) 2006 MontaVista Software, Inc. | ||
12 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
11 | * | 13 | * |
12 | * This program is free software; you can redistribute it and/or modify | 14 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by | 15 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c index 7c6b07aeea92..4b2de08f46d0 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * | 8 | * |
9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
10 | * (C) 2004 Intracom, S.A. | 10 | * (C) 2004 Intracom, S.A. |
11 | * (C) 2006 MontaVista Software, Inc. | ||
12 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
11 | * | 13 | * |
12 | * This program is free software; you can redistribute it and/or modify | 14 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by | 15 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index c3b7a6673e9c..d202eb4f3848 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <asm/io.h> | 45 | #include <asm/io.h> |
46 | #include <asm/irq.h> | 46 | #include <asm/irq.h> |
47 | #include <asm/hardware.h> | 47 | #include <asm/hardware.h> |
48 | #include <asm/arch/imx-uart.h> | ||
48 | 49 | ||
49 | /* We've been assigned a range on the "Low-density serial ports" major */ | 50 | /* We've been assigned a range on the "Low-density serial ports" major */ |
50 | #define SERIAL_IMX_MAJOR 204 | 51 | #define SERIAL_IMX_MAJOR 204 |
@@ -73,7 +74,8 @@ struct imx_port { | |||
73 | struct uart_port port; | 74 | struct uart_port port; |
74 | struct timer_list timer; | 75 | struct timer_list timer; |
75 | unsigned int old_status; | 76 | unsigned int old_status; |
76 | int txirq,rxirq,rtsirq; | 77 | int txirq,rxirq,rtsirq; |
78 | int have_rtscts:1; | ||
77 | }; | 79 | }; |
78 | 80 | ||
79 | /* | 81 | /* |
@@ -491,8 +493,12 @@ imx_set_termios(struct uart_port *port, struct termios *termios, | |||
491 | ucr2 = UCR2_SRST | UCR2_IRTS; | 493 | ucr2 = UCR2_SRST | UCR2_IRTS; |
492 | 494 | ||
493 | if (termios->c_cflag & CRTSCTS) { | 495 | if (termios->c_cflag & CRTSCTS) { |
494 | ucr2 &= ~UCR2_IRTS; | 496 | if( sport->have_rtscts ) { |
495 | ucr2 |= UCR2_CTSC; | 497 | ucr2 &= ~UCR2_IRTS; |
498 | ucr2 |= UCR2_CTSC; | ||
499 | } else { | ||
500 | termios->c_cflag &= ~CRTSCTS; | ||
501 | } | ||
496 | } | 502 | } |
497 | 503 | ||
498 | if (termios->c_cflag & CSTOPB) | 504 | if (termios->c_cflag & CSTOPB) |
@@ -719,27 +725,6 @@ static void __init imx_init_ports(void) | |||
719 | imx_ports[i].timer.function = imx_timeout; | 725 | imx_ports[i].timer.function = imx_timeout; |
720 | imx_ports[i].timer.data = (unsigned long)&imx_ports[i]; | 726 | imx_ports[i].timer.data = (unsigned long)&imx_ports[i]; |
721 | } | 727 | } |
722 | |||
723 | imx_gpio_mode(PC9_PF_UART1_CTS); | ||
724 | imx_gpio_mode(PC10_PF_UART1_RTS); | ||
725 | imx_gpio_mode(PC11_PF_UART1_TXD); | ||
726 | imx_gpio_mode(PC12_PF_UART1_RXD); | ||
727 | imx_gpio_mode(PB28_PF_UART2_CTS); | ||
728 | imx_gpio_mode(PB29_PF_UART2_RTS); | ||
729 | |||
730 | imx_gpio_mode(PB30_PF_UART2_TXD); | ||
731 | imx_gpio_mode(PB31_PF_UART2_RXD); | ||
732 | |||
733 | #if 0 /* We don't need these, on the mx1 the _modem_ side of the uart | ||
734 | * is implemented. | ||
735 | */ | ||
736 | imx_gpio_mode(PD7_AF_UART2_DTR); | ||
737 | imx_gpio_mode(PD8_AF_UART2_DCD); | ||
738 | imx_gpio_mode(PD9_AF_UART2_RI); | ||
739 | imx_gpio_mode(PD10_AF_UART2_DSR); | ||
740 | #endif | ||
741 | |||
742 | |||
743 | } | 728 | } |
744 | 729 | ||
745 | #ifdef CONFIG_SERIAL_IMX_CONSOLE | 730 | #ifdef CONFIG_SERIAL_IMX_CONSOLE |
@@ -932,7 +917,14 @@ static int serial_imx_resume(struct platform_device *dev) | |||
932 | 917 | ||
933 | static int serial_imx_probe(struct platform_device *dev) | 918 | static int serial_imx_probe(struct platform_device *dev) |
934 | { | 919 | { |
920 | struct imxuart_platform_data *pdata; | ||
921 | |||
935 | imx_ports[dev->id].port.dev = &dev->dev; | 922 | imx_ports[dev->id].port.dev = &dev->dev; |
923 | |||
924 | pdata = (struct imxuart_platform_data *)dev->dev.platform_data; | ||
925 | if(pdata && (pdata->flags & IMXUART_HAVE_RTSCTS)) | ||
926 | imx_ports[dev->id].have_rtscts = 1; | ||
927 | |||
936 | uart_add_one_port(&imx_reg, &imx_ports[dev->id].port); | 928 | uart_add_one_port(&imx_reg, &imx_ports[dev->id].port); |
937 | platform_set_drvdata(dev, &imx_ports[dev->id]); | 929 | platform_set_drvdata(dev, &imx_ports[dev->id]); |
938 | return 0; | 930 | return 0; |
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index fcd7744c4253..aeb8153ccf24 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -1500,20 +1500,18 @@ uart_block_til_ready(struct file *filp, struct uart_state *state) | |||
1500 | static struct uart_state *uart_get(struct uart_driver *drv, int line) | 1500 | static struct uart_state *uart_get(struct uart_driver *drv, int line) |
1501 | { | 1501 | { |
1502 | struct uart_state *state; | 1502 | struct uart_state *state; |
1503 | int ret = 0; | ||
1503 | 1504 | ||
1504 | mutex_lock(&port_mutex); | ||
1505 | state = drv->state + line; | 1505 | state = drv->state + line; |
1506 | if (mutex_lock_interruptible(&state->mutex)) { | 1506 | if (mutex_lock_interruptible(&state->mutex)) { |
1507 | state = ERR_PTR(-ERESTARTSYS); | 1507 | ret = -ERESTARTSYS; |
1508 | goto out; | 1508 | goto err; |
1509 | } | 1509 | } |
1510 | 1510 | ||
1511 | state->count++; | 1511 | state->count++; |
1512 | if (!state->port) { | 1512 | if (!state->port || state->port->flags & UPF_DEAD) { |
1513 | state->count--; | 1513 | ret = -ENXIO; |
1514 | mutex_unlock(&state->mutex); | 1514 | goto err_unlock; |
1515 | state = ERR_PTR(-ENXIO); | ||
1516 | goto out; | ||
1517 | } | 1515 | } |
1518 | 1516 | ||
1519 | if (!state->info) { | 1517 | if (!state->info) { |
@@ -1531,15 +1529,17 @@ static struct uart_state *uart_get(struct uart_driver *drv, int line) | |||
1531 | tasklet_init(&state->info->tlet, uart_tasklet_action, | 1529 | tasklet_init(&state->info->tlet, uart_tasklet_action, |
1532 | (unsigned long)state); | 1530 | (unsigned long)state); |
1533 | } else { | 1531 | } else { |
1534 | state->count--; | 1532 | ret = -ENOMEM; |
1535 | mutex_unlock(&state->mutex); | 1533 | goto err_unlock; |
1536 | state = ERR_PTR(-ENOMEM); | ||
1537 | } | 1534 | } |
1538 | } | 1535 | } |
1539 | |||
1540 | out: | ||
1541 | mutex_unlock(&port_mutex); | ||
1542 | return state; | 1536 | return state; |
1537 | |||
1538 | err_unlock: | ||
1539 | state->count--; | ||
1540 | mutex_unlock(&state->mutex); | ||
1541 | err: | ||
1542 | return ERR_PTR(ret); | ||
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | /* | 1545 | /* |
@@ -2085,45 +2085,6 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, | |||
2085 | } | 2085 | } |
2086 | } | 2086 | } |
2087 | 2087 | ||
2088 | /* | ||
2089 | * This reverses the effects of uart_configure_port, hanging up the | ||
2090 | * port before removal. | ||
2091 | */ | ||
2092 | static void | ||
2093 | uart_unconfigure_port(struct uart_driver *drv, struct uart_state *state) | ||
2094 | { | ||
2095 | struct uart_port *port = state->port; | ||
2096 | struct uart_info *info = state->info; | ||
2097 | |||
2098 | if (info && info->tty) | ||
2099 | tty_vhangup(info->tty); | ||
2100 | |||
2101 | mutex_lock(&state->mutex); | ||
2102 | |||
2103 | state->info = NULL; | ||
2104 | |||
2105 | /* | ||
2106 | * Free the port IO and memory resources, if any. | ||
2107 | */ | ||
2108 | if (port->type != PORT_UNKNOWN) | ||
2109 | port->ops->release_port(port); | ||
2110 | |||
2111 | /* | ||
2112 | * Indicate that there isn't a port here anymore. | ||
2113 | */ | ||
2114 | port->type = PORT_UNKNOWN; | ||
2115 | |||
2116 | /* | ||
2117 | * Kill the tasklet, and free resources. | ||
2118 | */ | ||
2119 | if (info) { | ||
2120 | tasklet_kill(&info->tlet); | ||
2121 | kfree(info); | ||
2122 | } | ||
2123 | |||
2124 | mutex_unlock(&state->mutex); | ||
2125 | } | ||
2126 | |||
2127 | static struct tty_operations uart_ops = { | 2088 | static struct tty_operations uart_ops = { |
2128 | .open = uart_open, | 2089 | .open = uart_open, |
2129 | .close = uart_close, | 2090 | .close = uart_close, |
@@ -2270,6 +2231,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port) | |||
2270 | state = drv->state + port->line; | 2231 | state = drv->state + port->line; |
2271 | 2232 | ||
2272 | mutex_lock(&port_mutex); | 2233 | mutex_lock(&port_mutex); |
2234 | mutex_lock(&state->mutex); | ||
2273 | if (state->port) { | 2235 | if (state->port) { |
2274 | ret = -EINVAL; | 2236 | ret = -EINVAL; |
2275 | goto out; | 2237 | goto out; |
@@ -2304,7 +2266,13 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port) | |||
2304 | port->cons && !(port->cons->flags & CON_ENABLED)) | 2266 | port->cons && !(port->cons->flags & CON_ENABLED)) |
2305 | register_console(port->cons); | 2267 | register_console(port->cons); |
2306 | 2268 | ||
2269 | /* | ||
2270 | * Ensure UPF_DEAD is not set. | ||
2271 | */ | ||
2272 | port->flags &= ~UPF_DEAD; | ||
2273 | |||
2307 | out: | 2274 | out: |
2275 | mutex_unlock(&state->mutex); | ||
2308 | mutex_unlock(&port_mutex); | 2276 | mutex_unlock(&port_mutex); |
2309 | 2277 | ||
2310 | return ret; | 2278 | return ret; |
@@ -2322,6 +2290,7 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *port) | |||
2322 | int uart_remove_one_port(struct uart_driver *drv, struct uart_port *port) | 2290 | int uart_remove_one_port(struct uart_driver *drv, struct uart_port *port) |
2323 | { | 2291 | { |
2324 | struct uart_state *state = drv->state + port->line; | 2292 | struct uart_state *state = drv->state + port->line; |
2293 | struct uart_info *info; | ||
2325 | 2294 | ||
2326 | BUG_ON(in_interrupt()); | 2295 | BUG_ON(in_interrupt()); |
2327 | 2296 | ||
@@ -2332,11 +2301,48 @@ int uart_remove_one_port(struct uart_driver *drv, struct uart_port *port) | |||
2332 | mutex_lock(&port_mutex); | 2301 | mutex_lock(&port_mutex); |
2333 | 2302 | ||
2334 | /* | 2303 | /* |
2304 | * Mark the port "dead" - this prevents any opens from | ||
2305 | * succeeding while we shut down the port. | ||
2306 | */ | ||
2307 | mutex_lock(&state->mutex); | ||
2308 | port->flags |= UPF_DEAD; | ||
2309 | mutex_unlock(&state->mutex); | ||
2310 | |||
2311 | /* | ||
2335 | * Remove the devices from devfs | 2312 | * Remove the devices from devfs |
2336 | */ | 2313 | */ |
2337 | tty_unregister_device(drv->tty_driver, port->line); | 2314 | tty_unregister_device(drv->tty_driver, port->line); |
2338 | 2315 | ||
2339 | uart_unconfigure_port(drv, state); | 2316 | info = state->info; |
2317 | if (info && info->tty) | ||
2318 | tty_vhangup(info->tty); | ||
2319 | |||
2320 | /* | ||
2321 | * All users of this port should now be disconnected from | ||
2322 | * this driver, and the port shut down. We should be the | ||
2323 | * only thread fiddling with this port from now on. | ||
2324 | */ | ||
2325 | state->info = NULL; | ||
2326 | |||
2327 | /* | ||
2328 | * Free the port IO and memory resources, if any. | ||
2329 | */ | ||
2330 | if (port->type != PORT_UNKNOWN) | ||
2331 | port->ops->release_port(port); | ||
2332 | |||
2333 | /* | ||
2334 | * Indicate that there isn't a port here anymore. | ||
2335 | */ | ||
2336 | port->type = PORT_UNKNOWN; | ||
2337 | |||
2338 | /* | ||
2339 | * Kill the tasklet, and free resources. | ||
2340 | */ | ||
2341 | if (info) { | ||
2342 | tasklet_kill(&info->tlet); | ||
2343 | kfree(info); | ||
2344 | } | ||
2345 | |||
2340 | state->port = NULL; | 2346 | state->port = NULL; |
2341 | mutex_unlock(&port_mutex); | 2347 | mutex_unlock(&port_mutex); |
2342 | 2348 | ||
diff --git a/drivers/sn/ioc4.c b/drivers/sn/ioc4.c index 67140a5804f5..cdeff909403e 100644 --- a/drivers/sn/ioc4.c +++ b/drivers/sn/ioc4.c | |||
@@ -310,7 +310,7 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) | |||
310 | pci_set_drvdata(idd->idd_pdev, idd); | 310 | pci_set_drvdata(idd->idd_pdev, idd); |
311 | 311 | ||
312 | mutex_lock(&ioc4_mutex); | 312 | mutex_lock(&ioc4_mutex); |
313 | list_add(&idd->idd_list, &ioc4_devices); | 313 | list_add_tail(&idd->idd_list, &ioc4_devices); |
314 | 314 | ||
315 | /* Add this IOC4 to all submodules */ | 315 | /* Add this IOC4 to all submodules */ |
316 | list_for_each_entry(is, &ioc4_submodules, is_list) { | 316 | list_for_each_entry(is, &ioc4_submodules, is_list) { |
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c index 7860c8a5800d..956b7a1e8af9 100644 --- a/drivers/usb/atm/speedtch.c +++ b/drivers/usb/atm/speedtch.c | |||
@@ -69,7 +69,7 @@ static const char speedtch_driver_name[] = "speedtch"; | |||
69 | #define RESUBMIT_DELAY 1000 /* milliseconds */ | 69 | #define RESUBMIT_DELAY 1000 /* milliseconds */ |
70 | 70 | ||
71 | #define DEFAULT_BULK_ALTSETTING 1 | 71 | #define DEFAULT_BULK_ALTSETTING 1 |
72 | #define DEFAULT_ISOC_ALTSETTING 2 | 72 | #define DEFAULT_ISOC_ALTSETTING 3 |
73 | #define DEFAULT_DL_512_FIRST 0 | 73 | #define DEFAULT_DL_512_FIRST 0 |
74 | #define DEFAULT_ENABLE_ISOC 0 | 74 | #define DEFAULT_ENABLE_ISOC 0 |
75 | #define DEFAULT_SW_BUFFERING 0 | 75 | #define DEFAULT_SW_BUFFERING 0 |
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index c1211fc037d9..546249843b8e 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c | |||
@@ -99,11 +99,11 @@ static const char usbatm_driver_name[] = "usbatm"; | |||
99 | 99 | ||
100 | #define UDSL_MAX_RCV_URBS 16 | 100 | #define UDSL_MAX_RCV_URBS 16 |
101 | #define UDSL_MAX_SND_URBS 16 | 101 | #define UDSL_MAX_SND_URBS 16 |
102 | #define UDSL_MAX_BUF_SIZE 64 * 1024 /* bytes */ | 102 | #define UDSL_MAX_BUF_SIZE 65536 |
103 | #define UDSL_DEFAULT_RCV_URBS 4 | 103 | #define UDSL_DEFAULT_RCV_URBS 4 |
104 | #define UDSL_DEFAULT_SND_URBS 4 | 104 | #define UDSL_DEFAULT_SND_URBS 4 |
105 | #define UDSL_DEFAULT_RCV_BUF_SIZE 64 * ATM_CELL_SIZE /* bytes */ | 105 | #define UDSL_DEFAULT_RCV_BUF_SIZE 3392 /* 64 * ATM_CELL_SIZE */ |
106 | #define UDSL_DEFAULT_SND_BUF_SIZE 64 * ATM_CELL_SIZE /* bytes */ | 106 | #define UDSL_DEFAULT_SND_BUF_SIZE 3392 /* 64 * ATM_CELL_SIZE */ |
107 | 107 | ||
108 | #define ATM_CELL_HEADER (ATM_CELL_SIZE - ATM_CELL_PAYLOAD) | 108 | #define ATM_CELL_HEADER (ATM_CELL_SIZE - ATM_CELL_PAYLOAD) |
109 | 109 | ||
@@ -135,7 +135,7 @@ MODULE_PARM_DESC(rcv_buf_bytes, | |||
135 | module_param(snd_buf_bytes, uint, S_IRUGO); | 135 | module_param(snd_buf_bytes, uint, S_IRUGO); |
136 | MODULE_PARM_DESC(snd_buf_bytes, | 136 | MODULE_PARM_DESC(snd_buf_bytes, |
137 | "Size of the buffers used for transmission, in bytes (range: 1-" | 137 | "Size of the buffers used for transmission, in bytes (range: 1-" |
138 | __MODULE_STRING(UDSL_MAX_SND_BUF_SIZE) ", default: " | 138 | __MODULE_STRING(UDSL_MAX_BUF_SIZE) ", default: " |
139 | __MODULE_STRING(UDSL_DEFAULT_SND_BUF_SIZE) ")"); | 139 | __MODULE_STRING(UDSL_DEFAULT_SND_BUF_SIZE) ")"); |
140 | 140 | ||
141 | 141 | ||
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index fbd938d4ea58..e2e00ba4e1e6 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -1805,6 +1805,12 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
1805 | USB_SPEED_FULL; | 1805 | USB_SPEED_FULL; |
1806 | hcd->self.root_hub = rhdev; | 1806 | hcd->self.root_hub = rhdev; |
1807 | 1807 | ||
1808 | /* wakeup flag init defaults to "everything works" for root hubs, | ||
1809 | * but drivers can override it in reset() if needed, along with | ||
1810 | * recording the overall controller's system wakeup capability. | ||
1811 | */ | ||
1812 | device_init_wakeup(&rhdev->dev, 1); | ||
1813 | |||
1808 | /* "reset" is misnamed; its role is now one-time init. the controller | 1814 | /* "reset" is misnamed; its role is now one-time init. the controller |
1809 | * should already have been reset (and boot firmware kicked off etc). | 1815 | * should already have been reset (and boot firmware kicked off etc). |
1810 | */ | 1816 | */ |
@@ -1813,13 +1819,6 @@ int usb_add_hcd(struct usb_hcd *hcd, | |||
1813 | goto err_hcd_driver_setup; | 1819 | goto err_hcd_driver_setup; |
1814 | } | 1820 | } |
1815 | 1821 | ||
1816 | /* wakeup flag init is in transition; for now we can't rely on PCI to | ||
1817 | * initialize these bits properly, so we let reset() override it. | ||
1818 | * This init should _precede_ the reset() once PCI behaves. | ||
1819 | */ | ||
1820 | device_init_wakeup(&rhdev->dev, | ||
1821 | device_can_wakeup(hcd->self.controller)); | ||
1822 | |||
1823 | /* NOTE: root hub and controller capabilities may not be the same */ | 1822 | /* NOTE: root hub and controller capabilities may not be the same */ |
1824 | if (device_can_wakeup(hcd->self.controller) | 1823 | if (device_can_wakeup(hcd->self.controller) |
1825 | && device_can_wakeup(&hcd->self.root_hub->dev)) | 1824 | && device_can_wakeup(&hcd->self.root_hub->dev)) |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 0c87f73f2933..90b8d43c6b33 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -1168,19 +1168,9 @@ static inline const char *plural(int n) | |||
1168 | static int choose_configuration(struct usb_device *udev) | 1168 | static int choose_configuration(struct usb_device *udev) |
1169 | { | 1169 | { |
1170 | int i; | 1170 | int i; |
1171 | u16 devstatus; | ||
1172 | int bus_powered; | ||
1173 | int num_configs; | 1171 | int num_configs; |
1174 | struct usb_host_config *c, *best; | 1172 | struct usb_host_config *c, *best; |
1175 | 1173 | ||
1176 | /* If this fails, assume the device is bus-powered */ | ||
1177 | devstatus = 0; | ||
1178 | usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus); | ||
1179 | le16_to_cpus(&devstatus); | ||
1180 | bus_powered = ((devstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0); | ||
1181 | dev_dbg(&udev->dev, "device is %s-powered\n", | ||
1182 | bus_powered ? "bus" : "self"); | ||
1183 | |||
1184 | best = NULL; | 1174 | best = NULL; |
1185 | c = udev->config; | 1175 | c = udev->config; |
1186 | num_configs = udev->descriptor.bNumConfigurations; | 1176 | num_configs = udev->descriptor.bNumConfigurations; |
@@ -1197,6 +1187,19 @@ static int choose_configuration(struct usb_device *udev) | |||
1197 | * similar errors in their descriptors. If the next test | 1187 | * similar errors in their descriptors. If the next test |
1198 | * were allowed to execute, such configurations would always | 1188 | * were allowed to execute, such configurations would always |
1199 | * be rejected and the devices would not work as expected. | 1189 | * be rejected and the devices would not work as expected. |
1190 | * In the meantime, we run the risk of selecting a config | ||
1191 | * that requires external power at a time when that power | ||
1192 | * isn't available. It seems to be the lesser of two evils. | ||
1193 | * | ||
1194 | * Bugzilla #6448 reports a device that appears to crash | ||
1195 | * when it receives a GET_DEVICE_STATUS request! We don't | ||
1196 | * have any other way to tell whether a device is self-powered, | ||
1197 | * but since we don't use that information anywhere but here, | ||
1198 | * the call has been removed. | ||
1199 | * | ||
1200 | * Maybe the GET_DEVICE_STATUS call and the test below can | ||
1201 | * be reinstated when device firmwares become more reliable. | ||
1202 | * Don't hold your breath. | ||
1200 | */ | 1203 | */ |
1201 | #if 0 | 1204 | #if 0 |
1202 | /* Rule out self-powered configs for a bus-powered device */ | 1205 | /* Rule out self-powered configs for a bus-powered device */ |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 544f7589912f..73f5a379d9b3 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -863,7 +863,7 @@ static int ohci_restart (struct ohci_hcd *ohci) | |||
863 | i = ohci->num_ports; | 863 | i = ohci->num_ports; |
864 | while (i--) | 864 | while (i--) |
865 | ohci_writel (ohci, RH_PS_PSS, | 865 | ohci_writel (ohci, RH_PS_PSS, |
866 | &ohci->regs->roothub.portstatus [temp]); | 866 | &ohci->regs->roothub.portstatus [i]); |
867 | ohci_dbg (ohci, "restart complete\n"); | 867 | ohci_dbg (ohci, "restart complete\n"); |
868 | } | 868 | } |
869 | return 0; | 869 | return 0; |
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index f419bd82ab7f..435273e7c85c 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c | |||
@@ -1557,6 +1557,9 @@ void hid_init_reports(struct hid_device *hid) | |||
1557 | #define USB_VENDOR_ID_HP 0x03f0 | 1557 | #define USB_VENDOR_ID_HP 0x03f0 |
1558 | #define USB_DEVICE_ID_HP_USBHUB_KB 0x020c | 1558 | #define USB_DEVICE_ID_HP_USBHUB_KB 0x020c |
1559 | 1559 | ||
1560 | #define USB_VENDOR_ID_IBM 0x04b3 | ||
1561 | #define USB_DEVICE_ID_IBM_USBHUB_KB 0x3005 | ||
1562 | |||
1560 | #define USB_VENDOR_ID_CREATIVELABS 0x062a | 1563 | #define USB_VENDOR_ID_CREATIVELABS 0x062a |
1561 | #define USB_DEVICE_ID_CREATIVELABS_SILVERCREST 0x0201 | 1564 | #define USB_DEVICE_ID_CREATIVELABS_SILVERCREST 0x0201 |
1562 | 1565 | ||
@@ -1681,6 +1684,7 @@ static const struct hid_blacklist { | |||
1681 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET}, | 1684 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_USBHUB_KB, HID_QUIRK_NOGET}, |
1682 | { USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_CREATIVELABS_SILVERCREST, HID_QUIRK_NOGET }, | 1685 | { USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_CREATIVELABS_SILVERCREST, HID_QUIRK_NOGET }, |
1683 | { USB_VENDOR_ID_HP, USB_DEVICE_ID_HP_USBHUB_KB, HID_QUIRK_NOGET }, | 1686 | { USB_VENDOR_ID_HP, USB_DEVICE_ID_HP_USBHUB_KB, HID_QUIRK_NOGET }, |
1687 | { USB_VENDOR_ID_IBM, USB_DEVICE_ID_IBM_USBHUB_KB, HID_QUIRK_NOGET }, | ||
1684 | { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, | 1688 | { USB_VENDOR_ID_TANGTOP, USB_DEVICE_ID_TANGTOP_USBPS2, HID_QUIRK_NOGET }, |
1685 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, | 1689 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, |
1686 | { USB_VENDOR_ID_SILVERCREST, USB_DEVICE_ID_SILVERCREST_KB, HID_QUIRK_NOGET }, | 1690 | { USB_VENDOR_ID_SILVERCREST, USB_DEVICE_ID_SILVERCREST_KB, HID_QUIRK_NOGET }, |
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index 3824df33094e..1fd9cb85f4ca 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/usb.h> | 17 | #include <linux/usb.h> |
18 | #include <linux/delay.h> | ||
18 | 19 | ||
19 | #define MAX_INTEL_HEX_RECORD_LENGTH 16 | 20 | #define MAX_INTEL_HEX_RECORD_LENGTH 16 |
20 | typedef struct _INTEL_HEX_RECORD | 21 | typedef struct _INTEL_HEX_RECORD |
@@ -114,6 +115,7 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
114 | 115 | ||
115 | /* De-assert reset (let the CPU run) */ | 116 | /* De-assert reset (let the CPU run) */ |
116 | err = emi26_set_reset(dev,0); | 117 | err = emi26_set_reset(dev,0); |
118 | msleep(250); /* let device settle */ | ||
117 | 119 | ||
118 | /* 2. We upload the FPGA firmware into the EMI | 120 | /* 2. We upload the FPGA firmware into the EMI |
119 | * Note: collect up to 1023 (yes!) bytes and send them with | 121 | * Note: collect up to 1023 (yes!) bytes and send them with |
@@ -150,6 +152,7 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
150 | goto wraperr; | 152 | goto wraperr; |
151 | } | 153 | } |
152 | } | 154 | } |
155 | msleep(250); /* let device settle */ | ||
153 | 156 | ||
154 | /* De-assert reset (let the CPU run) */ | 157 | /* De-assert reset (let the CPU run) */ |
155 | err = emi26_set_reset(dev,0); | 158 | err = emi26_set_reset(dev,0); |
@@ -192,6 +195,7 @@ static int emi26_load_firmware (struct usb_device *dev) | |||
192 | err("%s - error loading firmware: error = %d", __FUNCTION__, err); | 195 | err("%s - error loading firmware: error = %d", __FUNCTION__, err); |
193 | goto wraperr; | 196 | goto wraperr; |
194 | } | 197 | } |
198 | msleep(250); /* let device settle */ | ||
195 | 199 | ||
196 | /* return 1 to fail the driver inialization | 200 | /* return 1 to fail the driver inialization |
197 | * and give real driver change to load */ | 201 | * and give real driver change to load */ |
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 52fea2e08db8..fe351371f274 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/usb.h> | 17 | #include <linux/usb.h> |
18 | #include <linux/delay.h> | ||
18 | 19 | ||
19 | #define MAX_INTEL_HEX_RECORD_LENGTH 16 | 20 | #define MAX_INTEL_HEX_RECORD_LENGTH 16 |
20 | typedef struct _INTEL_HEX_RECORD | 21 | typedef struct _INTEL_HEX_RECORD |
@@ -123,6 +124,7 @@ static int emi62_load_firmware (struct usb_device *dev) | |||
123 | 124 | ||
124 | /* De-assert reset (let the CPU run) */ | 125 | /* De-assert reset (let the CPU run) */ |
125 | err = emi62_set_reset(dev,0); | 126 | err = emi62_set_reset(dev,0); |
127 | msleep(250); /* let device settle */ | ||
126 | 128 | ||
127 | /* 2. We upload the FPGA firmware into the EMI | 129 | /* 2. We upload the FPGA firmware into the EMI |
128 | * Note: collect up to 1023 (yes!) bytes and send them with | 130 | * Note: collect up to 1023 (yes!) bytes and send them with |
@@ -166,6 +168,7 @@ static int emi62_load_firmware (struct usb_device *dev) | |||
166 | err("%s - error loading firmware: error = %d", __FUNCTION__, err); | 168 | err("%s - error loading firmware: error = %d", __FUNCTION__, err); |
167 | goto wraperr; | 169 | goto wraperr; |
168 | } | 170 | } |
171 | msleep(250); /* let device settle */ | ||
169 | 172 | ||
170 | /* 4. We put the part of the firmware that lies in the external RAM into the EZ-USB */ | 173 | /* 4. We put the part of the firmware that lies in the external RAM into the EZ-USB */ |
171 | 174 | ||
@@ -228,6 +231,7 @@ static int emi62_load_firmware (struct usb_device *dev) | |||
228 | err("%s - error loading firmware: error = %d", __FUNCTION__, err); | 231 | err("%s - error loading firmware: error = %d", __FUNCTION__, err); |
229 | goto wraperr; | 232 | goto wraperr; |
230 | } | 233 | } |
234 | msleep(250); /* let device settle */ | ||
231 | 235 | ||
232 | kfree(buf); | 236 | kfree(buf); |
233 | 237 | ||
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c index 2deb4c01539e..7683926a1b6f 100644 --- a/drivers/usb/net/pegasus.c +++ b/drivers/usb/net/pegasus.c | |||
@@ -318,6 +318,8 @@ static int read_mii_word(pegasus_t * pegasus, __u8 phy, __u8 indx, __u16 * regd) | |||
318 | set_register(pegasus, PhyCtrl, (indx | PHY_READ)); | 318 | set_register(pegasus, PhyCtrl, (indx | PHY_READ)); |
319 | for (i = 0; i < REG_TIMEOUT; i++) { | 319 | for (i = 0; i < REG_TIMEOUT; i++) { |
320 | ret = get_registers(pegasus, PhyCtrl, 1, data); | 320 | ret = get_registers(pegasus, PhyCtrl, 1, data); |
321 | if (ret == -ESHUTDOWN) | ||
322 | goto fail; | ||
321 | if (data[0] & PHY_DONE) | 323 | if (data[0] & PHY_DONE) |
322 | break; | 324 | break; |
323 | } | 325 | } |
@@ -326,6 +328,7 @@ static int read_mii_word(pegasus_t * pegasus, __u8 phy, __u8 indx, __u16 * regd) | |||
326 | *regd = le16_to_cpu(regdi); | 328 | *regd = le16_to_cpu(regdi); |
327 | return ret; | 329 | return ret; |
328 | } | 330 | } |
331 | fail: | ||
329 | if (netif_msg_drv(pegasus)) | 332 | if (netif_msg_drv(pegasus)) |
330 | dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); | 333 | dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); |
331 | 334 | ||
@@ -354,12 +357,15 @@ static int write_mii_word(pegasus_t * pegasus, __u8 phy, __u8 indx, __u16 regd) | |||
354 | set_register(pegasus, PhyCtrl, (indx | PHY_WRITE)); | 357 | set_register(pegasus, PhyCtrl, (indx | PHY_WRITE)); |
355 | for (i = 0; i < REG_TIMEOUT; i++) { | 358 | for (i = 0; i < REG_TIMEOUT; i++) { |
356 | ret = get_registers(pegasus, PhyCtrl, 1, data); | 359 | ret = get_registers(pegasus, PhyCtrl, 1, data); |
360 | if (ret == -ESHUTDOWN) | ||
361 | goto fail; | ||
357 | if (data[0] & PHY_DONE) | 362 | if (data[0] & PHY_DONE) |
358 | break; | 363 | break; |
359 | } | 364 | } |
360 | if (i < REG_TIMEOUT) | 365 | if (i < REG_TIMEOUT) |
361 | return ret; | 366 | return ret; |
362 | 367 | ||
368 | fail: | ||
363 | if (netif_msg_drv(pegasus)) | 369 | if (netif_msg_drv(pegasus)) |
364 | dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); | 370 | dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); |
365 | return -ETIMEDOUT; | 371 | return -ETIMEDOUT; |
@@ -387,6 +393,8 @@ static int read_eprom_word(pegasus_t * pegasus, __u8 index, __u16 * retdata) | |||
387 | ret = get_registers(pegasus, EpromCtrl, 1, &tmp); | 393 | ret = get_registers(pegasus, EpromCtrl, 1, &tmp); |
388 | if (tmp & EPROM_DONE) | 394 | if (tmp & EPROM_DONE) |
389 | break; | 395 | break; |
396 | if (ret == -ESHUTDOWN) | ||
397 | goto fail; | ||
390 | } | 398 | } |
391 | if (i < REG_TIMEOUT) { | 399 | if (i < REG_TIMEOUT) { |
392 | ret = get_registers(pegasus, EpromData, 2, &retdatai); | 400 | ret = get_registers(pegasus, EpromData, 2, &retdatai); |
@@ -394,6 +402,7 @@ static int read_eprom_word(pegasus_t * pegasus, __u8 index, __u16 * retdata) | |||
394 | return ret; | 402 | return ret; |
395 | } | 403 | } |
396 | 404 | ||
405 | fail: | ||
397 | if (netif_msg_drv(pegasus)) | 406 | if (netif_msg_drv(pegasus)) |
398 | dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); | 407 | dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); |
399 | return -ETIMEDOUT; | 408 | return -ETIMEDOUT; |
@@ -433,12 +442,15 @@ static int write_eprom_word(pegasus_t * pegasus, __u8 index, __u16 data) | |||
433 | 442 | ||
434 | for (i = 0; i < REG_TIMEOUT; i++) { | 443 | for (i = 0; i < REG_TIMEOUT; i++) { |
435 | ret = get_registers(pegasus, EpromCtrl, 1, &tmp); | 444 | ret = get_registers(pegasus, EpromCtrl, 1, &tmp); |
445 | if (ret == -ESHUTDOWN) | ||
446 | goto fail; | ||
436 | if (tmp & EPROM_DONE) | 447 | if (tmp & EPROM_DONE) |
437 | break; | 448 | break; |
438 | } | 449 | } |
439 | disable_eprom_write(pegasus); | 450 | disable_eprom_write(pegasus); |
440 | if (i < REG_TIMEOUT) | 451 | if (i < REG_TIMEOUT) |
441 | return ret; | 452 | return ret; |
453 | fail: | ||
442 | if (netif_msg_drv(pegasus)) | 454 | if (netif_msg_drv(pegasus)) |
443 | dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); | 455 | dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); |
444 | return -ETIMEDOUT; | 456 | return -ETIMEDOUT; |
@@ -1378,9 +1390,8 @@ static int pegasus_suspend (struct usb_interface *intf, pm_message_t message) | |||
1378 | struct pegasus *pegasus = usb_get_intfdata(intf); | 1390 | struct pegasus *pegasus = usb_get_intfdata(intf); |
1379 | 1391 | ||
1380 | netif_device_detach (pegasus->net); | 1392 | netif_device_detach (pegasus->net); |
1393 | cancel_delayed_work(&pegasus->carrier_check); | ||
1381 | if (netif_running(pegasus->net)) { | 1394 | if (netif_running(pegasus->net)) { |
1382 | cancel_delayed_work(&pegasus->carrier_check); | ||
1383 | |||
1384 | usb_kill_urb(pegasus->rx_urb); | 1395 | usb_kill_urb(pegasus->rx_urb); |
1385 | usb_kill_urb(pegasus->intr_urb); | 1396 | usb_kill_urb(pegasus->intr_urb); |
1386 | } | 1397 | } |
@@ -1400,10 +1411,9 @@ static int pegasus_resume (struct usb_interface *intf) | |||
1400 | pegasus->intr_urb->status = 0; | 1411 | pegasus->intr_urb->status = 0; |
1401 | pegasus->intr_urb->actual_length = 0; | 1412 | pegasus->intr_urb->actual_length = 0; |
1402 | intr_callback(pegasus->intr_urb, NULL); | 1413 | intr_callback(pegasus->intr_urb, NULL); |
1403 | |||
1404 | queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, | ||
1405 | CARRIER_CHECK_DELAY); | ||
1406 | } | 1414 | } |
1415 | queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, | ||
1416 | CARRIER_CHECK_DELAY); | ||
1407 | return 0; | 1417 | return 0; |
1408 | } | 1418 | } |
1409 | 1419 | ||
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index f96b73f54bf1..5c60be521561 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -71,6 +71,16 @@ config USB_SERIAL_ANYDATA | |||
71 | To compile this driver as a module, choose M here: the | 71 | To compile this driver as a module, choose M here: the |
72 | module will be called anydata. | 72 | module will be called anydata. |
73 | 73 | ||
74 | config USB_SERIAL_ARK3116 | ||
75 | tristate "USB ARK Micro 3116 USB Serial Driver (EXPERIMENTAL)" | ||
76 | depends on USB_SERIAL && EXPERIMENTAL | ||
77 | help | ||
78 | Say Y here if you want to use a ARK Micro 3116 USB to Serial | ||
79 | device. | ||
80 | |||
81 | To compile this driver as a module, choose M here: the | ||
82 | module will be called ark3116 | ||
83 | |||
74 | config USB_SERIAL_BELKIN | 84 | config USB_SERIAL_BELKIN |
75 | tristate "USB Belkin and Peracom Single Port Serial Driver" | 85 | tristate "USB Belkin and Peracom Single Port Serial Driver" |
76 | depends on USB_SERIAL | 86 | depends on USB_SERIAL |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 93c21245b1af..5a0960fc9d3e 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -13,6 +13,7 @@ usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) | |||
13 | 13 | ||
14 | obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o | 14 | obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o |
15 | obj-$(CONFIG_USB_SERIAL_ANYDATA) += anydata.o | 15 | obj-$(CONFIG_USB_SERIAL_ANYDATA) += anydata.o |
16 | obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o | ||
16 | obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o | 17 | obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o |
17 | obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o | 18 | obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o |
18 | obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o | 19 | obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o |
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c index dbf1f063098c..694b205f9b73 100644 --- a/drivers/usb/serial/airprime.c +++ b/drivers/usb/serial/airprime.c | |||
@@ -18,6 +18,7 @@ | |||
18 | static struct usb_device_id id_table [] = { | 18 | static struct usb_device_id id_table [] = { |
19 | { USB_DEVICE(0xf3d, 0x0112) }, /* AirPrime CDMA Wireless PC Card */ | 19 | { USB_DEVICE(0xf3d, 0x0112) }, /* AirPrime CDMA Wireless PC Card */ |
20 | { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */ | 20 | { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */ |
21 | { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless Aircard 580 */ | ||
21 | { }, | 22 | { }, |
22 | }; | 23 | }; |
23 | MODULE_DEVICE_TABLE(usb, id_table); | 24 | MODULE_DEVICE_TABLE(usb, id_table); |
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c new file mode 100644 index 000000000000..8dec796222a0 --- /dev/null +++ b/drivers/usb/serial/ark3116.c | |||
@@ -0,0 +1,465 @@ | |||
1 | /* | ||
2 | * ark3116 | ||
3 | * - implements a driver for the arkmicro ark3116 chipset (vendor=0x6547, | ||
4 | * productid=0x0232) (used in a datacable called KQ-U8A) | ||
5 | * | ||
6 | * - based on code by krisfx -> thanks !! | ||
7 | * (see http://www.linuxquestions.org/questions/showthread.php?p=2184457#post2184457) | ||
8 | * | ||
9 | * - based on logs created by usbsnoopy | ||
10 | * | ||
11 | * Author : Simon Schulz [ark3116_driver<AT>auctionant.de] | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify it | ||
14 | * under the terms of the GNU General Public License as published by the | ||
15 | * Free Software Foundation; either version 2 of the License, or (at your | ||
16 | * option) any later version. | ||
17 | */ | ||
18 | |||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/tty.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/usb.h> | ||
24 | #include "usb-serial.h" | ||
25 | |||
26 | |||
27 | static int debug; | ||
28 | |||
29 | static struct usb_device_id id_table [] = { | ||
30 | { USB_DEVICE(0x6547, 0x0232) }, | ||
31 | { }, | ||
32 | }; | ||
33 | MODULE_DEVICE_TABLE(usb, id_table); | ||
34 | |||
35 | struct ark3116_private { | ||
36 | spinlock_t lock; | ||
37 | u8 termios_initialized; | ||
38 | }; | ||
39 | |||
40 | static inline void ARK3116_SND(struct usb_serial *serial, int seq, | ||
41 | __u8 request, __u8 requesttype, | ||
42 | __u16 value, __u16 index) | ||
43 | { | ||
44 | int result; | ||
45 | result = usb_control_msg(serial->dev, | ||
46 | usb_sndctrlpipe(serial->dev,0), | ||
47 | request, requesttype, value, index, | ||
48 | NULL,0x00, 1000); | ||
49 | dbg("%03d > ok",seq); | ||
50 | } | ||
51 | |||
52 | static inline void ARK3116_RCV(struct usb_serial *serial, int seq, | ||
53 | __u8 request, __u8 requesttype, | ||
54 | __u16 value, __u16 index, __u8 expected, | ||
55 | char *buf) | ||
56 | { | ||
57 | int result; | ||
58 | result = usb_control_msg(serial->dev, | ||
59 | usb_rcvctrlpipe(serial->dev,0), | ||
60 | request, requesttype, value, index, | ||
61 | buf, 0x0000001, 1000); | ||
62 | if (result) | ||
63 | dbg("%03d < %d bytes [0x%02X]",seq, result, buf[0]); | ||
64 | else | ||
65 | dbg("%03d < 0 bytes", seq); | ||
66 | } | ||
67 | |||
68 | |||
69 | static inline void ARK3116_RCV_QUIET(struct usb_serial *serial, | ||
70 | __u8 request, __u8 requesttype, | ||
71 | __u16 value, __u16 index, char *buf) | ||
72 | { | ||
73 | usb_control_msg(serial->dev, | ||
74 | usb_rcvctrlpipe(serial->dev,0), | ||
75 | request, requesttype, value, index, | ||
76 | buf, 0x0000001, 1000); | ||
77 | } | ||
78 | |||
79 | |||
80 | static int ark3116_attach(struct usb_serial *serial) | ||
81 | { | ||
82 | char *buf; | ||
83 | struct ark3116_private *priv; | ||
84 | int i; | ||
85 | |||
86 | for (i = 0; i < serial->num_ports; ++i) { | ||
87 | priv = kmalloc (sizeof (struct ark3116_private), GFP_KERNEL); | ||
88 | if (!priv) | ||
89 | goto cleanup; | ||
90 | memset (priv, 0x00, sizeof (struct ark3116_private)); | ||
91 | spin_lock_init(&priv->lock); | ||
92 | |||
93 | usb_set_serial_port_data(serial->port[i], priv); | ||
94 | } | ||
95 | |||
96 | buf = kmalloc(1, GFP_KERNEL); | ||
97 | if (!buf) { | ||
98 | dbg("error kmalloc -> out of mem ?"); | ||
99 | goto cleanup; | ||
100 | } | ||
101 | |||
102 | /* 3 */ | ||
103 | ARK3116_SND(serial, 3,0xFE,0x40,0x0008,0x0002); | ||
104 | ARK3116_SND(serial, 4,0xFE,0x40,0x0008,0x0001); | ||
105 | ARK3116_SND(serial, 5,0xFE,0x40,0x0000,0x0008); | ||
106 | ARK3116_SND(serial, 6,0xFE,0x40,0x0000,0x000B); | ||
107 | |||
108 | /* <-- seq7 */ | ||
109 | ARK3116_RCV(serial, 7,0xFE,0xC0,0x0000,0x0003, 0x00, buf); | ||
110 | ARK3116_SND(serial, 8,0xFE,0x40,0x0080,0x0003); | ||
111 | ARK3116_SND(serial, 9,0xFE,0x40,0x001A,0x0000); | ||
112 | ARK3116_SND(serial,10,0xFE,0x40,0x0000,0x0001); | ||
113 | ARK3116_SND(serial,11,0xFE,0x40,0x0000,0x0003); | ||
114 | |||
115 | /* <-- seq12 */ | ||
116 | ARK3116_RCV(serial,12,0xFE,0xC0,0x0000,0x0004, 0x00, buf); | ||
117 | ARK3116_SND(serial,13,0xFE,0x40,0x0000,0x0004); | ||
118 | |||
119 | /* 14 */ | ||
120 | ARK3116_RCV(serial,14,0xFE,0xC0,0x0000,0x0004, 0x00, buf); | ||
121 | ARK3116_SND(serial,15,0xFE,0x40,0x0000,0x0004); | ||
122 | |||
123 | /* 16 */ | ||
124 | ARK3116_RCV(serial,16,0xFE,0xC0,0x0000,0x0004, 0x00, buf); | ||
125 | /* --> seq17 */ | ||
126 | ARK3116_SND(serial,17,0xFE,0x40,0x0001,0x0004); | ||
127 | |||
128 | /* <-- seq18 */ | ||
129 | ARK3116_RCV(serial,18,0xFE,0xC0,0x0000,0x0004, 0x01, buf); | ||
130 | |||
131 | /* --> seq19 */ | ||
132 | ARK3116_SND(serial,19,0xFE,0x40,0x0003,0x0004); | ||
133 | |||
134 | |||
135 | /* <-- seq20 */ | ||
136 | /* seems like serial port status info (RTS, CTS,...) */ | ||
137 | /* returns modem control line status ?! */ | ||
138 | ARK3116_RCV(serial,20,0xFE,0xC0,0x0000,0x0006, 0xFF, buf); | ||
139 | |||
140 | /* set 9600 baud & do some init ?! */ | ||
141 | ARK3116_SND(serial,147,0xFE,0x40,0x0083,0x0003); | ||
142 | ARK3116_SND(serial,148,0xFE,0x40,0x0038,0x0000); | ||
143 | ARK3116_SND(serial,149,0xFE,0x40,0x0001,0x0001); | ||
144 | ARK3116_SND(serial,150,0xFE,0x40,0x0003,0x0003); | ||
145 | ARK3116_RCV(serial,151,0xFE,0xC0,0x0000,0x0004,0x03, buf); | ||
146 | ARK3116_SND(serial,152,0xFE,0x40,0x0000,0x0003); | ||
147 | ARK3116_RCV(serial,153,0xFE,0xC0,0x0000,0x0003,0x00, buf); | ||
148 | ARK3116_SND(serial,154,0xFE,0x40,0x0003,0x0003); | ||
149 | |||
150 | kfree(buf); | ||
151 | return(0); | ||
152 | |||
153 | cleanup: | ||
154 | for (--i; i>=0; --i) | ||
155 | usb_set_serial_port_data(serial->port[i], NULL); | ||
156 | return -ENOMEM; | ||
157 | } | ||
158 | |||
159 | static void ark3116_set_termios(struct usb_serial_port *port, | ||
160 | struct termios *old_termios) | ||
161 | { | ||
162 | struct usb_serial *serial = port->serial; | ||
163 | struct ark3116_private *priv = usb_get_serial_port_data(port); | ||
164 | unsigned int cflag = port->tty->termios->c_cflag; | ||
165 | unsigned long flags; | ||
166 | int baud; | ||
167 | int ark3116_baud; | ||
168 | char *buf; | ||
169 | char config; | ||
170 | |||
171 | config = 0; | ||
172 | |||
173 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
174 | |||
175 | if ((!port->tty) || (!port->tty->termios)) { | ||
176 | dbg("%s - no tty structures", __FUNCTION__); | ||
177 | return; | ||
178 | } | ||
179 | |||
180 | spin_lock_irqsave(&priv->lock, flags); | ||
181 | if (!priv->termios_initialized) { | ||
182 | *(port->tty->termios) = tty_std_termios; | ||
183 | port->tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; | ||
184 | priv->termios_initialized = 1; | ||
185 | } | ||
186 | spin_unlock_irqrestore(&priv->lock, flags); | ||
187 | |||
188 | cflag = port->tty->termios->c_cflag; | ||
189 | |||
190 | /* check that they really want us to change something: */ | ||
191 | if (old_termios) { | ||
192 | if ((cflag == old_termios->c_cflag) && | ||
193 | (RELEVANT_IFLAG(port->tty->termios->c_iflag) == | ||
194 | RELEVANT_IFLAG(old_termios->c_iflag))) { | ||
195 | dbg("%s - nothing to change...", __FUNCTION__); | ||
196 | return; | ||
197 | } | ||
198 | } | ||
199 | |||
200 | buf = kmalloc(1, GFP_KERNEL); | ||
201 | if (!buf) { | ||
202 | dbg("error kmalloc"); | ||
203 | return; | ||
204 | } | ||
205 | |||
206 | /* set data bit count (8/7/6/5) */ | ||
207 | if (cflag & CSIZE){ | ||
208 | switch (cflag & CSIZE){ | ||
209 | case CS5: | ||
210 | config |= 0x00; | ||
211 | dbg("setting CS5"); | ||
212 | break; | ||
213 | case CS6: | ||
214 | config |= 0x01; | ||
215 | dbg("setting CS6"); | ||
216 | break; | ||
217 | case CS7: | ||
218 | config |= 0x02; | ||
219 | dbg("setting CS7"); | ||
220 | break; | ||
221 | default: | ||
222 | err ("CSIZE was set but not CS5-CS8, using CS8!"); | ||
223 | case CS8: | ||
224 | config |= 0x03; | ||
225 | dbg("setting CS8"); | ||
226 | break; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | /* set parity (NONE,EVEN,ODD) */ | ||
231 | if (cflag & PARENB){ | ||
232 | if (cflag & PARODD) { | ||
233 | config |= 0x08; | ||
234 | dbg("setting parity to ODD"); | ||
235 | } else { | ||
236 | config |= 0x18; | ||
237 | dbg("setting parity to EVEN"); | ||
238 | } | ||
239 | } else { | ||
240 | dbg("setting parity to NONE"); | ||
241 | } | ||
242 | |||
243 | /* SET STOPBIT (1/2) */ | ||
244 | if (cflag & CSTOPB) { | ||
245 | config |= 0x04; | ||
246 | dbg ("setting 2 stop bits"); | ||
247 | } else { | ||
248 | dbg ("setting 1 stop bit"); | ||
249 | } | ||
250 | |||
251 | |||
252 | /* set baudrate: */ | ||
253 | baud = 0; | ||
254 | switch (cflag & CBAUD){ | ||
255 | case B0: | ||
256 | err("can't set 0baud, using 9600 instead"); | ||
257 | break; | ||
258 | case B75: baud = 75; break; | ||
259 | case B150: baud = 150; break; | ||
260 | case B300: baud = 300; break; | ||
261 | case B600: baud = 600; break; | ||
262 | case B1200: baud = 1200; break; | ||
263 | case B1800: baud = 1800; break; | ||
264 | case B2400: baud = 2400; break; | ||
265 | case B4800: baud = 4800; break; | ||
266 | case B9600: baud = 9600; break; | ||
267 | case B19200: baud = 19200; break; | ||
268 | case B38400: baud = 38400; break; | ||
269 | case B57600: baud = 57600; break; | ||
270 | case B115200: baud = 115200; break; | ||
271 | case B230400: baud = 230400; break; | ||
272 | case B460800: baud = 460800; break; | ||
273 | default: | ||
274 | dbg("does not support the baudrate requested (fix it)"); | ||
275 | break; | ||
276 | } | ||
277 | |||
278 | /* set 9600 as default (if given baudrate is invalid for example) */ | ||
279 | if (baud == 0) | ||
280 | baud = 9600; | ||
281 | |||
282 | /* | ||
283 | * found by try'n'error, be careful, maybe there are other options | ||
284 | * for multiplicator etc! | ||
285 | */ | ||
286 | if (baud == 460800) | ||
287 | /* strange, for 460800 the formula is wrong | ||
288 | * (dont use round(), then 9600baud is wrong) */ | ||
289 | ark3116_baud = 7; | ||
290 | else | ||
291 | ark3116_baud = 3000000 / baud; | ||
292 | |||
293 | /* ? */ | ||
294 | ARK3116_RCV(serial,0,0xFE,0xC0,0x0000,0x0003, 0x03, buf); | ||
295 | /* offset = buf[0]; */ | ||
296 | /* offset = 0x03; */ | ||
297 | /* dbg("using 0x%04X as target for 0x0003:",0x0080+offset); */ | ||
298 | |||
299 | |||
300 | /* set baudrate */ | ||
301 | dbg("setting baudrate to %d (->reg=%d)",baud,ark3116_baud); | ||
302 | ARK3116_SND(serial,147,0xFE,0x40,0x0083,0x0003); | ||
303 | ARK3116_SND(serial,148,0xFE,0x40,(ark3116_baud & 0x00FF) ,0x0000); | ||
304 | ARK3116_SND(serial,149,0xFE,0x40,(ark3116_baud & 0xFF00)>>8,0x0001); | ||
305 | ARK3116_SND(serial,150,0xFE,0x40,0x0003,0x0003); | ||
306 | |||
307 | /* ? */ | ||
308 | ARK3116_RCV(serial,151,0xFE,0xC0,0x0000,0x0004,0x03, buf); | ||
309 | ARK3116_SND(serial,152,0xFE,0x40,0x0000,0x0003); | ||
310 | |||
311 | /* set data bit count, stop bit count & parity: */ | ||
312 | dbg("updating bit count, stop bit or parity (cfg=0x%02X)", config); | ||
313 | ARK3116_RCV(serial,153,0xFE,0xC0,0x0000,0x0003,0x00, buf); | ||
314 | ARK3116_SND(serial,154,0xFE,0x40,config,0x0003); | ||
315 | |||
316 | if (cflag & CRTSCTS) | ||
317 | dbg("CRTSCTS not supported by chipset ?!"); | ||
318 | |||
319 | /* TEST ARK3116_SND(154,0xFE,0x40,0xFFFF, 0x0006); */ | ||
320 | |||
321 | kfree(buf); | ||
322 | return; | ||
323 | } | ||
324 | |||
325 | static int ark3116_open(struct usb_serial_port *port, struct file *filp) | ||
326 | { | ||
327 | struct termios tmp_termios; | ||
328 | struct usb_serial *serial = port->serial; | ||
329 | char *buf; | ||
330 | int result = 0; | ||
331 | |||
332 | dbg("%s - port %d", __FUNCTION__, port->number); | ||
333 | |||
334 | buf = kmalloc(1, GFP_KERNEL); | ||
335 | if (!buf) { | ||
336 | dbg("error kmalloc -> out of mem ?"); | ||
337 | return -ENOMEM; | ||
338 | } | ||
339 | |||
340 | result = usb_serial_generic_open(port, filp); | ||
341 | if (result) | ||
342 | return result; | ||
343 | |||
344 | /* open */ | ||
345 | ARK3116_RCV(serial,111,0xFE,0xC0,0x0000,0x0003, 0x02, buf); | ||
346 | |||
347 | ARK3116_SND(serial,112,0xFE,0x40,0x0082,0x0003); | ||
348 | ARK3116_SND(serial,113,0xFE,0x40,0x001A,0x0000); | ||
349 | ARK3116_SND(serial,114,0xFE,0x40,0x0000,0x0001); | ||
350 | ARK3116_SND(serial,115,0xFE,0x40,0x0002,0x0003); | ||
351 | |||
352 | ARK3116_RCV(serial,116,0xFE,0xC0,0x0000,0x0004, 0x03, buf); | ||
353 | ARK3116_SND(serial,117,0xFE,0x40,0x0002,0x0004); | ||
354 | |||
355 | ARK3116_RCV(serial,118,0xFE,0xC0,0x0000,0x0004, 0x02, buf); | ||
356 | ARK3116_SND(serial,119,0xFE,0x40,0x0000,0x0004); | ||
357 | |||
358 | ARK3116_RCV(serial,120,0xFE,0xC0,0x0000,0x0004, 0x00, buf); | ||
359 | |||
360 | ARK3116_SND(serial,121,0xFE,0x40,0x0001,0x0004); | ||
361 | |||
362 | ARK3116_RCV(serial,122,0xFE,0xC0,0x0000,0x0004, 0x01, buf); | ||
363 | |||
364 | ARK3116_SND(serial,123,0xFE,0x40,0x0003,0x0004); | ||
365 | |||
366 | /* returns different values (control lines ?!) */ | ||
367 | ARK3116_RCV(serial,124,0xFE,0xC0,0x0000,0x0006, 0xFF, buf); | ||
368 | |||
369 | /* initialise termios: */ | ||
370 | if (port->tty) | ||
371 | ark3116_set_termios(port, &tmp_termios); | ||
372 | |||
373 | kfree(buf); | ||
374 | |||
375 | return result; | ||
376 | |||
377 | } | ||
378 | |||
379 | static int ark3116_ioctl(struct usb_serial_port *port, struct file *file, | ||
380 | unsigned int cmd, unsigned long arg) | ||
381 | { | ||
382 | dbg("ioctl not supported yet..."); | ||
383 | return -ENOIOCTLCMD; | ||
384 | } | ||
385 | |||
386 | static int ark3116_tiocmget(struct usb_serial_port *port, struct file *file) | ||
387 | { | ||
388 | struct usb_serial *serial = port->serial; | ||
389 | char *buf; | ||
390 | char temp; | ||
391 | |||
392 | /* seems like serial port status info (RTS, CTS,...) is stored | ||
393 | * in reg(?) 0x0006 | ||
394 | * pcb connection point 11 = GND -> sets bit4 of response | ||
395 | * pcb connection point 7 = GND -> sets bit6 of response | ||
396 | */ | ||
397 | |||
398 | buf = kmalloc(1, GFP_KERNEL); | ||
399 | if (!buf) { | ||
400 | dbg("error kmalloc"); | ||
401 | return -ENOMEM; | ||
402 | } | ||
403 | |||
404 | /* read register: */ | ||
405 | ARK3116_RCV_QUIET(serial,0xFE,0xC0,0x0000,0x0006,buf); | ||
406 | temp = buf[0]; | ||
407 | kfree(buf); | ||
408 | |||
409 | /* i do not really know if bit4=CTS and bit6=DSR... was just a | ||
410 | * quick guess !! | ||
411 | */ | ||
412 | return (temp & (1<<4) ? TIOCM_CTS : 0) | | ||
413 | (temp & (1<<6) ? TIOCM_DSR : 0); | ||
414 | } | ||
415 | |||
416 | static struct usb_driver ark3116_driver = { | ||
417 | .name = "ark3116", | ||
418 | .probe = usb_serial_probe, | ||
419 | .disconnect = usb_serial_disconnect, | ||
420 | .id_table = id_table, | ||
421 | }; | ||
422 | |||
423 | static struct usb_serial_driver ark3116_device = { | ||
424 | .driver = { | ||
425 | .owner = THIS_MODULE, | ||
426 | .name = "ark3116", | ||
427 | }, | ||
428 | .id_table = id_table, | ||
429 | .num_interrupt_in = 1, | ||
430 | .num_bulk_in = 1, | ||
431 | .num_bulk_out = 1, | ||
432 | .num_ports = 1, | ||
433 | .attach = ark3116_attach, | ||
434 | .set_termios = ark3116_set_termios, | ||
435 | .ioctl = ark3116_ioctl, | ||
436 | .tiocmget = ark3116_tiocmget, | ||
437 | .open = ark3116_open, | ||
438 | }; | ||
439 | |||
440 | static int __init ark3116_init(void) | ||
441 | { | ||
442 | int retval; | ||
443 | |||
444 | retval = usb_serial_register(&ark3116_device); | ||
445 | if (retval) | ||
446 | return retval; | ||
447 | retval = usb_register(&ark3116_driver); | ||
448 | if (retval) | ||
449 | usb_serial_deregister(&ark3116_device); | ||
450 | return retval; | ||
451 | } | ||
452 | |||
453 | static void __exit ark3116_exit(void) | ||
454 | { | ||
455 | usb_deregister(&ark3116_driver); | ||
456 | usb_serial_deregister(&ark3116_device); | ||
457 | } | ||
458 | |||
459 | module_init(ark3116_init); | ||
460 | module_exit(ark3116_exit); | ||
461 | MODULE_LICENSE("GPL"); | ||
462 | |||
463 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
464 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
465 | |||
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 82151207d814..986d7622273d 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -307,6 +307,7 @@ static struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = { | |||
307 | 307 | ||
308 | 308 | ||
309 | static struct usb_device_id id_table_combined [] = { | 309 | static struct usb_device_id id_table_combined [] = { |
310 | { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, | ||
310 | { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, | 311 | { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, |
311 | { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, | 312 | { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, |
312 | { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, | 313 | { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, |
@@ -498,6 +499,7 @@ static struct usb_device_id id_table_combined [] = { | |||
498 | { USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) }, | 499 | { USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) }, |
499 | { USB_DEVICE(ICOM_ID1_VID, ICOM_ID1_PID) }, | 500 | { USB_DEVICE(ICOM_ID1_VID, ICOM_ID1_PID) }, |
500 | { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) }, | 501 | { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) }, |
502 | { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) }, | ||
501 | { }, /* Optional parameter entry */ | 503 | { }, /* Optional parameter entry */ |
502 | { } /* Terminating entry */ | 504 | { } /* Terminating entry */ |
503 | }; | 505 | }; |
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 2c55a5ea9c99..d69a917e768f 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
@@ -32,6 +32,10 @@ | |||
32 | #define FTDI_NF_RIC_PID 0x0001 /* Product Id */ | 32 | #define FTDI_NF_RIC_PID 0x0001 /* Product Id */ |
33 | 33 | ||
34 | 34 | ||
35 | /* ACT Solutions HomePro ZWave interface (http://www.act-solutions.com/HomePro.htm) */ | ||
36 | #define FTDI_ACTZWAVE_PID 0xF2D0 | ||
37 | |||
38 | |||
35 | /* www.irtrans.de device */ | 39 | /* www.irtrans.de device */ |
36 | #define FTDI_IRTRANS_PID 0xFC60 /* Product Id */ | 40 | #define FTDI_IRTRANS_PID 0xFC60 /* Product Id */ |
37 | 41 | ||
@@ -426,6 +430,11 @@ | |||
426 | #define PAPOUCH_VID 0x5050 /* Vendor ID */ | 430 | #define PAPOUCH_VID 0x5050 /* Vendor ID */ |
427 | #define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */ | 431 | #define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */ |
428 | 432 | ||
433 | /* | ||
434 | * ACG Identification Technologies GmbH products (http://www.acg.de/). | ||
435 | * Submitted by anton -at- goto10 -dot- org. | ||
436 | */ | ||
437 | #define FTDI_ACG_HFDUAL_PID 0xDD20 /* HF Dual ISO Reader (RFID) */ | ||
429 | 438 | ||
430 | /* Commands */ | 439 | /* Commands */ |
431 | #define FTDI_SIO_RESET 0 /* Reset the port */ | 440 | #define FTDI_SIO_RESET 0 /* Reset the port */ |
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 476cda107f4f..c62cc2876519 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -138,6 +138,7 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp) | |||
138 | 138 | ||
139 | return result; | 139 | return result; |
140 | } | 140 | } |
141 | EXPORT_SYMBOL_GPL(usb_serial_generic_open); | ||
141 | 142 | ||
142 | static void generic_cleanup (struct usb_serial_port *port) | 143 | static void generic_cleanup (struct usb_serial_port *port) |
143 | { | 144 | { |
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 4d40704dea2c..238033a87092 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -257,14 +257,14 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf | |||
257 | return (0); | 257 | return (0); |
258 | } | 258 | } |
259 | 259 | ||
260 | spin_lock(&port->lock); | 260 | spin_lock(&wport->lock); |
261 | if (port->write_urb_busy) { | 261 | if (wport->write_urb_busy) { |
262 | spin_unlock(&port->lock); | 262 | spin_unlock(&wport->lock); |
263 | dbg("%s - already writing", __FUNCTION__); | 263 | dbg("%s - already writing", __FUNCTION__); |
264 | return 0; | 264 | return 0; |
265 | } | 265 | } |
266 | port->write_urb_busy = 1; | 266 | wport->write_urb_busy = 1; |
267 | spin_unlock(&port->lock); | 267 | spin_unlock(&wport->lock); |
268 | 268 | ||
269 | count = (count > OMNINET_BULKOUTSIZE) ? OMNINET_BULKOUTSIZE : count; | 269 | count = (count > OMNINET_BULKOUTSIZE) ? OMNINET_BULKOUTSIZE : count; |
270 | 270 | ||
@@ -283,7 +283,7 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf | |||
283 | wport->write_urb->dev = serial->dev; | 283 | wport->write_urb->dev = serial->dev; |
284 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); | 284 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); |
285 | if (result) { | 285 | if (result) { |
286 | port->write_urb_busy = 0; | 286 | wport->write_urb_busy = 0; |
287 | err("%s - failed submitting write urb, error %d", __FUNCTION__, result); | 287 | err("%s - failed submitting write urb, error %d", __FUNCTION__, result); |
288 | } else | 288 | } else |
289 | result = count; | 289 | result = count; |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 071f86a59c08..9c36f0ece20f 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -189,11 +189,15 @@ static int serial_open (struct tty_struct *tty, struct file * filp) | |||
189 | 189 | ||
190 | portNumber = tty->index - serial->minor; | 190 | portNumber = tty->index - serial->minor; |
191 | port = serial->port[portNumber]; | 191 | port = serial->port[portNumber]; |
192 | if (!port) | 192 | if (!port) { |
193 | return -ENODEV; | 193 | retval = -ENODEV; |
194 | goto bailout_kref_put; | ||
195 | } | ||
194 | 196 | ||
195 | if (mutex_lock_interruptible(&port->mutex)) | 197 | if (mutex_lock_interruptible(&port->mutex)) { |
196 | return -ERESTARTSYS; | 198 | retval = -ERESTARTSYS; |
199 | goto bailout_kref_put; | ||
200 | } | ||
197 | 201 | ||
198 | ++port->open_count; | 202 | ++port->open_count; |
199 | 203 | ||
@@ -209,7 +213,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) | |||
209 | * safe because we are called with BKL held */ | 213 | * safe because we are called with BKL held */ |
210 | if (!try_module_get(serial->type->driver.owner)) { | 214 | if (!try_module_get(serial->type->driver.owner)) { |
211 | retval = -ENODEV; | 215 | retval = -ENODEV; |
212 | goto bailout_kref_put; | 216 | goto bailout_mutex_unlock; |
213 | } | 217 | } |
214 | 218 | ||
215 | /* only call the device specific open if this | 219 | /* only call the device specific open if this |
@@ -224,10 +228,11 @@ static int serial_open (struct tty_struct *tty, struct file * filp) | |||
224 | 228 | ||
225 | bailout_module_put: | 229 | bailout_module_put: |
226 | module_put(serial->type->driver.owner); | 230 | module_put(serial->type->driver.owner); |
227 | bailout_kref_put: | 231 | bailout_mutex_unlock: |
228 | kref_put(&serial->kref, destroy_serial); | ||
229 | port->open_count = 0; | 232 | port->open_count = 0; |
230 | mutex_unlock(&port->mutex); | 233 | mutex_unlock(&port->mutex); |
234 | bailout_kref_put: | ||
235 | kref_put(&serial->kref, destroy_serial); | ||
231 | return retval; | 236 | return retval; |
232 | } | 237 | } |
233 | 238 | ||
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 334b1db1bd7c..27597c576eff 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c | |||
@@ -29,12 +29,15 @@ static ssize_t backlight_show_power(struct class_device *cdev, char *buf) | |||
29 | 29 | ||
30 | static ssize_t backlight_store_power(struct class_device *cdev, const char *buf, size_t count) | 30 | static ssize_t backlight_store_power(struct class_device *cdev, const char *buf, size_t count) |
31 | { | 31 | { |
32 | int rc = -ENXIO, power; | 32 | int rc = -ENXIO; |
33 | char *endp; | 33 | char *endp; |
34 | struct backlight_device *bd = to_backlight_device(cdev); | 34 | struct backlight_device *bd = to_backlight_device(cdev); |
35 | int power = simple_strtoul(buf, &endp, 0); | ||
36 | size_t size = endp - buf; | ||
35 | 37 | ||
36 | power = simple_strtoul(buf, &endp, 0); | 38 | if (*endp && isspace(*endp)) |
37 | if (*endp && !isspace(*endp)) | 39 | size++; |
40 | if (size != count) | ||
38 | return -EINVAL; | 41 | return -EINVAL; |
39 | 42 | ||
40 | down(&bd->sem); | 43 | down(&bd->sem); |
@@ -65,12 +68,15 @@ static ssize_t backlight_show_brightness(struct class_device *cdev, char *buf) | |||
65 | 68 | ||
66 | static ssize_t backlight_store_brightness(struct class_device *cdev, const char *buf, size_t count) | 69 | static ssize_t backlight_store_brightness(struct class_device *cdev, const char *buf, size_t count) |
67 | { | 70 | { |
68 | int rc = -ENXIO, brightness; | 71 | int rc = -ENXIO; |
69 | char *endp; | 72 | char *endp; |
70 | struct backlight_device *bd = to_backlight_device(cdev); | 73 | struct backlight_device *bd = to_backlight_device(cdev); |
74 | int brightness = simple_strtoul(buf, &endp, 0); | ||
75 | size_t size = endp - buf; | ||
71 | 76 | ||
72 | brightness = simple_strtoul(buf, &endp, 0); | 77 | if (*endp && isspace(*endp)) |
73 | if (*endp && !isspace(*endp)) | 78 | size++; |
79 | if (size != count) | ||
74 | return -EINVAL; | 80 | return -EINVAL; |
75 | 81 | ||
76 | down(&bd->sem); | 82 | down(&bd->sem); |
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c index 86908a60c630..bc8ab005a3fb 100644 --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c | |||
@@ -31,12 +31,15 @@ static ssize_t lcd_show_power(struct class_device *cdev, char *buf) | |||
31 | 31 | ||
32 | static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_t count) | 32 | static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_t count) |
33 | { | 33 | { |
34 | int rc, power; | 34 | int rc = -ENXIO; |
35 | char *endp; | 35 | char *endp; |
36 | struct lcd_device *ld = to_lcd_device(cdev); | 36 | struct lcd_device *ld = to_lcd_device(cdev); |
37 | int power = simple_strtoul(buf, &endp, 0); | ||
38 | size_t size = endp - buf; | ||
37 | 39 | ||
38 | power = simple_strtoul(buf, &endp, 0); | 40 | if (*endp && isspace(*endp)) |
39 | if (*endp && !isspace(*endp)) | 41 | size++; |
42 | if (size != count) | ||
40 | return -EINVAL; | 43 | return -EINVAL; |
41 | 44 | ||
42 | down(&ld->sem); | 45 | down(&ld->sem); |
@@ -44,8 +47,7 @@ static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_ | |||
44 | pr_debug("lcd: set power to %d\n", power); | 47 | pr_debug("lcd: set power to %d\n", power); |
45 | ld->props->set_power(ld, power); | 48 | ld->props->set_power(ld, power); |
46 | rc = count; | 49 | rc = count; |
47 | } else | 50 | } |
48 | rc = -ENXIO; | ||
49 | up(&ld->sem); | 51 | up(&ld->sem); |
50 | 52 | ||
51 | return rc; | 53 | return rc; |
@@ -53,14 +55,12 @@ static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_ | |||
53 | 55 | ||
54 | static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf) | 56 | static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf) |
55 | { | 57 | { |
56 | int rc; | 58 | int rc = -ENXIO; |
57 | struct lcd_device *ld = to_lcd_device(cdev); | 59 | struct lcd_device *ld = to_lcd_device(cdev); |
58 | 60 | ||
59 | down(&ld->sem); | 61 | down(&ld->sem); |
60 | if (likely(ld->props && ld->props->get_contrast)) | 62 | if (likely(ld->props && ld->props->get_contrast)) |
61 | rc = sprintf(buf, "%d\n", ld->props->get_contrast(ld)); | 63 | rc = sprintf(buf, "%d\n", ld->props->get_contrast(ld)); |
62 | else | ||
63 | rc = -ENXIO; | ||
64 | up(&ld->sem); | 64 | up(&ld->sem); |
65 | 65 | ||
66 | return rc; | 66 | return rc; |
@@ -68,12 +68,15 @@ static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf) | |||
68 | 68 | ||
69 | static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, size_t count) | 69 | static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, size_t count) |
70 | { | 70 | { |
71 | int rc, contrast; | 71 | int rc = -ENXIO; |
72 | char *endp; | 72 | char *endp; |
73 | struct lcd_device *ld = to_lcd_device(cdev); | 73 | struct lcd_device *ld = to_lcd_device(cdev); |
74 | int contrast = simple_strtoul(buf, &endp, 0); | ||
75 | size_t size = endp - buf; | ||
74 | 76 | ||
75 | contrast = simple_strtoul(buf, &endp, 0); | 77 | if (*endp && isspace(*endp)) |
76 | if (*endp && !isspace(*endp)) | 78 | size++; |
79 | if (size != count) | ||
77 | return -EINVAL; | 80 | return -EINVAL; |
78 | 81 | ||
79 | down(&ld->sem); | 82 | down(&ld->sem); |
@@ -81,8 +84,7 @@ static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, si | |||
81 | pr_debug("lcd: set contrast to %d\n", contrast); | 84 | pr_debug("lcd: set contrast to %d\n", contrast); |
82 | ld->props->set_contrast(ld, contrast); | 85 | ld->props->set_contrast(ld, contrast); |
83 | rc = count; | 86 | rc = count; |
84 | } else | 87 | } |
85 | rc = -ENXIO; | ||
86 | up(&ld->sem); | 88 | up(&ld->sem); |
87 | 89 | ||
88 | return rc; | 90 | return rc; |
@@ -90,14 +92,12 @@ static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, si | |||
90 | 92 | ||
91 | static ssize_t lcd_show_max_contrast(struct class_device *cdev, char *buf) | 93 | static ssize_t lcd_show_max_contrast(struct class_device *cdev, char *buf) |
92 | { | 94 | { |
93 | int rc; | 95 | int rc = -ENXIO; |
94 | struct lcd_device *ld = to_lcd_device(cdev); | 96 | struct lcd_device *ld = to_lcd_device(cdev); |
95 | 97 | ||
96 | down(&ld->sem); | 98 | down(&ld->sem); |
97 | if (likely(ld->props)) | 99 | if (likely(ld->props)) |
98 | rc = sprintf(buf, "%d\n", ld->props->max_contrast); | 100 | rc = sprintf(buf, "%d\n", ld->props->max_contrast); |
99 | else | ||
100 | rc = -ENXIO; | ||
101 | up(&ld->sem); | 101 | up(&ld->sem); |
102 | 102 | ||
103 | return rc; | 103 | return rc; |
diff --git a/drivers/video/logo/Makefile b/drivers/video/logo/Makefile index 4ef5cd19609d..b985dfad6c63 100644 --- a/drivers/video/logo/Makefile +++ b/drivers/video/logo/Makefile | |||
@@ -34,7 +34,7 @@ extra-y += $(call logo-cfiles,_clut224,ppm) | |||
34 | extra-y += $(call logo-cfiles,_gray256,pgm) | 34 | extra-y += $(call logo-cfiles,_gray256,pgm) |
35 | 35 | ||
36 | # Create commands like "pnmtologo -t mono -n logo_mac_mono -o ..." | 36 | # Create commands like "pnmtologo -t mono -n logo_mac_mono -o ..." |
37 | quiet_cmd_logo = LOGO $@ | 37 | quiet_cmd_logo = LOGO $@ |
38 | cmd_logo = scripts/pnmtologo \ | 38 | cmd_logo = scripts/pnmtologo \ |
39 | -t $(patsubst $*_%,%,$(notdir $(basename $<))) \ | 39 | -t $(patsubst $*_%,%,$(notdir $(basename $<))) \ |
40 | -n $(notdir $(basename $<)) -o $@ $< | 40 | -n $(notdir $(basename $<)) -o $@ $< |