serial: use platform_{get,set}_drvdata()
authorJingoo Han <jg1.han@samsung.com>
Thu, 23 May 2013 10:39:36 +0000 (19:39 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Jun 2013 17:21:33 +0000 (10:21 -0700)
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>
drivers/tty/serial/cpm_uart/cpm_uart_core.c
drivers/tty/serial/mpc52xx_uart.c
drivers/tty/serial/of_serial.c
drivers/tty/serial/sc26xx.c
drivers/tty/serial/sunhv.c
drivers/tty/serial/sunsab.c
drivers/tty/serial/sunsu.c
drivers/tty/serial/sunzilog.c
drivers/tty/serial/ucc_uart.c
drivers/tty/serial/xilinx_uartps.c

index 97f4e1858649f42d4bc126431927325962f5bae1..f7672cae53212103c9283b2ff595d83a7f63ff17 100644 (file)
@@ -1384,7 +1384,7 @@ static int cpm_uart_probe(struct platform_device *ofdev)
        if (index >= UART_NR)
                return -ENODEV;
 
-       dev_set_drvdata(&ofdev->dev, pinfo);
+       platform_set_drvdata(ofdev, pinfo);
 
        /* initialize the device pointer for the port */
        pinfo->port.dev = &ofdev->dev;
@@ -1398,7 +1398,7 @@ static int cpm_uart_probe(struct platform_device *ofdev)
 
 static int cpm_uart_remove(struct platform_device *ofdev)
 {
-       struct uart_cpm_port *pinfo = dev_get_drvdata(&ofdev->dev);
+       struct uart_cpm_port *pinfo = platform_get_drvdata(ofdev);
        return uart_remove_one_port(&cpm_reg, &pinfo->port);
 }
 
index 510fa986cf9e2eb332512c0a36c77b65b095b0b6..2c03904359b98ba357e5a598c62509fb26ec7ecb 100644 (file)
@@ -1362,15 +1362,14 @@ static int mpc52xx_uart_of_probe(struct platform_device *op)
        if (ret)
                return ret;
 
-       dev_set_drvdata(&op->dev, (void *)port);
+       platform_set_drvdata(op, (void *)port);
        return 0;
 }
 
 static int
 mpc52xx_uart_of_remove(struct platform_device *op)
 {
-       struct uart_port *port = dev_get_drvdata(&op->dev);
-       dev_set_drvdata(&op->dev, NULL);
+       struct uart_port *port = platform_get_drvdata(op);
 
        if (port)
                uart_remove_one_port(&mpc52xx_uart_driver, port);
@@ -1382,7 +1381,7 @@ mpc52xx_uart_of_remove(struct platform_device *op)
 static int
 mpc52xx_uart_of_suspend(struct platform_device *op, pm_message_t state)
 {
-       struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev);
+       struct uart_port *port = (struct uart_port *) platform_get_drvdata(op);
 
        if (port)
                uart_suspend_port(&mpc52xx_uart_driver, port);
@@ -1393,7 +1392,7 @@ mpc52xx_uart_of_suspend(struct platform_device *op, pm_message_t state)
 static int
 mpc52xx_uart_of_resume(struct platform_device *op)
 {
-       struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev);
+       struct uart_port *port = (struct uart_port *) platform_get_drvdata(op);
 
        if (port)
                uart_resume_port(&mpc52xx_uart_driver, port);
index 39c7ea4cb14fb9e95fbc920d86010f39db2aa691..2caf9c6f61499f15738a29c6659d91f1c7fad826 100644 (file)
@@ -204,7 +204,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
 
        info->type = port_type;
        info->line = ret;
-       dev_set_drvdata(&ofdev->dev, info);
+       platform_set_drvdata(ofdev, info);
        return 0;
 out:
        kfree(info);
@@ -217,7 +217,7 @@ out:
  */
 static int of_platform_serial_remove(struct platform_device *ofdev)
 {
-       struct of_serial_info *info = dev_get_drvdata(&ofdev->dev);
+       struct of_serial_info *info = platform_get_drvdata(ofdev);
        switch (info->type) {
 #ifdef CONFIG_SERIAL_8250
        case PORT_8250 ... PORT_MAX_8250:
index c9735680762d87fc3362dd62e1eab528e1bcb027..4b1434d53e9d6ddbe9c478f0631379c527abf31a 100644 (file)
@@ -696,7 +696,7 @@ static int sc26xx_probe(struct platform_device *dev)
        if (err)
                goto out_remove_ports;
 
-       dev_set_drvdata(&dev->dev, up);
+       platform_set_drvdata(dev, up);
        return 0;
 
 out_remove_ports:
@@ -716,7 +716,7 @@ out_free_port:
 
 static int __exit sc26xx_driver_remove(struct platform_device *dev)
 {
-       struct uart_sc26xx_port *up = dev_get_drvdata(&dev->dev);
+       struct uart_sc26xx_port *up = platform_get_drvdata(dev);
 
        free_irq(up->port[0].irq, up);
 
@@ -728,7 +728,6 @@ static int __exit sc26xx_driver_remove(struct platform_device *dev)
        kfree(up);
        sc26xx_port = NULL;
 
-       dev_set_drvdata(&dev->dev, NULL);
        return 0;
 }
 
index ba60708053e0f740920d89b6fe76dd68666d8bd1..cf86e729532b9fc11b768863c94bfb9fe1da7109 100644 (file)
@@ -577,7 +577,7 @@ static int hv_probe(struct platform_device *op)
        if (err)
                goto out_remove_port;
 
-       dev_set_drvdata(&op->dev, port);
+       platform_set_drvdata(op, port);
 
        return 0;
 
@@ -601,7 +601,7 @@ out_free_port:
 
 static int hv_remove(struct platform_device *dev)
 {
-       struct uart_port *port = dev_get_drvdata(&dev->dev);
+       struct uart_port *port = platform_get_drvdata(dev);
 
        free_irq(port->irq, port);
 
@@ -612,8 +612,6 @@ static int hv_remove(struct platform_device *dev)
        kfree(port);
        sunhv_port = NULL;
 
-       dev_set_drvdata(&dev->dev, NULL);
-
        return 0;
 }
 
index a422c8b55a47b427b34ec09a3bda5b563ea6d8a0..5d6136b2a04a8c488e609696952e5517d5cc412a 100644 (file)
@@ -1037,7 +1037,7 @@ static int sab_probe(struct platform_device *op)
        if (err)
                goto out3;
 
-       dev_set_drvdata(&op->dev, &up[0]);
+       platform_set_drvdata(op, &up[0]);
 
        inst++;
 
@@ -1059,7 +1059,7 @@ out:
 
 static int sab_remove(struct platform_device *op)
 {
-       struct uart_sunsab_port *up = dev_get_drvdata(&op->dev);
+       struct uart_sunsab_port *up = platform_get_drvdata(op);
 
        uart_remove_one_port(&sunsab_reg, &up[1].port);
        uart_remove_one_port(&sunsab_reg, &up[0].port);
@@ -1070,8 +1070,6 @@ static int sab_remove(struct platform_device *op)
                   up[0].port.membase,
                   sizeof(union sab82532_async_regs));
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index 0d8465728473304ed26a66877536c7cf002f22a4..699cc1b5f6aa2c5c39cd89a2bb8ea5b192140015 100644 (file)
@@ -1454,7 +1454,7 @@ static int su_probe(struct platform_device *op)
                        kfree(up);
                        return err;
                }
-               dev_set_drvdata(&op->dev, up);
+               platform_set_drvdata(op, up);
 
                nr_inst++;
 
@@ -1483,7 +1483,7 @@ static int su_probe(struct platform_device *op)
        if (err)
                goto out_unmap;
 
-       dev_set_drvdata(&op->dev, up);
+       platform_set_drvdata(op, up);
 
        nr_inst++;
 
@@ -1496,7 +1496,7 @@ out_unmap:
 
 static int su_remove(struct platform_device *op)
 {
-       struct uart_sunsu_port *up = dev_get_drvdata(&op->dev);
+       struct uart_sunsu_port *up = platform_get_drvdata(op);
        bool kbdms = false;
 
        if (up->su_type == SU_PORT_MS ||
@@ -1516,8 +1516,6 @@ static int su_remove(struct platform_device *op)
        if (kbdms)
                kfree(up);
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index 813ef8eb8effaa5b6b2d9116dc3c2a4c43cba4f5..135a1520353260e8f6665538ccce381e3036c562 100644 (file)
@@ -1495,7 +1495,7 @@ static int zs_probe(struct platform_device *op)
                kbm_inst++;
        }
 
-       dev_set_drvdata(&op->dev, &up[0]);
+       platform_set_drvdata(op, &up[0]);
 
        return 0;
 }
@@ -1512,7 +1512,7 @@ static void zs_remove_one(struct uart_sunzilog_port *up)
 
 static int zs_remove(struct platform_device *op)
 {
-       struct uart_sunzilog_port *up = dev_get_drvdata(&op->dev);
+       struct uart_sunzilog_port *up = platform_get_drvdata(op);
        struct zilog_layout __iomem *regs;
 
        zs_remove_one(&up[0]);
@@ -1521,8 +1521,6 @@ static int zs_remove(struct platform_device *op)
        regs = sunzilog_chip_regs[up[0].port.line / 2];
        of_iounmap(&op->resource[0], regs, sizeof(struct zilog_layout));
 
-       dev_set_drvdata(&op->dev, NULL);
-
        return 0;
 }
 
index 7355303dad9968082da43b8b84fc3f745dda11a6..c8ab8e45e1b973213fb4e2d8e1f720c666906847 100644 (file)
@@ -1451,7 +1451,7 @@ static int ucc_uart_probe(struct platform_device *ofdev)
                goto out_np;
        }
 
-       dev_set_drvdata(&ofdev->dev, qe_port);
+       platform_set_drvdata(ofdev, qe_port);
 
        dev_info(&ofdev->dev, "UCC%u assigned to /dev/ttyQE%u\n",
                qe_port->ucc_num + 1, qe_port->port.line);
@@ -1471,13 +1471,12 @@ out_free:
 
 static int ucc_uart_remove(struct platform_device *ofdev)
 {
-       struct uart_qe_port *qe_port = dev_get_drvdata(&ofdev->dev);
+       struct uart_qe_port *qe_port = platform_get_drvdata(ofdev);
 
        dev_info(&ofdev->dev, "removing /dev/ttyQE%u\n", qe_port->port.line);
 
        uart_remove_one_port(&ucc_uart_driver, &qe_port->port);
 
-       dev_set_drvdata(&ofdev->dev, NULL);
        kfree(qe_port);
 
        return 0;
index b5f655d10098e9162dce996ddf248786913012c8..6c9174530422953a2b1294ab0c1cf55d3e128882 100644 (file)
@@ -974,12 +974,11 @@ static int xuartps_probe(struct platform_device *pdev)
                port->dev = &pdev->dev;
                port->uartclk = clk_get_rate(clk);
                port->private_data = clk;
-               dev_set_drvdata(&pdev->dev, port);
+               platform_set_drvdata(pdev, port);
                rc = uart_add_one_port(&xuartps_uart_driver, port);
                if (rc) {
                        dev_err(&pdev->dev,
                                "uart_add_one_port() failed; err=%i\n", rc);
-                       dev_set_drvdata(&pdev->dev, NULL);
                        return rc;
                }
                return 0;
@@ -994,13 +993,12 @@ static int xuartps_probe(struct platform_device *pdev)
  **/
 static int xuartps_remove(struct platform_device *pdev)
 {
-       struct uart_port *port = dev_get_drvdata(&pdev->dev);
+       struct uart_port *port = platform_get_drvdata(pdev);
        struct clk *clk = port->private_data;
        int rc;
 
        /* Remove the xuartps port from the serial core */
        rc = uart_remove_one_port(&xuartps_uart_driver, port);
-       dev_set_drvdata(&pdev->dev, NULL);
        port->mapbase = 0;
        clk_disable_unprepare(clk);
        return rc;
This page took 0.044201 seconds and 5 git commands to generate.