diff mbox series

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

Message ID 20180112113802.3888-1-hdegoede@redhat.com
State Superseded
Headers show
Series pwm: lpss-platform: Cleanly exit probe on boards without resources | expand

Commit Message

Hans de Goede Jan. 12, 2018, 11:38 a.m. UTC
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.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/pwm/pwm-lpss-platform.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Andy Shevchenko Jan. 12, 2018, 1:04 p.m. UTC | #1
+Cc: Mika

On Fri, 2018-01-12 at 12:38 +0100, Hans de Goede wrote:
> 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.

> +
> +	/*
> +	 * 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;

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?
Hans de Goede Jan. 14, 2018, 7:58 p.m. UTC | #2
Hi,

On 12-01-18 14:04, Andy Shevchenko wrote:
> +Cc: Mika
> 
> On Fri, 2018-01-12 at 12:38 +0100, Hans de Goede wrote:
>> 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.

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.)

>> +
>> +	/*
>> +	 * 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;
> 
> 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.

> 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

--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-lpss-platform.c b/drivers/pwm/pwm-lpss-platform.c
index 5d6ed1507d29..5e5f4d018178 100644
--- a/drivers/pwm/pwm-lpss-platform.c
+++ b/drivers/pwm/pwm-lpss-platform.c
@@ -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))