netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Xin Tian <tianx@yunsilicon.com>
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, kuba@kernel.org,
	pabeni@redhat.com, edumazet@google.com, davem@davemloft.net,
	jeff.johnson@oss.qualcomm.com, przemyslaw.kitszel@intel.com,
	weihg@yunsilicon.com, wanry@yunsilicon.com, horms@kernel.org,
	parthiban.veerasooran@microchip.com, masahiroy@kernel.org
Subject: Re: [PATCH v4 07/14] net-next/yunsilicon: Init auxiliary device
Date: Thu, 13 Feb 2025 16:37:02 +0200	[thread overview]
Message-ID: <20250213143702.GN17863@unreal> (raw)
In-Reply-To: <20250213091418.2067626-8-tianx@yunsilicon.com>

On Thu, Feb 13, 2025 at 05:14:19PM +0800, Xin Tian wrote:
> Initialize eth auxiliary device when pci probing
> 
> Co-developed-by: Honggang Wei <weihg@yunsilicon.com>
> Signed-off-by: Honggang Wei <weihg@yunsilicon.com>
> Co-developed-by: Lei Yan <jacky@yunsilicon.com>
> Signed-off-by: Lei Yan <jacky@yunsilicon.com>
> Signed-off-by: Xin Tian <tianx@yunsilicon.com>
> ---
>  .../ethernet/yunsilicon/xsc/common/xsc_core.h |  12 ++
>  .../net/ethernet/yunsilicon/xsc/pci/Makefile  |   3 +-
>  .../net/ethernet/yunsilicon/xsc/pci/adev.c    | 110 ++++++++++++++++++
>  .../net/ethernet/yunsilicon/xsc/pci/adev.h    |  14 +++
>  .../net/ethernet/yunsilicon/xsc/pci/main.c    |  10 ++
>  5 files changed, 148 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/net/ethernet/yunsilicon/xsc/pci/adev.c
>  create mode 100644 drivers/net/ethernet/yunsilicon/xsc/pci/adev.h

<...>

> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/adev.c b/drivers/net/ethernet/yunsilicon/xsc/pci/adev.c
> new file mode 100644
> index 000000000..1f8f27d72
> --- /dev/null
> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/adev.c
> @@ -0,0 +1,110 @@
> +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
> +/*
> + * Copyright (C) 2021-2025, Shanghai Yunsilicon Technology Co., Ltd.
> + * All rights reserved.
> + */
> +
> +#include <linux/auxiliary_bus.h>
> +#include <linux/idr.h>
> +
> +#include "adev.h"
> +
> +static DEFINE_IDA(xsc_adev_ida);
> +
> +enum xsc_adev_idx {
> +	XSC_ADEV_IDX_ETH,
> +	XSC_ADEV_IDX_MAX
> +};
> +
> +static const char * const xsc_adev_name[] = {
> +	[XSC_ADEV_IDX_ETH] = XSC_ETH_ADEV_NAME,
> +};
> +
> +static void xsc_release_adev(struct device *dev)
> +{
> +	/* Doing nothing, but auxiliary bus requires a release function */
> +}

It is unlikely to be true in driver lifetime model. At least you should
free xsc_adev here.

Thanks

> +
> +static int xsc_reg_adev(struct xsc_core_device *xdev, int idx)
> +{
> +	struct auxiliary_device	*adev;
> +	struct xsc_adev *xsc_adev;
> +	int ret;
> +
> +	xsc_adev = kzalloc(sizeof(*xsc_adev), GFP_KERNEL);
> +	if (!xsc_adev)
> +		return -ENOMEM;
> +
> +	adev = &xsc_adev->adev;
> +	adev->name = xsc_adev_name[idx];
> +	adev->id = xdev->adev_id;
> +	adev->dev.parent = &xdev->pdev->dev;
> +	adev->dev.release = xsc_release_adev;
> +	xsc_adev->xdev = xdev;
> +
> +	ret = auxiliary_device_init(adev);
> +	if (ret)
> +		goto err_free_adev;
> +
> +	ret = auxiliary_device_add(adev);
> +	if (ret)
> +		goto err_uninit_adev;
> +
> +	xdev->xsc_adev_list[idx] = xsc_adev;
> +
> +	return 0;
> +err_uninit_adev:
> +	auxiliary_device_uninit(adev);
> +err_free_adev:
> +	kfree(xsc_adev);
> +
> +	return ret;
> +}

  reply	other threads:[~2025-02-13 14:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-13  9:14 [PATCH v4 00/14] net-next/yunsilicon: ADD Yunsilicon XSC Ethernet Driver Xin Tian
2025-02-13  9:14 ` [PATCH v4 01/14] net-next/yunsilicon: Add xsc driver basic framework Xin Tian
2025-02-13  9:14 ` [PATCH v4 02/14] net-next/yunsilicon: Enable CMDQ Xin Tian
2025-02-13  9:14 ` [PATCH v4 03/14] net-next/yunsilicon: Add hardware setup APIs Xin Tian
2025-02-13  9:14 ` [PATCH v4 04/14] net-next/yunsilicon: Add qp and cq management Xin Tian
2025-02-18 16:31   ` Simon Horman
2025-02-20  8:58     ` tianx
2025-02-13  9:14 ` [PATCH v4 05/14] net-next/yunsilicon: Add eq and alloc Xin Tian
2025-02-18 17:10   ` Simon Horman
2025-02-20 15:35     ` tianx
2025-02-24 18:58       ` Simon Horman
2025-02-25  2:34         ` Xin Tian
2025-02-25 10:22           ` Simon Horman
2025-02-13  9:14 ` [PATCH v4 06/14] net-next/yunsilicon: Add pci irq Xin Tian
2025-02-13  9:14 ` [PATCH v4 07/14] net-next/yunsilicon: Init auxiliary device Xin Tian
2025-02-13 14:37   ` Leon Romanovsky [this message]
2025-02-14  3:14     ` tianx
2025-02-16  9:59       ` Leon Romanovsky
2025-02-17  2:16         ` tianx
2025-02-13  9:14 ` [PATCH v4 08/14] net-next/yunsilicon: Add ethernet interface Xin Tian
2025-02-13  9:14 ` [PATCH v4 09/14] net-next/yunsilicon: Init net device Xin Tian
2025-02-13  9:14 ` [PATCH v4 10/14] net-next/yunsilicon: Add eth needed qp and cq apis Xin Tian
2025-02-13  9:14 ` [PATCH v4 11/14] net-next/yunsilicon: ndo_open and ndo_stop Xin Tian
2025-02-13  9:14 ` [PATCH v4 12/14] net-next/yunsilicon: Add ndo_start_xmit Xin Tian
2025-02-13  9:14 ` [PATCH v4 13/14] net-next/yunsilicon: Add eth rx Xin Tian
2025-02-13  9:14 ` [PATCH v4 14/14] net-next/yunsilicon: add ndo_get_stats64 Xin Tian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250213143702.GN17863@unreal \
    --to=leon@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jeff.johnson@oss.qualcomm.com \
    --cc=kuba@kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=parthiban.veerasooran@microchip.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=tianx@yunsilicon.com \
    --cc=wanry@yunsilicon.com \
    --cc=weihg@yunsilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).