Hi Laurent On 24/10/2020 23:36, Laurent Pinchart wrote: > Hi Dan, > > On Sat, Oct 24, 2020 at 11:28:06PM +0100, Daniel Scally wrote: >> On 24/10/2020 10:37, Laurent Pinchart wrote: >> >>>>> I wonder if we could avoid depending on the I2C device being created by >>>>> getting the fwnode from adev, and setting ->secondary manually. adev >>>>> would need to be passed to get_acpi_ssdb_sensor_data() instead of dev. >>>> Let me try that; I initially wanted to do >>>> set_secondary_fwnode(&adev->dev, fwnode) to avoid depending on the I2C >>>> dev being created but it turns out &adev->dev isn't the same pointer. I >>>> shall try it and see. >> Actually, thinking on this further I think maybe we can't avoid that - >> it's not actually in this patch series but during assigning GPIO >> resources parsed from PMIC's ACPI node to the sensor, I'm using >> dev_name() on the i2c dev to pass to .dev_id member of gpiod_lookup_table > Any chance we can construct the I2C device name from the ACPI device, > the same way that the ACPI/I2C core does ? It may be a dead end, but if > we could avoid depending on the I2C device, I think it will make > initialization easier. I have a feeling that will be difficult though, > as we'll need the I2C bus number, which won't be readily available. I'd have to look into how the ACPI/I2C core does it to be confident, but I think it would be ok. Doesn't look to me like the bus number is involved; my sensor's device names come through as "i2c-OVTI2680:00"; that's just a prefix tacked on to dev_name(adev->dev). I'm sure there's something that will stop it being quite so easy, but hopefully not insurmountable. > Maybe this calls for extending the gpiod lookup API, but that would then > likely be something we would build on top. I'm thinking about a way to > specify the GPIO mapping in the software node, and retrieving it from > there, the same way this is done for GPIOs in OF-based systems. Yeah that's an option too; I had had the same thought actually. Probably an extensive piece of work in its own right though