From: Arnd Bergmann <arnd@arndb.de>
To: Jonghwa Lee <jonghwa3.lee@samsung.com>
Cc: linux-kernel@vger.kernel.org,
Mike Turquette <mturquette@linaro.org>,
Hartley Sweeten <hsweeten@visionengravers.com>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>
Subject: Re: [PATCH v3] clock: max77686: Add driver for Maxim 77686 32KHz crystal oscillator
Date: Mon, 11 Jun 2012 15:25:34 +0000 [thread overview]
Message-ID: <201206111525.34451.arnd@arndb.de> (raw)
In-Reply-To: <1339412480-7558-1-git-send-email-jonghwa3.lee@samsung.com>
On Monday 11 June 2012, Jonghwa Lee wrote:
> Maxim 77686 has three 32KHz clock outputs through the its crystal oscillator.
> This driver can control those ouputs by I2C bus. The clocks are used to supply
> to SOC and peripheral chips as a clock source. Clocks can be enabled/disabled only.
> It uses regmap interface to communicate with I2C bus.
>
> Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Thanks for fixing the issues pointed out in my first review, it
looks much better now.
> +struct clk *clk32khz_ap;
> +struct clk *clk32khz_cp;
> +struct clk *clk32khz_pmic;
As Felipe pointed out, you should not have global pointers
for these, not even static ones.
I think it's best if you use platform_set_drvdata() to attach
the array with the three max77686_clk structures to the platform
device.
> +char *max77686_clks[] = {
> + "32khap",
> + "32khcp",
> + "p32kh",
> +};
These can just be open-coded in the place where the strings
are used, there is no need to have a separate symbol for them.
> +static __devinit int max77686_clk_probe(struct platform_device *pdev)
> +{
> + struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
> + struct max77686_clk *max77686[MAX77686_CLKS_NUM];
> + int i, ret;
> +
> + for (i = 0; i < MAX77686_CLKS_NUM; i++) {
> + max77686[i] = devm_kzalloc(&pdev->dev,
> + sizeof(struct max77686_clk), GFP_KERNEL);
> + if (!max77686[i])
> + return -ENOMEM;
> +
> + max77686[i]->iodev = iodev;
> + max77686[i]->mask = 1 << i;
> + mutex_init(&max77686[i]->mutex);
> + }
> +
> +
> + clk32khz_ap = clk_register(&pdev->dev, max77686_clks[MAX77686_32KH_AP],
> + &max77686_clk_ops,
> + &max77686[MAX77686_32KH_AP]->hw,
> + NULL, 0, CLK_IS_ROOT);
> + if (IS_ERR(clk32khz_ap)) {
> + ret = PTR_ERR(clk32khz_ap);
> + goto err;
> + }
> +
> + clk32khz_cp = clk_register(&pdev->dev, max77686_clks[MAX77686_32KH_CP],
> + &max77686_clk_ops,
> + &max77686[MAX77686_32KH_CP]->hw,
> + NULL, 0, CLK_IS_ROOT);
> + if (IS_ERR(clk32khz_cp)) {
> + ret = PTR_ERR(clk32khz_cp);
> + goto err;
> + }
> +
> + clk32khz_pmic = clk_register(&pdev->dev, max77686_clks[MAX77686_P32KH],
> + &max77686_clk_ops,
> + &max77686[MAX77686_P32KH]->hw,
> + NULL, 0, CLK_IS_ROOT);
> + if (IS_ERR(clk32khz_pmic)) {
> + ret = PTR_ERR(clk32khz_pmic);
> + goto err;
> + }
Note that the prototype for clk_register has changed recently, so this
will have to be rewritten. It might simplify the code if you pull the call
to clk_register into the loop, and add a helper function for the loop body,
like
for (i = 0; i < MAX77686_CLKS_NUM; i++) {
ret = max77686_clk_register(&pdev->dev, iodev, i);
if (ret) {
max77686_clk_remove(pdev);
return ret;
}
}
> +static int __devexit max77686_clk_remove(struct platform_device *pdev)
> +{
> + kfree(clk32khz_ap);
> + kfree(clk32khz_cp);
> + kfree(clk32khz_pmic);
> + return 0;
> +}
As Mark mentioned, the kfree is not necessary, but the clk_unregister
is missing here and in the error path of the probe function.
Arnd
prev parent reply other threads:[~2012-06-11 15:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-11 11:01 [PATCH v3] clock: max77686: Add driver for Maxim 77686 32KHz crystal oscillator Jonghwa Lee
2012-06-11 11:09 ` Felipe Balbi
2012-06-11 11:21 ` Mark Brown
2012-06-11 11:16 ` Mark Brown
2012-06-11 15:25 ` Arnd Bergmann [this message]
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=201206111525.34451.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=hsweeten@visionengravers.com \
--cc=jonghwa3.lee@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=myungjoo.ham@samsung.com \
/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