Commit ccc3e6b0 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller
Browse files

net: dsa: Add helper to convert from devlink to ds



Given a devlink instance, return the dsa switch it is associated to.

Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d4602a9f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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;
+2 −10
Original line number Diff line number Diff line
@@ -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;