diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-05-22 20:52:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-05-26 00:27:58 -0400 |
commit | 8513fbd880093f00a47e85a552f14ca2de8d84d6 (patch) | |
tree | 6f061e2e9b87983cd91688bff5238c730db79137 /drivers/net/ethernet/ibm | |
parent | 6d0bfe22611602f36617bc7aa2ffa1bbb2f54c67 (diff) |
net: ethernet: 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: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/ibm')
-rw-r--r-- | drivers/net/ethernet/ibm/ehea/ehea_main.c | 4 | ||||
-rw-r--r-- | drivers/net/ethernet/ibm/emac/mal.c | 6 | ||||
-rw-r--r-- | drivers/net/ethernet/ibm/emac/rgmii.c | 18 | ||||
-rw-r--r-- | drivers/net/ethernet/ibm/emac/tah.c | 14 | ||||
-rw-r--r-- | drivers/net/ethernet/ibm/emac/zmii.c | 18 |
5 files changed, 26 insertions, 34 deletions
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c index 90ea0b1673ca..0605e76c7edd 100644 --- a/drivers/net/ethernet/ibm/ehea/ehea_main.c +++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c | |||
@@ -3289,7 +3289,7 @@ static int ehea_probe_adapter(struct platform_device *dev, | |||
3289 | 3289 | ||
3290 | adapter->pd = EHEA_PD_ID; | 3290 | adapter->pd = EHEA_PD_ID; |
3291 | 3291 | ||
3292 | dev_set_drvdata(&dev->dev, adapter); | 3292 | platform_set_drvdata(dev, adapter); |
3293 | 3293 | ||
3294 | 3294 | ||
3295 | /* initialize adapter and ports */ | 3295 | /* initialize adapter and ports */ |
@@ -3360,7 +3360,7 @@ out: | |||
3360 | 3360 | ||
3361 | static int ehea_remove(struct platform_device *dev) | 3361 | static int ehea_remove(struct platform_device *dev) |
3362 | { | 3362 | { |
3363 | struct ehea_adapter *adapter = dev_get_drvdata(&dev->dev); | 3363 | struct ehea_adapter *adapter = platform_get_drvdata(dev); |
3364 | int i; | 3364 | int i; |
3365 | 3365 | ||
3366 | for (i = 0; i < EHEA_MAX_PORTS; i++) | 3366 | for (i = 0; i < EHEA_MAX_PORTS; i++) |
diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm/emac/mal.c index 610ed223d1db..856ea66c9223 100644 --- a/drivers/net/ethernet/ibm/emac/mal.c +++ b/drivers/net/ethernet/ibm/emac/mal.c | |||
@@ -696,7 +696,7 @@ static int mal_probe(struct platform_device *ofdev) | |||
696 | 696 | ||
697 | /* Advertise this instance to the rest of the world */ | 697 | /* Advertise this instance to the rest of the world */ |
698 | wmb(); | 698 | wmb(); |
699 | dev_set_drvdata(&ofdev->dev, mal); | 699 | platform_set_drvdata(ofdev, mal); |
700 | 700 | ||
701 | mal_dbg_register(mal); | 701 | mal_dbg_register(mal); |
702 | 702 | ||
@@ -722,7 +722,7 @@ static int mal_probe(struct platform_device *ofdev) | |||
722 | 722 | ||
723 | static int mal_remove(struct platform_device *ofdev) | 723 | static int mal_remove(struct platform_device *ofdev) |
724 | { | 724 | { |
725 | struct mal_instance *mal = dev_get_drvdata(&ofdev->dev); | 725 | struct mal_instance *mal = platform_get_drvdata(ofdev); |
726 | 726 | ||
727 | MAL_DBG(mal, "remove" NL); | 727 | MAL_DBG(mal, "remove" NL); |
728 | 728 | ||
@@ -735,8 +735,6 @@ static int mal_remove(struct platform_device *ofdev) | |||
735 | "mal%d: commac list is not empty on remove!\n", | 735 | "mal%d: commac list is not empty on remove!\n", |
736 | mal->index); | 736 | mal->index); |
737 | 737 | ||
738 | dev_set_drvdata(&ofdev->dev, NULL); | ||
739 | |||
740 | free_irq(mal->serr_irq, mal); | 738 | free_irq(mal->serr_irq, mal); |
741 | free_irq(mal->txde_irq, mal); | 739 | free_irq(mal->txde_irq, mal); |
742 | free_irq(mal->txeob_irq, mal); | 740 | free_irq(mal->txeob_irq, mal); |
diff --git a/drivers/net/ethernet/ibm/emac/rgmii.c b/drivers/net/ethernet/ibm/emac/rgmii.c index 39251765b55d..c47e23d6eeaa 100644 --- a/drivers/net/ethernet/ibm/emac/rgmii.c +++ b/drivers/net/ethernet/ibm/emac/rgmii.c | |||
@@ -95,7 +95,7 @@ static inline u32 rgmii_mode_mask(int mode, int input) | |||
95 | 95 | ||
96 | int rgmii_attach(struct platform_device *ofdev, int input, int mode) | 96 | int rgmii_attach(struct platform_device *ofdev, int input, int mode) |
97 | { | 97 | { |
98 | struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 98 | struct rgmii_instance *dev = platform_get_drvdata(ofdev); |
99 | struct rgmii_regs __iomem *p = dev->base; | 99 | struct rgmii_regs __iomem *p = dev->base; |
100 | 100 | ||
101 | RGMII_DBG(dev, "attach(%d)" NL, input); | 101 | RGMII_DBG(dev, "attach(%d)" NL, input); |
@@ -124,7 +124,7 @@ int rgmii_attach(struct platform_device *ofdev, int input, int mode) | |||
124 | 124 | ||
125 | void rgmii_set_speed(struct platform_device *ofdev, int input, int speed) | 125 | void rgmii_set_speed(struct platform_device *ofdev, int input, int speed) |
126 | { | 126 | { |
127 | struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 127 | struct rgmii_instance *dev = platform_get_drvdata(ofdev); |
128 | struct rgmii_regs __iomem *p = dev->base; | 128 | struct rgmii_regs __iomem *p = dev->base; |
129 | u32 ssr; | 129 | u32 ssr; |
130 | 130 | ||
@@ -146,7 +146,7 @@ void rgmii_set_speed(struct platform_device *ofdev, int input, int speed) | |||
146 | 146 | ||
147 | void rgmii_get_mdio(struct platform_device *ofdev, int input) | 147 | void rgmii_get_mdio(struct platform_device *ofdev, int input) |
148 | { | 148 | { |
149 | struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 149 | struct rgmii_instance *dev = platform_get_drvdata(ofdev); |
150 | struct rgmii_regs __iomem *p = dev->base; | 150 | struct rgmii_regs __iomem *p = dev->base; |
151 | u32 fer; | 151 | u32 fer; |
152 | 152 | ||
@@ -167,7 +167,7 @@ void rgmii_get_mdio(struct platform_device *ofdev, int input) | |||
167 | 167 | ||
168 | void rgmii_put_mdio(struct platform_device *ofdev, int input) | 168 | void rgmii_put_mdio(struct platform_device *ofdev, int input) |
169 | { | 169 | { |
170 | struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 170 | struct rgmii_instance *dev = platform_get_drvdata(ofdev); |
171 | struct rgmii_regs __iomem *p = dev->base; | 171 | struct rgmii_regs __iomem *p = dev->base; |
172 | u32 fer; | 172 | u32 fer; |
173 | 173 | ||
@@ -188,7 +188,7 @@ void rgmii_put_mdio(struct platform_device *ofdev, int input) | |||
188 | 188 | ||
189 | void rgmii_detach(struct platform_device *ofdev, int input) | 189 | void rgmii_detach(struct platform_device *ofdev, int input) |
190 | { | 190 | { |
191 | struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 191 | struct rgmii_instance *dev = platform_get_drvdata(ofdev); |
192 | struct rgmii_regs __iomem *p; | 192 | struct rgmii_regs __iomem *p; |
193 | 193 | ||
194 | BUG_ON(!dev || dev->users == 0); | 194 | BUG_ON(!dev || dev->users == 0); |
@@ -214,7 +214,7 @@ int rgmii_get_regs_len(struct platform_device *ofdev) | |||
214 | 214 | ||
215 | void *rgmii_dump_regs(struct platform_device *ofdev, void *buf) | 215 | void *rgmii_dump_regs(struct platform_device *ofdev, void *buf) |
216 | { | 216 | { |
217 | struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 217 | struct rgmii_instance *dev = platform_get_drvdata(ofdev); |
218 | struct emac_ethtool_regs_subhdr *hdr = buf; | 218 | struct emac_ethtool_regs_subhdr *hdr = buf; |
219 | struct rgmii_regs *regs = (struct rgmii_regs *)(hdr + 1); | 219 | struct rgmii_regs *regs = (struct rgmii_regs *)(hdr + 1); |
220 | 220 | ||
@@ -279,7 +279,7 @@ static int rgmii_probe(struct platform_device *ofdev) | |||
279 | (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out"); | 279 | (dev->flags & EMAC_RGMII_FLAG_HAS_MDIO) ? "" : "out"); |
280 | 280 | ||
281 | wmb(); | 281 | wmb(); |
282 | dev_set_drvdata(&ofdev->dev, dev); | 282 | platform_set_drvdata(ofdev, dev); |
283 | 283 | ||
284 | return 0; | 284 | return 0; |
285 | 285 | ||
@@ -291,9 +291,7 @@ static int rgmii_probe(struct platform_device *ofdev) | |||
291 | 291 | ||
292 | static int rgmii_remove(struct platform_device *ofdev) | 292 | static int rgmii_remove(struct platform_device *ofdev) |
293 | { | 293 | { |
294 | struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 294 | struct rgmii_instance *dev = platform_get_drvdata(ofdev); |
295 | |||
296 | dev_set_drvdata(&ofdev->dev, NULL); | ||
297 | 295 | ||
298 | WARN_ON(dev->users != 0); | 296 | WARN_ON(dev->users != 0); |
299 | 297 | ||
diff --git a/drivers/net/ethernet/ibm/emac/tah.c b/drivers/net/ethernet/ibm/emac/tah.c index 795f1393e2b6..c231a4a32c4d 100644 --- a/drivers/net/ethernet/ibm/emac/tah.c +++ b/drivers/net/ethernet/ibm/emac/tah.c | |||
@@ -25,7 +25,7 @@ | |||
25 | 25 | ||
26 | int tah_attach(struct platform_device *ofdev, int channel) | 26 | int tah_attach(struct platform_device *ofdev, int channel) |
27 | { | 27 | { |
28 | struct tah_instance *dev = dev_get_drvdata(&ofdev->dev); | 28 | struct tah_instance *dev = platform_get_drvdata(ofdev); |
29 | 29 | ||
30 | mutex_lock(&dev->lock); | 30 | mutex_lock(&dev->lock); |
31 | /* Reset has been done at probe() time... nothing else to do for now */ | 31 | /* Reset has been done at probe() time... nothing else to do for now */ |
@@ -37,7 +37,7 @@ int tah_attach(struct platform_device *ofdev, int channel) | |||
37 | 37 | ||
38 | void tah_detach(struct platform_device *ofdev, int channel) | 38 | void tah_detach(struct platform_device *ofdev, int channel) |
39 | { | 39 | { |
40 | struct tah_instance *dev = dev_get_drvdata(&ofdev->dev); | 40 | struct tah_instance *dev = platform_get_drvdata(ofdev); |
41 | 41 | ||
42 | mutex_lock(&dev->lock); | 42 | mutex_lock(&dev->lock); |
43 | --dev->users; | 43 | --dev->users; |
@@ -46,7 +46,7 @@ void tah_detach(struct platform_device *ofdev, int channel) | |||
46 | 46 | ||
47 | void tah_reset(struct platform_device *ofdev) | 47 | void tah_reset(struct platform_device *ofdev) |
48 | { | 48 | { |
49 | struct tah_instance *dev = dev_get_drvdata(&ofdev->dev); | 49 | struct tah_instance *dev = platform_get_drvdata(ofdev); |
50 | struct tah_regs __iomem *p = dev->base; | 50 | struct tah_regs __iomem *p = dev->base; |
51 | int n; | 51 | int n; |
52 | 52 | ||
@@ -74,7 +74,7 @@ int tah_get_regs_len(struct platform_device *ofdev) | |||
74 | 74 | ||
75 | void *tah_dump_regs(struct platform_device *ofdev, void *buf) | 75 | void *tah_dump_regs(struct platform_device *ofdev, void *buf) |
76 | { | 76 | { |
77 | struct tah_instance *dev = dev_get_drvdata(&ofdev->dev); | 77 | struct tah_instance *dev = platform_get_drvdata(ofdev); |
78 | struct emac_ethtool_regs_subhdr *hdr = buf; | 78 | struct emac_ethtool_regs_subhdr *hdr = buf; |
79 | struct tah_regs *regs = (struct tah_regs *)(hdr + 1); | 79 | struct tah_regs *regs = (struct tah_regs *)(hdr + 1); |
80 | 80 | ||
@@ -118,7 +118,7 @@ static int tah_probe(struct platform_device *ofdev) | |||
118 | goto err_free; | 118 | goto err_free; |
119 | } | 119 | } |
120 | 120 | ||
121 | dev_set_drvdata(&ofdev->dev, dev); | 121 | platform_set_drvdata(ofdev, dev); |
122 | 122 | ||
123 | /* Initialize TAH and enable IPv4 checksum verification, no TSO yet */ | 123 | /* Initialize TAH and enable IPv4 checksum verification, no TSO yet */ |
124 | tah_reset(ofdev); | 124 | tah_reset(ofdev); |
@@ -137,9 +137,7 @@ static int tah_probe(struct platform_device *ofdev) | |||
137 | 137 | ||
138 | static int tah_remove(struct platform_device *ofdev) | 138 | static int tah_remove(struct platform_device *ofdev) |
139 | { | 139 | { |
140 | struct tah_instance *dev = dev_get_drvdata(&ofdev->dev); | 140 | struct tah_instance *dev = platform_get_drvdata(ofdev); |
141 | |||
142 | dev_set_drvdata(&ofdev->dev, NULL); | ||
143 | 141 | ||
144 | WARN_ON(dev->users != 0); | 142 | WARN_ON(dev->users != 0); |
145 | 143 | ||
diff --git a/drivers/net/ethernet/ibm/emac/zmii.c b/drivers/net/ethernet/ibm/emac/zmii.c index f91202f42125..4cdf286f7ee3 100644 --- a/drivers/net/ethernet/ibm/emac/zmii.c +++ b/drivers/net/ethernet/ibm/emac/zmii.c | |||
@@ -84,7 +84,7 @@ static inline u32 zmii_mode_mask(int mode, int input) | |||
84 | 84 | ||
85 | int zmii_attach(struct platform_device *ofdev, int input, int *mode) | 85 | int zmii_attach(struct platform_device *ofdev, int input, int *mode) |
86 | { | 86 | { |
87 | struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 87 | struct zmii_instance *dev = platform_get_drvdata(ofdev); |
88 | struct zmii_regs __iomem *p = dev->base; | 88 | struct zmii_regs __iomem *p = dev->base; |
89 | 89 | ||
90 | ZMII_DBG(dev, "init(%d, %d)" NL, input, *mode); | 90 | ZMII_DBG(dev, "init(%d, %d)" NL, input, *mode); |
@@ -150,7 +150,7 @@ int zmii_attach(struct platform_device *ofdev, int input, int *mode) | |||
150 | 150 | ||
151 | void zmii_get_mdio(struct platform_device *ofdev, int input) | 151 | void zmii_get_mdio(struct platform_device *ofdev, int input) |
152 | { | 152 | { |
153 | struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 153 | struct zmii_instance *dev = platform_get_drvdata(ofdev); |
154 | u32 fer; | 154 | u32 fer; |
155 | 155 | ||
156 | ZMII_DBG2(dev, "get_mdio(%d)" NL, input); | 156 | ZMII_DBG2(dev, "get_mdio(%d)" NL, input); |
@@ -163,7 +163,7 @@ void zmii_get_mdio(struct platform_device *ofdev, int input) | |||
163 | 163 | ||
164 | void zmii_put_mdio(struct platform_device *ofdev, int input) | 164 | void zmii_put_mdio(struct platform_device *ofdev, int input) |
165 | { | 165 | { |
166 | struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 166 | struct zmii_instance *dev = platform_get_drvdata(ofdev); |
167 | 167 | ||
168 | ZMII_DBG2(dev, "put_mdio(%d)" NL, input); | 168 | ZMII_DBG2(dev, "put_mdio(%d)" NL, input); |
169 | mutex_unlock(&dev->lock); | 169 | mutex_unlock(&dev->lock); |
@@ -172,7 +172,7 @@ void zmii_put_mdio(struct platform_device *ofdev, int input) | |||
172 | 172 | ||
173 | void zmii_set_speed(struct platform_device *ofdev, int input, int speed) | 173 | void zmii_set_speed(struct platform_device *ofdev, int input, int speed) |
174 | { | 174 | { |
175 | struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 175 | struct zmii_instance *dev = platform_get_drvdata(ofdev); |
176 | u32 ssr; | 176 | u32 ssr; |
177 | 177 | ||
178 | mutex_lock(&dev->lock); | 178 | mutex_lock(&dev->lock); |
@@ -193,7 +193,7 @@ void zmii_set_speed(struct platform_device *ofdev, int input, int speed) | |||
193 | 193 | ||
194 | void zmii_detach(struct platform_device *ofdev, int input) | 194 | void zmii_detach(struct platform_device *ofdev, int input) |
195 | { | 195 | { |
196 | struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 196 | struct zmii_instance *dev = platform_get_drvdata(ofdev); |
197 | 197 | ||
198 | BUG_ON(!dev || dev->users == 0); | 198 | BUG_ON(!dev || dev->users == 0); |
199 | 199 | ||
@@ -218,7 +218,7 @@ int zmii_get_regs_len(struct platform_device *ofdev) | |||
218 | 218 | ||
219 | void *zmii_dump_regs(struct platform_device *ofdev, void *buf) | 219 | void *zmii_dump_regs(struct platform_device *ofdev, void *buf) |
220 | { | 220 | { |
221 | struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 221 | struct zmii_instance *dev = platform_get_drvdata(ofdev); |
222 | struct emac_ethtool_regs_subhdr *hdr = buf; | 222 | struct emac_ethtool_regs_subhdr *hdr = buf; |
223 | struct zmii_regs *regs = (struct zmii_regs *)(hdr + 1); | 223 | struct zmii_regs *regs = (struct zmii_regs *)(hdr + 1); |
224 | 224 | ||
@@ -272,7 +272,7 @@ static int zmii_probe(struct platform_device *ofdev) | |||
272 | printk(KERN_INFO | 272 | printk(KERN_INFO |
273 | "ZMII %s initialized\n", ofdev->dev.of_node->full_name); | 273 | "ZMII %s initialized\n", ofdev->dev.of_node->full_name); |
274 | wmb(); | 274 | wmb(); |
275 | dev_set_drvdata(&ofdev->dev, dev); | 275 | platform_set_drvdata(ofdev, dev); |
276 | 276 | ||
277 | return 0; | 277 | return 0; |
278 | 278 | ||
@@ -284,9 +284,7 @@ static int zmii_probe(struct platform_device *ofdev) | |||
284 | 284 | ||
285 | static int zmii_remove(struct platform_device *ofdev) | 285 | static int zmii_remove(struct platform_device *ofdev) |
286 | { | 286 | { |
287 | struct zmii_instance *dev = dev_get_drvdata(&ofdev->dev); | 287 | struct zmii_instance *dev = platform_get_drvdata(ofdev); |
288 | |||
289 | dev_set_drvdata(&ofdev->dev, NULL); | ||
290 | 288 | ||
291 | WARN_ON(dev->users != 0); | 289 | WARN_ON(dev->users != 0); |
292 | 290 | ||