public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@savoirfairelinux.com,
	"David S. Miller" <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH net-next v2 3/7] net: dsa: mv88e6xxx: add switch info
Date: Sat, 16 Apr 2016 01:55:58 +0200	[thread overview]
Message-ID: <20160415235558.GC32136@lunn.ch> (raw)
In-Reply-To: <1460762488-2633-4-git-send-email-vivien.didelot@savoirfairelinux.com>

> +	for (i = 0, info = &table[i]; i < num; info = &table[++i])
> +		if (info->prod_num == (id & 0xfff0) >> 4)
> +			goto found;
>  
>  	return NULL;
> -}
>  
> -char *mv88e6xxx_drv_probe(struct device *dsa_dev, struct device *host_dev,
> -			  int sw_addr, void **priv,
> -			  const struct mv88e6xxx_switch_id *table,
> -			  unsigned int num)
> -{
> -	struct mv88e6xxx_priv_state *ps;
> -	struct mii_bus *bus = dsa_host_dev_to_mii_bus(host_dev);
> -	char *name;
> -
> -	if (!bus)
> +found:
> +	ps = devm_kzalloc(dsa_dev, sizeof(*ps), GFP_KERNEL);
> +	if (!ps)


This looks like a goto to jump around a return NULL. Ugly.  I would
keep this lookup in a separate function. You can then avoid ugly stuff
like this.

CodingStyle says:

                Chapter 6: Functions

Functions should be short and sweet, and do just one thing.  They should
fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24,
as we all know), and do one thing and do that well.

   Andrew

  reply	other threads:[~2016-04-15 23:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-15 23:21 [PATCH net-next v2 0/7] net: dsa: mv88e6xxx: factorize switch info Vivien Didelot
2016-04-15 23:21 ` [PATCH net-next v2 1/7] net: dsa: mv88e6xxx: drop double ds assignment Vivien Didelot
2016-04-15 23:39   ` Andrew Lunn
2016-04-15 23:21 ` [PATCH net-next v2 2/7] net: dsa: mv88e6xxx: drop revision probing Vivien Didelot
2016-04-15 23:43   ` Andrew Lunn
2016-04-15 23:21 ` [PATCH net-next v2 3/7] net: dsa: mv88e6xxx: add switch info Vivien Didelot
2016-04-15 23:55   ` Andrew Lunn [this message]
2016-04-15 23:21 ` [PATCH net-next v2 4/7] net: dsa: mv88e6xxx: add family to info Vivien Didelot
2016-04-15 23:57   ` Andrew Lunn
2016-04-15 23:21 ` [PATCH net-next v2 5/7] net: dsa: mv88e6xxx: add number of ports " Vivien Didelot
2016-04-15 23:59   ` Andrew Lunn
2016-04-15 23:21 ` [PATCH net-next v2 6/7] net: dsa: mv88e6xxx: add number of db " Vivien Didelot
2016-04-16  0:01   ` Andrew Lunn
2016-04-15 23:21 ` [PATCH net-next v2 7/7] net: dsa: mv88e6xxx: remove switch ID Vivien Didelot
2016-04-16  0:03   ` Andrew Lunn

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=20160415235558.GC32136@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@savoirfairelinux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@savoirfairelinux.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