Skip to content

Commit 45c16fe

Browse files
andy-shevrafaeljw
authored andcommitted
ACPI: configfs: Make get_header() to return error pointer
Instead of duplicating error codes here and there, make get_header() to return error pointer. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent ae57338 commit 45c16fe

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

drivers/acpi/acpi_configfs.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ static inline struct acpi_table_header *get_header(struct config_item *cfg)
7070
if (!table->header)
7171
pr_err("table not loaded\n");
7272

73-
return table->header;
73+
return table->header ?: ERR_PTR(-EINVAL);
7474
}
7575

7676
static ssize_t acpi_table_aml_read(struct config_item *cfg,
7777
void *data, size_t size)
7878
{
7979
struct acpi_table_header *h = get_header(cfg);
8080

81-
if (!h)
82-
return -EINVAL;
81+
if (IS_ERR(h))
82+
return PTR_ERR(h);
8383

8484
if (data)
8585
memcpy(data, h, h->length);
@@ -100,8 +100,8 @@ static ssize_t acpi_table_signature_show(struct config_item *cfg, char *str)
100100
{
101101
struct acpi_table_header *h = get_header(cfg);
102102

103-
if (!h)
104-
return -EINVAL;
103+
if (IS_ERR(h))
104+
return PTR_ERR(h);
105105

106106
return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->signature);
107107
}
@@ -110,8 +110,8 @@ static ssize_t acpi_table_length_show(struct config_item *cfg, char *str)
110110
{
111111
struct acpi_table_header *h = get_header(cfg);
112112

113-
if (!h)
114-
return -EINVAL;
113+
if (IS_ERR(h))
114+
return PTR_ERR(h);
115115

116116
return sysfs_emit(str, "%d\n", h->length);
117117
}
@@ -120,8 +120,8 @@ static ssize_t acpi_table_revision_show(struct config_item *cfg, char *str)
120120
{
121121
struct acpi_table_header *h = get_header(cfg);
122122

123-
if (!h)
124-
return -EINVAL;
123+
if (IS_ERR(h))
124+
return PTR_ERR(h);
125125

126126
return sysfs_emit(str, "%d\n", h->revision);
127127
}
@@ -130,8 +130,8 @@ static ssize_t acpi_table_oem_id_show(struct config_item *cfg, char *str)
130130
{
131131
struct acpi_table_header *h = get_header(cfg);
132132

133-
if (!h)
134-
return -EINVAL;
133+
if (IS_ERR(h))
134+
return PTR_ERR(h);
135135

136136
return sysfs_emit(str, "%.*s\n", ACPI_OEM_ID_SIZE, h->oem_id);
137137
}
@@ -140,8 +140,8 @@ static ssize_t acpi_table_oem_table_id_show(struct config_item *cfg, char *str)
140140
{
141141
struct acpi_table_header *h = get_header(cfg);
142142

143-
if (!h)
144-
return -EINVAL;
143+
if (IS_ERR(h))
144+
return PTR_ERR(h);
145145

146146
return sysfs_emit(str, "%.*s\n", ACPI_OEM_TABLE_ID_SIZE, h->oem_table_id);
147147
}
@@ -150,8 +150,8 @@ static ssize_t acpi_table_oem_revision_show(struct config_item *cfg, char *str)
150150
{
151151
struct acpi_table_header *h = get_header(cfg);
152152

153-
if (!h)
154-
return -EINVAL;
153+
if (IS_ERR(h))
154+
return PTR_ERR(h);
155155

156156
return sysfs_emit(str, "%d\n", h->oem_revision);
157157
}
@@ -161,8 +161,8 @@ static ssize_t acpi_table_asl_compiler_id_show(struct config_item *cfg,
161161
{
162162
struct acpi_table_header *h = get_header(cfg);
163163

164-
if (!h)
165-
return -EINVAL;
164+
if (IS_ERR(h))
165+
return PTR_ERR(h);
166166

167167
return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->asl_compiler_id);
168168
}
@@ -172,8 +172,8 @@ static ssize_t acpi_table_asl_compiler_revision_show(struct config_item *cfg,
172172
{
173173
struct acpi_table_header *h = get_header(cfg);
174174

175-
if (!h)
176-
return -EINVAL;
175+
if (IS_ERR(h))
176+
return PTR_ERR(h);
177177

178178
return sysfs_emit(str, "%d\n", h->asl_compiler_revision);
179179
}

0 commit comments

Comments
 (0)