nvme-pci: cmb sysfs: one file, one value
An attribute should only be exporting one value as recommended in Documentation/filesystems/sysfs.rst. Implement CMB attributes this way. The old attribute will remain for backward compatibility. Signed-off-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Родитель
0521905e85
Коммит
1751e97aa9
|
@ -2063,6 +2063,24 @@ static ssize_t cmb_show(struct device *dev, struct device_attribute *attr,
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR_RO(cmb);
|
static DEVICE_ATTR_RO(cmb);
|
||||||
|
|
||||||
|
static ssize_t cmbloc_show(struct device *dev, struct device_attribute *attr,
|
||||||
|
char *buf)
|
||||||
|
{
|
||||||
|
struct nvme_dev *ndev = to_nvme_dev(dev_get_drvdata(dev));
|
||||||
|
|
||||||
|
return sysfs_emit(buf, "%u\n", ndev->cmbloc);
|
||||||
|
}
|
||||||
|
static DEVICE_ATTR_RO(cmbloc);
|
||||||
|
|
||||||
|
static ssize_t cmbsz_show(struct device *dev, struct device_attribute *attr,
|
||||||
|
char *buf)
|
||||||
|
{
|
||||||
|
struct nvme_dev *ndev = to_nvme_dev(dev_get_drvdata(dev));
|
||||||
|
|
||||||
|
return sysfs_emit(buf, "%u\n", ndev->cmbsz);
|
||||||
|
}
|
||||||
|
static DEVICE_ATTR_RO(cmbsz);
|
||||||
|
|
||||||
static umode_t nvme_pci_attrs_are_visible(struct kobject *kobj,
|
static umode_t nvme_pci_attrs_are_visible(struct kobject *kobj,
|
||||||
struct attribute *a, int n)
|
struct attribute *a, int n)
|
||||||
{
|
{
|
||||||
|
@ -2070,13 +2088,19 @@ static umode_t nvme_pci_attrs_are_visible(struct kobject *kobj,
|
||||||
dev_get_drvdata(container_of(kobj, struct device, kobj));
|
dev_get_drvdata(container_of(kobj, struct device, kobj));
|
||||||
struct nvme_dev *dev = to_nvme_dev(ctrl);
|
struct nvme_dev *dev = to_nvme_dev(ctrl);
|
||||||
|
|
||||||
if (a == &dev_attr_cmb.attr && !dev->cmbsz)
|
if (a == &dev_attr_cmb.attr ||
|
||||||
return 0;
|
a == &dev_attr_cmbloc.attr ||
|
||||||
|
a == &dev_attr_cmbsz.attr) {
|
||||||
|
if (!dev->cmbsz)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return a->mode;
|
return a->mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct attribute *nvme_pci_attrs[] = {
|
static struct attribute *nvme_pci_attrs[] = {
|
||||||
&dev_attr_cmb.attr,
|
&dev_attr_cmb.attr,
|
||||||
|
&dev_attr_cmbloc.attr,
|
||||||
|
&dev_attr_cmbsz.attr,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче