[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200719154014.GJ1383417@lunn.ch>
Date: Sun, 19 Jul 2020 17:40:14 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Florian Fainelli <f.fainelli@...il.com>
Cc: netdev@...r.kernel.org, Vivien Didelot <vivien.didelot@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Jiri Pirko <jiri@...lanox.com>,
Eric Dumazet <edumazet@...gle.com>,
Taehee Yoo <ap420073@...il.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Maxim Mikityanskiy <maximmi@...lanox.com>,
Richard Cochran <richardcochran@...il.com>,
Michal Kubecek <mkubecek@...e.cz>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next 2/4] net: dsa: Add wrappers for overloaded
ndo_ops
> +#if IS_ENABLED(CONFIG_NET_DSA)
> +#define dsa_build_ndo_op(name, arg1_type, arg1_name, arg2_type, arg2_name) \
> +static int inline dsa_##name(struct net_device *dev, arg1_type arg1_name, \
> + arg2_type arg2_name) \
> +{ \
> + const struct dsa_netdevice_ops *ops; \
> + int err = -EOPNOTSUPP; \
> + \
> + if (!dev->dsa_ptr) \
> + return err; \
> + \
> + ops = dev->dsa_ptr->netdev_ops; \
> + if (!ops || !ops->name) \
> + return err; \
> + \
> + return ops->name(dev, arg1_name, arg2_name); \
> +}
> +#else
> +#define dsa_build_ndo_op(name, ...) \
> +static inline int dsa_##name(struct net_device *dev, ...) \
> +{ \
> + return -EOPNOTSUPP; \
> +}
> +#endif
> +
> +dsa_build_ndo_op(ndo_do_ioctl, struct ifreq *, ifr, int, cmd);
> +dsa_build_ndo_op(ndo_get_phys_port_name, char *, name, size_t, len);
Hi Florian
I tend to avoid this sort of macro magic. Tools like
https://elixir.bootlin.com/ and other cross references have trouble
following it. The current macros only handle calls with two
parameters. And i doubt it is actually saving many lines of code, if
there are only two invocations.
Andrew
Powered by blists - more mailing lists