Skip to content

Commit 7c4cd2a

Browse files
phreerjwrdegoede
authored andcommitted
platform/surface: aggregator: Log critical errors during SAM probing
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 <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Weifeng Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 76f09e2 commit 7c4cd2a

File tree

1 file changed

+28
-14
lines changed
  • drivers/platform/surface/aggregator

1 file changed

+28
-14
lines changed

drivers/platform/surface/aggregator/core.c

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -618,15 +618,17 @@ static const struct acpi_gpio_mapping ssam_acpi_gpios[] = {
618618

619619
static int ssam_serial_hub_probe(struct serdev_device *serdev)
620620
{
621-
struct acpi_device *ssh = ACPI_COMPANION(&serdev->dev);
621+
struct device *dev = &serdev->dev;
622+
struct acpi_device *ssh = ACPI_COMPANION(dev);
622623
struct ssam_controller *ctrl;
623624
acpi_status astatus;
624625
int status;
625626

626-
if (gpiod_count(&serdev->dev, NULL) < 0)
627-
return -ENODEV;
627+
status = gpiod_count(dev, NULL);
628+
if (status < 0)
629+
return dev_err_probe(dev, status, "no GPIO found\n");
628630

629-
status = devm_acpi_dev_add_driver_gpios(&serdev->dev, ssam_acpi_gpios);
631+
status = devm_acpi_dev_add_driver_gpios(dev, ssam_acpi_gpios);
630632
if (status)
631633
return status;
632634

@@ -637,21 +639,25 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)
637639

638640
/* Initialize controller. */
639641
status = ssam_controller_init(ctrl, serdev);
640-
if (status)
642+
if (status) {
643+
dev_err_probe(dev, status, "failed to initialize ssam controller\n");
641644
goto err_ctrl_init;
645+
}
642646

643647
ssam_controller_lock(ctrl);
644648

645649
/* Set up serdev device. */
646650
serdev_device_set_drvdata(serdev, ctrl);
647651
serdev_device_set_client_ops(serdev, &ssam_serdev_ops);
648652
status = serdev_device_open(serdev);
649-
if (status)
653+
if (status) {
654+
dev_err_probe(dev, status, "failed to open serdev device\n");
650655
goto err_devopen;
656+
}
651657

652658
astatus = ssam_serdev_setup_via_acpi(ssh->handle, serdev);
653659
if (ACPI_FAILURE(astatus)) {
654-
status = -ENXIO;
660+
status = dev_err_probe(dev, -ENXIO, "failed to setup serdev\n");
655661
goto err_devinit;
656662
}
657663

@@ -667,25 +673,33 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)
667673
* states.
668674
*/
669675
status = ssam_log_firmware_version(ctrl);
670-
if (status)
676+
if (status) {
677+
dev_err_probe(dev, status, "failed to get firmware version\n");
671678
goto err_initrq;
679+
}
672680

673681
status = ssam_ctrl_notif_d0_entry(ctrl);
674-
if (status)
682+
if (status) {
683+
dev_err_probe(dev, status, "D0-entry notification failed\n");
675684
goto err_initrq;
685+
}
676686

677687
status = ssam_ctrl_notif_display_on(ctrl);
678-
if (status)
688+
if (status) {
689+
dev_err_probe(dev, status, "display-on notification failed\n");
679690
goto err_initrq;
691+
}
680692

681-
status = sysfs_create_group(&serdev->dev.kobj, &ssam_sam_group);
693+
status = sysfs_create_group(&dev->kobj, &ssam_sam_group);
682694
if (status)
683695
goto err_initrq;
684696

685697
/* Set up IRQ. */
686698
status = ssam_irq_setup(ctrl);
687-
if (status)
699+
if (status) {
700+
dev_err_probe(dev, status, "failed to setup IRQ\n");
688701
goto err_irq;
702+
}
689703

690704
/* Finally, set main controller reference. */
691705
status = ssam_try_set_controller(ctrl);
@@ -702,15 +716,15 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev)
702716
* resumed. In short, this causes some spurious unwanted wake-ups.
703717
* For now let's thus default power/wakeup to false.
704718
*/
705-
device_set_wakeup_capable(&serdev->dev, true);
719+
device_set_wakeup_capable(dev, true);
706720
acpi_dev_clear_dependencies(ssh);
707721

708722
return 0;
709723

710724
err_mainref:
711725
ssam_irq_free(ctrl);
712726
err_irq:
713-
sysfs_remove_group(&serdev->dev.kobj, &ssam_sam_group);
727+
sysfs_remove_group(&dev->kobj, &ssam_sam_group);
714728
err_initrq:
715729
ssam_controller_lock(ctrl);
716730
ssam_controller_shutdown(ctrl);

0 commit comments

Comments
 (0)