diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2011-05-18 13:19:24 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-05-18 14:32:23 -0400 |
commit | b1608d69cb804e414d0887140ba08a9398e4e638 (patch) | |
tree | 8999cd827e7fb4138ff83f7829d8fdcf44ee653d /drivers/net/fs_enet/fs_enet-main.c | |
parent | 01294d82622d6d9d64bde8e4530c7e2c6dbb6ee6 (diff) |
drivercore: revert addition of of_match to struct device
Commit b826291c, "drivercore/dt: add a match table pointer to struct
device" added an of_match pointer to struct device to cache the
of_match_table entry discovered at driver match time. This was unsafe
because matching is not an atomic operation with probing a driver. If
two or more drivers are attempted to be matched to a driver at the
same time, then the cached matching entry pointer could get
overwritten.
This patch reverts the of_match cache pointer and reworks all users to
call of_match_device() directly instead.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/net/fs_enet/fs_enet-main.c')
-rw-r--r-- | drivers/net/fs_enet/fs_enet-main.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c index 24cb953900dd..5131e61c358c 100644 --- a/drivers/net/fs_enet/fs_enet-main.c +++ b/drivers/net/fs_enet/fs_enet-main.c | |||
@@ -998,8 +998,10 @@ static const struct net_device_ops fs_enet_netdev_ops = { | |||
998 | #endif | 998 | #endif |
999 | }; | 999 | }; |
1000 | 1000 | ||
1001 | static struct of_device_id fs_enet_match[]; | ||
1001 | static int __devinit fs_enet_probe(struct platform_device *ofdev) | 1002 | static int __devinit fs_enet_probe(struct platform_device *ofdev) |
1002 | { | 1003 | { |
1004 | const struct of_device_id *match; | ||
1003 | struct net_device *ndev; | 1005 | struct net_device *ndev; |
1004 | struct fs_enet_private *fep; | 1006 | struct fs_enet_private *fep; |
1005 | struct fs_platform_info *fpi; | 1007 | struct fs_platform_info *fpi; |
@@ -1007,14 +1009,15 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev) | |||
1007 | const u8 *mac_addr; | 1009 | const u8 *mac_addr; |
1008 | int privsize, len, ret = -ENODEV; | 1010 | int privsize, len, ret = -ENODEV; |
1009 | 1011 | ||
1010 | if (!ofdev->dev.of_match) | 1012 | match = of_match_device(fs_enet_match, &ofdev->dev); |
1013 | if (!match) | ||
1011 | return -EINVAL; | 1014 | return -EINVAL; |
1012 | 1015 | ||
1013 | fpi = kzalloc(sizeof(*fpi), GFP_KERNEL); | 1016 | fpi = kzalloc(sizeof(*fpi), GFP_KERNEL); |
1014 | if (!fpi) | 1017 | if (!fpi) |
1015 | return -ENOMEM; | 1018 | return -ENOMEM; |
1016 | 1019 | ||
1017 | if (!IS_FEC(ofdev->dev.of_match)) { | 1020 | if (!IS_FEC(match)) { |
1018 | data = of_get_property(ofdev->dev.of_node, "fsl,cpm-command", &len); | 1021 | data = of_get_property(ofdev->dev.of_node, "fsl,cpm-command", &len); |
1019 | if (!data || len != 4) | 1022 | if (!data || len != 4) |
1020 | goto out_free_fpi; | 1023 | goto out_free_fpi; |
@@ -1049,7 +1052,7 @@ static int __devinit fs_enet_probe(struct platform_device *ofdev) | |||
1049 | fep->dev = &ofdev->dev; | 1052 | fep->dev = &ofdev->dev; |
1050 | fep->ndev = ndev; | 1053 | fep->ndev = ndev; |
1051 | fep->fpi = fpi; | 1054 | fep->fpi = fpi; |
1052 | fep->ops = ofdev->dev.of_match->data; | 1055 | fep->ops = match->data; |
1053 | 1056 | ||
1054 | ret = fep->ops->setup_data(ndev); | 1057 | ret = fep->ops->setup_data(ndev); |
1055 | if (ret) | 1058 | if (ret) |