public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/4] ACPI: platform: Get rid of redundant 'else'
@ 2022-08-29 14:10 Andy Shevchenko
  2022-08-29 14:10 ` [PATCH v1 2/4] ACPI: platform: Remove redundant print on ENOMEM Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-08-29 14:10 UTC (permalink / raw)
  To: Andy Shevchenko, linux-acpi, linux-kernel; +Cc: Rafael J. Wysocki, Len Brown

In the snippets like the following

	if (...)
		return / goto / break / continue ...;
	else
		...

the 'else' is redundant. Get rid of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/acpi_platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 1a1c78b23fba..75e26528056d 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -114,9 +114,9 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
 
 	INIT_LIST_HEAD(&resource_list);
 	count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
-	if (count < 0) {
+	if (count < 0)
 		return NULL;
-	} else if (count > 0) {
+	if (count > 0) {
 		resources = kcalloc(count, sizeof(struct resource),
 				    GFP_KERNEL);
 		if (!resources) {
-- 
2.35.1


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

* [PATCH v1 2/4] ACPI: platform: Remove redundant print on ENOMEM
  2022-08-29 14:10 [PATCH v1 1/4] ACPI: platform: Get rid of redundant 'else' Andy Shevchenko
@ 2022-08-29 14:10 ` Andy Shevchenko
  2022-08-29 14:10 ` [PATCH v1 3/4] ACPI: platform: Use sizeof(*pointer) instead of sizeof(type) Andy Shevchenko
  2022-08-29 14:11 ` [PATCH v1 4/4] ACPI: platform: Keep list of ACPI IDs sorted Andy Shevchenko
  2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-08-29 14:10 UTC (permalink / raw)
  To: Andy Shevchenko, linux-acpi, linux-kernel; +Cc: Rafael J. Wysocki, Len Brown

We rely on somebody else to print enough information on failures.
So remove the log in acpi_create_platform_device() when return
-ENOMEM.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/acpi_platform.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 75e26528056d..042f80588c18 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -120,7 +120,6 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
 		resources = kcalloc(count, sizeof(struct resource),
 				    GFP_KERNEL);
 		if (!resources) {
-			dev_err(&adev->dev, "No memory for resources\n");
 			acpi_dev_free_resource_list(&resource_list);
 			return ERR_PTR(-ENOMEM);
 		}
-- 
2.35.1


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

* [PATCH v1 3/4] ACPI: platform: Use sizeof(*pointer) instead of sizeof(type)
  2022-08-29 14:10 [PATCH v1 1/4] ACPI: platform: Get rid of redundant 'else' Andy Shevchenko
  2022-08-29 14:10 ` [PATCH v1 2/4] ACPI: platform: Remove redundant print on ENOMEM Andy Shevchenko
@ 2022-08-29 14:10 ` Andy Shevchenko
  2022-08-29 14:11 ` [PATCH v1 4/4] ACPI: platform: Keep list of ACPI IDs sorted Andy Shevchenko
  2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-08-29 14:10 UTC (permalink / raw)
  To: Andy Shevchenko, linux-acpi, linux-kernel; +Cc: Rafael J. Wysocki, Len Brown

It is preferred to use sizeof(*pointer) instead of sizeof(type).
The type of the variable can change and one needs not change
the former (unlike the latter). No functional change intended.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/acpi_platform.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 042f80588c18..0d812fe248d4 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -117,8 +117,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
 	if (count < 0)
 		return NULL;
 	if (count > 0) {
-		resources = kcalloc(count, sizeof(struct resource),
-				    GFP_KERNEL);
+		resources = kcalloc(count, sizeof(*resources), GFP_KERNEL);
 		if (!resources) {
 			acpi_dev_free_resource_list(&resource_list);
 			return ERR_PTR(-ENOMEM);
-- 
2.35.1


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

* [PATCH v1 4/4] ACPI: platform: Keep list of ACPI IDs sorted
  2022-08-29 14:10 [PATCH v1 1/4] ACPI: platform: Get rid of redundant 'else' Andy Shevchenko
  2022-08-29 14:10 ` [PATCH v1 2/4] ACPI: platform: Remove redundant print on ENOMEM Andy Shevchenko
  2022-08-29 14:10 ` [PATCH v1 3/4] ACPI: platform: Use sizeof(*pointer) instead of sizeof(type) Andy Shevchenko
@ 2022-08-29 14:11 ` Andy Shevchenko
  2022-08-29 14:28   ` Rafael J. Wysocki
  2 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2022-08-29 14:11 UTC (permalink / raw)
  To: Andy Shevchenko, linux-acpi, linux-kernel; +Cc: Rafael J. Wysocki, Len Brown

For better maintenance keep list of the ACPI IDs sorted.
While at it, replace terminator with more standard '{ }'.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/acpi/acpi_platform.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 0d812fe248d4..f13409583cd9 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -20,13 +20,13 @@
 #include "internal.h"
 
 static const struct acpi_device_id forbidden_id_list[] = {
+	{"ACPI0009", 0},	/* IOxAPIC */
+	{"ACPI000A", 0},	/* IOAPIC */
 	{"PNP0000",  0},	/* PIC */
 	{"PNP0100",  0},	/* Timer */
 	{"PNP0200",  0},	/* AT DMA Controller */
-	{"ACPI0009", 0},	/* IOxAPIC */
-	{"ACPI000A", 0},	/* IOAPIC */
 	{"SMB0001",  0},	/* ACPI SMBUS virtual device */
-	{"", 0},
+	{ }
 };
 
 static struct platform_device *acpi_platform_device_find_by_companion(struct acpi_device *adev)
-- 
2.35.1


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

* Re: [PATCH v1 4/4] ACPI: platform: Keep list of ACPI IDs sorted
  2022-08-29 14:11 ` [PATCH v1 4/4] ACPI: platform: Keep list of ACPI IDs sorted Andy Shevchenko
@ 2022-08-29 14:28   ` Rafael J. Wysocki
  2022-08-29 15:18     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2022-08-29 14:28 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List,
	Rafael J. Wysocki, Len Brown

On Mon, Aug 29, 2022 at 4:10 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> For better maintenance keep list of the ACPI IDs sorted.
> While at it, replace terminator with more standard '{ }'.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Subject: ACPI: platform: Sort forbidden_id_list[] in ascending order

Changelog:

"For easier maintenance, sort the forbidden_id_list[] table rows in
ascending order with respect to the device ID field.

While at it, use an empty row as the list terminator, which is more
usual in the kernel."

Pretty please.

> ---
>  drivers/acpi/acpi_platform.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
> index 0d812fe248d4..f13409583cd9 100644
> --- a/drivers/acpi/acpi_platform.c
> +++ b/drivers/acpi/acpi_platform.c
> @@ -20,13 +20,13 @@
>  #include "internal.h"
>
>  static const struct acpi_device_id forbidden_id_list[] = {
> +       {"ACPI0009", 0},        /* IOxAPIC */
> +       {"ACPI000A", 0},        /* IOAPIC */
>         {"PNP0000",  0},        /* PIC */
>         {"PNP0100",  0},        /* Timer */
>         {"PNP0200",  0},        /* AT DMA Controller */
> -       {"ACPI0009", 0},        /* IOxAPIC */
> -       {"ACPI000A", 0},        /* IOAPIC */
>         {"SMB0001",  0},        /* ACPI SMBUS virtual device */
> -       {"", 0},
> +       { }
>  };
>
>  static struct platform_device *acpi_platform_device_find_by_companion(struct acpi_device *adev)
> --

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

* Re: [PATCH v1 4/4] ACPI: platform: Keep list of ACPI IDs sorted
  2022-08-29 14:28   ` Rafael J. Wysocki
@ 2022-08-29 15:18     ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2022-08-29 15:18 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List, Len Brown

On Mon, Aug 29, 2022 at 04:28:23PM +0200, Rafael J. Wysocki wrote:
> On Mon, Aug 29, 2022 at 4:10 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > For better maintenance keep list of the ACPI IDs sorted.
> > While at it, replace terminator with more standard '{ }'.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> Subject: ACPI: platform: Sort forbidden_id_list[] in ascending order
> 
> Changelog:
> 
> "For easier maintenance, sort the forbidden_id_list[] table rows in
> ascending order with respect to the device ID field.
> 
> While at it, use an empty row as the list terminator, which is more
> usual in the kernel."
> 
> Pretty please.

Sure, thanks for the corrections, will embed them in v2.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2022-08-29 15:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-29 14:10 [PATCH v1 1/4] ACPI: platform: Get rid of redundant 'else' Andy Shevchenko
2022-08-29 14:10 ` [PATCH v1 2/4] ACPI: platform: Remove redundant print on ENOMEM Andy Shevchenko
2022-08-29 14:10 ` [PATCH v1 3/4] ACPI: platform: Use sizeof(*pointer) instead of sizeof(type) Andy Shevchenko
2022-08-29 14:11 ` [PATCH v1 4/4] ACPI: platform: Keep list of ACPI IDs sorted Andy Shevchenko
2022-08-29 14:28   ` Rafael J. Wysocki
2022-08-29 15:18     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox