public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: linux-media@vger.kernel.org,
	Mike Turquette <mturquette@linaro.org>,
	Mauro Carvalho Chehab <mchehab@redhat.com>
Subject: Re: [PATCH 1/2] omap3isp: Use the common clock framework
Date: Thu, 04 Apr 2013 13:34:43 +0200	[thread overview]
Message-ID: <3042650.zKZtsJVg4A@avalon> (raw)
In-Reply-To: <20130404112004.GG10541@valkosipuli.retiisi.org.uk>

Hi Sakari,

Thanks for the comments.

On Thursday 04 April 2013 14:20:04 Sakari Ailus wrote:
> Hi Laurent,
> 
> I don't remember when did I see equally nice patch to the omap3isp driver!
> 
> :-) Thanks!
> 
> A few comments below.
> 
> On Thu, Apr 04, 2013 at 01:08:38PM +0200, Laurent Pinchart wrote:
> ...
> 
> > +static int isp_xclk_set_rate(struct clk_hw *hw, unsigned long rate,
> > +			     unsigned long parent_rate)
> > +{
> > +	struct isp_xclk *xclk = to_isp_xclk(hw);
> > +	unsigned long flags;
> > +	u32 divider;
> > +
> > +	divider = isp_xclk_calc_divider(&rate, parent_rate);
> > +
> > +	spin_lock_irqsave(&xclk->lock, flags);
> > +
> > +	xclk->divider = divider;
> > +	if (xclk->enabled)
> > +		isp_xclk_update(xclk, divider);
> > +
> > +	spin_unlock_irqrestore(&xclk->lock, flags);
> > +
> > +	dev_dbg(xclk->isp->dev, "%s: cam_xclk%c set to %lu Hz (div %u)\n",
> > +		__func__, xclk->id == ISP_XCLK_A ? 'a' : 'b', rate, divider);
> > +	return 0;
> > +}
> > +
> > +static const struct clk_ops isp_xclk_ops = {
> > +	.prepare = isp_xclk_prepare,
> > +	.unprepare = isp_xclk_unprepare,
> > +	.enable = isp_xclk_enable,
> > +	.disable = isp_xclk_disable,
> > +	.recalc_rate = isp_xclk_recalc_rate,
> > +	.round_rate = isp_xclk_round_rate,
> > +	.set_rate = isp_xclk_set_rate,
> > +};
> > +
> > +static const char *isp_xclk_parent_name = "cam_mclk";
> > +
> > +static const struct clk_init_data isp_xclk_init_data = {
> > +	.name = "cam_xclk",
> > +	.ops = &isp_xclk_ops,
> > +	.parent_names = &isp_xclk_parent_name,
> > +	.num_parents = 1,
> > +};
> 
> isp_xclk_init_data is unused.

Indeed. I wonder how I've missed that, the compiler should have complained. 
I'll fix it for v2.

> > +static int isp_xclk_init(struct isp_device *isp)
> > +{
> > +	struct isp_platform_data *pdata = isp->pdata;
> > +	struct clk_init_data init;
> 
> Init can be declared inside the loop.

OK.

> > +	unsigned int i;
> > +
> > +	for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i) {
> > +		struct isp_xclk *xclk = &isp->xclks[i];
> > +		struct clk *clk;
> > +
> > +		xclk->isp = isp;
> > +		xclk->id = i == 0 ? ISP_XCLK_A : ISP_XCLK_B;
> > +		xclk->divider = 1;
> > +		spin_lock_init(&xclk->lock);
> > +
> > +		init.name = i == 0 ? "cam_xclka" : "cam_xclkb";
> > +		init.ops = &isp_xclk_ops;
> > +		init.parent_names = &isp_xclk_parent_name;
> > +		init.num_parents = 1;
> > +
> > +		xclk->hw.init = &init;
> > +
> > +		clk = devm_clk_register(isp->dev, &xclk->hw);
> > +		if (IS_ERR(clk))
> > +			return PTR_ERR(clk);
> > +
> > +		if (pdata->xclks[i].con_id == NULL &&
> > +		    pdata->xclks[i].dev_id == NULL)
> > +			continue;
> > +
> > +		xclk->lookup = kzalloc(sizeof(*xclk->lookup), GFP_KERNEL);
> 
> How about devm_kzalloc()? You'd save a bit of error handling (which is btw.
> missing now, as well as kfree in cleanup).

As Sylwester pointed out, clkdev_drop() frees the memory. I don't really like 
that clkdev_add/clkdev_drop inconsistency, that might be something worth 
fixing at some point.

> > +		if (xclk->lookup == NULL)
> > +			return -ENOMEM;
> > +
> > +		xclk->lookup->con_id = pdata->xclks[i].con_id;
> > +		xclk->lookup->dev_id = pdata->xclks[i].dev_id;
> > +		xclk->lookup->clk = clk;
> > +
> > +		clkdev_add(xclk->lookup);
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static void isp_xclk_cleanup(struct isp_device *isp)
> > +{
> > +	unsigned int i;
> > +
> > +	for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i) {
> > +		struct isp_xclk *xclk = &isp->xclks[i];
> > +
> > +		if (xclk->lookup)
> > +			clkdev_drop(xclk->lookup);
> > +	}
> > +}

-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2013-04-04 11:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-04 11:08 [PATCH 0/2] OMAP3 ISP common clock framework support Laurent Pinchart
2013-04-04 11:08 ` [PATCH 1/2] omap3isp: Use the common clock framework Laurent Pinchart
2013-04-04 11:20   ` Sakari Ailus
2013-04-04 11:27     ` Sylwester Nawrocki
2013-04-04 13:07       ` Sakari Ailus
2013-04-04 11:34     ` Laurent Pinchart [this message]
2013-04-04 11:08 ` [PATCH 2/2] mt9p031: " Laurent Pinchart
2013-04-04 21:25 ` [PATCH 0/2] OMAP3 ISP common clock framework support Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3042650.zKZtsJVg4A@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@redhat.com \
    --cc=mturquette@linaro.org \
    --cc=sakari.ailus@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox