All of lore.kernel.org
 help / color / mirror / Atom feed
From: Logan Gunthorpe <logang@deltatee.com>
To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	Logan Gunthorpe <logang@deltatee.com>
Subject: [PATCH 3/3] PCI: Force trailing new line to resource_alignment_param in sysfs
Date: Fri, 24 May 2019 14:16:10 -0600	[thread overview]
Message-ID: <20190524201610.8039-4-logang@deltatee.com> (raw)
In-Reply-To: <20190524201610.8039-1-logang@deltatee.com>

When 'pci=resource_alignment=' is specified on the command line, there
is no trailing new line.  Then, when it's read through the corresponding
sysfs attribute, there will be no newline and a cat command will not
show correctly in a shell. If the parameter is set through sysfs
a new line will be stored and it will 'cat' correctly.

To solve this, append a new line character in the show function if
one does not already exist.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/pci.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 3e71e161f18b..99d130ac6b96 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6090,6 +6090,16 @@ static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
 		count = snprintf(buf, PAGE_SIZE, "%s", resource_alignment_param);
 	spin_unlock(&resource_alignment_lock);
 
+	/*
+	 * When set by the command line, resource_alignment_param will not
+	 * have a trailing line feed, which is ugly. So conditionally add
+	 * it here.
+	 */
+	if (count >= 2 && buf[count - 2] != '\n' && count < PAGE_SIZE - 1) {
+		buf[count - 1] = '\n';
+		buf[count++] = 0;
+	}
+
 	return count;
 }
 
-- 
2.20.1


  parent reply	other threads:[~2019-05-24 20:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-24 20:16 [PATCH 0/3] Cleanup resource_alignment parameter Logan Gunthorpe
2019-05-24 20:16 ` [PATCH 1/3] PCI: Clean up resource_alignment parameter to not require static buffer Logan Gunthorpe
2019-05-24 20:16 ` [PATCH 2/3] PCI: Move pci_[get|set]_resource_alignment_param() into their callers Logan Gunthorpe
2019-05-24 20:16 ` Logan Gunthorpe [this message]
2019-08-21 13:16 ` [PATCH 0/3] Cleanup resource_alignment parameter Bjorn Helgaas

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=20190524201610.8039-4-logang@deltatee.com \
    --to=logang@deltatee.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.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.