Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: use platform_{get,set}_drvdata()

Use the wrapper functions for getting and setting the driver data using
platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
so we can directly pass a struct platform_device.

Also, unnecessary dev_set_drvdata() is removed, because the driver core
clears the driver data to NULL after device_release or on probe failure.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jingoo Han and committed by
Greg Kroah-Hartman
696faedd 9d141cb9

+23 -36
+2 -2
drivers/tty/serial/cpm_uart/cpm_uart_core.c
··· 1384 1384 if (index >= UART_NR) 1385 1385 return -ENODEV; 1386 1386 1387 - dev_set_drvdata(&ofdev->dev, pinfo); 1387 + platform_set_drvdata(ofdev, pinfo); 1388 1388 1389 1389 /* initialize the device pointer for the port */ 1390 1390 pinfo->port.dev = &ofdev->dev; ··· 1398 1398 1399 1399 static int cpm_uart_remove(struct platform_device *ofdev) 1400 1400 { 1401 - struct uart_cpm_port *pinfo = dev_get_drvdata(&ofdev->dev); 1401 + struct uart_cpm_port *pinfo = platform_get_drvdata(ofdev); 1402 1402 return uart_remove_one_port(&cpm_reg, &pinfo->port); 1403 1403 } 1404 1404
+4 -5
drivers/tty/serial/mpc52xx_uart.c
··· 1362 1362 if (ret) 1363 1363 return ret; 1364 1364 1365 - dev_set_drvdata(&op->dev, (void *)port); 1365 + platform_set_drvdata(op, (void *)port); 1366 1366 return 0; 1367 1367 } 1368 1368 1369 1369 static int 1370 1370 mpc52xx_uart_of_remove(struct platform_device *op) 1371 1371 { 1372 - struct uart_port *port = dev_get_drvdata(&op->dev); 1373 - dev_set_drvdata(&op->dev, NULL); 1372 + struct uart_port *port = platform_get_drvdata(op); 1374 1373 1375 1374 if (port) 1376 1375 uart_remove_one_port(&mpc52xx_uart_driver, port); ··· 1381 1382 static int 1382 1383 mpc52xx_uart_of_suspend(struct platform_device *op, pm_message_t state) 1383 1384 { 1384 - struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev); 1385 + struct uart_port *port = (struct uart_port *) platform_get_drvdata(op); 1385 1386 1386 1387 if (port) 1387 1388 uart_suspend_port(&mpc52xx_uart_driver, port); ··· 1392 1393 static int 1393 1394 mpc52xx_uart_of_resume(struct platform_device *op) 1394 1395 { 1395 - struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev); 1396 + struct uart_port *port = (struct uart_port *) platform_get_drvdata(op); 1396 1397 1397 1398 if (port) 1398 1399 uart_resume_port(&mpc52xx_uart_driver, port);
+2 -2
drivers/tty/serial/of_serial.c
··· 204 204 205 205 info->type = port_type; 206 206 info->line = ret; 207 - dev_set_drvdata(&ofdev->dev, info); 207 + platform_set_drvdata(ofdev, info); 208 208 return 0; 209 209 out: 210 210 kfree(info); ··· 217 217 */ 218 218 static int of_platform_serial_remove(struct platform_device *ofdev) 219 219 { 220 - struct of_serial_info *info = dev_get_drvdata(&ofdev->dev); 220 + struct of_serial_info *info = platform_get_drvdata(ofdev); 221 221 switch (info->type) { 222 222 #ifdef CONFIG_SERIAL_8250 223 223 case PORT_8250 ... PORT_MAX_8250:
+2 -3
drivers/tty/serial/sc26xx.c
··· 696 696 if (err) 697 697 goto out_remove_ports; 698 698 699 - dev_set_drvdata(&dev->dev, up); 699 + platform_set_drvdata(dev, up); 700 700 return 0; 701 701 702 702 out_remove_ports: ··· 716 716 717 717 static int __exit sc26xx_driver_remove(struct platform_device *dev) 718 718 { 719 - struct uart_sc26xx_port *up = dev_get_drvdata(&dev->dev); 719 + struct uart_sc26xx_port *up = platform_get_drvdata(dev); 720 720 721 721 free_irq(up->port[0].irq, up); 722 722 ··· 728 728 kfree(up); 729 729 sc26xx_port = NULL; 730 730 731 - dev_set_drvdata(&dev->dev, NULL); 732 731 return 0; 733 732 } 734 733
+2 -4
drivers/tty/serial/sunhv.c
··· 577 577 if (err) 578 578 goto out_remove_port; 579 579 580 - dev_set_drvdata(&op->dev, port); 580 + platform_set_drvdata(op, port); 581 581 582 582 return 0; 583 583 ··· 601 601 602 602 static int hv_remove(struct platform_device *dev) 603 603 { 604 - struct uart_port *port = dev_get_drvdata(&dev->dev); 604 + struct uart_port *port = platform_get_drvdata(dev); 605 605 606 606 free_irq(port->irq, port); 607 607 ··· 611 611 612 612 kfree(port); 613 613 sunhv_port = NULL; 614 - 615 - dev_set_drvdata(&dev->dev, NULL); 616 614 617 615 return 0; 618 616 }
+2 -4
drivers/tty/serial/sunsab.c
··· 1037 1037 if (err) 1038 1038 goto out3; 1039 1039 1040 - dev_set_drvdata(&op->dev, &up[0]); 1040 + platform_set_drvdata(op, &up[0]); 1041 1041 1042 1042 inst++; 1043 1043 ··· 1059 1059 1060 1060 static int sab_remove(struct platform_device *op) 1061 1061 { 1062 - struct uart_sunsab_port *up = dev_get_drvdata(&op->dev); 1062 + struct uart_sunsab_port *up = platform_get_drvdata(op); 1063 1063 1064 1064 uart_remove_one_port(&sunsab_reg, &up[1].port); 1065 1065 uart_remove_one_port(&sunsab_reg, &up[0].port); ··· 1069 1069 of_iounmap(&op->resource[0], 1070 1070 up[0].port.membase, 1071 1071 sizeof(union sab82532_async_regs)); 1072 - 1073 - dev_set_drvdata(&op->dev, NULL); 1074 1072 1075 1073 return 0; 1076 1074 }
+3 -5
drivers/tty/serial/sunsu.c
··· 1454 1454 kfree(up); 1455 1455 return err; 1456 1456 } 1457 - dev_set_drvdata(&op->dev, up); 1457 + platform_set_drvdata(op, up); 1458 1458 1459 1459 nr_inst++; 1460 1460 ··· 1483 1483 if (err) 1484 1484 goto out_unmap; 1485 1485 1486 - dev_set_drvdata(&op->dev, up); 1486 + platform_set_drvdata(op, up); 1487 1487 1488 1488 nr_inst++; 1489 1489 ··· 1496 1496 1497 1497 static int su_remove(struct platform_device *op) 1498 1498 { 1499 - struct uart_sunsu_port *up = dev_get_drvdata(&op->dev); 1499 + struct uart_sunsu_port *up = platform_get_drvdata(op); 1500 1500 bool kbdms = false; 1501 1501 1502 1502 if (up->su_type == SU_PORT_MS || ··· 1515 1515 1516 1516 if (kbdms) 1517 1517 kfree(up); 1518 - 1519 - dev_set_drvdata(&op->dev, NULL); 1520 1518 1521 1519 return 0; 1522 1520 }
+2 -4
drivers/tty/serial/sunzilog.c
··· 1495 1495 kbm_inst++; 1496 1496 } 1497 1497 1498 - dev_set_drvdata(&op->dev, &up[0]); 1498 + platform_set_drvdata(op, &up[0]); 1499 1499 1500 1500 return 0; 1501 1501 } ··· 1512 1512 1513 1513 static int zs_remove(struct platform_device *op) 1514 1514 { 1515 - struct uart_sunzilog_port *up = dev_get_drvdata(&op->dev); 1515 + struct uart_sunzilog_port *up = platform_get_drvdata(op); 1516 1516 struct zilog_layout __iomem *regs; 1517 1517 1518 1518 zs_remove_one(&up[0]); ··· 1520 1520 1521 1521 regs = sunzilog_chip_regs[up[0].port.line / 2]; 1522 1522 of_iounmap(&op->resource[0], regs, sizeof(struct zilog_layout)); 1523 - 1524 - dev_set_drvdata(&op->dev, NULL); 1525 1523 1526 1524 return 0; 1527 1525 }
+2 -3
drivers/tty/serial/ucc_uart.c
··· 1451 1451 goto out_np; 1452 1452 } 1453 1453 1454 - dev_set_drvdata(&ofdev->dev, qe_port); 1454 + platform_set_drvdata(ofdev, qe_port); 1455 1455 1456 1456 dev_info(&ofdev->dev, "UCC%u assigned to /dev/ttyQE%u\n", 1457 1457 qe_port->ucc_num + 1, qe_port->port.line); ··· 1471 1471 1472 1472 static int ucc_uart_remove(struct platform_device *ofdev) 1473 1473 { 1474 - struct uart_qe_port *qe_port = dev_get_drvdata(&ofdev->dev); 1474 + struct uart_qe_port *qe_port = platform_get_drvdata(ofdev); 1475 1475 1476 1476 dev_info(&ofdev->dev, "removing /dev/ttyQE%u\n", qe_port->port.line); 1477 1477 1478 1478 uart_remove_one_port(&ucc_uart_driver, &qe_port->port); 1479 1479 1480 - dev_set_drvdata(&ofdev->dev, NULL); 1481 1480 kfree(qe_port); 1482 1481 1483 1482 return 0;
+2 -4
drivers/tty/serial/xilinx_uartps.c
··· 974 974 port->dev = &pdev->dev; 975 975 port->uartclk = clk_get_rate(clk); 976 976 port->private_data = clk; 977 - dev_set_drvdata(&pdev->dev, port); 977 + platform_set_drvdata(pdev, port); 978 978 rc = uart_add_one_port(&xuartps_uart_driver, port); 979 979 if (rc) { 980 980 dev_err(&pdev->dev, 981 981 "uart_add_one_port() failed; err=%i\n", rc); 982 - dev_set_drvdata(&pdev->dev, NULL); 983 982 return rc; 984 983 } 985 984 return 0; ··· 993 994 **/ 994 995 static int xuartps_remove(struct platform_device *pdev) 995 996 { 996 - struct uart_port *port = dev_get_drvdata(&pdev->dev); 997 + struct uart_port *port = platform_get_drvdata(pdev); 997 998 struct clk *clk = port->private_data; 998 999 int rc; 999 1000 1000 1001 /* Remove the xuartps port from the serial core */ 1001 1002 rc = uart_remove_one_port(&xuartps_uart_driver, port); 1002 - dev_set_drvdata(&pdev->dev, NULL); 1003 1003 port->mapbase = 0; 1004 1004 clk_disable_unprepare(clk); 1005 1005 return rc;