Skip to contentSkip to conversation

pwm: lpss-platform: Cleanly exit probe on boards without resources

PATCH In review Hans de Goede 2 participants 3 messages Jan 12, 2018 – Jan 14, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: lpss-platform: Cleanly exit probe on boards without resources

Some boards which do not use the pwm-controller have an empty or invalid resource-table in ACPI the for pwm-controller. Currently this causes these error messages to get logged:

[    3.281966] pwm-lpss 80862288:00: invalid resource
[    3.287098] pwm-lpss: probe of 80862288:00 failed with error -22

This commit silences these error messages on these boards by cleanly exiting pwm_lpss_probe_platform() if there is no memory resource.

---
 drivers/pwm/pwm-lpss-platform.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/pwm/pwm-lpss-platform.c +7 -0
index 5d6ed1507d29..5e5f4d018178 100644
@@ -52,7 +52,14 @@ static int pwm_lpss_probe_platform(struct platform_device *pdev)
 		return -ENODEV;
 
 	info = (const struct pwm_lpss_boardinfo *)id->driver_data;
+
+	/*
+	 * Some boards which don't use the pwm controller have an empty
+	 * resources table, so if we cannot get the resource, return -ENODEV.
+	 */
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r)
+		return -ENODEV;
 
 	lpwm = pwm_lpss_probe(&pdev->dev, r, info);
 	if (IS_ERR(lpwm))
Signature · 1 line
2.14.3
#1 lore raw

+Cc: Mika

Quoted 11 lines · Hans de Goede

Some boards which do not use the pwm-controller have an empty or invalid
resource-table in ACPI the for pwm-controller. Currently this causes these
error messages to get logged:

[    3.281966] pwm-lpss 80862288:00: invalid resource
[    3.287098] pwm-lpss: probe of 80862288:00 failed with error -22

This commit silences these error messages on these boards by cleanly exiting pwm_lpss_probe_platform() if there is no memory resource.

I don't see anything wrong with message per se.

drivers/pwm/pwm-lpss-platform.c static int pwm_lpss_probe_platform(struct platform_device *pdev) · line 62

Quoted 10 lines
drivers/pwm/pwm-lpss-platform.c +3 -0
+
+	/*
+	 * Some boards which don't use the pwm controller have an

empty

drivers/pwm/pwm-lpss-platform.c +4 -1
+	 * resources table, so if we cannot get the resource, return
-ENODEV.
+	 */
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r)
+		return -ENODEV;

But this one looks like a quirk for some platforms when other can survive without.

Can we actually check this in acpi_lpss.c and prevent platform device registration at all?

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#2 lore raw

Hi,

Quoted 11 lines · Andy Shevchenko

+Cc: Mika

Quoted 8 lines · Hans de Goede

Some boards which do not use the pwm-controller have an empty or invalid
resource-table in ACPI the for pwm-controller. Currently this causes these
error messages to get logged:

[    3.281966] pwm-lpss 80862288:00: invalid resource
[    3.287098] pwm-lpss: probe of 80862288:00 failed with error -22
Quoted 5 lines
Quoted 3 lines

This commit silences these error messages on these boards by cleanly exiting pwm_lpss_probe_platform() if there is no memory resource.

I don't see anything wrong with message per se.

Given all the effort distros have done with splash-screens to give users a nice clean boot experience, we really want dmesg --level=err to not print anything unless there is a real problem with either the hardware or the kernel.

(Note that plymouth will drop back to text-mode when kernel errors do show up.)

Quoted 5 lines
Quoted 5 lines
drivers/pwm/pwm-lpss-platform.c +3 -0
+
+	/*
+	 * Some boards which don't use the pwm controller have an

empty

(quoted diff) +1 -0
+	 * resources table, so if we cannot get the resource, return
Quoted 8 lines

drivers/pwm/pwm-lpss-platform.c static int pwm_lpss_probe_platform(struct platform_device *pdev) · line 62

Quoted 5 lines
drivers/pwm/pwm-lpss-platform.c +3 -1
-ENODEV.
+	 */
  	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r)
+		return -ENODEV;

But this one looks like a quirk for some platforms when other can survive without.

Right, this is something platform specific, but on platforms which have a proper resource for the PWM this patch is a no-op, so there is no need to do a quirk table for this, we can just silence the error and be done with it.

Quoted 2 lines

Can we actually check this in acpi_lpss.c and prevent platform device registration at all?

That is a good idea, it was not entirely trivial to achieve this but I've come up with a patch which does that. If that is deemed acceptable then we can go with that patch instead.

Regards,

Hans