From b458925ed5797a20f22cdf005625e25106cf7124 Mon Sep 17 00:00:00 2001 From: zhong jiang Date: Sun, 16 Sep 2018 21:45:02 +0800 Subject: net: dsa: remove redundant null pointer check before put_device put_device has taken the null pinter check into account. So it is safe to remove the duplicated check before put_device. Signed-off-by: zhong jiang Signed-off-by: David S. Miller --- net/dsa/legacy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'net/dsa/legacy.c') diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c index 42a7b85b84e1..8aa92b09db76 100644 --- a/net/dsa/legacy.c +++ b/net/dsa/legacy.c @@ -392,8 +392,7 @@ static void dsa_of_free_platform_data(struct dsa_platform_data *pd) } /* Drop our reference to the MDIO bus device */ - if (pd->chip[i].host_dev) - put_device(pd->chip[i].host_dev); + put_device(pd->chip[i].host_dev); } kfree(pd->chip); } -- cgit v1.2.3 From 2af1ccd58107d65f87b747c90a965b2ba97b4feb Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Sun, 21 Oct 2018 22:01:05 +0200 Subject: net: dsa: legacy: simplify getting .driver_data We should get 'driver_data' from 'struct device' directly. Going via platform_device is an unneeded step back and forth. Signed-off-by: Wolfram Sang Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller --- net/dsa/legacy.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'net/dsa/legacy.c') diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c index 8aa92b09db76..cb42939db776 100644 --- a/net/dsa/legacy.c +++ b/net/dsa/legacy.c @@ -686,8 +686,7 @@ static void dsa_shutdown(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int dsa_suspend(struct device *d) { - struct platform_device *pdev = to_platform_device(d); - struct dsa_switch_tree *dst = platform_get_drvdata(pdev); + struct dsa_switch_tree *dst = dev_get_drvdata(d); int i, ret = 0; for (i = 0; i < dst->pd->nr_chips; i++) { @@ -702,8 +701,7 @@ static int dsa_suspend(struct device *d) static int dsa_resume(struct device *d) { - struct platform_device *pdev = to_platform_device(d); - struct dsa_switch_tree *dst = platform_get_drvdata(pdev); + struct dsa_switch_tree *dst = dev_get_drvdata(d); int i, ret = 0; for (i = 0; i < dst->pd->nr_chips; i++) { -- cgit v1.2.3