Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1380390

Re: [PATCH net-next v2 3/7] net: dsa: mv88e6xxx: add switch info

From Andrew Lunn <andrew@lunn.ch>
Newsgroups linux.kernel
Subject Re: [PATCH net-next v2 3/7] net: dsa: mv88e6xxx: add switch info
Date 2016-04-16 02:00 +0200
Message-ID <rolOA-2HR-43@gated-at.bofh.it> (permalink)
References <rollw-2sf-7@gated-at.bofh.it> <rollx-2sf-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


> +	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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH net-next v2 0/7] net: dsa: mv88e6xxx: factorize switch info Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-04-16 01:30 +0200
  [PATCH net-next v2 6/7] net: dsa: mv88e6xxx: add number of db to info Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-04-16 01:30 +0200
    Re: [PATCH net-next v2 6/7] net: dsa: mv88e6xxx: add number of db to  info Andrew Lunn <andrew@lunn.ch> - 2016-04-16 02:10 +0200
  [PATCH net-next v2 7/7] net: dsa: mv88e6xxx: remove switch ID Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-04-16 01:30 +0200
    Re: [PATCH net-next v2 7/7] net: dsa: mv88e6xxx: remove switch ID Andrew Lunn <andrew@lunn.ch> - 2016-04-16 02:10 +0200
  [PATCH net-next v2 3/7] net: dsa: mv88e6xxx: add switch info Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-04-16 01:30 +0200
    Re: [PATCH net-next v2 3/7] net: dsa: mv88e6xxx: add switch info Andrew Lunn <andrew@lunn.ch> - 2016-04-16 02:00 +0200
  [PATCH net-next v2 2/7] net: dsa: mv88e6xxx: drop revision probing Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-04-16 01:30 +0200
    Re: [PATCH net-next v2 2/7] net: dsa: mv88e6xxx: drop revision  probing Andrew Lunn <andrew@lunn.ch> - 2016-04-16 01:50 +0200

csiph-web