[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <176183986424.3742839.1867363151241824725@ping.linuxembedded.co.uk>
Date: Thu, 30 Oct 2025 15:57:44 +0000
From: Kieran Bingham <kieran.bingham@...asonboard.com>
To: Svyatoslav Ryhel <clamor95@...il.com>, Tarang Raval <tarang.raval@...iconsignals.io>
Cc: Mauro Carvalho Chehab <mchehab@...nel.org>, Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, Sakari Ailus <sakari.ailus@...ux.intel.com>, Hans Verkuil <hverkuil@...all.nl>, Hans de Goede <hansg@...nel.org>, André Apitzsch <git@...tzsch.eu>, Sylvain Petinot <sylvain.petinot@...s.st.com>, Benjamin Mugnier <benjamin.mugnier@...s.st.com>, Dongcheng Yan <dongcheng.yan@...el.com>, Heimir Thor Sverrisson <heimir.sverrisson@...il.com>, linux-media@...r.kernel.org <linux-media@...r.kernel.org>, devicetree@...r.kernel.org <devicetree@...r.kernel.org>, linux-kernel@...r.kernel.org <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 2/2] media: i2c: add Sony IMX111 CMOS camera sensor driver
Quoting Svyatoslav Ryhel (2025-10-30 15:13:31)
...
> >
> > > +static int imx111_initialize(struct imx111 *sensor)
> > > +{
> > > + struct device *dev = regmap_get_device(sensor->regmap);
> > > + int ret;
> >
> > ret = 0;
> >
>
> cci_write does not state that ret must be initiated.
>
> > > +
> > > + /* Configure the PLL. */
> > > + cci_write(sensor->regmap, IMX111_PRE_PLL_CLK_DIVIDER_PLL1,
> > > + sensor->pll->pre_div, &ret);
You definitely need to initialise ret = 0 or this line above will
probably fail because cci_write uses 'ret' to decide to do anything or
not.
- https://docs.kernel.org/driver-api/media/v4l2-cci.html
===============================================================================
int cci_write(struct regmap *map, u32 reg, u64 val, int *err)
Write a value to a single CCI register
Parameters
struct regmap *map
Register map to write to
u32 reg
Register address to write, use CCI_REG#() macros to encode reg width
u64 val
Value to be written
int *err
Optional pointer to store errors, if a previous error is set then
the write will be skipped
Return
0 on success or a negative error code on failure.
===============================================================================
So it should be initialised in a good state *or* you use NULL on
this first call and assign it - but init to ret = 0 is cleaner here I
think.
> > > + cci_write(sensor->regmap, IMX111_PLL_MULTIPLIER_PLL1, sensor->pll->mult, &ret);
> > > + cci_write(sensor->regmap, IMX111_POST_DIVIDER, IMX111_POST_DIVIDER_DIV1, &ret);
> > > + cci_write(sensor->regmap, IMX111_PLL_SETTLING_TIME,
> > > + to_settle_delay(sensor->pll->extclk_rate), &ret);
> > > +
> > > + ret = cci_multi_reg_write(sensor->regmap, imx111_global_init,
> > > + ARRAY_SIZE(imx111_global_init), NULL);
> >
> > You are overwriting the previous errors.
> >
> > please use ret |=
No - just continue with the same pattern:
cci_multi_reg_write(sensor->regmap, imx111_global_init,
ARRAY_SIZE(imx111_global_init), &ret);
> >
> > > + if (ret < 0) {
> > > + dev_err(dev, "Failed to initialize the sensor\n");
> > > + return ret;
> > > + }
> > > +
> > > + return 0;
> > > +}
Powered by blists - more mailing lists