Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Andy Shevchenko and committed by
Rafael J. Wysocki
45c16fe1 ae573387

+19 -19
+19 -19
drivers/acpi/acpi_configfs.c
··· 70 70 if (!table->header) 71 71 pr_err("table not loaded\n"); 72 72 73 - return table->header; 73 + return table->header ?: ERR_PTR(-EINVAL); 74 74 } 75 75 76 76 static ssize_t acpi_table_aml_read(struct config_item *cfg, ··· 78 78 { 79 79 struct acpi_table_header *h = get_header(cfg); 80 80 81 - if (!h) 82 - return -EINVAL; 81 + if (IS_ERR(h)) 82 + return PTR_ERR(h); 83 83 84 84 if (data) 85 85 memcpy(data, h, h->length); ··· 100 100 { 101 101 struct acpi_table_header *h = get_header(cfg); 102 102 103 - if (!h) 104 - return -EINVAL; 103 + if (IS_ERR(h)) 104 + return PTR_ERR(h); 105 105 106 106 return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->signature); 107 107 } ··· 110 110 { 111 111 struct acpi_table_header *h = get_header(cfg); 112 112 113 - if (!h) 114 - return -EINVAL; 113 + if (IS_ERR(h)) 114 + return PTR_ERR(h); 115 115 116 116 return sysfs_emit(str, "%d\n", h->length); 117 117 } ··· 120 120 { 121 121 struct acpi_table_header *h = get_header(cfg); 122 122 123 - if (!h) 124 - return -EINVAL; 123 + if (IS_ERR(h)) 124 + return PTR_ERR(h); 125 125 126 126 return sysfs_emit(str, "%d\n", h->revision); 127 127 } ··· 130 130 { 131 131 struct acpi_table_header *h = get_header(cfg); 132 132 133 - if (!h) 134 - return -EINVAL; 133 + if (IS_ERR(h)) 134 + return PTR_ERR(h); 135 135 136 136 return sysfs_emit(str, "%.*s\n", ACPI_OEM_ID_SIZE, h->oem_id); 137 137 } ··· 140 140 { 141 141 struct acpi_table_header *h = get_header(cfg); 142 142 143 - if (!h) 144 - return -EINVAL; 143 + if (IS_ERR(h)) 144 + return PTR_ERR(h); 145 145 146 146 return sysfs_emit(str, "%.*s\n", ACPI_OEM_TABLE_ID_SIZE, h->oem_table_id); 147 147 } ··· 150 150 { 151 151 struct acpi_table_header *h = get_header(cfg); 152 152 153 - if (!h) 154 - return -EINVAL; 153 + if (IS_ERR(h)) 154 + return PTR_ERR(h); 155 155 156 156 return sysfs_emit(str, "%d\n", h->oem_revision); 157 157 } ··· 161 161 { 162 162 struct acpi_table_header *h = get_header(cfg); 163 163 164 - if (!h) 165 - return -EINVAL; 164 + if (IS_ERR(h)) 165 + return PTR_ERR(h); 166 166 167 167 return sysfs_emit(str, "%.*s\n", ACPI_NAMESEG_SIZE, h->asl_compiler_id); 168 168 } ··· 172 172 { 173 173 struct acpi_table_header *h = get_header(cfg); 174 174 175 - if (!h) 176 - return -EINVAL; 175 + if (IS_ERR(h)) 176 + return PTR_ERR(h); 177 177 178 178 return sysfs_emit(str, "%d\n", h->asl_compiler_revision); 179 179 }