An potential issue in tegra_i2c_probe()

I noticed this code in the function tegra_i2c_probe() :

static int tegra_i2c_probe(struct platform_device *pdev)
struct tegra_i2c_dev *i2c_dev;
struct resource *res;
int err;

    i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL);
    if ((i2c_dev->bus_clk_rate == I2C_HS_MODE) &&
                    !i2c_dev->hw->has_hs_mode_support) {
            dev_info(i2c_dev->dev, "HS mode not supported\n");
            i2c_dev->bus_clk_rate = 100000; /* default clock rate */


The point is that i2c_dev->bus_clk_rate is tested and perhaps will be adjusted in the ‘if’ statement above. However, the first place that i2c_dev->bus_clk_rate is initialized is from tegra_i2c_parse_dt(i2c_dev) where it gets its first value through:
of_property_read_u32(np, “clock-frequency”, &i2c_dev->bus_clk_rate)

So I can see, i2c_dev->bus_clk_rate is used before it is initialized.


Hi @johnny96.young,

Thanks for spotting this and letting us know. Can you point me to the source repo or SDK package where you picked this code up from?

That would make it easier for me to forward this to the correct engineers.


Hi Markus,

This code exists in the source from version Jetson-kit–35.1.0 to Jetson-kit–35.3.1.

Thank you !

Thank you!