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/char | |
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/char')
-rw-r--r-- | drivers/char/hw_random/n2-drv.c | 7 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_si_intf.c | 7 | ||||
-rw-r--r-- | drivers/char/xilinx_hwicap/xilinx_hwicap.c | 14 |
3 files changed, 19 insertions, 9 deletions
diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c index 43ac61978d8b..ac6739e085e3 100644 --- a/drivers/char/hw_random/n2-drv.c +++ b/drivers/char/hw_random/n2-drv.c | |||
@@ -619,15 +619,18 @@ static void __devinit n2rng_driver_version(void) | |||
619 | pr_info("%s", version); | 619 | pr_info("%s", version); |
620 | } | 620 | } |
621 | 621 | ||
622 | static const struct of_device_id n2rng_match[]; | ||
622 | static int __devinit n2rng_probe(struct platform_device *op) | 623 | static int __devinit n2rng_probe(struct platform_device *op) |
623 | { | 624 | { |
625 | const struct of_device_id *match; | ||
624 | int victoria_falls; | 626 | int victoria_falls; |
625 | int err = -ENOMEM; | 627 | int err = -ENOMEM; |
626 | struct n2rng *np; | 628 | struct n2rng *np; |
627 | 629 | ||
628 | if (!op->dev.of_match) | 630 | match = of_match_device(n2rng_match, &op->dev); |
631 | if (!match) | ||
629 | return -EINVAL; | 632 | return -EINVAL; |
630 | victoria_falls = (op->dev.of_match->data != NULL); | 633 | victoria_falls = (match->data != NULL); |
631 | 634 | ||
632 | n2rng_driver_version(); | 635 | n2rng_driver_version(); |
633 | np = kzalloc(sizeof(*np), GFP_KERNEL); | 636 | np = kzalloc(sizeof(*np), GFP_KERNEL); |
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index cc6c9b2546a3..64c6b8530615 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -2554,9 +2554,11 @@ static struct pci_driver ipmi_pci_driver = { | |||
2554 | }; | 2554 | }; |
2555 | #endif /* CONFIG_PCI */ | 2555 | #endif /* CONFIG_PCI */ |
2556 | 2556 | ||
2557 | static struct of_device_id ipmi_match[]; | ||
2557 | static int __devinit ipmi_probe(struct platform_device *dev) | 2558 | static int __devinit ipmi_probe(struct platform_device *dev) |
2558 | { | 2559 | { |
2559 | #ifdef CONFIG_OF | 2560 | #ifdef CONFIG_OF |
2561 | const struct of_device_id *match; | ||
2560 | struct smi_info *info; | 2562 | struct smi_info *info; |
2561 | struct resource resource; | 2563 | struct resource resource; |
2562 | const __be32 *regsize, *regspacing, *regshift; | 2564 | const __be32 *regsize, *regspacing, *regshift; |
@@ -2566,7 +2568,8 @@ static int __devinit ipmi_probe(struct platform_device *dev) | |||
2566 | 2568 | ||
2567 | dev_info(&dev->dev, "probing via device tree\n"); | 2569 | dev_info(&dev->dev, "probing via device tree\n"); |
2568 | 2570 | ||
2569 | if (!dev->dev.of_match) | 2571 | match = of_match_device(ipmi_match, &dev->dev); |
2572 | if (!match) | ||
2570 | return -EINVAL; | 2573 | return -EINVAL; |
2571 | 2574 | ||
2572 | ret = of_address_to_resource(np, 0, &resource); | 2575 | ret = of_address_to_resource(np, 0, &resource); |
@@ -2601,7 +2604,7 @@ static int __devinit ipmi_probe(struct platform_device *dev) | |||
2601 | return -ENOMEM; | 2604 | return -ENOMEM; |
2602 | } | 2605 | } |
2603 | 2606 | ||
2604 | info->si_type = (enum si_type) dev->dev.of_match->data; | 2607 | info->si_type = (enum si_type) match->data; |
2605 | info->addr_source = SI_DEVICETREE; | 2608 | info->addr_source = SI_DEVICETREE; |
2606 | info->irq_setup = std_irq_setup; | 2609 | info->irq_setup = std_irq_setup; |
2607 | 2610 | ||
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index d6412c16385f..39ccdeada791 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c | |||
@@ -715,13 +715,13 @@ static int __devexit hwicap_remove(struct device *dev) | |||
715 | } | 715 | } |
716 | 716 | ||
717 | #ifdef CONFIG_OF | 717 | #ifdef CONFIG_OF |
718 | static int __devinit hwicap_of_probe(struct platform_device *op) | 718 | static int __devinit hwicap_of_probe(struct platform_device *op, |
719 | const struct hwicap_driver_config *config) | ||
719 | { | 720 | { |
720 | struct resource res; | 721 | struct resource res; |
721 | const unsigned int *id; | 722 | const unsigned int *id; |
722 | const char *family; | 723 | const char *family; |
723 | int rc; | 724 | int rc; |
724 | const struct hwicap_driver_config *config = op->dev.of_match->data; | ||
725 | const struct config_registers *regs; | 725 | const struct config_registers *regs; |
726 | 726 | ||
727 | 727 | ||
@@ -751,20 +751,24 @@ static int __devinit hwicap_of_probe(struct platform_device *op) | |||
751 | regs); | 751 | regs); |
752 | } | 752 | } |
753 | #else | 753 | #else |
754 | static inline int hwicap_of_probe(struct platform_device *op) | 754 | static inline int hwicap_of_probe(struct platform_device *op, |
755 | const struct hwicap_driver_config *config) | ||
755 | { | 756 | { |
756 | return -EINVAL; | 757 | return -EINVAL; |
757 | } | 758 | } |
758 | #endif /* CONFIG_OF */ | 759 | #endif /* CONFIG_OF */ |
759 | 760 | ||
761 | static const struct of_device_id __devinitconst hwicap_of_match[]; | ||
760 | static int __devinit hwicap_drv_probe(struct platform_device *pdev) | 762 | static int __devinit hwicap_drv_probe(struct platform_device *pdev) |
761 | { | 763 | { |
764 | const struct of_device_id *match; | ||
762 | struct resource *res; | 765 | struct resource *res; |
763 | const struct config_registers *regs; | 766 | const struct config_registers *regs; |
764 | const char *family; | 767 | const char *family; |
765 | 768 | ||
766 | if (pdev->dev.of_match) | 769 | match = of_match_device(hwicap_of_match, &pdev->dev); |
767 | return hwicap_of_probe(pdev); | 770 | if (match) |
771 | return hwicap_of_probe(pdev, match->data); | ||
768 | 772 | ||
769 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 773 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
770 | if (!res) | 774 | if (!res) |