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>
This commit is contained in:
@@ -715,13 +715,13 @@ static int __devexit hwicap_remove(struct device *dev)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
static int __devinit hwicap_of_probe(struct platform_device *op)
|
||||
static int __devinit hwicap_of_probe(struct platform_device *op,
|
||||
const struct hwicap_driver_config *config)
|
||||
{
|
||||
struct resource res;
|
||||
const unsigned int *id;
|
||||
const char *family;
|
||||
int rc;
|
||||
const struct hwicap_driver_config *config = op->dev.of_match->data;
|
||||
const struct config_registers *regs;
|
||||
|
||||
|
||||
@@ -751,20 +751,24 @@ static int __devinit hwicap_of_probe(struct platform_device *op)
|
||||
regs);
|
||||
}
|
||||
#else
|
||||
static inline int hwicap_of_probe(struct platform_device *op)
|
||||
static inline int hwicap_of_probe(struct platform_device *op,
|
||||
const struct hwicap_driver_config *config)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif /* CONFIG_OF */
|
||||
|
||||
static const struct of_device_id __devinitconst hwicap_of_match[];
|
||||
static int __devinit hwicap_drv_probe(struct platform_device *pdev)
|
||||
{
|
||||
const struct of_device_id *match;
|
||||
struct resource *res;
|
||||
const struct config_registers *regs;
|
||||
const char *family;
|
||||
|
||||
if (pdev->dev.of_match)
|
||||
return hwicap_of_probe(pdev);
|
||||
match = of_match_device(hwicap_of_match, &pdev->dev);
|
||||
if (match)
|
||||
return hwicap_of_probe(pdev, match->data);
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res)
|
||||
|
Reference in New Issue
Block a user