From: Hans de Goede <hdegoede@redhat.com>
To: "Pali Rohár" <pali@kernel.org>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Paul Menzel" <pmenzel@molgen.mpg.de>,
"Wolfram Sang" <wsa@kernel.org>,
eric.piel@tremplin-utc.net, "Marius Hoch" <mail@mariushoch.de>,
Dell.Client.Kernel@dell.com,
"Kai Heng Feng" <kai.heng.feng@canonical.com>,
platform-driver-x86@vger.kernel.org,
"Jean Delvare" <jdelvare@suse.com>,
"Andi Shyti" <andi.shyti@kernel.org>,
linux-i2c@vger.kernel.org
Subject: Re: [PATCH v4 4/6] platform/x86: dell-smo8800: Move instantiation of lis3lv02d i2c_client from i2c-i801 to dell-lis3lv02d
Date: Tue, 2 Jul 2024 20:54:10 +0200 [thread overview]
Message-ID: <64f9103b-becf-4a66-908b-c655b3c37a38@redhat.com> (raw)
In-Reply-To: <20240624181420.nvdszjycejdc5fer@pali>
Hi,
On 6/24/24 8:14 PM, Pali Rohár wrote:
> On Monday 24 June 2024 13:15:16 Hans de Goede wrote:
>> +static int match_acpi_device_ids(struct device *dev, const void *data)
>> +{
>
> You can mark this function as __init as it is called only from
> dell_lis3lv02d_init to free space.
>
>> + const struct acpi_device_id *ids = data;
>> +
>> + return acpi_match_device(ids, dev) ? 1 : 0;
>> +}
>> +
>> +static int __init dell_lis3lv02d_init(void)
>> +{
>> + struct device *dev;
>> + int err;
>> +
>> + /*
>> + * First check for a matching platform_device. This protects against
>> + * SMO88xx ACPI fwnodes which actually do have an I2C resource, which
>> + * will already have an i2c_client instantiated (not a platform_device).
>> + */
>> + dev = bus_find_device(&platform_bus_type, NULL, smo8800_ids, match_acpi_device_ids);
>> + if (!dev) {
>> + pr_debug("No SMO88xx platform-device found\n");
>> + return 0;
>
> Is zero return value expected? Should not be it something like -ENODEV?
This is a module_init() function returning non 0 leads to an error getting
logged and the modprobe command to return a non 0 value which is not what
we want.
>> + }
>> + put_device(dev);
>> +
>> + lis3lv02d_dmi_id = dmi_first_match(lis3lv02d_devices);
>> + if (!lis3lv02d_dmi_id) {
>
> You can cache the value lis3lv02d_dmi_id->driver_data instead of caching
> lis3lv02d_dmi_id pointer and then you can mark lis3lv02d_devices array
> as __initconst to free additional space not needed at runtime on x86
> machines without accelerometer where CONFIG_DELL_SMO8800=y.
This is a good idea, done for v5.
Regards,
Hans
>
>> + pr_warn("accelerometer is present on SMBus but its address is unknown, skipping registration\n");
>> + return 0;
>> + }
>> +
>> + /*
>> + * Register i2c-bus notifier + queue initial scan for lis3lv02d
>> + * i2c_client instantiation.
>> + */
>> + err = bus_register_notifier(&i2c_bus_type, &i2c_nb);
>> + if (err)
>> + return err;
>> +
>> + notifier_registered = true;
>> +
>> + queue_work(system_long_wq, &i2c_work);
>> + return 0;
>> +}
>> +module_init(dell_lis3lv02d_init);
>> +
>> +static void __exit dell_lis3lv02d_module_exit(void)
>> +{
>> + if (!notifier_registered)
>> + return;
>> +
>> + bus_unregister_notifier(&i2c_bus_type, &i2c_nb);
>> + cancel_work_sync(&i2c_work);
>> + i2c_unregister_device(i2c_dev);
>> +}
>> +module_exit(dell_lis3lv02d_module_exit);
>> +
>> +MODULE_DESCRIPTION("lis3lv02d i2c-client instantiation for ACPI SMO88xx devices");
>> +MODULE_AUTHOR("Hans de Goede <hansg@kernel.org>");
>> +MODULE_LICENSE("GPL");
>> --
>> 2.45.1
>>
>
next prev parent reply other threads:[~2024-07-02 18:54 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 11:15 [PATCH v4 0/6] i2c-i801 / dell-lis3lv02d: Move instantiation of lis3lv02d i2c_client from i2c-i801 to dell-lis3lv02d Hans de Goede
2024-06-24 11:15 ` [PATCH v4 1/6] i2c: core: Setup i2c_adapter runtime-pm before calling device_add() Hans de Goede
2024-06-24 11:15 ` [PATCH v4 2/6] i2c: i801: Use a different adapter-name for IDF adapters Hans de Goede
2024-06-24 11:15 ` [PATCH v4 3/6] platform/x86: dell-smo8800: Move SMO88xx acpi_device_ids to dell-smo8800-ids.h Hans de Goede
2024-06-24 11:15 ` [PATCH v4 4/6] platform/x86: dell-smo8800: Move instantiation of lis3lv02d i2c_client from i2c-i801 to dell-lis3lv02d Hans de Goede
2024-06-24 18:14 ` Pali Rohár
2024-07-02 18:54 ` Hans de Goede [this message]
2024-06-28 0:01 ` kernel test robot
2024-06-24 11:15 ` [PATCH v4 5/6] platform/x86: dell-smo8800: Add a couple more models to lis3lv02d_devices[] Hans de Goede
2024-06-24 18:14 ` Pali Rohár
2024-07-02 19:15 ` Hans de Goede
2024-06-24 11:15 ` [PATCH v4 6/6] platform/x86: dell-smo8800: Add support for probing for the accelerometer i2c address Hans de Goede
2024-06-24 18:21 ` Pali Rohár
2024-07-03 10:52 ` Hans de Goede
2024-06-28 1:42 ` kernel test robot
2024-06-24 18:28 ` [PATCH v4 0/6] i2c-i801 / dell-lis3lv02d: Move instantiation of lis3lv02d i2c_client from i2c-i801 to dell-lis3lv02d Pali Rohár
2024-07-03 10:58 ` Hans de Goede
2024-07-03 18:41 ` Pali Rohár
2024-07-04 10:17 ` Hans de Goede
2024-07-04 15:54 ` Pali Rohár
2024-07-04 17:54 ` Hans de Goede
2024-07-04 10:29 ` Hans de Goede
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=64f9103b-becf-4a66-908b-c655b3c37a38@redhat.com \
--to=hdegoede@redhat.com \
--cc=Dell.Client.Kernel@dell.com \
--cc=andi.shyti@kernel.org \
--cc=andy@kernel.org \
--cc=eric.piel@tremplin-utc.net \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jdelvare@suse.com \
--cc=kai.heng.feng@canonical.com \
--cc=linux-i2c@vger.kernel.org \
--cc=mail@mariushoch.de \
--cc=pali@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=pmenzel@molgen.mpg.de \
--cc=wsa@kernel.org \
/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