aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLogan Gunthorpe <logang@deltatee.com>2019-08-22 12:10:13 -0400
committerBjorn Helgaas <bhelgaas@google.com>2019-09-05 17:47:30 -0400
commite499081da1a247a8a5a234211c7127fb0b91ca92 (patch)
treec9d1a45ef6093df6123020fb2b4b21dd3f9f867f
parent273b177cac4b649c3c6d448e85bbc64cebfe7a0a (diff)
PCI: Force trailing new line to resource_alignment_param in sysfs
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. Link: https://lore.kernel.org/r/20190822161013.5481-4-logang@deltatee.com Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/pci.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index ff3abc577a25..5f70ff1031d2 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6126,6 +6126,16 @@ static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
6126 count = snprintf(buf, PAGE_SIZE, "%s", resource_alignment_param); 6126 count = snprintf(buf, PAGE_SIZE, "%s", resource_alignment_param);
6127 spin_unlock(&resource_alignment_lock); 6127 spin_unlock(&resource_alignment_lock);
6128 6128
6129 /*
6130 * When set by the command line, resource_alignment_param will not
6131 * have a trailing line feed, which is ugly. So conditionally add
6132 * it here.
6133 */
6134 if (count >= 2 && buf[count - 2] != '\n' && count < PAGE_SIZE - 1) {
6135 buf[count - 1] = '\n';
6136 buf[count++] = 0;
6137 }
6138
6129 return count; 6139 return count;
6130} 6140}
6131 6141