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/tty/serial/of_serial.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/tty/serial/of_serial.c')
-rw-r--r-- | drivers/tty/serial/of_serial.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c index 0e8eec516df4..c911b2419abb 100644 --- a/drivers/tty/serial/of_serial.c +++ b/drivers/tty/serial/of_serial.c | |||
@@ -80,14 +80,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev, | |||
80 | /* | 80 | /* |
81 | * Try to register a serial port | 81 | * Try to register a serial port |
82 | */ | 82 | */ |
83 | static struct of_device_id of_platform_serial_table[]; | ||
83 | static int __devinit of_platform_serial_probe(struct platform_device *ofdev) | 84 | static int __devinit of_platform_serial_probe(struct platform_device *ofdev) |
84 | { | 85 | { |
86 | const struct of_device_id *match; | ||
85 | struct of_serial_info *info; | 87 | struct of_serial_info *info; |
86 | struct uart_port port; | 88 | struct uart_port port; |
87 | int port_type; | 89 | int port_type; |
88 | int ret; | 90 | int ret; |
89 | 91 | ||
90 | if (!ofdev->dev.of_match) | 92 | match = of_match_device(of_platform_serial_table, &ofdev->dev); |
93 | if (!match) | ||
91 | return -EINVAL; | 94 | return -EINVAL; |
92 | 95 | ||
93 | if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL)) | 96 | if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL)) |
@@ -97,7 +100,7 @@ static int __devinit of_platform_serial_probe(struct platform_device *ofdev) | |||
97 | if (info == NULL) | 100 | if (info == NULL) |
98 | return -ENOMEM; | 101 | return -ENOMEM; |
99 | 102 | ||
100 | port_type = (unsigned long)ofdev->dev.of_match->data; | 103 | port_type = (unsigned long)match->data; |
101 | ret = of_platform_serial_setup(ofdev, port_type, &port); | 104 | ret = of_platform_serial_setup(ofdev, port_type, &port); |
102 | if (ret) | 105 | if (ret) |
103 | goto out; | 106 | goto out; |