From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Russell King <rmk+lkml@arm.linux.org.uk>
Cc: Greg KH <greg@kroah.com>,
Linux Kernel list <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>
Subject: Re: Platform device matching, & weird strncmp usage
Date: Sat, 07 Jan 2006 08:38:12 +1100 [thread overview]
Message-ID: <1136583493.4840.137.camel@localhost.localdomain> (raw)
In-Reply-To: <20060106185352.GG16093@flint.arm.linux.org.uk>
On Fri, 2006-01-06 at 18:53 +0000, Russell King wrote:
> On Fri, Jan 06, 2006 at 04:59:39PM +1100, Benjamin Herrenschmidt wrote:
> > static int platform_match(struct device * dev, struct device_driver * drv)
> > {
> > struct platform_device *pdev = container_of(dev, struct platform_device, dev);
> >
> > return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0);
> > }
> >
> > As far as I know, strncmp() is _NOT_ supposed to return 0 if one string
> > is shorter than the other and they match until that point. Thus the
> > above will never match unless the <name> portion of pdev->name is
> > exactly of size BUS_ID_SIZE which is obviously not the case...
>
> pdev->name is just the <name> part - it's pdev->dev.name which has
> both the <name> and <instance>. I think the strncmp is unnecessary,
> and it can be replaced by a plain strcmp.
Ah indeed, I got confused by having both strings.
Ben.
next prev parent reply other threads:[~2006-01-06 21:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-06 5:59 Benjamin Herrenschmidt
2006-01-06 6:04 ` Benjamin Herrenschmidt
2006-01-06 18:53 ` Russell King
2006-01-06 21:38 ` Benjamin Herrenschmidt [this message]
2006-01-07 19:24 ` Kurtis D. Rader
2006-01-07 19:42 ` Bob Copeland
2006-01-07 22:14 ` Benjamin Herrenschmidt
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=1136583493.4840.137.camel@localhost.localdomain \
--to=benh@kernel.crashing.org \
--cc=akpm@osdl.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk+lkml@arm.linux.org.uk \
/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
all inboxes | Powered by JetHome®