Commit 00e4bbc8 authored by Jingoo Han's avatar Jingoo Han Committed by Marc Kleine-Budde

net: can: 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: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 4c4726fa
...@@ -580,7 +580,7 @@ static int bfin_can_probe(struct platform_device *pdev) ...@@ -580,7 +580,7 @@ static int bfin_can_probe(struct platform_device *pdev)
priv->pin_list = pdata; priv->pin_list = pdata;
priv->can.clock.freq = get_sclk(); priv->can.clock.freq = get_sclk();
dev_set_drvdata(&pdev->dev, dev); platform_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
dev->flags |= IFF_ECHO; /* we support local echo */ dev->flags |= IFF_ECHO; /* we support local echo */
...@@ -613,7 +613,7 @@ static int bfin_can_probe(struct platform_device *pdev) ...@@ -613,7 +613,7 @@ static int bfin_can_probe(struct platform_device *pdev)
static int bfin_can_remove(struct platform_device *pdev) static int bfin_can_remove(struct platform_device *pdev)
{ {
struct net_device *dev = dev_get_drvdata(&pdev->dev); struct net_device *dev = platform_get_drvdata(pdev);
struct bfin_can_priv *priv = netdev_priv(dev); struct bfin_can_priv *priv = netdev_priv(dev);
struct resource *res; struct resource *res;
...@@ -621,8 +621,6 @@ static int bfin_can_remove(struct platform_device *pdev) ...@@ -621,8 +621,6 @@ static int bfin_can_remove(struct platform_device *pdev)
unregister_candev(dev); unregister_candev(dev);
dev_set_drvdata(&pdev->dev, NULL);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res)); release_mem_region(res->start, resource_size(res));
...@@ -635,7 +633,7 @@ static int bfin_can_remove(struct platform_device *pdev) ...@@ -635,7 +633,7 @@ static int bfin_can_remove(struct platform_device *pdev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg) static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg)
{ {
struct net_device *dev = dev_get_drvdata(&pdev->dev); struct net_device *dev = platform_get_drvdata(pdev);
struct bfin_can_priv *priv = netdev_priv(dev); struct bfin_can_priv *priv = netdev_priv(dev);
struct bfin_can_regs __iomem *reg = priv->membase; struct bfin_can_regs __iomem *reg = priv->membase;
int timeout = BFIN_CAN_TIMEOUT; int timeout = BFIN_CAN_TIMEOUT;
...@@ -658,7 +656,7 @@ static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg) ...@@ -658,7 +656,7 @@ static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg)
static int bfin_can_resume(struct platform_device *pdev) static int bfin_can_resume(struct platform_device *pdev)
{ {
struct net_device *dev = dev_get_drvdata(&pdev->dev); struct net_device *dev = platform_get_drvdata(pdev);
struct bfin_can_priv *priv = netdev_priv(dev); struct bfin_can_priv *priv = netdev_priv(dev);
struct bfin_can_regs __iomem *reg = priv->membase; struct bfin_can_regs __iomem *reg = priv->membase;
......
...@@ -265,7 +265,7 @@ static int cc770_isa_probe(struct platform_device *pdev) ...@@ -265,7 +265,7 @@ static int cc770_isa_probe(struct platform_device *pdev)
else else
priv->clkout = COR_DEFAULT; priv->clkout = COR_DEFAULT;
dev_set_drvdata(&pdev->dev, dev); platform_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
err = register_cc770dev(dev); err = register_cc770dev(dev);
...@@ -293,12 +293,11 @@ static int cc770_isa_probe(struct platform_device *pdev) ...@@ -293,12 +293,11 @@ static int cc770_isa_probe(struct platform_device *pdev)
static int cc770_isa_remove(struct platform_device *pdev) static int cc770_isa_remove(struct platform_device *pdev)
{ {
struct net_device *dev = dev_get_drvdata(&pdev->dev); struct net_device *dev = platform_get_drvdata(pdev);
struct cc770_priv *priv = netdev_priv(dev); struct cc770_priv *priv = netdev_priv(dev);
int idx = pdev->id; int idx = pdev->id;
unregister_cc770dev(dev); unregister_cc770dev(dev);
dev_set_drvdata(&pdev->dev, NULL);
if (mem[idx]) { if (mem[idx]) {
iounmap(priv->reg_base); iounmap(priv->reg_base);
......
...@@ -216,7 +216,7 @@ static int cc770_platform_probe(struct platform_device *pdev) ...@@ -216,7 +216,7 @@ static int cc770_platform_probe(struct platform_device *pdev)
priv->reg_base, dev->irq, priv->can.clock.freq, priv->reg_base, dev->irq, priv->can.clock.freq,
priv->cpu_interface, priv->bus_config, priv->clkout); priv->cpu_interface, priv->bus_config, priv->clkout);
dev_set_drvdata(&pdev->dev, dev); platform_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
err = register_cc770dev(dev); err = register_cc770dev(dev);
...@@ -240,7 +240,7 @@ static int cc770_platform_probe(struct platform_device *pdev) ...@@ -240,7 +240,7 @@ static int cc770_platform_probe(struct platform_device *pdev)
static int cc770_platform_remove(struct platform_device *pdev) static int cc770_platform_remove(struct platform_device *pdev)
{ {
struct net_device *dev = dev_get_drvdata(&pdev->dev); struct net_device *dev = platform_get_drvdata(pdev);
struct cc770_priv *priv = netdev_priv(dev); struct cc770_priv *priv = netdev_priv(dev);
struct resource *mem; struct resource *mem;
......
...@@ -1646,7 +1646,7 @@ static int grcan_setup_netdev(struct platform_device *ofdev, ...@@ -1646,7 +1646,7 @@ static int grcan_setup_netdev(struct platform_device *ofdev,
if (err) if (err)
goto exit_free_candev; goto exit_free_candev;
dev_set_drvdata(&ofdev->dev, dev); platform_set_drvdata(ofdev, dev);
/* Reset device to allow bit-timing to be set. No need to call /* Reset device to allow bit-timing to be set. No need to call
* grcan_reset at this stage. That is done in grcan_open. * grcan_reset at this stage. That is done in grcan_open.
...@@ -1715,13 +1715,12 @@ static int grcan_probe(struct platform_device *ofdev) ...@@ -1715,13 +1715,12 @@ static int grcan_probe(struct platform_device *ofdev)
static int grcan_remove(struct platform_device *ofdev) static int grcan_remove(struct platform_device *ofdev)
{ {
struct net_device *dev = dev_get_drvdata(&ofdev->dev); struct net_device *dev = platform_get_drvdata(ofdev);
struct grcan_priv *priv = netdev_priv(dev); struct grcan_priv *priv = netdev_priv(dev);
unregister_candev(dev); /* Will in turn call grcan_close */ unregister_candev(dev); /* Will in turn call grcan_close */
irq_dispose_mapping(dev->irq); irq_dispose_mapping(dev->irq);
dev_set_drvdata(&ofdev->dev, NULL);
netif_napi_del(&priv->napi); netif_napi_del(&priv->napi);
free_candev(dev); free_candev(dev);
......
...@@ -302,7 +302,7 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev) ...@@ -302,7 +302,7 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
goto exit_free_mscan; goto exit_free_mscan;
} }
dev_set_drvdata(&ofdev->dev, dev); platform_set_drvdata(ofdev, dev);
dev_info(&ofdev->dev, "MSCAN at 0x%p, irq %d, clock %d Hz\n", dev_info(&ofdev->dev, "MSCAN at 0x%p, irq %d, clock %d Hz\n",
priv->reg_base, dev->irq, priv->can.clock.freq); priv->reg_base, dev->irq, priv->can.clock.freq);
...@@ -321,11 +321,9 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev) ...@@ -321,11 +321,9 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
static int mpc5xxx_can_remove(struct platform_device *ofdev) static int mpc5xxx_can_remove(struct platform_device *ofdev)
{ {
struct net_device *dev = dev_get_drvdata(&ofdev->dev); struct net_device *dev = platform_get_drvdata(ofdev);
struct mscan_priv *priv = netdev_priv(dev); struct mscan_priv *priv = netdev_priv(dev);
dev_set_drvdata(&ofdev->dev, NULL);
unregister_mscandev(dev); unregister_mscandev(dev);
iounmap(priv->reg_base); iounmap(priv->reg_base);
irq_dispose_mapping(dev->irq); irq_dispose_mapping(dev->irq);
...@@ -338,7 +336,7 @@ static int mpc5xxx_can_remove(struct platform_device *ofdev) ...@@ -338,7 +336,7 @@ static int mpc5xxx_can_remove(struct platform_device *ofdev)
static struct mscan_regs saved_regs; static struct mscan_regs saved_regs;
static int mpc5xxx_can_suspend(struct platform_device *ofdev, pm_message_t state) static int mpc5xxx_can_suspend(struct platform_device *ofdev, pm_message_t state)
{ {
struct net_device *dev = dev_get_drvdata(&ofdev->dev); struct net_device *dev = platform_get_drvdata(ofdev);
struct mscan_priv *priv = netdev_priv(dev); struct mscan_priv *priv = netdev_priv(dev);
struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base; struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
...@@ -349,7 +347,7 @@ static int mpc5xxx_can_suspend(struct platform_device *ofdev, pm_message_t state ...@@ -349,7 +347,7 @@ static int mpc5xxx_can_suspend(struct platform_device *ofdev, pm_message_t state
static int mpc5xxx_can_resume(struct platform_device *ofdev) static int mpc5xxx_can_resume(struct platform_device *ofdev)
{ {
struct net_device *dev = dev_get_drvdata(&ofdev->dev); struct net_device *dev = platform_get_drvdata(ofdev);
struct mscan_priv *priv = netdev_priv(dev); struct mscan_priv *priv = netdev_priv(dev);
struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base; struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
......
...@@ -197,7 +197,7 @@ static int sja1000_isa_probe(struct platform_device *pdev) ...@@ -197,7 +197,7 @@ static int sja1000_isa_probe(struct platform_device *pdev)
else else
priv->cdr = CDR_DEFAULT; priv->cdr = CDR_DEFAULT;
dev_set_drvdata(&pdev->dev, dev); platform_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
err = register_sja1000dev(dev); err = register_sja1000dev(dev);
...@@ -225,12 +225,11 @@ static int sja1000_isa_probe(struct platform_device *pdev) ...@@ -225,12 +225,11 @@ static int sja1000_isa_probe(struct platform_device *pdev)
static int sja1000_isa_remove(struct platform_device *pdev) static int sja1000_isa_remove(struct platform_device *pdev)
{ {
struct net_device *dev = dev_get_drvdata(&pdev->dev); struct net_device *dev = platform_get_drvdata(pdev);
struct sja1000_priv *priv = netdev_priv(dev); struct sja1000_priv *priv = netdev_priv(dev);
int idx = pdev->id; int idx = pdev->id;
unregister_sja1000dev(dev); unregister_sja1000dev(dev);
dev_set_drvdata(&pdev->dev, NULL);
if (mem[idx]) { if (mem[idx]) {
iounmap(priv->reg_base); iounmap(priv->reg_base);
......
...@@ -72,13 +72,11 @@ static void sja1000_ofp_write_reg(const struct sja1000_priv *priv, ...@@ -72,13 +72,11 @@ static void sja1000_ofp_write_reg(const struct sja1000_priv *priv,
static int sja1000_ofp_remove(struct platform_device *ofdev) static int sja1000_ofp_remove(struct platform_device *ofdev)
{ {
struct net_device *dev = dev_get_drvdata(&ofdev->dev); struct net_device *dev = platform_get_drvdata(ofdev);
struct sja1000_priv *priv = netdev_priv(dev); struct sja1000_priv *priv = netdev_priv(dev);
struct device_node *np = ofdev->dev.of_node; struct device_node *np = ofdev->dev.of_node;
struct resource res; struct resource res;
dev_set_drvdata(&ofdev->dev, NULL);
unregister_sja1000dev(dev); unregister_sja1000dev(dev);
free_sja1000dev(dev); free_sja1000dev(dev);
iounmap(priv->reg_base); iounmap(priv->reg_base);
...@@ -181,7 +179,7 @@ static int sja1000_ofp_probe(struct platform_device *ofdev) ...@@ -181,7 +179,7 @@ static int sja1000_ofp_probe(struct platform_device *ofdev)
priv->reg_base, dev->irq, priv->can.clock.freq, priv->reg_base, dev->irq, priv->can.clock.freq,
priv->ocr, priv->cdr); priv->ocr, priv->cdr);
dev_set_drvdata(&ofdev->dev, dev); platform_set_drvdata(ofdev, dev);
SET_NETDEV_DEV(dev, &ofdev->dev); SET_NETDEV_DEV(dev, &ofdev->dev);
err = register_sja1000dev(dev); err = register_sja1000dev(dev);
......
...@@ -135,7 +135,7 @@ static int sp_probe(struct platform_device *pdev) ...@@ -135,7 +135,7 @@ static int sp_probe(struct platform_device *pdev)
break; break;
} }
dev_set_drvdata(&pdev->dev, dev); platform_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
err = register_sja1000dev(dev); err = register_sja1000dev(dev);
...@@ -161,12 +161,11 @@ static int sp_probe(struct platform_device *pdev) ...@@ -161,12 +161,11 @@ static int sp_probe(struct platform_device *pdev)
static int sp_remove(struct platform_device *pdev) static int sp_remove(struct platform_device *pdev)
{ {
struct net_device *dev = dev_get_drvdata(&pdev->dev); struct net_device *dev = platform_get_drvdata(pdev);
struct sja1000_priv *priv = netdev_priv(dev); struct sja1000_priv *priv = netdev_priv(dev);
struct resource *res; struct resource *res;
unregister_sja1000dev(dev); unregister_sja1000dev(dev);
dev_set_drvdata(&pdev->dev, NULL);
if (priv->reg_base) if (priv->reg_base)
iounmap(priv->reg_base); iounmap(priv->reg_base);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment