Commit e7a11b44 authored by Dan Williams's avatar Dan Williams

nfit: cleanup acpi_nfit_init calling convention

Pass the nfit buffer as a parameter rather than hanging it off of
acpi_desc.
Reviewed-by: default avatar"Lee, Chun-Yi" <jlee@suse.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 31932041
...@@ -2291,12 +2291,11 @@ static int acpi_nfit_check_deletions(struct acpi_nfit_desc *acpi_desc, ...@@ -2291,12 +2291,11 @@ static int acpi_nfit_check_deletions(struct acpi_nfit_desc *acpi_desc,
return 0; return 0;
} }
int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, acpi_size sz) int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, void *data, acpi_size sz)
{ {
struct device *dev = acpi_desc->dev; struct device *dev = acpi_desc->dev;
struct nfit_table_prev prev; struct nfit_table_prev prev;
const void *end; const void *end;
u8 *data;
int rc; int rc;
mutex_lock(&acpi_desc->init_mutex); mutex_lock(&acpi_desc->init_mutex);
...@@ -2321,7 +2320,6 @@ int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, acpi_size sz) ...@@ -2321,7 +2320,6 @@ int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, acpi_size sz)
list_cut_position(&prev.flushes, &acpi_desc->flushes, list_cut_position(&prev.flushes, &acpi_desc->flushes,
acpi_desc->flushes.prev); acpi_desc->flushes.prev);
data = (u8 *) acpi_desc->nfit;
end = data + sz; end = data + sz;
while (!IS_ERR_OR_NULL(data)) while (!IS_ERR_OR_NULL(data))
data = add_table(acpi_desc, &prev, data, end); data = add_table(acpi_desc, &prev, data, end);
...@@ -2461,40 +2459,30 @@ static int acpi_nfit_add(struct acpi_device *adev) ...@@ -2461,40 +2459,30 @@ static int acpi_nfit_add(struct acpi_device *adev)
if (!acpi_desc->nvdimm_bus) if (!acpi_desc->nvdimm_bus)
return -ENOMEM; return -ENOMEM;
/* /* Save the acpi header for exporting the revision via sysfs */
* Save the acpi header for later and then skip it,
* making nfit point to the first nfit table header.
*/
acpi_desc->acpi_header = *tbl; acpi_desc->acpi_header = *tbl;
acpi_desc->nfit = (void *) tbl + sizeof(struct acpi_table_nfit);
sz -= sizeof(struct acpi_table_nfit);
/* Evaluate _FIT and override with that if present */ /* Evaluate _FIT and override with that if present */
status = acpi_evaluate_object(adev->handle, "_FIT", NULL, &buf); status = acpi_evaluate_object(adev->handle, "_FIT", NULL, &buf);
if (ACPI_SUCCESS(status) && buf.length > 0) { if (ACPI_SUCCESS(status) && buf.length > 0) {
union acpi_object *obj; union acpi_object *obj = buf.pointer;
/*
* Adjust for the acpi_object header of the _FIT if (obj->type == ACPI_TYPE_BUFFER)
*/ rc = acpi_nfit_init(acpi_desc, obj->buffer.pointer,
obj = buf.pointer; obj->buffer.length);
if (obj->type == ACPI_TYPE_BUFFER) { else
acpi_desc->nfit =
(struct acpi_nfit_header *)obj->buffer.pointer;
sz = obj->buffer.length;
rc = acpi_nfit_init(acpi_desc, sz);
} else
dev_dbg(dev, "%s invalid type %d, ignoring _FIT\n", dev_dbg(dev, "%s invalid type %d, ignoring _FIT\n",
__func__, (int) obj->type); __func__, (int) obj->type);
acpi_desc->nfit = NULL;
kfree(buf.pointer); kfree(buf.pointer);
} else } else
rc = acpi_nfit_init(acpi_desc, sz); /* skip over the lead-in header table */
rc = acpi_nfit_init(acpi_desc, (void *) tbl
+ sizeof(struct acpi_table_nfit),
sz - sizeof(struct acpi_table_nfit));
if (rc) { if (rc)
nvdimm_bus_unregister(acpi_desc->nvdimm_bus); nvdimm_bus_unregister(acpi_desc->nvdimm_bus);
return rc; return rc;
}
return 0;
} }
static int acpi_nfit_remove(struct acpi_device *adev) static int acpi_nfit_remove(struct acpi_device *adev)
...@@ -2511,8 +2499,8 @@ static void acpi_nfit_notify(struct acpi_device *adev, u32 event) ...@@ -2511,8 +2499,8 @@ static void acpi_nfit_notify(struct acpi_device *adev, u32 event)
{ {
struct acpi_nfit_desc *acpi_desc = dev_get_drvdata(&adev->dev); struct acpi_nfit_desc *acpi_desc = dev_get_drvdata(&adev->dev);
struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *obj;
struct device *dev = &adev->dev; struct device *dev = &adev->dev;
union acpi_object *obj;
acpi_status status; acpi_status status;
int ret; int ret;
...@@ -2550,14 +2538,12 @@ static void acpi_nfit_notify(struct acpi_device *adev, u32 event) ...@@ -2550,14 +2538,12 @@ static void acpi_nfit_notify(struct acpi_device *adev, u32 event)
obj = buf.pointer; obj = buf.pointer;
if (obj->type == ACPI_TYPE_BUFFER) { if (obj->type == ACPI_TYPE_BUFFER) {
acpi_desc->nfit = ret = acpi_nfit_init(acpi_desc, obj->buffer.pointer,
(struct acpi_nfit_header *)obj->buffer.pointer; obj->buffer.length);
ret = acpi_nfit_init(acpi_desc, obj->buffer.length);
if (ret) if (ret)
dev_err(dev, "failed to merge updated NFIT\n"); dev_err(dev, "failed to merge updated NFIT\n");
} else } else
dev_err(dev, "Invalid _FIT\n"); dev_err(dev, "Invalid _FIT\n");
acpi_desc->nfit = NULL;
kfree(buf.pointer); kfree(buf.pointer);
out_unlock: out_unlock:
......
...@@ -135,7 +135,6 @@ struct nfit_mem { ...@@ -135,7 +135,6 @@ struct nfit_mem {
struct acpi_nfit_desc { struct acpi_nfit_desc {
struct nvdimm_bus_descriptor nd_desc; struct nvdimm_bus_descriptor nd_desc;
struct acpi_table_header acpi_header; struct acpi_table_header acpi_header;
struct acpi_nfit_header *nfit;
struct mutex init_mutex; struct mutex init_mutex;
struct list_head memdevs; struct list_head memdevs;
struct list_head flushes; struct list_head flushes;
...@@ -201,6 +200,6 @@ static inline struct acpi_nfit_desc *to_acpi_desc( ...@@ -201,6 +200,6 @@ static inline struct acpi_nfit_desc *to_acpi_desc(
} }
const u8 *to_nfit_uuid(enum nfit_uuids id); const u8 *to_nfit_uuid(enum nfit_uuids id);
int acpi_nfit_init(struct acpi_nfit_desc *nfit, acpi_size sz); int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, void *nfit, acpi_size sz);
void acpi_nfit_desc_init(struct acpi_nfit_desc *acpi_desc, struct device *dev); void acpi_nfit_desc_init(struct acpi_nfit_desc *acpi_desc, struct device *dev);
#endif /* __NFIT_H__ */ #endif /* __NFIT_H__ */
...@@ -1460,7 +1460,6 @@ static int nfit_test_probe(struct platform_device *pdev) ...@@ -1460,7 +1460,6 @@ static int nfit_test_probe(struct platform_device *pdev)
nfit_test->setup(nfit_test); nfit_test->setup(nfit_test);
acpi_desc = &nfit_test->acpi_desc; acpi_desc = &nfit_test->acpi_desc;
acpi_nfit_desc_init(acpi_desc, &pdev->dev); acpi_nfit_desc_init(acpi_desc, &pdev->dev);
acpi_desc->nfit = nfit_test->nfit_buf;
acpi_desc->blk_do_io = nfit_test_blk_do_io; acpi_desc->blk_do_io = nfit_test_blk_do_io;
nd_desc = &acpi_desc->nd_desc; nd_desc = &acpi_desc->nd_desc;
nd_desc->provider_name = NULL; nd_desc->provider_name = NULL;
...@@ -1469,7 +1468,8 @@ static int nfit_test_probe(struct platform_device *pdev) ...@@ -1469,7 +1468,8 @@ static int nfit_test_probe(struct platform_device *pdev)
if (!acpi_desc->nvdimm_bus) if (!acpi_desc->nvdimm_bus)
return -ENXIO; return -ENXIO;
rc = acpi_nfit_init(acpi_desc, nfit_test->nfit_size); rc = acpi_nfit_init(acpi_desc, nfit_test->nfit_buf,
nfit_test->nfit_size);
if (rc) { if (rc) {
nvdimm_bus_unregister(acpi_desc->nvdimm_bus); nvdimm_bus_unregister(acpi_desc->nvdimm_bus);
return rc; return rc;
...@@ -1481,7 +1481,8 @@ static int nfit_test_probe(struct platform_device *pdev) ...@@ -1481,7 +1481,8 @@ static int nfit_test_probe(struct platform_device *pdev)
nfit_test->setup_hotplug = 1; nfit_test->setup_hotplug = 1;
nfit_test->setup(nfit_test); nfit_test->setup(nfit_test);
rc = acpi_nfit_init(acpi_desc, nfit_test->nfit_size); rc = acpi_nfit_init(acpi_desc, nfit_test->nfit_buf,
nfit_test->nfit_size);
if (rc) { if (rc) {
nvdimm_bus_unregister(acpi_desc->nvdimm_bus); nvdimm_bus_unregister(acpi_desc->nvdimm_bus);
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment