Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751691AbdI1TfZ (ORCPT ); Thu, 28 Sep 2017 15:35:25 -0400 Received: from mail.savoirfairelinux.com ([208.88.110.44]:56660 "EHLO mail.savoirfairelinux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751126AbdI1TfY (ORCPT ); Thu, 28 Sep 2017 15:35:24 -0400 From: Vivien Didelot To: Brandon Streiff , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "David S. Miller" , Florian Fainelli , Andrew Lunn , Richard Cochran , Erik Hons , Brandon Streiff Subject: Re: [PATCH net-next RFC 5/9] net: dsa: forward hardware timestamping ioctls to switch driver In-Reply-To: <1506612341-18061-6-git-send-email-brandon.streiff@ni.com> References: <1506612341-18061-1-git-send-email-brandon.streiff@ni.com> <1506612341-18061-6-git-send-email-brandon.streiff@ni.com> Date: Thu, 28 Sep 2017 15:31:44 -0400 Message-ID: <877ewiy5zz.fsf@weeman.i-did-not-set--mail-host-address--so-tickle-me> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1242 Lines: 59 Hi Brandon, Brandon Streiff writes: > static int dsa_slave_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) > { > + struct dsa_slave_priv *p = netdev_priv(dev); > + struct dsa_switch *ds = p->dp->ds; > + int port = p->dp->index; > + > if (!dev->phydev) > return -ENODEV; Move this check below: > > - return phy_mii_ioctl(dev->phydev, ifr, cmd); > + switch (cmd) { > + case SIOCGMIIPHY: > + case SIOCGMIIREG: > + case SIOCSMIIREG: > + if (dev->phydev) > + return phy_mii_ioctl(dev->phydev, ifr, cmd); > + else > + return -EOPNOTSUPP; if (!dev->phydev) return -ENODEV; return phy_mii_ioctl(dev->phydev, ifr, cmd); > + case SIOCGHWTSTAMP: > + if (ds->ops->port_hwtstamp_get) > + return ds->ops->port_hwtstamp_get(ds, port, ifr); > + else > + return -EOPNOTSUPP; Here you can replace the else statement with break; > + case SIOCSHWTSTAMP: > + if (ds->ops->port_hwtstamp_set) > + return ds->ops->port_hwtstamp_set(ds, port, ifr); > + else > + return -EOPNOTSUPP; Same here; > + default: > + return -EOPNOTSUPP; > + } Then drop the default case and return -EOPNOTSUPP after the switch. > } Thanks, Vivien