From: sashiko-bot@kernel.org
To: "Atharva Tiwari" <atharvatiwarilinuxdev@gmail.com>
Cc: "Bjorn Helgaas" <bhelgaas@google.com>,
"Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Len Brown" <lenb@kernel.org>,
"Linus Walleij" <linusw@kernel.org>,
"Bartosz Golaszewski" <brgl@kernel.org>,
"Sven Peter" <sven@kernel.org>, "Janne Grunau" <j@jannau.net>,
"Neal Gompa" <neal@gompa.dev>,
"Guenter Roeck" <linux@roeck-us.net>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>, "Lee Jones" <lee@kernel.org>,
"Pavel Machek" <pavel@kernel.org>,
"Griffin Kroah-Hartman" <griffin@kroah.com>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Sebastian Reichel" <sre@kernel.org>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Wim Van Sebroeck" <wim@linux-watchdog.org>,
"Jarkko Sakkinen" <jarkko@kernel.org>,
"Mimi Zohar" <zohar@linux.ibm.com>,
"Roberto Sassu" <roberto.sassu@huawei.com>,
"Dmitry Kasatkin" <dmitry.kasatkin@gmail.com>,
"Eric Snowberg" <eric.snowberg@oracle.com>,
"Paul Moore" <paul@paul-moore.com>,
"James Morris" <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
linux-pci@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-hwmon@vger.kernel.org, linux-leds@vger.kernel.org,
mfd@lists.linux.dev, linux-rtc@vger.kernel.org,
linux-watchdog@vger.kernel.org, keyrings@vger.kernel.org,
linux-security-module@vger.kernel.org
Subject: Re: [RFC PATCH 05/14] iio/accel: add driver for apple SMS
Date: Thu, 29 Oct 2026 09:20:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-189025@kernel.org> (raw)
In-Reply-To: <20261029085504.3547-6-atharvatiwarilinuxdev@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] iio: accel: macsmc-accel: unindexed event channels cause -EBUSY probe failure
- [Medium] iio: accel: macsmc-accel: missing event config callbacks in macsmc_accel_info
- [Low] iio: accel: macsmc-accel: missing pm_sleep_ptr() wrapper on macsmc_accel_pm_ops
--
commit ee4b509c282b1a026627accf04e0b08185034ca5
Author: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
iio/accel: add driver for apple SMS
This commit adds an IIO accelerometer driver for the Apple Sudden Motion
Sensor (SMS) to report X, Y, and Z axes along with drop, orientation, and
shock events, and registers the macsmc-accel MFD cell in macsmc-core when the
MOCN key is present.
> diff --git a/drivers/iio/accel/macsmc-accel.c b/drivers/iio/accel/macsmc-accel.c
> new file mode 100644
> index 0000000000000..0abf81e7bd334
> --- /dev/null
> +++ b/drivers/iio/accel/macsmc-accel.c
[ ... ]
> +static const struct iio_event_spec macsmc_accel_event_spec = {
> + .type = IIO_EV_TYPE_CHANGE,
> + .dir = IIO_EV_DIR_NONE,
> + .mask_separate = BIT(IIO_EV_INFO_ENABLE),
> +};
> +
> +static const struct iio_chan_spec macsmc_accel_channels[] = {
> + {
> + .type = IIO_ACCEL,
> + .modified = 1,
> + .channel2 = IIO_MOD_X,
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> + },
> + {
> + .type = IIO_ACCEL,
> + .modified = 1,
> + .channel2 = IIO_MOD_Y,
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> + },
> + {
> + .type = IIO_ACCEL,
> + .modified = 1,
> + .channel2 = IIO_MOD_Z,
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> + },
> + {
> + .type = IIO_ACCEL,
> + .channel = SMS_DROP,
> + .event_spec = &macsmc_accel_event_spec,
> + .num_event_specs = 1,
> + },
> + {
> + .type = IIO_ACCEL,
> + .channel = SMS_ORIENTATION,
> + .event_spec = &macsmc_accel_event_spec,
> + .num_event_specs = 1,
> + },
> + {
> + .type = IIO_ACCEL,
> + .channel = SMS_SHOCK,
> + .event_spec = &macsmc_accel_event_spec,
> + .num_event_specs = 1,
> + },
> +};
[Severity: High]
Will macsmc_accel_probe() always fail with -EBUSY when registering these three
event channels?
In macsmc_accel_channels[], the SMS_DROP, SMS_ORIENTATION, and SMS_SHOCK
channels set .channel and .event_spec = &macsmc_accel_event_spec (which sets
.mask_separate = BIT(IIO_EV_INFO_ENABLE)), but they leave .indexed as 0.
When devm_iio_device_register() registers the event attributes:
macsmc_accel_probe()
-> devm_iio_device_register()
-> __iio_device_register()
-> iio_device_register_eventset()
-> __iio_add_event_config_attrs()
-> iio_device_add_event_sysfs()
-> iio_device_add_event()
-> __iio_add_chan_devattr()
-> __iio_device_attr_init()
-> __iio_chan_prefix_emit()
drivers/iio/industrialio-core.c:__iio_chan_prefix_emit() only includes
chan->channel in the sysfs attribute name when chan->indexed is set:
seq_buf_printf(&s, "%s_%s", dir, type);
if (chan->indexed)
seq_buf_printf(&s, "%d", chan->channel);
Because chan->indexed is 0 on all three event channels, each one generates the
same separate sysfs attribute name "in_accel_change_en". When the second event
channel (SMS_ORIENTATION) is processed in __iio_add_chan_devattr(), it detects
the duplicate IIO_SEPARATE attribute name in ev_int->dev_attr_list and returns
-EBUSY:
list_for_each_entry(t, attr_list, l)
if (strcmp(t->dev_attr.attr.name,
iio_attr->dev_attr.attr.name) == 0) {
if (shared_by == IIO_SEPARATE)
dev_err(dev, "tried to double register : %s\n",
t->dev_attr.attr.name);
ret = -EBUSY;
goto error_device_attr_deinit;
}
Should these three event channels set .indexed = 1 (and should
macsmc_accel_event() use IIO_EVENT_CODE() or otherwise match the channel
configuration) so that their sysfs attribute names do not collide?
> +
> +static const struct iio_info macsmc_accel_info = {
> + .read_raw = macsmc_accel_read_raw
> +};
[Severity: Medium]
Should macsmc_accel_info also provide .read_event_config and
.write_event_config callbacks, or should BIT(IIO_EV_INFO_ENABLE) be omitted
from macsmc_accel_event_spec?
Because macsmc_accel_event_spec sets .mask_separate = BIT(IIO_EV_INFO_ENABLE),
iio_device_add_event() creates sysfs event enable attributes backed by
iio_ev_state_show() and iio_ev_state_store() in
drivers/iio/industrialio-event.c:
if (!indio_dev->info->read_event_config)
return -EINVAL;
and:
if (!indio_dev->info->write_event_config)
return -EINVAL;
With both callbacks left NULL in macsmc_accel_info, any userspace read or
write on the exported *_change_en sysfs attributes will fail with -EINVAL.
> +
> +static int macsmc_accel_restore(struct device *dev)
> +{
> + struct macsmc_accel *drv = dev_get_drvdata(dev);
> +
> + return macsmc_accel_dev_init(drv);
> +}
> +
> +static const struct dev_pm_ops macsmc_accel_pm_ops = {
> + .restore = macsmc_accel_restore,
> +};
[ ... ]
> +static struct platform_driver macsmc_accel_driver = {
> + .probe = macsmc_accel_probe,
> + .driver = {
> + .name = "macsmc-accel",
> + .pm = &macsmc_accel_pm_ops,
> + },
> +};
[Severity: Low]
Could macsmc_accel_pm_ops wrap macsmc_accel_restore with pm_sleep_ptr(), and
macsmc_accel_driver wrap &macsmc_accel_pm_ops with pm_sleep_ptr(), so the PM
callback and ops structure are compiled out when CONFIG_PM_SLEEP is disabled?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261029085504.3547-1-atharvatiwarilinuxdev@gmail.com?part=5
next prev parent reply other threads:[~2026-10-29 9:20 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 8:51 [RFC PATCH 00/14] Add macsmc support for Intel Macs, replacing applesmc Atharva Tiwari
2026-10-29 8:51 ` [RFC PATCH 01/14] treewide: Add backend for macsmc Atharva Tiwari
2026-10-29 9:20 ` sashiko-bot
2026-10-29 8:51 ` [RFC PATCH 02/14] platform/x86: add backend for macsmc in intel macs Atharva Tiwari
2026-10-29 9:23 ` sashiko-bot
2026-10-29 12:59 ` Ilpo Järvinen
2026-10-29 8:52 ` [RFC PATCH 03/14] watchdog: add driver for apple smc Atharva Tiwari
2026-10-29 9:17 ` sashiko-bot
2026-10-29 13:30 ` Andy Shevchenko
2026-10-29 8:52 ` [RFC PATCH 04/14] iio/light: add new driver for macsmc Atharva Tiwari
2026-10-29 9:17 ` sashiko-bot
2026-10-29 8:52 ` [RFC PATCH 05/14] iio/accel: add driver for apple SMS Atharva Tiwari
2026-10-29 9:20 ` sashiko-bot [this message]
2026-10-29 8:52 ` [RFC PATCH 06/14] leds: add support for macsmc kbl Atharva Tiwari
2026-10-29 9:16 ` sashiko-bot
2026-10-29 8:52 ` [RFC PATCH 07/14] rtc: add support for x86 macs in macsmc-rtc Atharva Tiwari
2026-10-29 9:15 ` sashiko-bot
2026-10-29 8:52 ` [RFC PATCH 08/14] treewide: Add a flag to detect the Apple T2 chip Atharva Tiwari
2026-10-29 9:11 ` sashiko-bot
2026-10-29 8:52 ` [RFC PATCH 09/14] treewide: disable other rtc's in t2 macs Atharva Tiwari
2026-10-29 9:16 ` sashiko-bot
2026-10-29 8:52 ` [RFC PATCH 10/14] power/supply: add support for x86 macs in macsmc-power Atharva Tiwari
2026-10-29 9:19 ` sashiko-bot
2026-10-29 8:52 ` [RFC PATCH 11/14] acpi: disable battery and adapter for x86 apple machines Atharva Tiwari
2026-10-29 9:13 ` sashiko-bot
2026-10-29 8:52 ` [RFC PATCH 12/14] hwmon/macsmc: add more types Atharva Tiwari
2026-10-29 9:18 ` sashiko-bot
2026-10-29 8:52 ` [RFC PATCH 13/14] hwmon: add support for x86 macs in macsmc-hwmon Atharva Tiwari
2026-10-29 9:20 ` sashiko-bot
2026-10-29 8:52 ` [RFC PATCH 14/14] mfd/macsmc: add ioctl to access smc keys Atharva Tiwari
2026-10-29 9:22 ` Sasha Finkelstein
2026-10-29 14:39 ` Atharva Tiwari
2026-10-29 14:53 ` Sasha Finkelstein
2026-10-29 15:25 ` Aditya Garg
2026-10-29 15:42 ` Sasha Finkelstein
2026-10-29 9:26 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-189025@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexandre.belloni@bootlin.com \
--cc=andy@kernel.org \
--cc=atharvatiwarilinuxdev@gmail.com \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=brgl@kernel.org \
--cc=dave.hansen@linux.intel.com \
--cc=dlechner@baylibre.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=eric.snowberg@oracle.com \
--cc=griffin@kroah.com \
--cc=hansg@kernel.org \
--cc=hpa@zytor.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=j@jannau.net \
--cc=jarkko@kernel.org \
--cc=jic23@kernel.org \
--cc=jmorris@namei.org \
--cc=keyrings@vger.kernel.org \
--cc=lee@kernel.org \
--cc=lenb@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mfd@lists.linux.dev \
--cc=mingo@redhat.com \
--cc=neal@gompa.dev \
--cc=nuno.sa@analog.com \
--cc=paul@paul-moore.com \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=roberto.sassu@huawei.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=serge@hallyn.com \
--cc=sre@kernel.org \
--cc=sven@kernel.org \
--cc=tglx@kernel.org \
--cc=wim@linux-watchdog.org \
--cc=x86@kernel.org \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox