public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: "J. German Rivera" <German.Rivera@freescale.com>
Cc: gregkh@linuxfoundation.org, arnd@arndb.de,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	stuart.yoder@freescale.com, bhupesh.sharma@freescale.com,
	agraf@suse.de, bhamciu1@freescale.com, nir.erez@freescale.com,
	itai.katz@freescale.com, scottwood@freescale.com,
	R89243@freescale.com, richard.schmitt@freescale.com
Subject: Re: [PATCH 1/7] staging: fsl-mc: MC bus IRQ support
Date: Thu, 30 Apr 2015 14:49:57 +0300	[thread overview]
Message-ID: <20150430114957.GW14154@mwanda> (raw)
In-Reply-To: <1430242750-17745-2-git-send-email-German.Rivera@freescale.com>

On Tue, Apr 28, 2015 at 12:39:04PM -0500, J. German Rivera wrote:
> Change-Id: I2a986c465989c3811de19cfe9ed0b77168250cb1
> Reviewed-on: http://git.am.freescale.net:8181/33626
> Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com>

These things are totally useless to the rest of us.  Don't add them.


> diff --git a/drivers/staging/fsl-mc/TODO b/drivers/staging/fsl-mc/TODO
> index d78288b..1b8868d 100644
> --- a/drivers/staging/fsl-mc/TODO
> +++ b/drivers/staging/fsl-mc/TODO
> @@ -8,6 +8,9 @@
>  * Add at least one device driver for a DPAA2 object (child device of the
>    fsl-mc bus).
>  
> +* Enable code blocks guarded by #ifdef GIC_ITS_MC_SUPPORT, when GIC-ITS
> +  support for the MC MSIs gets merged.
> +

When will that be?  I'd really prefer to not add these ifdeffed bits at
all.

> +	if (status & (DPRC_IRQ_EVENT_OBJ_ADDED |
> +		      DPRC_IRQ_EVENT_OBJ_REMOVED |
> +		      DPRC_IRQ_EVENT_CONTAINER_DESTROYED |
> +		      DPRC_IRQ_EVENT_OBJ_DESTROYED |
> +		      DPRC_IRQ_EVENT_OBJ_CREATED)) {
> +		unsigned int irq_count;
> +
> +		error = dprc_scan_objects(mc_dev, &irq_count);
> +		if (error < 0) {
> +			dev_err(dev, "dprc_scan_objects() failed: %d\n", error);
> +			goto out;
> +		}
> +
> +		WARN_ON((int16_t)irq_count < 0);

This code is doing "WARN_ON(test_bit(15, (unsigned long *)&irq_count));".
That seems like nonsense.  Anyway, just delete the WARN_ON().

> +
> +		if ((int16_t)irq_count >
> +			mc_bus->resource_pools[FSL_MC_POOL_IRQ].max_count) {

Why are we casting this?  Also can you align it like:

		if (irq_count >
		    mc_bus->resource_pools[FSL_MC_POOL_IRQ].max_count) {

[tab][tab][space][space][space][space]mc_bus->resource_pools[

That way you can tell the if condition from the indented block.  Plus
that is standard kernel indenting style these days.


[ snip ]

> +	irqs = devm_kzalloc(&mc_dev->dev, irq_count * sizeof(irqs[0]),
> +			    GFP_KERNEL);
> +	if (!irqs) {
> +		error = -ENOMEM;
> +		dev_err(&mc_dev->dev, "No memory to allocate irqs[]\n");
> +		goto error;

I kind of hate One Err Style error handling, because the error labels
are so general...  You can never guess the point of it until you scroll
down to read what "goto error;" does.  The error handling here calls
devm_kfree() which is not needed...  devm_ functions automatically
clean up after themselves.  This seems a pattern throughout.  Do a
search for devm_free() and see which ones are really needed or not.

Also the error message isn't needed here.  kzalloc() has its own better
error messages built-in.  Adding these error messages which will never
be printed is just a waste of RAM.

In other words this should look like:

	irqs = devm_kcalloc(&mc_dev->dev, sizeof(*irqs), irq_count,
			    GFP_KERNEL);
	if (!irqs)
		return -ENOMEM;

regards,
dan carpenter


  reply	other threads:[~2015-04-30 11:50 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28 17:39 [PATCH 0/7] staging: fsl-mc: New functionality to the MC bus driver J. German Rivera
2015-04-28 17:39 ` [PATCH 1/7] staging: fsl-mc: MC bus IRQ support J. German Rivera
2015-04-30 11:49   ` Dan Carpenter [this message]
2015-05-04 22:09     ` Jose Rivera
2015-05-05  8:48       ` Dan Carpenter
2015-05-05 16:08         ` Jose Rivera
2015-05-05 16:40           ` Dan Carpenter
2015-05-05 19:56             ` Scott Wood
2015-05-05 20:22               ` Jose Rivera
2015-05-05 20:40                 ` Scott Wood
2015-05-06  6:42               ` Dan Carpenter
2015-05-05 19:42           ` Scott Wood
2015-05-05 20:26             ` Jose Rivera
2015-04-28 17:39 ` [PATCH 2/7] staging: fsl_-mc: add device binding path 'driver_override' J. German Rivera
2015-04-28 17:39 ` [PATCH 3/7] staging: fsl-mc: Propagate driver_override for a child DPRC's children J. German Rivera
2015-04-28 17:39 ` [PATCH 4/7] staging: fsl-mc: Upgraded MC bus driver to match MC fw 7.0.0 J. German Rivera
2015-04-30 12:12   ` Dan Carpenter
2015-05-04 23:58     ` Jose Rivera
2015-05-05  8:51       ` Dan Carpenter
2015-04-28 17:39 ` [PATCH 5/7] staging: fsl-mc: Allow the MC bus driver to run without GIC support J. German Rivera
2015-04-28 17:39 ` [PATCH 6/7] staging: fsl-mc: Add locking to serialize mc_send_command() calls J. German Rivera
2015-04-30 12:59   ` Dan Carpenter
2015-05-05 16:20     ` Jose Rivera
2015-04-28 17:39 ` [PATCH 7/7] staging: fsl-mc: Use DPMCP IRQ and completion var to wait for MC J. German Rivera
2015-04-30 13:01   ` Dan Carpenter

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=20150430114957.GW14154@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=German.Rivera@freescale.com \
    --cc=R89243@freescale.com \
    --cc=agraf@suse.de \
    --cc=arnd@arndb.de \
    --cc=bhamciu1@freescale.com \
    --cc=bhupesh.sharma@freescale.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=itai.katz@freescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nir.erez@freescale.com \
    --cc=richard.schmitt@freescale.com \
    --cc=scottwood@freescale.com \
    --cc=stuart.yoder@freescale.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