[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bdcc3052-1403-8c2f-f703-66180394c461@linux.intel.com>
Date: Wed, 20 Mar 2024 13:55:52 +0200 (EET)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Luke Jones <luke@...nes.dev>
cc: platform-driver-x86@...r.kernel.org, Hans de Goede <hdegoede@...hat.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] platform/x86: asus-wmi: support toggling POST sound
On Wed, 20 Mar 2024, Luke Jones wrote:
> On Wed, 20 Mar 2024, at 6:48 AM, Ilpo Järvinen wrote:
> > On Sun, 10 Mar 2024, Luke D. Jones wrote:
> >
> > > Add support for toggling the BIOS POST sound on some ASUS laptops.
> > >
> > > Signed-off-by: Luke D. Jones <luke@...nes.dev>
> > > ---
> > > .../ABI/testing/sysfs-platform-asus-wmi | 7 +++
> > > drivers/platform/x86/asus-wmi.c | 54 +++++++++++++++++++
> > > include/linux/platform_data/x86/asus-wmi.h | 3 ++
> > > 3 files changed, 64 insertions(+)
> > >
> > > diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi
> > > index e32b4f0ae15f..f3c53b7453f0 100644
> > > --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
> > > +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
> > > @@ -194,3 +194,10 @@ Contact: "Luke Jones" <luke@...nes.dev>
> > > Description:
> > > Set the target temperature limit of the Nvidia dGPU:
> > > * min=75, max=87
> > > +
> > > +What: /sys/devices/platform/<platform>/boot_sound
> > > +Date: Jun 2023
> > > +KernelVersion: 6.9
> > > +Contact: "Luke Jones" <luke@...nes.dev>
> > > +Description:
> > > + Set if the BIOS POST sound is played on boot.
> > > @@ -2106,6 +2107,55 @@ static ssize_t panel_od_store(struct device *dev,
> > > }
> > > static DEVICE_ATTR_RW(panel_od);
> > >
> > > +/* Bootup sound ***************************************************************/
> > > +
> > > +static ssize_t boot_sound_show(struct device *dev,
> > > + struct device_attribute *attr, char *buf)
> > > +{
> > > + struct asus_wmi *asus = dev_get_drvdata(dev);
> > > + int result;
> > > +
> > > + result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_BOOT_SOUND);
> > > + if (result < 0)
> > > + return result;
> > > +
> > > + return sysfs_emit(buf, "%d\n", result);
> > > +}
> > > +
> > > +static ssize_t boot_sound_store(struct device *dev,
> > > + struct device_attribute *attr,
> > > + const char *buf, size_t count)
> > > +{
> > > + int result, err;
> > > + u32 snd;
> > > +
> > > + struct asus_wmi *asus = dev_get_drvdata(dev);
> > > +
> > > + result = kstrtou32(buf, 10, &snd);
> > > + if (result)
> > > + return result;
> > > +
> > > + if (snd > 1)
> > > + return -EINVAL;
> >
> > Why not just use kstrtobool()?
>
> Consistency with other methods mostly. Plus the possibility that asus
> might do something like add different sounds. I'll change it if a revert
> back to kstrtou32 later doesn't break things.
Hi Luke,
I'd tend to think it's not the most likely scenario. But if they still do
something like that, the code could do both kstrtou32() and kstrtobool()
to keep the sysfs interface backwards compatible.
But it isn't end of the world for me if you want to keep it as
kstrtou32().
Annoyingly the other kstrtou32()s may not be easily converted over to
kstrtobool() because u32 formatting accepts 16-based values too such as
0x0. Perhaps hex format wouldn't be used by anyone but the risk is still
there and the benefits are not that high.
--
i.
Powered by blists - more mailing lists