[SERIAL] sunzilog: Fix bugs in device deregristration.

1) Need to unregister 2 ports per of_device.
2) Need to of_iounmap() 1 mapping per of_device.
3) Need to free up the IRQ only after all devices
have been unregistered.

Signed-off-by: David S. Miller <davem@davemloft.net>

authored by David S. Miller and committed by David S. Miller 4fa97dcf 36764631

+22 -7
+22 -7
drivers/serial/sunzilog.c
··· 1335 1335 return ret; 1336 1336 } 1337 1337 1338 + static int zilog_irq = -1; 1339 + 1338 1340 static int __devinit zs_probe(struct of_device *dev, const struct of_device_id *match) 1339 1341 { 1340 - static int zilog_irq = -1; 1341 1342 struct of_device *op = to_of_device(&dev->dev); 1342 1343 struct uart_sunzilog_port *up; 1343 1344 struct zilog_layout __iomem *rp; ··· 1414 1413 } 1415 1414 } 1416 1415 1416 + dev_set_drvdata(&dev->dev, &up[0]); 1417 + 1417 1418 return 0; 1418 1419 } 1419 1420 1420 - static int __devexit zs_remove(struct of_device *dev) 1421 + static void __devexit zs_remove_one(struct uart_sunzilog_port *up) 1421 1422 { 1422 - struct uart_sunzilog_port *up = dev_get_drvdata(&dev->dev); 1423 - struct zilog_channel __iomem *channel; 1424 - 1425 1423 if (ZS_IS_KEYB(up) || ZS_IS_MOUSE(up)) { 1426 1424 #ifdef CONFIG_SERIO 1427 1425 serio_unregister_port(&up->serio); 1428 1426 #endif 1429 1427 } else 1430 1428 uart_remove_one_port(&sunzilog_reg, &up->port); 1429 + } 1431 1430 1432 - channel = ZILOG_CHANNEL_FROM_PORT(&up->port); 1431 + static int __devexit zs_remove(struct of_device *dev) 1432 + { 1433 + struct uart_sunzilog_port *up = dev_get_drvdata(&dev->dev); 1434 + struct zilog_layout __iomem *regs; 1433 1435 1434 - of_iounmap(channel, sizeof(struct zilog_channel)); 1436 + zs_remove_one(&up[0]); 1437 + zs_remove_one(&up[1]); 1438 + 1439 + regs = sunzilog_chip_regs[up[0].port.line / 2]; 1440 + of_iounmap(regs, sizeof(struct zilog_layout)); 1441 + 1442 + dev_set_drvdata(&dev->dev, NULL); 1435 1443 1436 1444 return 0; 1437 1445 } ··· 1498 1488 static void __exit sunzilog_exit(void) 1499 1489 { 1500 1490 of_unregister_driver(&zs_driver); 1491 + 1492 + if (zilog_irq != -1) { 1493 + free_irq(zilog_irq, sunzilog_irq_chain); 1494 + zilog_irq = -1; 1495 + } 1501 1496 1502 1497 if (NUM_SUNZILOG) { 1503 1498 uart_unregister_driver(&sunzilog_reg);