Accessing driver data from parse_dt

Hello,

I am trying out L4T r32.2.2 on an AGX Xavier and trying to modify the imx185 camera board to support camera slave mode.

In r28.2 parse_dt function was called from probe, so the imx185 private data structure had already been created and linked to camera_common_data->priv which was passed into parse_dt. This structure made it trivial to add custom settings to the device tree. In my case I have a property that is set to “true” to indicate the camera is the slave and then I set a flag in camera_common_data->priv.

Now parse_dt is called from camera_common_sensor_ops and tegracam_get_privdata(tc_dev) just returns null, meaning it is being called before that is set inside probe.

Is there a way to have the driver’s private data structure available during parse_dt, or should I just handle it in probe?

Thanks!

Looks like parse_dt is called during tegracam_device_register, but you can’t call tegracam_set_privdata before then because it de-references tc_dev->s_data which doesn’t exist until tegracam_device_register.

So it looks like the simplest solution is to set tc_dev->priv manually before the call to tegracam_device_register

@@ -789,6 +813,7 @@ static int imx185_probe(struct i2c_client *client,
        tc_dev->sensor_ops = &imx185_common_ops;
        tc_dev->v4l2sd_internal_ops = &imx185_subdev_internal_ops;
        tc_dev->tcctrl_ops = &imx185_ctrl_ops;
+       tc_dev->priv = (void *)priv;
 
        err = tegracam_device_register(tc_dev);
        if (err) {