Thread (5 messages) flat view 5 messages, 3 authors, 2010-02-10

Re: [PATCH] [V3] net: emaclite: adding MDIO and phy lib support

From: John Williams <hidden>
Date: 2010-02-09 22:30:30
Also in: netdev

Hi John,

Sorry If I'm painting bike-sheds here, just one tiny tweak might be in
order to standardise your mutex_unlock exit path:
+static int xemaclite_mdio_read(struct mii_bus *bus, int phy_id, int reg)
+{
+ =A0 =A0 =A0 struct net_local *lp =3D bus->priv;
+ =A0 =A0 =A0 u32 ctrl_reg;
+ =A0 =A0 =A0 u32 rc;
+
+ =A0 =A0 =A0 mutex_lock(&lp->mdio_mutex);
+
+ =A0 =A0 =A0 if (xemaclite_mdio_wait(lp)) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 mutex_unlock(&lp->mdio_mutex);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ETIMEDOUT;
+ =A0 =A0 =A0 }
[snip]

+ =A0 =A0 =A0 if (xemaclite_mdio_wait(lp)) {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 mutex_unlock(&lp->mdio_mutex);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ETIMEDOUT;
+ =A0 =A0 =A0 }
[snip]

+ =A0 =A0 =A0 dev_dbg(&lp->ndev->dev,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 "xemaclite_mdio_read(phy_id=3D%i, reg=3D%x)=
 =3D=3D %x\n",
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 phy_id, reg, rc);
+
+ =A0 =A0 =A0 return rc;
Can this be better expressed like this:

my_func() {
  mutex_lock()
..

  if(some error) {
    rc=3D-ETIMEDOUT;
    goto out_unlock;
  }
  ...

  /* success path */
  rc=3D0;
..
out_unlock:
  mutex_unlock()
  return rc;
}


Is this style still favoured in driver exit paths?

Thanks,

John
--=20
John Williams, PhD, B.Eng, B.IT
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com  p: +61-7-30090663  f: +61-7-30090663
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help