Re: [net-next: PATCH v3 3/8] net: dsa: switch to device_/fwnode_ APIs

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

 



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





[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux