diff mbox series

[v2,2/2] platform/surface: aggregator: Log critical errors during SAM probing

Message ID 20240503030900.1334763-3-weifeng.liu.z@gmail.com (mailing list archive)
State Superseded, archived
Headers show
Series Defer probing of SAM if serdev device is not ready | expand

Commit Message

Weifeng Liu May 3, 2024, 3:08 a.m. UTC
Emits messages upon errors during probing of SAM.  Hopefully this could
provide useful context to user for the purpose of diagnosis when
something miserable happen.

Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Weifeng Liu <weifeng.liu.z@gmail.com>
---
 drivers/platform/surface/aggregator/core.c | 32 ++++++++++++++++------
 1 file changed, 24 insertions(+), 8 deletions(-)

Comments

Andy Shevchenko May 3, 2024, 4:36 p.m. UTC | #1
On Fri, May 03, 2024 at 11:08:47AM +0800, Weifeng Liu wrote:
> Emits messages upon errors during probing of SAM.  Hopefully this could
> provide useful context to user for the purpose of diagnosis when
> something miserable happen.

...

>  	acpi_status astatus;
>  	int status;
>  
> -	if (gpiod_count(&serdev->dev, NULL) < 0)
> -		return -ENODEV;
> +	status = gpiod_count(&serdev->dev, NULL);
> +	if (status < 0)
> +		return dev_err_probe(&serdev->dev, status, "no GPIO found\n");

Note, with

	struct device *dev = &serdev->dev;

this and other lines become shorter and you may join some of them...

...

> +		status = dev_err_probe(&serdev->dev, -ENXIO,
> +				       "failed to setup serdev\n");

...like here:

		status = dev_err_probe(dev, -ENXIO, "failed to setup serdev\n");

...

> +		dev_err_probe(&serdev->dev, status,
> +			      "failed to get firmware version\n");

...or here.

...

With the above being addressed,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
diff mbox series

Patch

diff --git a/drivers/platform/surface/aggregator/core.c b/drivers/platform/surface/aggregator/core.c
index 87dea91f91fe..b3359ce13e0d 100644
--- a/drivers/platform/surface/aggregator/core.c
+++ b/drivers/platform/surface/aggregator/core.c
@@ -623,8 +623,9 @@  static int ssam_serial_hub_probe(struct serdev_device *serdev)
 	acpi_status astatus;
 	int status;
 
-	if (gpiod_count(&serdev->dev, NULL) < 0)
-		return -ENODEV;
+	status = gpiod_count(&serdev->dev, NULL);
+	if (status < 0)
+		return dev_err_probe(&serdev->dev, status, "no GPIO found\n");
 
 	status = devm_acpi_dev_add_driver_gpios(&serdev->dev, ssam_acpi_gpios);
 	if (status)
@@ -637,8 +638,11 @@  static int ssam_serial_hub_probe(struct serdev_device *serdev)
 
 	/* Initialize controller. */
 	status = ssam_controller_init(ctrl, serdev);
-	if (status)
+	if (status) {
+		dev_err_probe(&serdev->dev, status,
+			      "failed to initialize ssam controller\n");
 		goto err_ctrl_init;
+	}
 
 	ssam_controller_lock(ctrl);
 
@@ -664,7 +668,8 @@  static int ssam_serial_hub_probe(struct serdev_device *serdev)
 
 	astatus = ssam_serdev_setup_via_acpi(ssh->handle, serdev);
 	if (ACPI_FAILURE(astatus)) {
-		status = -ENXIO;
+		status = dev_err_probe(&serdev->dev, -ENXIO,
+				       "failed to setup serdev\n");
 		goto err_devinit;
 	}
 
@@ -680,16 +685,25 @@  static int ssam_serial_hub_probe(struct serdev_device *serdev)
 	 * states.
 	 */
 	status = ssam_log_firmware_version(ctrl);
-	if (status)
+	if (status) {
+		dev_err_probe(&serdev->dev, status,
+			      "failed to get firmware version\n");
 		goto err_initrq;
+	}
 
 	status = ssam_ctrl_notif_d0_entry(ctrl);
-	if (status)
+	if (status) {
+		dev_err_probe(&serdev->dev, status,
+			      "failed to notify EC of entry of D0\n");
 		goto err_initrq;
+	}
 
 	status = ssam_ctrl_notif_display_on(ctrl);
-	if (status)
+	if (status) {
+		dev_err_probe(&serdev->dev, status,
+			      "failed to notify EC of display on\n");
 		goto err_initrq;
+	}
 
 	status = sysfs_create_group(&serdev->dev.kobj, &ssam_sam_group);
 	if (status)
@@ -697,8 +711,10 @@  static int ssam_serial_hub_probe(struct serdev_device *serdev)
 
 	/* Set up IRQ. */
 	status = ssam_irq_setup(ctrl);
-	if (status)
+	if (status) {
+		dev_err_probe(&serdev->dev, status, "failed to setup IRQ\n");
 		goto err_irq;
+	}
 
 	/* Finally, set main controller reference. */
 	status = ssam_try_set_controller(ctrl);