From patchwork Fri Sep 18 19:11:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 1367219 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lunn.ch Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BtNjs0nyTz9sSC for ; Sat, 19 Sep 2020 05:11:45 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726335AbgIRTLj (ORCPT ); Fri, 18 Sep 2020 15:11:39 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:44230 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbgIRTLh (ORCPT ); Fri, 18 Sep 2020 15:11:37 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1kJLn1-00FH97-S6; Fri, 18 Sep 2020 21:11:23 +0200 From: Andrew Lunn To: David Miller Cc: netdev , Chris Healy , Florian Fainelli , Jiri Pirko , Vladimir Oltean , Andrew Lunn Subject: [PATCH net-next v4 3/9] net: dsa: Add helper to convert from devlink to ds Date: Fri, 18 Sep 2020 21:11:03 +0200 Message-Id: <20200918191109.3640779-4-andrew@lunn.ch> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200918191109.3640779-1-andrew@lunn.ch> References: <20200918191109.3640779-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Given a devlink instance, return the dsa switch it is associated to. Reviewed-by: Florian Fainelli Signed-off-by: Andrew Lunn --- include/net/dsa.h | 7 +++++++ net/dsa/dsa.c | 12 ++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index 75c8fac82017..42ae6d4d9d43 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -664,6 +664,13 @@ struct dsa_devlink_priv { struct dsa_switch *ds; }; +static inline struct dsa_switch *dsa_devlink_to_ds(struct devlink *dl) +{ + struct dsa_devlink_priv *dl_priv = devlink_priv(dl); + + return dl_priv->ds; +} + struct dsa_switch_driver { struct list_head list; const struct dsa_switch_ops *ops; diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 1ce9ba8cf545..9b7019d86165 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -330,11 +330,7 @@ EXPORT_SYMBOL_GPL(call_dsa_notifiers); int dsa_devlink_param_get(struct devlink *dl, u32 id, struct devlink_param_gset_ctx *ctx) { - struct dsa_devlink_priv *dl_priv; - struct dsa_switch *ds; - - dl_priv = devlink_priv(dl); - ds = dl_priv->ds; + struct dsa_switch *ds = dsa_devlink_to_ds(dl); if (!ds->ops->devlink_param_get) return -EOPNOTSUPP; @@ -346,11 +342,7 @@ EXPORT_SYMBOL_GPL(dsa_devlink_param_get); int dsa_devlink_param_set(struct devlink *dl, u32 id, struct devlink_param_gset_ctx *ctx) { - struct dsa_devlink_priv *dl_priv; - struct dsa_switch *ds; - - dl_priv = devlink_priv(dl); - ds = dl_priv->ds; + struct dsa_switch *ds = dsa_devlink_to_ds(dl); if (!ds->ops->devlink_param_set) return -EOPNOTSUPP;