From: Graeme Gregory <gg@slimlogic.co.uk>
To: Jesper Juhl <jj@chaosbits.net>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
linux-kernel@vger.kernel.org,
Jorge Eduardo Candelaria <jedu@slimlogic.co.uk>
Subject: Re: [PATCH] mfd: avoid two assignments if failures happen in tps65910_i2c_probe
Date: Fri, 15 Jul 2011 10:12:26 +0100 [thread overview]
Message-ID: <4E20047A.4080909@slimlogic.co.uk> (raw)
In-Reply-To: <alpine.LNX.2.00.1107132319020.22281@swampdragon.chaosbits.net>
On 07/13/2011 10:22 PM, Jesper Juhl wrote:
> In drivers/mfd/tps65910.c:tps65910_i2c_probe() there's potential for a
> tiny optimization.
>
> We assign to init_data->irq and init_data->irq_base long before we
> need them, and there are two potential exits from the function before
> they are needed.
>
> Moving the assignments below these two potential exits means we
> completely avoid doing them in these two (failure) cases.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> drivers/mfd/tps65910.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> - compile tested only.
> - patch is on top of the patch in https://lkml.org/lkml/2011/7/5/503
> which is now in linux-next.
>
> diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
> index 7a3eb2d..65e9479 100644
> --- a/drivers/mfd/tps65910.c
> +++ b/drivers/mfd/tps65910.c
> @@ -147,9 +147,6 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
> if (init_data == NULL)
> return -ENOMEM;
>
> - init_data->irq = pmic_plat_data->irq;
> - init_data->irq_base = pmic_plat_data->irq;
> -
> tps65910 = kzalloc(sizeof(struct tps65910), GFP_KERNEL);
> if (tps65910 == NULL) {
> kfree(init_data);
> @@ -170,6 +167,9 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
> if (ret < 0)
> goto err;
>
> + init_data->irq = pmic_plat_data->irq;
> + init_data->irq_base = pmic_plat_data->irq;
> +
> tps65910_gpio_init(tps65910, pmic_plat_data->gpio_base);
>
> ret = tps65910_irq_init(tps65910, init_data->irq, init_data);
Not sure this form of micro optimisation really buys anything, but the
resulting code does look nicer so.
Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
next prev parent reply other threads:[~2011-07-15 9:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-13 21:22 Jesper Juhl
2011-07-15 9:12 ` Graeme Gregory [this message]
2011-07-27 9:52 ` Samuel Ortiz
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=4E20047A.4080909@slimlogic.co.uk \
--to=gg@slimlogic.co.uk \
--cc=jedu@slimlogic.co.uk \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@linux.intel.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
all inboxes | Powered by JetHome®