From: Guenter Roeck <linux@roeck-us.net>
To: Frank Li <Frank.li@nxp.com>
Cc: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Jean Delvare <jdelvare@suse.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
Krzysztof Kozlowski <krzk@kernel.org>,
linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v3 4/5] hwmon: tmp108: Add support for I3C device
Date: Mon, 11 Nov 2024 15:31:39 -0800 [thread overview]
Message-ID: <7bdd2db8-41c8-43d8-ae73-84a221d2d004@roeck-us.net> (raw)
In-Reply-To: <ZzKRRdXpeHVyUDOM@lizhi-Precision-Tower-5810>
On 11/11/24 15:20, Frank Li wrote:
> On Mon, Nov 11, 2024 at 10:37:04AM -0800, Guenter Roeck wrote:
>> On 11/11/24 10:10, Guenter Roeck wrote:
>>> On 11/11/24 10:04, Guenter Roeck wrote:
>>> [ ... ]
>>>>> +static int p3t1085_i3c_probe(struct i3c_device *i3cdev)
>>>>> +{
>>>>> + struct device *dev = i3cdev_to_dev(i3cdev);
>>>>> + struct regmap *regmap;
>>>>> +
>>>>> + regmap = devm_regmap_init_i3c(i3cdev, &tmp108_regmap_config);
>>>>> + if (IS_ERR(regmap))
>>>>> + return dev_err_probe(dev, PTR_ERR(regmap),
>>>>> + "Failed to register i3c regmap\n");
>>>>> +
>>>>> + return tmp108_common_probe(dev, regmap, "p3t1085_i3c");
>>>>> +}
>>>>> +
>>>>> +static struct i3c_driver p3t1085_driver = {
>>>>> + .driver = {
>>>>> + .name = "p3t1085_i3c",
>>>>> + },
>>>>> + .probe = p3t1085_i3c_probe,
>>>>> + .id_table = p3t1085_i3c_ids,
>>>>> +};
>>>>> +module_i3c_driver(p3t1085_driver);
>>>>> +#endif
>>>>
>>>> While looking at i3c code, I found module_i3c_i2c_driver(). Can we use
>>>> that function to register both i2c and i3c in one call ?
>>>>
>>> Answering my own question: No, because devm_regmap_init_i3c()
>>> does not provide a dummy function if i3C is not enabled.
>>>
>>
>> I do have another concern, though: What happens if the i2c part of the driver
>> registers and the i3c part fails to register ? module_i3c_i2c_driver() handles
>> that situation by unregistering the i2c driver, but I don't really know
>> what happens if a single module registers two drivers and one of them fails.
>
> After use module_i3c_i2c_driver(), and remove #ifdef I3C, and disable I3C
> in config, build passed.
>
> It possible cause by
>
> static inline int i3c_i2c_driver_register(struct i3c_driver *i3cdrv,
> struct i2c_driver *i2cdrv)
> {
> int ret;
>
> ret = i2c_add_driver(i2cdrv);
> if (ret || !IS_ENABLED(CONFIG_I3C))
> return ret;
>
> ^^^ !IS_ENABLED(CONFIG_I3C) is true, so linker skip below part. So no
> ref to i3cdrv, so linker remove all related codes.
>
Yes, but I don't think we can rely on the compiler removing the call to
devm_regmap_init_i3c().
Thanks,
Guenter
next prev parent reply other threads:[~2024-11-12 0:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-11 17:31 [PATCH v3 0/5] hwmon: tmp108: Add support for P3T1085 Frank Li
2024-11-11 17:31 ` [PATCH v3 1/5] dt-bindings: hwmon: ti,tmp108: Add nxp,p3t1085 compatible string Frank Li
2024-11-11 19:22 ` Guenter Roeck
2024-11-11 17:31 ` [PATCH v3 2/5] hwmon: tmp108: Add NXP p3t1085 support Frank Li
2024-11-11 19:23 ` Guenter Roeck
2024-11-11 17:32 ` [PATCH v3 3/5] hwmon: tmp108: Add helper function tmp108_common_probe() to prepare I3C support Frank Li
2024-11-11 19:44 ` Guenter Roeck
2024-11-11 21:59 ` Frank Li
2024-11-11 17:32 ` [PATCH v3 4/5] hwmon: tmp108: Add support for I3C device Frank Li
2024-11-11 18:04 ` Guenter Roeck
2024-11-11 18:10 ` Guenter Roeck
2024-11-11 18:37 ` Guenter Roeck
2024-11-11 23:20 ` Frank Li
2024-11-11 23:31 ` Guenter Roeck [this message]
2024-11-11 23:34 ` Guenter Roeck
2024-11-14 7:36 ` kernel test robot
2024-11-11 17:32 ` [PATCH v3 5/5] arm64: dts: imx93-9x9-qsb: add temp-sensor nxp,p3t1085 Frank Li
2024-11-11 19:13 ` Marco Felsch
2024-11-11 19:24 ` Frank Li
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=7bdd2db8-41c8-43d8-ae73-84a221d2d004@roeck-us.net \
--to=linux@roeck-us.net \
--cc=Frank.li@nxp.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=jdelvare@suse.com \
--cc=jic23@kernel.org \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=krzk@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@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