[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YuEhsqjq5eN6gGO6@smile.fi.intel.com>
Date: Wed, 27 Jul 2022 14:29:54 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Marcin Wojtas <mw@...ihalf.com>
Cc: linux-kernel@...r.kernel.org, linux-acpi@...r.kernel.org,
netdev@...r.kernel.org, rafael@...nel.org, sean.wang@...iatek.com,
Landen.Chao@...iatek.com, linus.walleij@...aro.org, andrew@...n.ch,
vivien.didelot@...il.com, f.fainelli@...il.com, olteanv@...il.com,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, linux@...linux.org.uk, hkallweit1@...il.com,
gjb@...ihalf.com, jaz@...ihalf.com, tn@...ihalf.com,
Samer.El-Haj-Mahmoud@....com, upstream@...ihalf.com
Subject: Re: [net-next: PATCH v3 3/8] net: dsa: switch to device_/fwnode_ APIs
On Wed, Jul 27, 2022 at 08:43:16AM +0200, Marcin Wojtas wrote:
> In order to support both DT and ACPI in future, modify the generic DSA
> code to use device_/fwnode_ equivalent routines. Drop using port's 'dn'
> field and use only fwnode - update all dependent drivers.
>
> Because support for more generic fwnode is added, replace '_of' suffix
> with '_fw' in related routines. No functional change is introduced by
> this patch.
...
> static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
> {
> - struct device_node *phy_handle = NULL;
> + struct fwnode_handle *phy_handle = NULL;
> struct dsa_switch *ds = chip->ds;
> phy_interface_t mode;
> struct dsa_port *dp;
> @@ -3499,15 +3499,15 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
>
> if (chip->info->ops->serdes_set_tx_amplitude) {
> if (dp)
> - phy_handle = of_parse_phandle(dp->dn, "phy-handle", 0);
> + phy_handle = fwnode_find_reference(dp->fwnode, "phy-handle", 0);
>
> - if (phy_handle && !of_property_read_u32(phy_handle,
> - "tx-p2p-microvolt",
> - &tx_amp))
> + if (!IS_ERR(phy_handle) && !fwnode_property_read_u32(phy_handle,
> + "tx-p2p-microvolt",
> + &tx_amp))
> err = chip->info->ops->serdes_set_tx_amplitude(chip,
> port, tx_amp);
> - if (phy_handle) {
> - of_node_put(phy_handle);
> + if (!IS_ERR(phy_handle)) {
> + fwnode_handle_put(phy_handle);
> if (err)
> return err;
> }
I believe after 002752af7b89 ("device property: Allow error pointer to be
passed to fwnode APIs") you may simplify above like:
if (!fwnode_property_read_u32(phy_handle, "tx-p2p-microvolt",
&tx_amp))
err = chip->info->ops->serdes_set_tx_amplitude(chip,
port, tx_amp);
else
err = 0;
fwnode_handle_put(phy_handle);
if (err)
return err;
It also possible you can do refactoring before/after this one.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists