From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Thu, 15 Jul 2021 17:16:51 +0300
Subject: ACPI: configfs: Make get_header() to return error pointer
Patch-mainline: v5.15-rc1
Git-commit: 45c16fe1d1283bdd3e32bd869bf5aa177fcd50f7
References: jsc#SLE-19223
Instead of duplicating error codes here and there,
make get_header() to return error pointer.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Lee, Chun-Yi <jlee@suse.com>
---
drivers/acpi/acpi_configfs.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
--- a/drivers/acpi/acpi_configfs.c
+++ b/drivers/acpi/acpi_configfs.c
@@ -70,7 +70,7 @@ static inline struct acpi_table_header *
if (!table->header)
pr_err("table not loaded\n");
- return table->header;
+ return table->header ?: ERR_PTR(-EINVAL);
}
static ssize_t acpi_table_aml_read(struct config_item *cfg,
@@ -78,8 +78,8 @@ static ssize_t acpi_table_aml_read(struc
{
struct acpi_table_header *h = get_header(cfg);
- if (!h)
- return -EINVAL;
+ if (IS_ERR(h))
+ return PTR_ERR(h);
if (data)
memcpy(data, h, h->length);
@@ -100,8 +100,8 @@ static ssize_t acpi_table_signature_show
{
struct acpi_table_header *h = get_header(cfg);
- if (!h)
- return -EINVAL;
+ if (IS_ERR(h))
+ return PTR_ERR(h);
return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->signature);
}
@@ -110,8 +110,8 @@ static ssize_t acpi_table_length_show(st
{
struct acpi_table_header *h = get_header(cfg);
- if (!h)
- return -EINVAL;
+ if (IS_ERR(h))
+ return PTR_ERR(h);
return sysfs_emit(str, "%d\n", h->length);
}
@@ -120,8 +120,8 @@ static ssize_t acpi_table_revision_show(
{
struct acpi_table_header *h = get_header(cfg);
- if (!h)
- return -EINVAL;
+ if (IS_ERR(h))
+ return PTR_ERR(h);
return sysfs_emit(str, "%d\n", h->revision);
}
@@ -130,8 +130,8 @@ static ssize_t acpi_table_oem_id_show(st
{
struct acpi_table_header *h = get_header(cfg);
- if (!h)
- return -EINVAL;
+ if (IS_ERR(h))
+ return PTR_ERR(h);
return sysfs_emit(str, "%.*s\n", ACPI_OEM_ID_SIZE, h->oem_id);
}
@@ -140,8 +140,8 @@ static ssize_t acpi_table_oem_table_id_s
{
struct acpi_table_header *h = get_header(cfg);
- if (!h)
- return -EINVAL;
+ if (IS_ERR(h))
+ return PTR_ERR(h);
return sysfs_emit(str, "%.*s\n", ACPI_OEM_TABLE_ID_SIZE, h->oem_table_id);
}
@@ -150,8 +150,8 @@ static ssize_t acpi_table_oem_revision_s
{
struct acpi_table_header *h = get_header(cfg);
- if (!h)
- return -EINVAL;
+ if (IS_ERR(h))
+ return PTR_ERR(h);
return sysfs_emit(str, "%d\n", h->oem_revision);
}
@@ -161,8 +161,8 @@ static ssize_t acpi_table_asl_compiler_i
{
struct acpi_table_header *h = get_header(cfg);
- if (!h)
- return -EINVAL;
+ if (IS_ERR(h))
+ return PTR_ERR(h);
return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->asl_compiler_id);
}
@@ -172,8 +172,8 @@ static ssize_t acpi_table_asl_compiler_r
{
struct acpi_table_header *h = get_header(cfg);
- if (!h)
- return -EINVAL;
+ if (IS_ERR(h))
+ return PTR_ERR(h);
return sysfs_emit(str, "%d\n", h->asl_compiler_revision);
}