Skip to contentSkip to conversation

ACPI / cpuidle: remove superfluous pr == NULL checks

PATCH In review Bartlomiej Zolnierkiewicz 2 participants 2 messages Aug 30, 2013 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI / cpuidle: remove superfluous pr == NULL checks

The only acpi_processor_get_power_info_fadt() user (acpi_processor_get_power_info()) dereferences pr before calling the function.

The only acpi_processor_hotplug() user (acpi_cpu_soft_notify()) checks for pr == NULL before calling the function.

The only acpi_processor_cst_has_changed() user (acpi_processor_notify()) checks for pr == NULL before calling the function.

The only acpi_processor_power_init() user (__acpi_processor_start()) dereferences pr before calling the function.

Thus remove superfluous pr == NULL checks from affected functions.

Also:

While at it remove redundant brackets from acpi_processor_hotplug().

---
 drivers/acpi/processor_idle.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/acpi/processor_idle.c +1 -14
index f98dd00..35c8f2b 100644
@@ -272,9 +272,6 @@ static void tsc_check_state(int state) { return; }
 static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
 {
 
-	if (!pr)
-		return -EINVAL;
-
 	if (!pr->pblk)
 		return -ENODEV;
 
@@ -1076,12 +1073,8 @@ int acpi_processor_hotplug(struct acpi_processor *pr)
 	if (disabled_by_idle_boot_param())
 		return 0;
 
-	if (!pr)
-		return -EINVAL;
-
-	if (nocst) {
+	if (nocst)
 		return -ENODEV;
-	}
 
 	if (!pr->flags.power_setup_done)
 		return -ENODEV;
@@ -1108,9 +1101,6 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
 	if (disabled_by_idle_boot_param())
 		return 0;
 
-	if (!pr)
-		return -EINVAL;
-
 	if (nocst)
 		return -ENODEV;
 
@@ -1183,9 +1173,6 @@ int acpi_processor_power_init(struct acpi_processor *pr)
 		first_run++;
 	}
 
-	if (!pr)
-		return -EINVAL;
-
 	if (acpi_gbl_FADT.cst_control && !nocst) {
 		status =
 		    acpi_os_write_port(acpi_gbl_FADT.smi_command, acpi_gbl_FADT.cst_control, 8);
Signature · 1 line
1.8.2.3
#1 lore raw
Quoted 15 lines · Bartlomiej Zolnierkiewicz

The only acpi_processor_get_power_info_fadt() user (acpi_processor_get_power_info()) dereferences pr before calling the function.

The only acpi_processor_hotplug() user (acpi_cpu_soft_notify()) checks for pr == NULL before calling the function.

The only acpi_processor_cst_has_changed() user (acpi_processor_notify()) checks for pr == NULL before calling the function.

The only acpi_processor_power_init() user (__acpi_processor_start()) dereferences pr before calling the function.

Thus remove superfluous pr == NULL checks from affected functions.

Quoted 7 lines

Also:

While at it remove redundant brackets from acpi_processor_hotplug().

Thanks, I'll queue this up for 3.13.

Quoted 53 lines
---
 drivers/acpi/processor_idle.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/acpi/processor_idle.c +1 -14
index f98dd00..35c8f2b 100644
@@ -272,9 +272,6 @@ static void tsc_check_state(int state) { return; }
 static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
 {
 
-	if (!pr)
-		return -EINVAL;
-
 	if (!pr->pblk)
 		return -ENODEV;
 
@@ -1076,12 +1073,8 @@ int acpi_processor_hotplug(struct acpi_processor *pr)
 	if (disabled_by_idle_boot_param())
 		return 0;
 
-	if (!pr)
-		return -EINVAL;
-
-	if (nocst) {
+	if (nocst)
 		return -ENODEV;
-	}
 
 	if (!pr->flags.power_setup_done)
 		return -ENODEV;
@@ -1108,9 +1101,6 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
 	if (disabled_by_idle_boot_param())
 		return 0;
 
-	if (!pr)
-		return -EINVAL;
-
 	if (nocst)
 		return -ENODEV;
 
@@ -1183,9 +1173,6 @@ int acpi_processor_power_init(struct acpi_processor *pr)
 		first_run++;
 	}
 
-	if (!pr)
-		return -EINVAL;
-
 	if (acpi_gbl_FADT.cst_control && !nocst) {
 		status =
 		    acpi_os_write_port(acpi_gbl_FADT.smi_command, acpi_gbl_FADT.cst_control, 8);
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.