All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: Sachin Kamat <sachin.kamat@linaro.org>
Cc: <linux-kernel@vger.kernel.org>, <broonie@kernel.org>,
	<ldewangan@nvidia.com>, <gg@slimlogic.co.uk>,
	<yong.shen@linaro.org>, <s.hauer@pengutronix.de>,
	<marek.vasut@gmail.com>, <Nancy.Chen@freescale.com>
Subject: Re: [PATCH 7/7] regulator: ti-abb: Use devm_regulator_register
Date: Wed, 4 Sep 2013 08:27:56 -0500	[thread overview]
Message-ID: <5227355C.1020205@ti.com> (raw)
In-Reply-To: <1378276263-10735-7-git-send-email-sachin.kamat@linaro.org>

On 09/04/2013 01:31 AM, Sachin Kamat wrote:
> devm_* simplifies the code.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>

Seems to do a little more than devm_* alone, there is pruning of error
handling done here as well.

I am not comfortable with loosing print message information that help
debug issues on the field - which we usually have to based on just
kernel logs.

Please reduce the change to just using devm_regulator_register and
removal of .remove function and i am ok with that change.
> ---
>  drivers/regulator/ti-abb-regulator.c |   82 ++++++++++------------------------
>  1 file changed, 23 insertions(+), 59 deletions(-)
> 
> diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c
> index 3753ed0..02392f8 100644
> --- a/drivers/regulator/ti-abb-regulator.c
> +++ b/drivers/regulator/ti-abb-regulator.c
> @@ -696,22 +696,17 @@ static int ti_abb_probe(struct platform_device *pdev)
>  	match = of_match_device(ti_abb_of_match, dev);
>  	if (!match) {
>  		/* We do not expect this to happen */
> -		ret = -ENODEV;
>  		dev_err(dev, "%s: Unable to match device\n", __func__);
> -		goto err;
> +		return -ENODEV;
>  	}
>  	if (!match->data) {
> -		ret = -EINVAL;
>  		dev_err(dev, "%s: Bad data in match\n", __func__);
> -		goto err;
> +		return -EINVAL;
>  	}
>  
>  	abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL);
> -	if (!abb) {
> -		dev_err(dev, "%s: Unable to allocate ABB struct\n", __func__);
> -		ret = -ENOMEM;
> -		goto err;
> -	}
> +	if (!abb)
> +		return -ENOMEM;
here.

>  	abb->regs = match->data;
>  
>  	/* Map ABB resources */
> @@ -719,21 +714,17 @@ static int ti_abb_probe(struct platform_device *pdev)
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname);
>  	if (!res) {
>  		dev_err(dev, "Missing '%s' IO resource\n", pname);
> -		ret = -ENODEV;
> -		goto err;
> +		return -ENODEV;
>  	}
>  	abb->base = devm_ioremap_resource(dev, res);
> -	if (IS_ERR(abb->base)) {
> -		ret = PTR_ERR(abb->base);
> -		goto err;
> -	}
> +	if (IS_ERR(abb->base))
> +		return PTR_ERR(abb->base);
>  
>  	pname = "int-address";
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname);
>  	if (!res) {
>  		dev_err(dev, "Missing '%s' IO resource\n", pname);
> -		ret = -ENODEV;
> -		goto err;
> +		return -ENODEV;
>  	}
>  	/*
>  	 * We may have shared interrupt register offsets which are
> @@ -743,8 +734,7 @@ static int ti_abb_probe(struct platform_device *pdev)
>  					     resource_size(res));
>  	if (!abb->int_base) {
>  		dev_err(dev, "Unable to map '%s'\n", pname);
> -		ret = -ENOMEM;
> -		goto err;
> +		return -ENOMEM;
>  	}
>  
>  	/* Map Optional resources */
> @@ -764,8 +754,7 @@ static int ti_abb_probe(struct platform_device *pdev)
>  					       resource_size(res));
>  	if (!abb->efuse_base) {
>  		dev_err(dev, "Unable to map '%s'\n", pname);
> -		ret = -ENOMEM;
> -		goto err;
> +		return -ENOMEM;
>  	}
>  
>  	pname = "ldo-address";
> @@ -776,10 +765,8 @@ static int ti_abb_probe(struct platform_device *pdev)
>  		goto skip_opt;
>  	}
>  	abb->ldo_base = devm_ioremap_resource(dev, res);
> -	if (IS_ERR(abb->ldo_base)) {
> -		ret = PTR_ERR(abb->ldo_base);
> -		goto err;
> -	}
> +	if (IS_ERR(abb->ldo_base))
> +		return PTR_ERR(abb->ldo_base);
>  
>  	/* IF ldo_base is set, the following are mandatory */
>  	pname = "ti,ldovbb-override-mask";
> @@ -788,12 +775,11 @@ static int ti_abb_probe(struct platform_device *pdev)
>  				 &abb->ldovbb_override_mask);
>  	if (ret) {
>  		dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
> -		goto err;
> +		return ret;
>  	}
>  	if (!abb->ldovbb_override_mask) {
>  		dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
> -		ret = -EINVAL;
> -		goto err;
> +		return -EINVAL;
>  	}
>  
>  	pname = "ti,ldovbb-vset-mask";
> @@ -802,12 +788,11 @@ static int ti_abb_probe(struct platform_device *pdev)
>  				 &abb->ldovbb_vset_mask);
>  	if (ret) {
>  		dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
> -		goto err;
> +		return ret;
>  	}
>  	if (!abb->ldovbb_vset_mask) {
>  		dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
> -		ret = -EINVAL;
> -		goto err;
> +		return -EINVAL;
>  	}
>  
>  skip_opt:
> @@ -817,31 +802,29 @@ skip_opt:
>  				 &abb->txdone_mask);
>  	if (ret) {
>  		dev_err(dev, "Missing '%s' (%d)\n", pname, ret);
> -		goto err;
> +		return ret;
>  	}
>  	if (!abb->txdone_mask) {
>  		dev_err(dev, "Invalid property:'%s' set as 0!\n", pname);
> -		ret = -EINVAL;
> -		goto err;
> +		return -EINVAL;
>  	}
>  
>  	initdata = of_get_regulator_init_data(dev, pdev->dev.of_node);
>  	if (!initdata) {
> -		ret = -ENOMEM;
>  		dev_err(dev, "%s: Unable to alloc regulator init data\n",
>  			__func__);
> -		goto err;
> +		return -ENOMEM;
>  	}
>  
>  	/* init ABB opp_sel table */
>  	ret = ti_abb_init_table(dev, abb, initdata);
>  	if (ret)
> -		goto err;
> +		return ret;
>  
>  	/* init ABB timing */
>  	ret = ti_abb_init_timings(dev, abb);
>  	if (ret)
> -		goto err;
> +		return ret;
>  
>  	desc = &abb->rdesc;
>  	desc->name = dev_name(dev);
> @@ -859,12 +842,12 @@ skip_opt:
>  	config.driver_data = abb;
>  	config.of_node = pdev->dev.of_node;
>  
> -	rdev = regulator_register(desc, &config);
> +	rdev = devm_regulator_register(dev, desc, &config);

ok with this.

>  	if (IS_ERR(rdev)) {
>  		ret = PTR_ERR(rdev);
>  		dev_err(dev, "%s: failed to register regulator(%d)\n",
>  			__func__, ret);
> -		goto err;
> +		return ret;
>  	}
>  	platform_set_drvdata(pdev, rdev);
>  
> @@ -872,31 +855,12 @@ skip_opt:
>  	ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->regs->setup_reg, abb->base);
>  
>  	return 0;
> -
> -err:
> -	dev_err(dev, "%s: Failed to initialize(%d)\n", __func__, ret);
> -	return ret;
here -> with this, the lazy non detailed prints end with a generic
fail case.

I can cleanup the error handling if you like.

> -}
> -
> -/**
> - * ti_abb_remove() - cleanups
> - * @pdev: ABB platform device
> - *
> - * Return: 0
> - */
> -static int ti_abb_remove(struct platform_device *pdev)
> -{
> -	struct regulator_dev *rdev = platform_get_drvdata(pdev);
> -
> -	regulator_unregister(rdev);
> -	return 0;
ok with this
>  }
>  
>  MODULE_ALIAS("platform:ti_abb");
>  
>  static struct platform_driver ti_abb_driver = {
>  	.probe = ti_abb_probe,
> -	.remove = ti_abb_remove,
ok with this
>  	.driver = {
>  		   .name = "ti_abb",
>  		   .owner = THIS_MODULE,
> 


-- 
Regards,
Nishanth Menon

  reply	other threads:[~2013-09-04 13:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-04  6:30 [PATCH 1/7] regulator: anatop-regulator: Use devm_regulator_register Sachin Kamat
2013-09-04  6:30 ` [PATCH 2/7] regulator: isl6271a-regulator: " Sachin Kamat
2013-09-04 14:26   ` Marek Vasut
2013-09-04  6:30 ` [PATCH 3/7] regulator: mc13783: " Sachin Kamat
2013-09-04 14:27   ` Marek Vasut
2013-09-04  6:31 ` [PATCH 4/7] regulator: mc13892: " Sachin Kamat
2013-09-04 14:29   ` Marek Vasut
2013-09-04  6:31 ` [PATCH 5/7] regulator: palmas: " Sachin Kamat
2013-09-04 14:32   ` Marek Vasut
2013-09-04 15:14     ` Sachin Kamat
2013-09-04  6:31 ` [PATCH 6/7] regulator: rc5t583: " Sachin Kamat
2013-09-04 14:33   ` Marek Vasut
2013-09-04  6:31 ` [PATCH 7/7] regulator: ti-abb: " Sachin Kamat
2013-09-04 13:27   ` Nishanth Menon [this message]
2013-09-04 15:12     ` Mark Brown
2013-09-04 15:15       ` Nishanth Menon
2013-09-04 16:26     ` Sachin Kamat
2013-09-04 16:33       ` Nishanth Menon
2013-09-04 16:48         ` Sachin Kamat
2013-09-04 17:00           ` Nishanth Menon
2013-09-04 18:03             ` Mark Brown
2013-09-04  9:49 ` [PATCH 1/7] regulator: anatop-regulator: " Mark Brown
2013-09-04 14:25 ` Marek Vasut

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=5227355C.1020205@ti.com \
    --to=nm@ti.com \
    --cc=Nancy.Chen@freescale.com \
    --cc=broonie@kernel.org \
    --cc=gg@slimlogic.co.uk \
    --cc=ldewangan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marek.vasut@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sachin.kamat@linaro.org \
    --cc=yong.shen@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.