[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YyhsQ+l1Sls00F0M@paasikivi.fi.intel.com>
Date: Mon, 19 Sep 2022 13:18:59 +0000
From: Sakari Ailus <sakari.ailus@...ux.intel.com>
To: Marco Felsch <m.felsch@...gutronix.de>
Cc: mchehab@...nel.org, laurent.pinchart+renesas@...asonboard.com,
akinobu.mita@...il.com, jacopo+renesas@...ndi.org,
linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/3] media: mt9m111: add V4L2_CID_LINK_FREQ support
Hi Marco,
On Mon, Sep 19, 2022 at 03:08:29PM +0200, Marco Felsch wrote:
> Hi Sakari,
>
> On 22-09-19, Sakari Ailus wrote:
> > Hi Marco,
> >
> > On Fri, Sep 16, 2022 at 03:57:11PM +0200, Marco Felsch wrote:
> > > Add support to report the link frequency.
> > >
> > > Signed-off-by: Marco Felsch <m.felsch@...gutronix.de>
> > > ---
> > > The v1 of this small series can be found here:
> > > https://lore.kernel.org/all/20220818144712.997477-1-m.felsch@pengutronix.de/
> > >
> > > Thanks a lot to Jacopo for the review feedback on my v1.
> > >
> > > Changelog:
> > >
> > > v2:
> > > - use V4L2_CID_LINK_FREQ instead of V4L2_CID_PIXEL_RATE
> > > ---
> > > drivers/media/i2c/mt9m111.c | 21 ++++++++++++++++++++-
> > > 1 file changed, 20 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
> > > index afc86efa9e3e..52be1c310455 100644
> > > --- a/drivers/media/i2c/mt9m111.c
> > > +++ b/drivers/media/i2c/mt9m111.c
> > > @@ -1249,6 +1249,8 @@ static int mt9m111_probe(struct i2c_client *client)
> > > {
> > > struct mt9m111 *mt9m111;
> > > struct i2c_adapter *adapter = client->adapter;
> > > + static s64 extclk_rate;
> > > + struct v4l2_ctrl *ctrl;
> > > int ret;
> > >
> > > if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) {
> > > @@ -1271,6 +1273,13 @@ static int mt9m111_probe(struct i2c_client *client)
> > > if (IS_ERR(mt9m111->clk))
> > > return PTR_ERR(mt9m111->clk);
> > >
> > > + ret = clk_prepare_enable(mt9m111->clk);
> > > + if (ret < 0)
> > > + return ret;
> > > +
> > > + extclk_rate = clk_get_rate(mt9m111->clk);
> > > + clk_disable_unprepare(mt9m111->clk);
> >
> > I don't think you'll need to enable a clock to just get its frequency.
>
> The official API states that you need to turn on the clk before
> requesting it and it makes sense. Also there is a new helper
> devm_clk_get_enabled() which addresses simple clk usage since most of
> drivers don't enable it before requesting the rate.
I guess the rate could change in the meantime, unless exclusive access is
requested. The clock framework currently doesn't offer a way to set the
assigned rate and prevent changing it. But above, couldn't the clock
frequency be changed again once the clock has been disabled?
--
Sakari Ailus
Powered by blists - more mailing lists