Re: [PATCH 1/2] net: dsa: felix: allow the device to be disabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 12 Mar 2020 at 18:44, Michael Walle <michael@xxxxxxxx> wrote:
>
> If there is no specific configuration of the felix switch in the device
> tree, but only the default configuration (ie. given by the SoCs dtsi
> file), the probe fails because no CPU port has been set. On the other
> hand you cannot set a default CPU port because that depends on the
> actual board using the switch.
>
> [    2.701300] DSA: tree 0 has no CPU port
> [    2.705167] mscc_felix 0000:00:00.5: Failed to register DSA switch: -22
> [    2.711844] mscc_felix: probe of 0000:00:00.5 failed with error -22
>
> Thus let the device tree disable this device entirely, like it is also
> done with the enetc driver of the same SoC.
>
> Signed-off-by: Michael Walle <michael@xxxxxxxx>
> ---
>  drivers/net/dsa/ocelot/felix.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
> index 69546383a382..531c7710063f 100644
> --- a/drivers/net/dsa/ocelot/felix.c
> +++ b/drivers/net/dsa/ocelot/felix.c
> @@ -699,6 +699,11 @@ static int felix_pci_probe(struct pci_dev *pdev,
>         struct felix *felix;
>         int err;
>
> +       if (pdev->dev.of_node && !of_device_is_available(pdev->dev.of_node)) {
> +               dev_info(&pdev->dev, "device is disabled, skipping\n");
> +               return -ENODEV;
> +       }
> +

IMHO since DSA is already dependent on device tree for PHY bindings,
it would make more sense to move this there:

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index e7c30b472034..f7ca01d93928 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -878,7 +878,7 @@ static int dsa_switch_probe(struct dsa_switch *ds)
        if (!ds->num_ports)
                return -EINVAL;

-       if (np) {
+       if (np && of_device_is_available(np)) {
                err = dsa_switch_parse_of(ds, np);
                if (err)
                        dsa_switch_release_ports(ds);

so that we could enforce more uniform behavior across device drivers.
Then you might want to make felix shut up:

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 35124ef7e75b..fbd17fa94bff 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -712,10 +712,8 @@ static int felix_pci_probe(struct pci_dev *pdev,
        felix->ds = ds;

        err = dsa_register_switch(ds);
-       if (err) {
-               dev_err(&pdev->dev, "Failed to register DSA switch: %d\n", err);
+       if (err)
                goto err_register_ds;
-       }

        return 0;

This has the disadvantage of not printing the "nice" "device is
disabled, skipping" message (useless in my opinion), but the advantage
of also shutting up on -EPROBE_DEFER.

>         err = pci_enable_device(pdev);
>         if (err) {
>                 dev_err(&pdev->dev, "device enable failed\n");
> --
> 2.20.1
>

Thanks,
-Vladimir



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux