Re: [PATCH net-next v12 2/5] net: rnpgbe: Add n500/n210 chip support with BAR2 mapping

Jörg Sommer
2025-09-16T19:21:30Z

[-- Attachment #1: Type: text/plain, Size: 2861 bytes --]

Dong Yibo schrieb am Di 16. Sep, 19:29 (+0800):
> diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c
> index 60bbc806f17b..0afe39621661 100644
> --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c
> +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c
> @@ -2,8 +2,11 @@
> /* Copyright(c) 2020 - 2025 Mucse Corporation. */
>
> #include <linux/pci.h>
> +#include <net/rtnetlink.h>
> +#include <linux/etherdevice.h>
>
> #include "rnpgbe.h"
> +#include "rnpgbe_hw.h"
>
> static const char rnpgbe_driver_name[] = "rnpgbe";
>
> @@ -25,6 +28,54 @@ static struct pci_device_id rnpgbe_pci_tbl[] = {
> {0, },
> };
>
> +/**
> + * rnpgbe_add_adapter - Add netdev for this pci_dev
> + * @pdev: PCI device information structure
> + * @board_type: board type
> + *
> + * rnpgbe_add_adapter initializes a netdev for this pci_dev
> + * structure. Initializes Bar map, private structure, and a
> + * hardware reset occur.
> + *
> + * Return: 0 on success, negative errno on failure
> + **/
> +static int rnpgbe_add_adapter(struct pci_dev *pdev,
> + int board_type)
> +{
> + struct net_device *netdev;
> + void __iomem *hw_addr;
> + struct mucse *mucse;
> + struct mucse_hw *hw;
> + int err;
> +
> + netdev = alloc_etherdev_mq(sizeof(struct mucse), RNPGBE_MAX_QUEUES);
> + if (!netdev)
> + return -ENOMEM;
> +
> + SET_NETDEV_DEV(netdev, &pdev->dev);
> + mucse = netdev_priv(netdev);
> + mucse->netdev = netdev;
> + mucse->pdev = pdev;
> + pci_set_drvdata(pdev, mucse);
> +
> + hw = &mucse->hw;
> + hw_addr = devm_ioremap(&pdev->dev,
> + pci_resource_start(pdev, 2),
> + pci_resource_len(pdev, 2));
> + if (!hw_addr) {
> + err = -EIO;
> + goto err_free_net;
> + }
> +
> + hw->hw_addr = hw_addr;
> +
> + return 0;
> +
> +err_free_net:
> + free_netdev(netdev);
> + return err;
> +}
> +
> /**
> * rnpgbe_probe - Device initialization routine
> * @pdev: PCI device information struct
> @@ -37,6 +88,7 @@ static struct pci_device_id rnpgbe_pci_tbl[] = {
> **/
> static int rnpgbe_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> {
> + int board_type = id->driver_data;
> int err;
>
> err = pci_enable_device_mem(pdev);
> @@ -63,6 +115,9 @@ static int rnpgbe_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> dev_err(&pdev->dev, "pci_save_state failed %d\n", err);
> goto err_free_regions;
> }
> + err = rnpgbe_add_adapter(pdev, board_type);

Would an empty line before this assignment make the code more readable?

--
Professor: ‚Gott‘, unverständliches und mythisches Wesen, das sich einmal
pro Woche im Kreis der Sterblichen manifestiert um Weisheit auf Folien
unter das Volk zu bringen. (Dschungelbuch 11, FSU Jena)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]