Commit 71327000 authored by Bjorn Helgaas's avatar Bjorn Helgaas
Browse files

Merge branch 'pci/sysfs'

- Fix dsm_label_utf16s_to_utf8s() buffer overrun (Krzysztof Wilczyński)

- Use sysfs_emit() and sysfs_emit_at() in "show" functions (Krzysztof
  Wilczyński)

- Fix 'resource_alignment' newline issues (Krzysztof Wilczyński)

- Add newline to 'devspec' sysfs file (Krzysztof Wilczyński)

* pci/sysfs:
  PCI/sysfs: Add 'devspec' newline
  PCI/sysfs: Fix 'resource_alignment' newline issues
  PCI/sysfs: Use sysfs_emit() and sysfs_emit_at() in "show" functions
  PCI/sysfs: Rely on lengths from scnprintf(), dsm_label_utf16s_to_utf8s()
  PCI/sysfs: Fix dsm_label_utf16s_to_utf8s() buffer overrun

# Conflicts:
#	drivers/pci/p2pdma.c
parents 131e4f76 14c19b2a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ static ssize_t power_read_file(struct pci_slot *pci_slot, char *buf)
	if (retval)
		return retval;

	return sprintf(buf, "%d\n", value);
	return sysfs_emit(buf, "%d\n", value);
}

static ssize_t power_write_file(struct pci_slot *pci_slot, const char *buf,
@@ -130,7 +130,7 @@ static ssize_t attention_read_file(struct pci_slot *pci_slot, char *buf)
	if (retval)
		return retval;

	return sprintf(buf, "%d\n", value);
	return sysfs_emit(buf, "%d\n", value);
}

static ssize_t attention_write_file(struct pci_slot *pci_slot, const char *buf,
@@ -175,7 +175,7 @@ static ssize_t latch_read_file(struct pci_slot *pci_slot, char *buf)
	if (retval)
		return retval;

	return sprintf(buf, "%d\n", value);
	return sysfs_emit(buf, "%d\n", value);
}

static struct pci_slot_attribute hotplug_slot_attr_latch = {
@@ -192,7 +192,7 @@ static ssize_t presence_read_file(struct pci_slot *pci_slot, char *buf)
	if (retval)
		return retval;

	return sprintf(buf, "%d\n", value);
	return sysfs_emit(buf, "%d\n", value);
}

static struct pci_slot_attribute hotplug_slot_attr_presence = {
+2 −2
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ static ssize_t add_slot_store(struct kobject *kobj, struct kobj_attribute *attr,
static ssize_t add_slot_show(struct kobject *kobj,
			     struct kobj_attribute *attr, char *buf)
{
	return sprintf(buf, "0\n");
	return sysfs_emit(buf, "0\n");
}

static ssize_t remove_slot_store(struct kobject *kobj,
@@ -80,7 +80,7 @@ static ssize_t remove_slot_store(struct kobject *kobj,
static ssize_t remove_slot_show(struct kobject *kobj,
				struct kobj_attribute *attr, char *buf)
{
	return sprintf(buf, "0\n");
	return sysfs_emit(buf, "0\n");
}

static struct kobj_attribute add_slot_attr =
+21 −17
Original line number Diff line number Diff line
@@ -24,50 +24,54 @@
static ssize_t show_ctrl(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct pci_dev *pdev;
	char *out = buf;
	int index, busnr;
	struct resource *res;
	struct pci_bus *bus;
	size_t len = 0;

	pdev = to_pci_dev(dev);
	bus = pdev->subordinate;

	out += sprintf(buf, "Free resources: memory\n");
	len += sysfs_emit_at(buf, len, "Free resources: memory\n");
	pci_bus_for_each_resource(bus, res, index) {
		if (res && (res->flags & IORESOURCE_MEM) &&
				!(res->flags & IORESOURCE_PREFETCH)) {
			out += sprintf(out, "start = %8.8llx, length = %8.8llx\n",
			len += sysfs_emit_at(buf, len,
					     "start = %8.8llx, length = %8.8llx\n",
					     (unsigned long long)res->start,
					     (unsigned long long)resource_size(res));
		}
	}
	out += sprintf(out, "Free resources: prefetchable memory\n");
	len += sysfs_emit_at(buf, len, "Free resources: prefetchable memory\n");
	pci_bus_for_each_resource(bus, res, index) {
		if (res && (res->flags & IORESOURCE_MEM) &&
			       (res->flags & IORESOURCE_PREFETCH)) {
			out += sprintf(out, "start = %8.8llx, length = %8.8llx\n",
			len += sysfs_emit_at(buf, len,
					     "start = %8.8llx, length = %8.8llx\n",
					     (unsigned long long)res->start,
					     (unsigned long long)resource_size(res));
		}
	}
	out += sprintf(out, "Free resources: IO\n");
	len += sysfs_emit_at(buf, len, "Free resources: IO\n");
	pci_bus_for_each_resource(bus, res, index) {
		if (res && (res->flags & IORESOURCE_IO)) {
			out += sprintf(out, "start = %8.8llx, length = %8.8llx\n",
			len += sysfs_emit_at(buf, len,
					     "start = %8.8llx, length = %8.8llx\n",
					     (unsigned long long)res->start,
					     (unsigned long long)resource_size(res));
		}
	}
	out += sprintf(out, "Free resources: bus numbers\n");
	len += sysfs_emit_at(buf, len, "Free resources: bus numbers\n");
	for (busnr = bus->busn_res.start; busnr <= bus->busn_res.end; busnr++) {
		if (!pci_find_bus(pci_domain_nr(bus), busnr))
			break;
	}
	if (busnr < bus->busn_res.end)
		out += sprintf(out, "start = %8.8x, length = %8.8x\n",
		len += sysfs_emit_at(buf, len,
				     "start = %8.8x, length = %8.8x\n",
				     busnr, (int)(bus->busn_res.end - busnr));

	return out - buf;
	return len;
}
static DEVICE_ATTR(ctrl, S_IRUGO, show_ctrl, NULL);

+6 −6
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ static ssize_t sriov_totalvfs_show(struct device *dev,
{
	struct pci_dev *pdev = to_pci_dev(dev);

	return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev));
	return sysfs_emit(buf, "%u\n", pci_sriov_get_totalvfs(pdev));
}

static ssize_t sriov_numvfs_show(struct device *dev,
@@ -361,7 +361,7 @@ static ssize_t sriov_numvfs_show(struct device *dev,
	num_vfs = pdev->sriov->num_VFs;
	device_unlock(&pdev->dev);

	return sprintf(buf, "%u\n", num_vfs);
	return sysfs_emit(buf, "%u\n", num_vfs);
}

/*
@@ -435,7 +435,7 @@ static ssize_t sriov_offset_show(struct device *dev,
{
	struct pci_dev *pdev = to_pci_dev(dev);

	return sprintf(buf, "%u\n", pdev->sriov->offset);
	return sysfs_emit(buf, "%u\n", pdev->sriov->offset);
}

static ssize_t sriov_stride_show(struct device *dev,
@@ -444,7 +444,7 @@ static ssize_t sriov_stride_show(struct device *dev,
{
	struct pci_dev *pdev = to_pci_dev(dev);

	return sprintf(buf, "%u\n", pdev->sriov->stride);
	return sysfs_emit(buf, "%u\n", pdev->sriov->stride);
}

static ssize_t sriov_vf_device_show(struct device *dev,
@@ -453,7 +453,7 @@ static ssize_t sriov_vf_device_show(struct device *dev,
{
	struct pci_dev *pdev = to_pci_dev(dev);

	return sprintf(buf, "%x\n", pdev->sriov->vf_device);
	return sysfs_emit(buf, "%x\n", pdev->sriov->vf_device);
}

static ssize_t sriov_drivers_autoprobe_show(struct device *dev,
@@ -462,7 +462,7 @@ static ssize_t sriov_drivers_autoprobe_show(struct device *dev,
{
	struct pci_dev *pdev = to_pci_dev(dev);

	return sprintf(buf, "%u\n", pdev->sriov->drivers_autoprobe);
	return sysfs_emit(buf, "%u\n", pdev->sriov->drivers_autoprobe);
}

static ssize_t sriov_drivers_autoprobe_store(struct device *dev,
+4 −4
Original line number Diff line number Diff line
@@ -464,11 +464,11 @@ static ssize_t msi_mode_show(struct device *dev, struct device_attribute *attr,
		return retval;

	entry = irq_get_msi_desc(irq);
	if (entry)
		return sprintf(buf, "%s\n",
				entry->msi_attrib.is_msix ? "msix" : "msi");

	if (!entry)
		return -ENODEV;

	return sysfs_emit(buf, "%s\n",
			  entry->msi_attrib.is_msix ? "msix" : "msi");
}

static int populate_msi_sysfs(struct pci_dev *pdev)
Loading