[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4ae4a622-f45f-36a4-2ff5-b0553a40dc22@gmail.com>
Date: Fri, 22 Feb 2019 12:04:07 -0800
From: Florian Fainelli <f.fainelli@...il.com>
To: Jakub Kicinski <jakub.kicinski@...ronome.com>, davem@...emloft.net,
jiri@...nulli.us
Cc: mkubecek@...e.cz, andrew@...n.ch, netdev@...r.kernel.org,
oss-drivers@...ronome.com
Subject: Re: [PATCH net-next v2 3/5] devlink: create a special NDO for getting
the devlink instance
On 2/22/19 11:54 AM, Jakub Kicinski wrote:
> Instead of iterating over all devlink ports add a NDO which
> will return the devlink instance from the driver.
>
> v2: add the netdev_to_devlink() helper (Michal)
>
> Suggested-by: Jiri Pirko <jiri@...nulli.us>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@...ronome.com>
> ---
[snip]
> - mutex_unlock(&devlink_mutex);
> + devlink = netdev_to_devlink(dev);
> + if (!devlink || !devlink->ops->info_get)
> + return;
AFAICT devlink_create() allows one to specify a NULL ops argument (not
that this makes sense), so probably need to add a check against
devlink->ops here as well, unless we want to change devlink_create() to
refuse a NULL ops pointer.
Other than that:
Reviewed-by: Florian Fainelli <f.fainelli@...il.com>
> +
> + mutex_lock(&devlink->lock);
> + __devlink_compat_running_version(devlink, buf, len);
> + mutex_unlock(&devlink->lock);
> }
>
> int devlink_compat_flash_update(struct net_device *dev, const char *file_name)
> {
> - struct devlink_port *devlink_port;
> struct devlink *devlink;
> + int ret;
>
> - mutex_lock(&devlink_mutex);
> - list_for_each_entry(devlink, &devlink_list, list) {
> - mutex_lock(&devlink->lock);
> - list_for_each_entry(devlink_port, &devlink->port_list, list) {
> - int ret = -EOPNOTSUPP;
> -
> - if (devlink_port->type != DEVLINK_PORT_TYPE_ETH ||
> - devlink_port->type_dev != dev)
> - continue;
> -
> - mutex_unlock(&devlink_mutex);
> - if (devlink->ops->flash_update)
> - ret = devlink->ops->flash_update(devlink,
> - file_name,
> - NULL, NULL);
> - mutex_unlock(&devlink->lock);
> - return ret;
> - }
> - mutex_unlock(&devlink->lock);
> - }
> - mutex_unlock(&devlink_mutex);
> + devlink = netdev_to_devlink(dev);
> + if (!devlink || !devlink->ops->flash_update)
> + return -EOPNOTSUPP;
>
And same here.
--
Florian
Powered by blists - more mailing lists