Skip to content

Commit a093cb6

Browse files
andy-shevjwrdegoede
authored andcommitted
platform/x86: ideapad-laptop: Make the scope_guard() clear of its scope
First of all, it's a bit counterintuitive to have something like int err; ... scoped_guard(...) err = foo(...); if (err) return err; Second, with a particular kernel configuration and compiler version in one of such cases the objtool is not happy: ideapad-laptop.o: warning: objtool: .text.fan_mode_show: unexpected end of section I'm not an expert on all this, but the theory is that compiler and linker in this case can't understand that 'result' variable will be always initialized as long as no error has been returned. Assigning 'result' to a dummy value helps with this. Note, that fixing the scoped_guard() scope (as per above) does not make issue gone. That said, assign dummy value and make the scope_guard() clear of its scope. For the sake of consistency do it in the entire file. Fixes: 7cc06e7 ("platform/x86: ideapad-laptop: add a mutex to synchronize VPC commands") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202408290219.BrPO8twi-lkp@intel.com/ Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240829165105.1609180-1-andriy.shevchenko@linux.intel.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 24b6616 commit a093cb6

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

drivers/platform/x86/ideapad-laptop.c

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -554,13 +554,14 @@ static ssize_t camera_power_show(struct device *dev,
554554
char *buf)
555555
{
556556
struct ideapad_private *priv = dev_get_drvdata(dev);
557-
unsigned long result;
557+
unsigned long result = 0;
558558
int err;
559559

560-
scoped_guard(mutex, &priv->vpc_mutex)
560+
scoped_guard(mutex, &priv->vpc_mutex) {
561561
err = read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &result);
562-
if (err)
563-
return err;
562+
if (err)
563+
return err;
564+
}
564565

565566
return sysfs_emit(buf, "%d\n", !!result);
566567
}
@@ -577,10 +578,11 @@ static ssize_t camera_power_store(struct device *dev,
577578
if (err)
578579
return err;
579580

580-
scoped_guard(mutex, &priv->vpc_mutex)
581+
scoped_guard(mutex, &priv->vpc_mutex) {
581582
err = write_ec_cmd(priv->adev->handle, VPCCMD_W_CAMERA, state);
582-
if (err)
583-
return err;
583+
if (err)
584+
return err;
585+
}
584586

585587
return count;
586588
}
@@ -628,13 +630,14 @@ static ssize_t fan_mode_show(struct device *dev,
628630
char *buf)
629631
{
630632
struct ideapad_private *priv = dev_get_drvdata(dev);
631-
unsigned long result;
633+
unsigned long result = 0;
632634
int err;
633635

634-
scoped_guard(mutex, &priv->vpc_mutex)
636+
scoped_guard(mutex, &priv->vpc_mutex) {
635637
err = read_ec_data(priv->adev->handle, VPCCMD_R_FAN, &result);
636-
if (err)
637-
return err;
638+
if (err)
639+
return err;
640+
}
638641

639642
return sysfs_emit(buf, "%lu\n", result);
640643
}
@@ -654,10 +657,11 @@ static ssize_t fan_mode_store(struct device *dev,
654657
if (state > 4 || state == 3)
655658
return -EINVAL;
656659

657-
scoped_guard(mutex, &priv->vpc_mutex)
660+
scoped_guard(mutex, &priv->vpc_mutex) {
658661
err = write_ec_cmd(priv->adev->handle, VPCCMD_W_FAN, state);
659-
if (err)
660-
return err;
662+
if (err)
663+
return err;
664+
}
661665

662666
return count;
663667
}
@@ -737,13 +741,14 @@ static ssize_t touchpad_show(struct device *dev,
737741
char *buf)
738742
{
739743
struct ideapad_private *priv = dev_get_drvdata(dev);
740-
unsigned long result;
744+
unsigned long result = 0;
741745
int err;
742746

743-
scoped_guard(mutex, &priv->vpc_mutex)
747+
scoped_guard(mutex, &priv->vpc_mutex) {
744748
err = read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &result);
745-
if (err)
746-
return err;
749+
if (err)
750+
return err;
751+
}
747752

748753
priv->r_touchpad_val = result;
749754

@@ -762,10 +767,11 @@ static ssize_t touchpad_store(struct device *dev,
762767
if (err)
763768
return err;
764769

765-
scoped_guard(mutex, &priv->vpc_mutex)
770+
scoped_guard(mutex, &priv->vpc_mutex) {
766771
err = write_ec_cmd(priv->adev->handle, VPCCMD_W_TOUCHPAD, state);
767-
if (err)
768-
return err;
772+
if (err)
773+
return err;
774+
}
769775

770776
priv->r_touchpad_val = state;
771777

0 commit comments

Comments
 (0)