From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
gregkh-l3A5Bk7waGM@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Milton Miller <miltonm-ogEGBHC/i9Y@public.gmane.org>,
sparclinux-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Linus Torvalds <torvalds@linux-foundati>
Subject: [PATCH 1/2] of: fix race when matching drivers
Date: Wed, 18 May 2011 13:21:00 -0600 [thread overview]
Message-ID: <20110518192100.28986.94335.stgit@ponder> (raw)
In-Reply-To: <20110518185751.28986.69446.stgit@ponder>
From: Milton Miller <miltonm-ogEGBHC/i9Y@public.gmane.org>
If two drivers are probing devices at the same time, both will write
their match table result to the dev->of_match cache at the same time.
Only write the result if the device matches.
In a thread titled "SBus devices sometimes detected, sometimes not",
Meelis reported his SBus hme was not detected about 50% of the time.
>From the debug suggested by Grant it was obvious another driver matched
some devices between the call to match the hme and the hme discovery
failling.
Reported-by: Meelis Roos <mroos-Y27EyoLml9s@public.gmane.org>
Signed-off-by: Milton Miller <miltonm-ogEGBHC/i9Y@public.gmane.org>
[grant.likely: modified to only call of_match_device() once]
Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
---
include/linux/of_device.h | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index 8bfe6c1..b33d688 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -21,8 +21,12 @@ extern void of_device_make_bus_id(struct device *dev);
static inline int of_driver_match_device(struct device *dev,
const struct device_driver *drv)
{
- dev->of_match = of_match_device(drv->of_match_table, dev);
- return dev->of_match != NULL;
+ const struct of_device_id *match;
+
+ match = of_match_device(drv->of_match_table, dev);
+ if (match)
+ dev->of_match = match;
+ return match != NULL;
}
extern struct platform_device *of_dev_get(struct platform_device *dev);
next prev parent reply other threads:[~2011-05-18 19:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-18 19:20 [git pull][PATCH 0/2] Fix regression caused by addition of 'of_match' Grant Likely
2011-05-18 19:21 ` Grant Likely [this message]
2011-05-18 19:54 ` [PATCH 1/2] of: fix race when matching drivers Greg KH
2011-05-18 21:03 ` David Miller
2011-05-18 19:21 ` [PATCH 2/2] drivercore: revert addition of of_match to struct device Grant Likely
2011-05-18 19:55 ` Greg KH
2011-05-18 21:03 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110518192100.28986.94335.stgit@ponder \
--to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=gregkh-l3A5Bk7waGM@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=miltonm-ogEGBHC/i9Y@public.gmane.org \
--cc=sparclinux-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=torvalds@linux-foundati \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).