* [PATCH v2] ACPI: NFIT: add helper to_nfit_mem() to take device to nfit_mem
@ 2023-07-12 12:08 Ben Dooks
2023-07-13 20:35 ` Alison Schofield
0 siblings, 1 reply; 2+ messages in thread
From: Ben Dooks @ 2023-07-12 12:08 UTC (permalink / raw)
To: nvdimm; +Cc: linux-acpi, Ben Dooks
Add a quick helper to just do struct device to the struct nfit_mem
field it should be referencing. This reduces the number of code
lines in some of the following code as it removes the intermediate
struct nvdimm.
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
v2:
- fix typo of follwoing
- add blank line in to_nfit_mem()
---
drivers/acpi/nfit/core.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 0fcc247fdfac..b04c8a41380a 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1361,18 +1361,23 @@ static const struct attribute_group *acpi_nfit_attribute_groups[] = {
NULL,
};
-static struct acpi_nfit_memory_map *to_nfit_memdev(struct device *dev)
+static struct nfit_mem *to_nfit_mem(struct device *dev)
{
struct nvdimm *nvdimm = to_nvdimm(dev);
- struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
+
+ return nvdimm_provider_data(nvdimm);
+}
+
+static struct acpi_nfit_memory_map *to_nfit_memdev(struct device *dev)
+{
+ struct nfit_mem *nfit_mem = to_nfit_mem(dev);
return __to_nfit_memdev(nfit_mem);
}
static struct acpi_nfit_control_region *to_nfit_dcr(struct device *dev)
{
- struct nvdimm *nvdimm = to_nvdimm(dev);
- struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
+ struct nfit_mem *nfit_mem = to_nfit_mem(dev);
return nfit_mem->dcr;
}
@@ -1531,8 +1536,7 @@ static DEVICE_ATTR_RO(serial);
static ssize_t family_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct nvdimm *nvdimm = to_nvdimm(dev);
- struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
+ struct nfit_mem *nfit_mem = to_nfit_mem(dev);
if (nfit_mem->family < 0)
return -ENXIO;
@@ -1543,8 +1547,7 @@ static DEVICE_ATTR_RO(family);
static ssize_t dsm_mask_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct nvdimm *nvdimm = to_nvdimm(dev);
- struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
+ struct nfit_mem *nfit_mem = to_nfit_mem(dev);
if (nfit_mem->family < 0)
return -ENXIO;
@@ -1555,8 +1558,7 @@ static DEVICE_ATTR_RO(dsm_mask);
static ssize_t flags_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct nvdimm *nvdimm = to_nvdimm(dev);
- struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
+ struct nfit_mem *nfit_mem = to_nfit_mem(dev);
u16 flags = __to_nfit_memdev(nfit_mem)->flags;
if (test_bit(NFIT_MEM_DIRTY, &nfit_mem->flags))
@@ -1576,8 +1578,7 @@ static DEVICE_ATTR_RO(flags);
static ssize_t id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct nvdimm *nvdimm = to_nvdimm(dev);
- struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
+ struct nfit_mem *nfit_mem = to_nfit_mem(dev);
return sprintf(buf, "%s\n", nfit_mem->id);
}
@@ -1586,8 +1587,7 @@ static DEVICE_ATTR_RO(id);
static ssize_t dirty_shutdown_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct nvdimm *nvdimm = to_nvdimm(dev);
- struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
+ struct nfit_mem *nfit_mem = to_nfit_mem(dev);
return sprintf(buf, "%d\n", nfit_mem->dirty_shutdown);
}
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] ACPI: NFIT: add helper to_nfit_mem() to take device to nfit_mem
2023-07-12 12:08 [PATCH v2] ACPI: NFIT: add helper to_nfit_mem() to take device to nfit_mem Ben Dooks
@ 2023-07-13 20:35 ` Alison Schofield
0 siblings, 0 replies; 2+ messages in thread
From: Alison Schofield @ 2023-07-13 20:35 UTC (permalink / raw)
To: Ben Dooks; +Cc: nvdimm, linux-acpi
On Wed, Jul 12, 2023 at 01:08:10PM +0100, Ben Dooks wrote:
> Add a quick helper to just do struct device to the struct nfit_mem
> field it should be referencing. This reduces the number of code
> lines in some of the following code as it removes the intermediate
> struct nvdimm.
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
> ---
> v2:
> - fix typo of follwoing
> - add blank line in to_nfit_mem()
> ---
> drivers/acpi/nfit/core.c | 28 ++++++++++++++--------------
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index 0fcc247fdfac..b04c8a41380a 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -1361,18 +1361,23 @@ static const struct attribute_group *acpi_nfit_attribute_groups[] = {
> NULL,
> };
>
> -static struct acpi_nfit_memory_map *to_nfit_memdev(struct device *dev)
> +static struct nfit_mem *to_nfit_mem(struct device *dev)
> {
> struct nvdimm *nvdimm = to_nvdimm(dev);
> - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
> +
> + return nvdimm_provider_data(nvdimm);
> +}
> +
> +static struct acpi_nfit_memory_map *to_nfit_memdev(struct device *dev)
> +{
> + struct nfit_mem *nfit_mem = to_nfit_mem(dev);
>
> return __to_nfit_memdev(nfit_mem);
> }
>
> static struct acpi_nfit_control_region *to_nfit_dcr(struct device *dev)
> {
> - struct nvdimm *nvdimm = to_nvdimm(dev);
> - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
> + struct nfit_mem *nfit_mem = to_nfit_mem(dev);
>
> return nfit_mem->dcr;
> }
> @@ -1531,8 +1536,7 @@ static DEVICE_ATTR_RO(serial);
> static ssize_t family_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> - struct nvdimm *nvdimm = to_nvdimm(dev);
> - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
> + struct nfit_mem *nfit_mem = to_nfit_mem(dev);
>
> if (nfit_mem->family < 0)
> return -ENXIO;
> @@ -1543,8 +1547,7 @@ static DEVICE_ATTR_RO(family);
> static ssize_t dsm_mask_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> - struct nvdimm *nvdimm = to_nvdimm(dev);
> - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
> + struct nfit_mem *nfit_mem = to_nfit_mem(dev);
>
> if (nfit_mem->family < 0)
> return -ENXIO;
> @@ -1555,8 +1558,7 @@ static DEVICE_ATTR_RO(dsm_mask);
> static ssize_t flags_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> - struct nvdimm *nvdimm = to_nvdimm(dev);
> - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
> + struct nfit_mem *nfit_mem = to_nfit_mem(dev);
> u16 flags = __to_nfit_memdev(nfit_mem)->flags;
>
> if (test_bit(NFIT_MEM_DIRTY, &nfit_mem->flags))
> @@ -1576,8 +1578,7 @@ static DEVICE_ATTR_RO(flags);
> static ssize_t id_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> - struct nvdimm *nvdimm = to_nvdimm(dev);
> - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
> + struct nfit_mem *nfit_mem = to_nfit_mem(dev);
>
> return sprintf(buf, "%s\n", nfit_mem->id);
> }
> @@ -1586,8 +1587,7 @@ static DEVICE_ATTR_RO(id);
> static ssize_t dirty_shutdown_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> - struct nvdimm *nvdimm = to_nvdimm(dev);
> - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
> + struct nfit_mem *nfit_mem = to_nfit_mem(dev);
>
> return sprintf(buf, "%d\n", nfit_mem->dirty_shutdown);
> }
> --
> 2.40.1
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-13 20:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-12 12:08 [PATCH v2] ACPI: NFIT: add helper to_nfit_mem() to take device to nfit_mem Ben Dooks
2023-07-13 20:35 ` Alison Schofield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox