[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f904ed54-da90-4746-8230-0ae5dd0ca276@roeck-us.net>
Date: Fri, 15 Nov 2024 20:35:04 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Mark Brown <broonie@...nel.org>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Frank Li <Frank.Li@....com>
Subject: Re: regmap I3C support
On 11/14/24 09:26, Mark Brown wrote:
> On Thu, Nov 14, 2024 at 06:45:52AM -0800, Guenter Roeck wrote:
>
>> We now use
>
>> config SENSORS_TMP108
>> tristate "Texas Instruments TMP108"
>> depends on I2C
>> depends on I3C || !I3C
>> select REGMAP_I2C
>> select REGMAP_I3C if I3C
>
>> and in the i3c_probe function
>
>> #ifdef CONFIG_REGMAP_I3C
>> regmap = devm_regmap_init_i3c(i3cdev, &tmp108_regmap_config);
>> #else
>> regmap = ERR_PTR(-ENODEV);
>> #endif
>> if (IS_ERR(regmap))
>
>> Clumsy, and not my preferred solution, but it works.
>
> Right, so the fact that I3C depends on I2C deals with a lot of the
> problems that plague the I2C/SPI combination. Ugh. I guess the helper
> should be OK and there's not much doing for I2C/SPI.
It looks like we can use
if (IS_ENABLED(CONFIG_REGMAP_I3C)) {
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");
...
}
even if a stub function is not available as long as there is an external
declaration.
I don't really like it, but it turns out that this kind of code is already used
elsewhere in the kernel. It looks like dead code elimination can now assumed
to be available when building kernel code. We live and learn.
Guenter
Powered by blists - more mailing lists