summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLogan Gunthorpe <logang@deltatee.com>2019-08-22 10:10:12 -0600
committerBjorn Helgaas <bhelgaas@google.com>2019-09-05 16:47:22 -0500
commit273b177cac4b649c3c6d448e85bbc64cebfe7a0a (patch)
treeedd8e5a691e1cfc1d82530db7e759c587175c2f4 /drivers
parent70aaf61a9b8b86eb08da96344efd1c0f0925ee6e (diff)
downloadlinux-273b177cac4b649c3c6d448e85bbc64cebfe7a0a.tar.bz2
PCI: Move pci_[get|set]_resource_alignment_param() into their callers
Both the functions pci_get_resource_alignment_param() and pci_set_resource_alignment_param() are now only called in one place: resource_alignment_show() and resource_alignment_store() respectively. There is no value in this extra set of functions so move both into their callers respectively. [bhelgaas: fold in "GFP_KERNEL while atomic" fix from Christoph Hellwig <hch@infradead.org> https://lore.kernel.org/r/20190902075006.GB754@infradead.org] Link: https://lore.kernel.org/r/20190822161013.5481-3-logang@deltatee.com Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pci/pci.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index fbfb64ba447d..ff3abc577a25 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -6117,39 +6117,31 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
}
}
-static ssize_t pci_set_resource_alignment_param(const char *buf, size_t count)
-{
- spin_lock(&resource_alignment_lock);
-
- kfree(resource_alignment_param);
- resource_alignment_param = kstrndup(buf, count, GFP_KERNEL);
-
- spin_unlock(&resource_alignment_lock);
-
- return resource_alignment_param ? count : -ENOMEM;
-}
-
-static ssize_t pci_get_resource_alignment_param(char *buf, size_t size)
+static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
{
size_t count = 0;
spin_lock(&resource_alignment_lock);
if (resource_alignment_param)
- count = snprintf(buf, size, "%s", resource_alignment_param);
+ count = snprintf(buf, PAGE_SIZE, "%s", resource_alignment_param);
spin_unlock(&resource_alignment_lock);
return count;
}
-static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
-{
- return pci_get_resource_alignment_param(buf, PAGE_SIZE);
-}
-
static ssize_t resource_alignment_store(struct bus_type *bus,
const char *buf, size_t count)
{
- return pci_set_resource_alignment_param(buf, count);
+ char *param = kstrndup(buf, count, GFP_KERNEL);
+
+ if (!param)
+ return -ENOMEM;
+
+ spin_lock(&resource_alignment_lock);
+ kfree(resource_alignment_param);
+ resource_alignment_param = param;
+ spin_unlock(&resource_alignment_lock);
+ return count;
}
static BUS_ATTR_RW(resource_alignment);