Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5aaba363 authored by Sudeep Holla's avatar Sudeep Holla Committed by Greg Kroah-Hartman
Browse files

cpumask: factor out show_cpumap into separate helper function



Many sysfs *_show function use cpu{list,mask}_scnprintf to copy cpumap
to the buffer aligned to PAGE_SIZE, append '\n' and '\0' to return null
terminated buffer with newline.

This patch creates a new helper function cpumap_print_to_pagebuf in
cpumask.h using newly added bitmap_print_to_pagebuf and consolidates
most of those sysfs functions using the new helper function.

Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
Suggested-by: default avatarStephen Boyd <sboyd@codeaurora.org>
Tested-by: default avatarStephen Boyd <sboyd@codeaurora.org>
Acked-by: default avatar"Rafael J. Wysocki" <rjw@rjwysocki.net>
Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: x86@kernel.org
Cc: linux-acpi@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0372ffb3
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -130,10 +130,7 @@ static ssize_t _iommu_cpumask_show(struct device *dev,
				   struct device_attribute *attr,
				   char *buf)
{
	int n = cpulist_scnprintf(buf, PAGE_SIZE - 2, &iommu_cpumask);
	buf[n++] = '\n';
	buf[n] = '\0';
	return n;
	return cpumap_print_to_pagebuf(true, buf, &iommu_cpumask);
}
static DEVICE_ATTR(cpumask, S_IRUGO, _iommu_cpumask_show, NULL);

+1 −5
Original line number Diff line number Diff line
@@ -219,7 +219,6 @@ static ssize_t amd_uncore_attr_show_cpumask(struct device *dev,
					    struct device_attribute *attr,
					    char *buf)
{
	int n;
	cpumask_t *active_mask;
	struct pmu *pmu = dev_get_drvdata(dev);

@@ -230,10 +229,7 @@ static ssize_t amd_uncore_attr_show_cpumask(struct device *dev,
	else
		return 0;

	n = cpulist_scnprintf(buf, PAGE_SIZE - 2, active_mask);
	buf[n++] = '\n';
	buf[n] = '\0';
	return n;
	return cpumap_print_to_pagebuf(true, buf, active_mask);
}
static DEVICE_ATTR(cpumask, S_IRUGO, amd_uncore_attr_show_cpumask, NULL);

+1 −5
Original line number Diff line number Diff line
@@ -365,11 +365,7 @@ static void rapl_pmu_event_read(struct perf_event *event)
static ssize_t rapl_get_attr_cpumask(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	int n = cpulist_scnprintf(buf, PAGE_SIZE - 2, &rapl_cpu_mask);

	buf[n++] = '\n';
	buf[n] = '\0';
	return n;
	return cpumap_print_to_pagebuf(true, buf, &rapl_cpu_mask);
}

static DEVICE_ATTR(cpumask, S_IRUGO, rapl_get_attr_cpumask, NULL);
+1 −5
Original line number Diff line number Diff line
@@ -647,11 +647,7 @@ static int uncore_pmu_event_init(struct perf_event *event)
static ssize_t uncore_get_attr_cpumask(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	int n = cpulist_scnprintf(buf, PAGE_SIZE - 2, &uncore_cpu_mask);

	buf[n++] = '\n';
	buf[n] = '\0';
	return n;
	return cpumap_print_to_pagebuf(true, buf, &uncore_cpu_mask);
}

static DEVICE_ATTR(cpumask, S_IRUGO, uncore_get_attr_cpumask, NULL);
+3 −5
Original line number Diff line number Diff line
@@ -350,12 +350,10 @@ static ssize_t acpi_pad_idlecpus_store(struct device *dev,
static ssize_t acpi_pad_idlecpus_show(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	int n = 0;
	n = cpumask_scnprintf(buf, PAGE_SIZE-2, to_cpumask(pad_busy_cpus_bits));
	buf[n++] = '\n';
	buf[n] = '\0';
	return n;
	return cpumap_print_to_pagebuf(false, buf,
				       to_cpumask(pad_busy_cpus_bits));
}

static DEVICE_ATTR(idlecpus, S_IRUGO|S_IWUSR,
	acpi_pad_idlecpus_show,
	acpi_pad_idlecpus_store);
Loading