All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: Rob Herring <robh@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH 3/4] of: Convert to using %pOFn instead of device_node.name
Date: Mon, 10 Sep 2018 11:06:25 +0200	[thread overview]
Message-ID: <20180910090625.GA702@ulmo> (raw)
In-Reply-To: <0999919005219fa94ccc69ff57659d47911d3abd.camel@perches.com>

[-- Attachment #1: Type: text/plain, Size: 3223 bytes --]

On Fri, Sep 07, 2018 at 05:30:23PM -0700, Joe Perches wrote:
> On Fri, 2018-09-07 at 14:29 +0200, Thierry Reding wrote:
> > On Tue, Aug 28, 2018 at 10:52:53AM -0500, Rob Herring wrote:
> > > In preparation to remove the node name pointer from struct device_node,
> > > convert printf users to use the %pOFn format specifier.
> > > 
> > > Cc: Frank Rowand <frowand.list@gmail.com>
> > > Cc: Andrew Lunn <andrew@lunn.ch>
> > > Cc: Florian Fainelli <f.fainelli@gmail.com>
> > > Cc: devicetree@vger.kernel.org
> > > Cc: netdev@vger.kernel.org
> > > Signed-off-by: Rob Herring <robh@kernel.org>
> > > ---
> > >  drivers/of/device.c   |  4 ++--
> > >  drivers/of/of_mdio.c  | 12 ++++++------
> > >  drivers/of/of_numa.c  |  4 ++--
> > >  drivers/of/overlay.c  |  4 ++--
> > >  drivers/of/platform.c |  8 ++++----
> > >  drivers/of/unittest.c | 12 ++++++------
> > >  6 files changed, 22 insertions(+), 22 deletions(-)
> > > 
> > > diff --git a/drivers/of/device.c b/drivers/of/device.c
> > > index 5957cd4fa262..daa075d87317 100644
> > > --- a/drivers/of/device.c
> > > +++ b/drivers/of/device.c
> > > @@ -219,7 +219,7 @@ static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len
> > >  		return -ENODEV;
> > >  
> > >  	/* Name & Type */
> > > -	csize = snprintf(str, len, "of:N%sT%s", dev->of_node->name,
> > > +	csize = snprintf(str, len, "of:N%pOFnT%s", dev->of_node,
> > >  			 dev->of_node->type);
> > >  	tsize = csize;
> > >  	len -= csize;
> > 
> > This seems to cause the modalias to be improperly constructed. As a
> > consequence, automatic module loading at boot time is now broken. I
> > think the reason why this fails is because vsnprintf() will skip all
> > alpha-numeric characters after a call to pointer(). Presumably this
> > is meant to be a generic way of skipping whatever specifiers we throw
> > at it.
> > 
> > Unfortunately for the case of OF modaliases, this means that the 'T'
> > character gets eaten, so we end up with something like this:
> > 
> > 	# udevadm info /sys/bus/platform/devices/54200000.dc
> > 	[...]
> > 	E: MODALIAS=of:Ndc<NULL>Cnvidia,tegra124-dc
> > 	[...]
> > 
> > instead of this:
> > 
> > 	# udevadm info /sys/bus/platform/devices/54200000.dc
> > 	[...]
> > 	E: MODALIAS=of:NdcT<NULL>Cnvidia,tegra124-dc
> > 	[...]
> > 
> > Everything is back to normal if I revert this patch. However, since
> > that's obviously not what we want, I think perhaps what we need is a
> > way for pointer() (and its implementations) to report back how many
> > characters in the format string it consumed so that we can support
> > these kinds of back-to-back strings.
> > 
> > If nobody else has the time I can look into coding up a fix, but in the
> > meantime it might be best to back this one out until we can handle the
> > OF modalias format string.
> 
> Or just use 2 consecutive snprintf calls
> 
> 	csize = snprintf(str, len, "of:N%pOFn", dev->of_node);
> 	csize += snprintf(str + csize, len - csize, "T%s",
> 			  dev->of_node->type);

Yeah, that's what I ended up doing. Rob came up with another alternative
which is to output the 'T' via %c, which also works around the issue.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-09-10  9:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28 15:52 [PATCH 0/4] of: Convert to using %pOFn for node name printf Rob Herring
2018-08-28 15:52 ` [PATCH 1/4] of/unittest: remove use of node name pointer in overlay high level test Rob Herring
2018-08-28 15:52 ` [PATCH 2/4] of/unittest: add printf tests for node name Rob Herring
2018-08-28 15:52 ` [PATCH 3/4] of: Convert to using %pOFn instead of device_node.name Rob Herring
2018-09-07 12:29   ` Thierry Reding
2018-09-07 14:58     ` Rob Herring
2018-09-08  0:30     ` Joe Perches
2018-09-10  9:06       ` Thierry Reding [this message]
2018-08-28 15:52 ` [PATCH 4/4] vsprintf: print OF node name using full_name Rob Herring
2018-08-31 23:51 ` [PATCH 0/4] of: Convert to using %pOFn for node name printf Frank Rowand

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=20180910090625.GA702@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=frowand.list@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robh@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.