History

libnvdimm: Move nvdimm_attribute_group to device_type

A 'struct device_type' instance can carry default attributes for the device. Use this facility to remove the export of nvdimm_attribute_group and put the responsibility on the core rather than leaf implementations to define this attribute.

Dan Williams committed 7 years ago

Commit 360eba71 parent 4ce79fa4 files · +20 −27Browse files

Unified · Split

4 files
  1. arch/powerpc/platforms/pseries/papr_scm.c +2 −7
  2. drivers/acpi/nfit/core.c +0 −1
  3. drivers/nvdimm/dimm_devs.c +18 −18
  4. include/linux/libnvdimm.h +0 −1
arch/powerpc/platforms/pseries/papr_scm.c+2−7
@@ -289,11 +289,6 @@ static const struct attribute_group *bus_attr_groups[] = { · 288 unmodified lines
289289 NULL,
290290 };
291291
292−static const struct attribute_group *papr_scm_dimm_groups[] = {
293− &nvdimm_attribute_group,
294− NULL,
295−};
296−
297292 static inline int papr_scm_node(int node)
298293 {
299294 int min_dist = INT_MAX, dist;
@@ -339,8 +334,8 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p) · 39 unmodified lines
339334 dimm_flags = 0;
340335 set_bit(NDD_ALIASING, &dimm_flags);
341336
342− p->nvdimm = nvdimm_create(p->bus, p, papr_scm_dimm_groups,
343− dimm_flags, PAPR_SCM_DIMM_CMD_MASK, 0, NULL);
337+ p->nvdimm = nvdimm_create(p->bus, p, NULL, dimm_flags,
338+ PAPR_SCM_DIMM_CMD_MASK, 0, NULL);
344339 if (!p->nvdimm) {
345340 dev_err(dev, "Error creating DIMM object for %pOF\n", p->dn);
346341 goto err;
drivers/acpi/nfit/core.c+0−1
@@ -1698,7 +1698,6 @@ static const struct attribute_group acpi_nfit_dimm_attribute_group = { · 1697 unmodified lines
16981698 };
16991699
17001700 static const struct attribute_group *acpi_nfit_dimm_attribute_groups[] = {
1701− &nvdimm_attribute_group,
17021701 &acpi_nfit_dimm_attribute_group,
17031702 NULL,
17041703 };
drivers/nvdimm/dimm_devs.c+18−18
@@ -202,22 +202,6 @@ static void nvdimm_release(struct device *dev) · 201 unmodified lines
202202 kfree(nvdimm);
203203 }
204204
205−static const struct attribute_group *nvdimm_attribute_groups[] = {
206− &nd_device_attribute_group,
207− NULL,
208−};
209−
210−static const struct device_type nvdimm_device_type = {
211− .name = "nvdimm",
212− .release = nvdimm_release,
213− .groups = nvdimm_attribute_groups,
214−};
215−
216−bool is_nvdimm(struct device *dev)
217−{
218− return dev->type == &nvdimm_device_type;
219−}
220−
221205 struct nvdimm *to_nvdimm(struct device *dev)
222206 {
223207 struct nvdimm *nvdimm = container_of(dev, struct nvdimm, dev);
@@ -456,11 +440,27 @@ static umode_t nvdimm_visible(struct kobject *kobj, struct attribute *a, int n) · 232 unmodified lines
456440 return 0;
457441 }
458442
459−struct attribute_group nvdimm_attribute_group = {
443+static const struct attribute_group nvdimm_attribute_group = {
460444 .attrs = nvdimm_attributes,
461445 .is_visible = nvdimm_visible,
462446 };
463−EXPORT_SYMBOL_GPL(nvdimm_attribute_group);
447+
448+static const struct attribute_group *nvdimm_attribute_groups[] = {
449+ &nd_device_attribute_group,
450+ &nvdimm_attribute_group,
451+ NULL,
452+};
453+
454+static const struct device_type nvdimm_device_type = {
455+ .name = "nvdimm",
456+ .release = nvdimm_release,
457+ .groups = nvdimm_attribute_groups,
458+};
459+
460+bool is_nvdimm(struct device *dev)
461+{
462+ return dev->type == &nvdimm_device_type;
463+}
464464
465465 struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus,
466466 void *provider_data, const struct attribute_group **groups,
include/linux/libnvdimm.h+0−1
@@ -66,7 +66,6 @@ enum { · 65 unmodified lines
6666 };
6767
6868 extern struct attribute_group nvdimm_bus_attribute_group;
69−extern struct attribute_group nvdimm_attribute_group;
7069
7170 struct nvdimm;
7271 struct nvdimm_bus_descriptor;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t