linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Minor cleanups
@ 2020-07-21  9:59 Hanjun Guo
  2020-07-21  9:59 ` [PATCH 1/3] ACPI: tables: Remove the duplicated checks for acpi_parse_entries_array() Hanjun Guo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Hanjun Guo @ 2020-07-21  9:59 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: linux-acpi, linuxarm, Hanjun Guo

When reviewing patchset "[PATCH v2 0/6] ACPI: Only create NUMA nodes
from entries in SRAT or SRAT emulation." [0] from Jonathan, I found some
code can be improved, here are some cleanup patches.

[0]: https://www.spinics.net/lists/linux-mm/msg220777.html

Hanjun Guo (3):
  ACPI: tables: Remove the duplicated checks for
    acpi_parse_entries_array()
  ACPI: NUMA: Remove the useless sub table pointer check
  ACPI: NUMA: Remove the useless 'node >= MAX_NUMNODES' check

 drivers/acpi/numa/srat.c | 10 +---------
 drivers/acpi/tables.c    | 17 +++--------------
 2 files changed, 4 insertions(+), 23 deletions(-)

-- 
1.7.12.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] ACPI: tables: Remove the duplicated checks for acpi_parse_entries_array()
  2020-07-21  9:59 [PATCH 0/3] Minor cleanups Hanjun Guo
@ 2020-07-21  9:59 ` Hanjun Guo
  2020-07-21  9:59 ` [PATCH 2/3] ACPI: NUMA: Remove the useless sub table pointer check Hanjun Guo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Hanjun Guo @ 2020-07-21  9:59 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: linux-acpi, linuxarm, Hanjun Guo

acpi_disabled, pointer id and table_header are checked in
acpi_table_parse_entries_array(), and acpi_parse_entries_array() is only
called by acpi_table_parse_entries_array(), so those checks in
acpi_parse_entries_array() are duplicate.

Remove those duplicated check and move the table_size check to
function acpi_table_parse_entries_array() as well.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
 drivers/acpi/tables.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 0e905c3..c85e1c6 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -292,20 +292,6 @@ static int __init acpi_parse_entries_array(char *id, unsigned long table_size,
 	int errs = 0;
 	int i;
 
-	if (acpi_disabled)
-		return -ENODEV;
-
-	if (!id)
-		return -EINVAL;
-
-	if (!table_size)
-		return -EINVAL;
-
-	if (!table_header) {
-		pr_warn("%4.4s not present\n", id);
-		return -ENODEV;
-	}
-
 	table_end = (unsigned long)table_header + table_header->length;
 
 	/* Parse all entries looking for a match. */
@@ -371,6 +357,9 @@ int __init acpi_table_parse_entries_array(char *id,
 	if (!id)
 		return -EINVAL;
 
+	if (!table_size)
+		return -EINVAL;
+
 	if (!strncmp(id, ACPI_SIG_MADT, 4))
 		instance = acpi_apic_instance;
 
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] ACPI: NUMA: Remove the useless sub table pointer check
  2020-07-21  9:59 [PATCH 0/3] Minor cleanups Hanjun Guo
  2020-07-21  9:59 ` [PATCH 1/3] ACPI: tables: Remove the duplicated checks for acpi_parse_entries_array() Hanjun Guo
@ 2020-07-21  9:59 ` Hanjun Guo
  2020-07-21  9:59 ` [PATCH 3/3] ACPI: NUMA: Remove the useless 'node >= MAX_NUMNODES' check Hanjun Guo
  2020-07-27 13:20 ` [PATCH 0/3] Minor cleanups Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: Hanjun Guo @ 2020-07-21  9:59 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: linux-acpi, linuxarm, Hanjun Guo

In acpi_parse_entries_array(), the subtable entries (entry.hdr)
will never be NULL, so for ACPI subtable handler in struct
acpi_subtable_proc, will never handle NULL subtable entries,
remove those useless subtable pointer checks in those callback
handlers.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
 drivers/acpi/numa/srat.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index 5be5a97..3d430b0 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -291,8 +291,6 @@ static int __init acpi_parse_slit(struct acpi_table_header *table)
 	struct acpi_srat_x2apic_cpu_affinity *processor_affinity;
 
 	processor_affinity = (struct acpi_srat_x2apic_cpu_affinity *)header;
-	if (!processor_affinity)
-		return -EINVAL;
 
 	acpi_table_print_srat_entry(&header->common);
 
@@ -309,8 +307,6 @@ static int __init acpi_parse_slit(struct acpi_table_header *table)
 	struct acpi_srat_cpu_affinity *processor_affinity;
 
 	processor_affinity = (struct acpi_srat_cpu_affinity *)header;
-	if (!processor_affinity)
-		return -EINVAL;
 
 	acpi_table_print_srat_entry(&header->common);
 
@@ -327,8 +323,6 @@ static int __init acpi_parse_slit(struct acpi_table_header *table)
 	struct acpi_srat_gicc_affinity *processor_affinity;
 
 	processor_affinity = (struct acpi_srat_gicc_affinity *)header;
-	if (!processor_affinity)
-		return -EINVAL;
 
 	acpi_table_print_srat_entry(&header->common);
 
@@ -347,8 +341,6 @@ static int __init acpi_parse_slit(struct acpi_table_header *table)
 	struct acpi_srat_mem_affinity *memory_affinity;
 
 	memory_affinity = (struct acpi_srat_mem_affinity *)header;
-	if (!memory_affinity)
-		return -EINVAL;
 
 	acpi_table_print_srat_entry(&header->common);
 
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] ACPI: NUMA: Remove the useless 'node >= MAX_NUMNODES' check
  2020-07-21  9:59 [PATCH 0/3] Minor cleanups Hanjun Guo
  2020-07-21  9:59 ` [PATCH 1/3] ACPI: tables: Remove the duplicated checks for acpi_parse_entries_array() Hanjun Guo
  2020-07-21  9:59 ` [PATCH 2/3] ACPI: NUMA: Remove the useless sub table pointer check Hanjun Guo
@ 2020-07-21  9:59 ` Hanjun Guo
  2020-07-27 13:20 ` [PATCH 0/3] Minor cleanups Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: Hanjun Guo @ 2020-07-21  9:59 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: linux-acpi, linuxarm, Hanjun Guo

acpi_map_pxm_to_node() will never return numa node greater
than MAX_NUMNODES, so 'node >= MAX_NUMNODES' is not needed,
remove it.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
---
 drivers/acpi/numa/srat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/numa/srat.c b/drivers/acpi/numa/srat.c
index 3d430b0..15bbaab 100644
--- a/drivers/acpi/numa/srat.c
+++ b/drivers/acpi/numa/srat.c
@@ -230,7 +230,7 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
 		pxm &= 0xff;
 
 	node = acpi_map_pxm_to_node(pxm);
-	if (node == NUMA_NO_NODE || node >= MAX_NUMNODES) {
+	if (node == NUMA_NO_NODE) {
 		pr_err("SRAT: Too many proximity domains.\n");
 		goto out_err_bad_srat;
 	}
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] Minor cleanups
  2020-07-21  9:59 [PATCH 0/3] Minor cleanups Hanjun Guo
                   ` (2 preceding siblings ...)
  2020-07-21  9:59 ` [PATCH 3/3] ACPI: NUMA: Remove the useless 'node >= MAX_NUMNODES' check Hanjun Guo
@ 2020-07-27 13:20 ` Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2020-07-27 13:20 UTC (permalink / raw)
  To: Hanjun Guo; +Cc: Rafael J. Wysocki, ACPI Devel Maling List, Linuxarm

On Tue, Jul 21, 2020 at 12:06 PM Hanjun Guo <guohanjun@huawei.com> wrote:
>
> When reviewing patchset "[PATCH v2 0/6] ACPI: Only create NUMA nodes
> from entries in SRAT or SRAT emulation." [0] from Jonathan, I found some
> code can be improved, here are some cleanup patches.
>
> [0]: https://www.spinics.net/lists/linux-mm/msg220777.html
>
> Hanjun Guo (3):
>   ACPI: tables: Remove the duplicated checks for
>     acpi_parse_entries_array()
>   ACPI: NUMA: Remove the useless sub table pointer check
>   ACPI: NUMA: Remove the useless 'node >= MAX_NUMNODES' check
>
>  drivers/acpi/numa/srat.c | 10 +---------
>  drivers/acpi/tables.c    | 17 +++--------------
>  2 files changed, 4 insertions(+), 23 deletions(-)
>
> --

All three patches applied as 5.9 material, thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-27 13:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21  9:59 [PATCH 0/3] Minor cleanups Hanjun Guo
2020-07-21  9:59 ` [PATCH 1/3] ACPI: tables: Remove the duplicated checks for acpi_parse_entries_array() Hanjun Guo
2020-07-21  9:59 ` [PATCH 2/3] ACPI: NUMA: Remove the useless sub table pointer check Hanjun Guo
2020-07-21  9:59 ` [PATCH 3/3] ACPI: NUMA: Remove the useless 'node >= MAX_NUMNODES' check Hanjun Guo
2020-07-27 13:20 ` [PATCH 0/3] Minor cleanups Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).