On Thu, 29 Aug 2019 11:27:03 -0700, Shannon Nelson wrote:
> This patch adds a basic driver framework for the Pensando IONIC
> network device.  There is no functionality right now other than
> the ability to load and unload.
> 
> Signed-off-by: Shannon Nelson <snel...@pensando.io>

> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c 
> b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
> new file mode 100644
> index 000000000000..6892409cd64b
> --- /dev/null
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c
> @@ -0,0 +1,44 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright(c) 2017 - 2019 Pensando Systems, Inc */
> +
> +#include <linux/module.h>
> +#include <linux/netdevice.h>
> +
> +#include "ionic.h"
> +#include "ionic_bus.h"
> +#include "ionic_devlink.h"
> +
> +static int ionic_dl_info_get(struct devlink *dl, struct devlink_info_req 
> *req,
> +                          struct netlink_ext_ack *extack)
> +{
> +     devlink_info_driver_name_put(req, IONIC_DRV_NAME);

This may fail, should the error not be propagated?

> +     return 0;
> +}
> +
> +static const struct devlink_ops ionic_dl_ops = {
> +     .info_get       = ionic_dl_info_get,
> +};
> +
> +struct ionic *ionic_devlink_alloc(struct device *dev)
> +{
> +     struct ionic *ionic;
> +     struct devlink *dl;
> +
> +     dl = devlink_alloc(&ionic_dl_ops, sizeof(struct ionic));
> +     if (!dl) {
> +             dev_warn(dev, "devlink_alloc failed");

missing new line at the end of warning, but the warning is unnecessary,
if memory allocation fails kernel will generate a big OOM splat, anyway

> +             return NULL;
> +     }
> +
> +     ionic = devlink_priv(dl);
> +
> +     return ionic;

return devlink_priv(dl);

> +}
> +
> +void ionic_devlink_free(struct ionic *ionic)
> +{
> +     struct devlink *dl = priv_to_devlink(ionic);
> +
> +     devlink_free(dl);
> +}

Reply via email to