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
289 NULL,289 NULL,
290};290};
291 291
292static const struct attribute_group *papr_scm_dimm_groups[] = {
293 &nvdimm_attribute_group,
294 NULL,
295};
296
297static inline int papr_scm_node(int node)292static inline int papr_scm_node(int node)
298{293{
299 int min_dist = INT_MAX, dist;294 int min_dist = INT_MAX, dist;
@@ -339,8 +334,8 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p) · 39 unmodified lines
339 dimm_flags = 0;334 dimm_flags = 0;
340 set_bit(NDD_ALIASING, &dimm_flags);335 set_bit(NDD_ALIASING, &dimm_flags);
341 336
342 p->nvdimm = nvdimm_create(p->bus, p, papr_scm_dimm_groups,337 p->nvdimm = nvdimm_create(p->bus, p, NULL, dimm_flags,
343 dimm_flags, PAPR_SCM_DIMM_CMD_MASK, 0, NULL);338 PAPR_SCM_DIMM_CMD_MASK, 0, NULL);
344 if (!p->nvdimm) {339 if (!p->nvdimm) {
345 dev_err(dev, "Error creating DIMM object for %pOF\n", p->dn);340 dev_err(dev, "Error creating DIMM object for %pOF\n", p->dn);
346 goto err;341 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
1698};1698};
1699 1699
1700static const struct attribute_group *acpi_nfit_dimm_attribute_groups[] = {1700static const struct attribute_group *acpi_nfit_dimm_attribute_groups[] = {
1701 &nvdimm_attribute_group,
1702 &acpi_nfit_dimm_attribute_group,1701 &acpi_nfit_dimm_attribute_group,
1703 NULL,1702 NULL,
1704};1703};
drivers/nvdimm/dimm_devs.c+18−18
@@ -202,22 +202,6 @@ static void nvdimm_release(struct device *dev) · 201 unmodified lines
202 kfree(nvdimm);202 kfree(nvdimm);
203}203}
204 204
205static const struct attribute_group *nvdimm_attribute_groups[] = {
206 &nd_device_attribute_group,
207 NULL,
208};
209
210static const struct device_type nvdimm_device_type = {
211 .name = "nvdimm",
212 .release = nvdimm_release,
213 .groups = nvdimm_attribute_groups,
214};
215
216bool is_nvdimm(struct device *dev)
217{
218 return dev->type == &nvdimm_device_type;
219}
220
221struct nvdimm *to_nvdimm(struct device *dev)205struct nvdimm *to_nvdimm(struct device *dev)
222{206{
223 struct nvdimm *nvdimm = container_of(dev, struct nvdimm, dev);207 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
456 return 0;440 return 0;
457}441}
458 442
459struct attribute_group nvdimm_attribute_group = {443static const struct attribute_group nvdimm_attribute_group = {
460 .attrs = nvdimm_attributes,444 .attrs = nvdimm_attributes,
461 .is_visible = nvdimm_visible,445 .is_visible = nvdimm_visible,
462};446};
463EXPORT_SYMBOL_GPL(nvdimm_attribute_group);447
448static const struct attribute_group *nvdimm_attribute_groups[] = {
449 &nd_device_attribute_group,
450 &nvdimm_attribute_group,
451 NULL,
452};
453
454static const struct device_type nvdimm_device_type = {
455 .name = "nvdimm",
456 .release = nvdimm_release,
457 .groups = nvdimm_attribute_groups,
458};
459
460bool is_nvdimm(struct device *dev)
461{
462 return dev->type == &nvdimm_device_type;
463}
464 464
465struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus,465struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus,
466 void *provider_data, const struct attribute_group **groups,466 void *provider_data, const struct attribute_group **groups,
include/linux/libnvdimm.h+0−1
@@ -66,7 +66,6 @@ enum { · 65 unmodified lines
66};66};
67 67
68extern struct attribute_group nvdimm_bus_attribute_group;68extern struct attribute_group nvdimm_bus_attribute_group;
69extern struct attribute_group nvdimm_attribute_group;
70 69
71struct nvdimm;70struct nvdimm;
72struct nvdimm_bus_descriptor;71struct 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