linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: "Krzysztof Wilczyński" <kw@linux.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	Logan Gunthorpe <logang@deltatee.com>,
	Joe Perches <joe@perches.com>,
	Oliver O'Halloran <oohall@gmail.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>,
	Tyrel Datwyler <tyreld@linux.ibm.com>,
	Russell Currey <ruscur@russell.cc>,
	Kurt Schwemmer <kurt.schwemmer@microsemi.com>,
	Vidya Sagar <vidyas@nvidia.com>,
	Xiongfeng Wang <wangxiongfeng2@huawei.com>,
	linux-pci@vger.kernel.org,
	Sebastian Ott <sebott@linux.vnet.ibm.com>
Subject: Re: [PATCH v6 4/6] PCI/sysfs: Add missing trailing newline to devspec_show()
Date: Thu, 3 Jun 2021 18:00:46 -0500	[thread overview]
Message-ID: <20210603230046.GA2149598@bjorn-Precision-5520> (raw)
In-Reply-To: <20210603000112.703037-5-kw@linux.com>

[+cc Sebastian]

On Thu, Jun 03, 2021 at 12:01:10AM +0000, Krzysztof Wilczyński wrote:
> At the moment, when the value of the "devspec" sysfs object is read from
> the user space there will be no newline present, and the utilities such
> as the "cat" command won't display the result of the read correctly in
> a shell, as the trailing newline is currently missing.
> 
> To fix this, append a newline character in the show() function.

There are a few other devspec_show() functions:

  arch/powerpc/platforms/pseries/ibmebus.c
  arch/powerpc/platforms/pseries/vio.c
  arch/sparc/kernel/vio.c
  drivers/usb/core/sysfs.c

and they all include the newline.  So I assume it's not likely that
this minor user-visible change will break something.

I did cc: Sebastian, since his dfc73e7acd99 ("PCI: Move Open Firmware
devspec attribute to PCI common code") moved this code to pci-sysfs.c
in the first place (it came from microblaze and powerpc code that
*also* did not include the newline).

I notice that pci-sysfs.c is the only one that returns 0 if of_node is
NULL.  Probably makes more sense than what the others do.  I'm
guessing the others would print "(null)" which doesn't seem quite
right for a sysfs attribute.

But pci-sysfs.c also goes to a little more work than necessary to look
up of_node:

  struct pci_dev *pdev = to_pci_dev(dev);
  struct device_node *np = pci_device_to_OF_node(pdev);

when I think this would be equivalent:

  struct device_node *np = dev->of_node;

Some of the others do a similar dance with struct platform_device.

Why'd I write all the above?  I dunno; this looks good to me, no
action required for you :)

> Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
> Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> ---
>  drivers/pci/pci-sysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index beb8d1f4fafe..5d63df7c1820 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -537,7 +537,7 @@ static ssize_t devspec_show(struct device *dev,
>  
>  	if (np == NULL)
>  		return 0;
> -	return sysfs_emit(buf, "%pOF", np);
> +	return sysfs_emit(buf, "%pOF\n", np);
>  }
>  static DEVICE_ATTR_RO(devspec);
>  #endif
> -- 
> 2.31.1
> 

  reply	other threads:[~2021-06-03 23:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  0:01 [PATCH v6 0/6] PCI/sysfs: Use sysfs_emit() and sysfs_emit_at() in "show" functions Krzysztof Wilczyński
2021-06-03  0:01 ` [PATCH v6 1/6] " Krzysztof Wilczyński
2021-06-03  0:01 ` [PATCH v6 2/6] PCI/sysfs: Use return value from dsm_label_utf16s_to_utf8s() directly Krzysztof Wilczyński
2021-06-03  0:01 ` [PATCH v6 3/6] PCI/sysfs: Fix trailing newline handling of resource_alignment_param Krzysztof Wilczyński
2021-06-03 23:40   ` Bjorn Helgaas
2021-06-04 13:25     ` Krzysztof Wilczyński
2021-06-03  0:01 ` [PATCH v6 4/6] PCI/sysfs: Add missing trailing newline to devspec_show() Krzysztof Wilczyński
2021-06-03 23:00   ` Bjorn Helgaas [this message]
2021-06-03  0:01 ` [PATCH v6 5/6] PCI/sysfs: Only show value when driver_override is not NULL Krzysztof Wilczyński
2021-06-03 21:17   ` Bjorn Helgaas
2021-06-03 21:37     ` Bjorn Helgaas
2021-06-03 22:19     ` Krzysztof Wilczyński
2021-06-03 23:23   ` Bjorn Helgaas
2021-06-04  0:47     ` Alex Williamson
2021-06-04  1:10       ` Krzysztof Wilczyński
2021-06-03  0:01 ` [PATCH v6 6/6] PCI/sysfs: Fix a buffer overrun problem with dsm_label_utf16s_to_utf8s() Krzysztof Wilczyński
2021-06-04  4:07 ` [PATCH v6 0/6] PCI/sysfs: Use sysfs_emit() and sysfs_emit_at() in "show" functions Bjorn Helgaas
2021-06-04 13:38   ` Krzysztof Wilczyński

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=20210603230046.GA2149598@bjorn-Precision-5520 \
    --to=helgaas@kernel.org \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=joe@perches.com \
    --cc=kurt.schwemmer@microsemi.com \
    --cc=kw@linux.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=mpe@ellerman.id.au \
    --cc=oohall@gmail.com \
    --cc=paulus@samba.org \
    --cc=ruscur@russell.cc \
    --cc=sebott@linux.vnet.ibm.com \
    --cc=tyreld@linux.ibm.com \
    --cc=vidyas@nvidia.com \
    --cc=wangxiongfeng2@huawei.com \
    /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).