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.
Unified · Split
| @@ -289,11 +289,6 @@ static const struct attribute_group *bus_attr_groups[] = { · 288 unmodified lines | |||
| 289 | NULL, | 289 | NULL, |
| 290 | }; | 290 | }; |
| 291 | 291 | ||
| 292 | static const struct attribute_group *papr_scm_dimm_groups[] = { | ||
| 293 | &nvdimm_attribute_group, | ||
| 294 | NULL, | ||
| 295 | }; | ||
| 296 | |||
| 297 | static inline int papr_scm_node(int node) | 292 | static 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; |
| @@ -1698,7 +1698,6 @@ static const struct attribute_group acpi_nfit_dimm_attribute_group = { · 1697 unmodified lines | |||
| 1698 | }; | 1698 | }; |
| 1699 | 1699 | ||
| 1700 | static const struct attribute_group *acpi_nfit_dimm_attribute_groups[] = { | 1700 | static 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 | }; |
| @@ -202,22 +202,6 @@ static void nvdimm_release(struct device *dev) · 201 unmodified lines | |||
| 202 | kfree(nvdimm); | 202 | kfree(nvdimm); |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 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 | |||
| 221 | struct nvdimm *to_nvdimm(struct device *dev) | 205 | struct 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 | ||
| 459 | struct attribute_group nvdimm_attribute_group = { | 443 | static 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 | }; |
| 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 | } | ||
| 464 | 464 | ||
| 465 | struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus, | 465 | struct 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, |
| @@ -66,7 +66,6 @@ enum { · 65 unmodified lines | |||
| 66 | }; | 66 | }; |
| 67 | 67 | ||
| 68 | extern struct attribute_group nvdimm_bus_attribute_group; | 68 | extern struct attribute_group nvdimm_bus_attribute_group; |
| 69 | extern struct attribute_group nvdimm_attribute_group; | ||
| 70 | 69 | ||
| 71 | struct nvdimm; | 70 | struct nvdimm; |
| 72 | struct nvdimm_bus_descriptor; | 71 | struct nvdimm_bus_descriptor; |