Skip to contentSkip to conversation

ACPI / LPSS: Make condition local to lpt_register_clock_device

PATCH Applied Andy Shevchenko 2 participants 4 messages Mar 20, 2013 – Mar 26, 2013 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ACPI / LPSS: Make condition local to lpt_register_clock_device

It seems more logical to have the check of lpss_clk_dev variable in lpt_register_clock_device() because last one actually assignes the variable.

---
 drivers/acpi/acpi_lpss.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/acpi/acpi_lpss.c +4 -2
index c87db0e..c695841 100644
@@ -84,6 +84,9 @@ static struct platform_device *lpss_clk_dev;
 
 static inline void lpt_register_clock_device(void)
 {
+	if (lpss_clk_dev)
+		return;
+
 	lpss_clk_dev = platform_device_register_simple("clk-lpt", -1, NULL, 0);
 }
 
@@ -92,8 +95,7 @@ static int register_device_clock(struct acpi_device *adev,
 {
 	const struct lpss_device_desc *dev_desc = pdata->dev_desc;
 
-	if (!lpss_clk_dev)
-		lpt_register_clock_device();
+	lpt_register_clock_device();
 
 	if (!dev_desc->clk_parent || !pdata->mmio_base
 	    || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE)
Signature · 1 line
1.8.2.rc0.22.gb3600c3
#1 lore raw

PATCH 2/2 ACPI / LPSS: make code less confusing for reader

The excerpt like this:

	if (err) {
		err = 0;
		goto error_out;
	}

makes a reader confused even if it's commented. Let's do necessary actions and return no error explicitly.

---
 drivers/acpi/acpi_lpss.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/acpi_lpss.c +2 -2
index c695841..5d7ded2 100644
@@ -152,8 +152,8 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
 			 * Skip the device, but don't terminate the namespace
 			 * scan.
 			 */
-			ret = 0;
-			goto err_out;
+			kfree(pdata);
+			return 0;
 		}
 	}
 
Signature · 1 line
1.8.2.rc0.22.gb3600c3
#2 lore raw

Re: [PATCH 2/2] ACPI / LPSS: make code less confusing for reader

Quoted 11 lines · Andy Shevchenko

The excerpt like this:

	if (err) {
		err = 0;
		goto error_out;
	}

makes a reader confused even if it's commented. Let's do necessary actions and return no error explicitly.

Applied to linux-pm.git/linux-next.

Thanks,
Rafael

Quoted 20 lines
---
 drivers/acpi/acpi_lpss.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/acpi_lpss.c +2 -2
index c695841..5d7ded2 100644
@@ -152,8 +152,8 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
 			 * Skip the device, but don't terminate the namespace
 			 * scan.
 			 */
-			ret = 0;
-			goto err_out;
+			kfree(pdata);
+			return 0;
 		}
 	}
 
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#3 lore raw
In reply to Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

It seems more logical to have the check of lpss_clk_dev variable in lpt_register_clock_device() because last one actually assignes the variable.

Actually, I came to the opposite conclusion when I was working on the code in question. :-)

Not applied.

Thanks,
Rafael

Quoted 29 lines
---
 drivers/acpi/acpi_lpss.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/acpi/acpi_lpss.c +4 -2
index c87db0e..c695841 100644
@@ -84,6 +84,9 @@ static struct platform_device *lpss_clk_dev;
 
 static inline void lpt_register_clock_device(void)
 {
+	if (lpss_clk_dev)
+		return;
+
 	lpss_clk_dev = platform_device_register_simple("clk-lpt", -1, NULL, 0);
 }
 
@@ -92,8 +95,7 @@ static int register_device_clock(struct acpi_device *adev,
 {
 	const struct lpss_device_desc *dev_desc = pdata->dev_desc;
 
-	if (!lpss_clk_dev)
-		lpt_register_clock_device();
+	lpt_register_clock_device();
 
 	if (!dev_desc->clk_parent || !pdata->mmio_base
 	    || pdata->mmio_size < dev_desc->prv_offset + LPSS_CLK_SIZE)
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.