Re: [PATCH v2 1/2] i2c: i2c-designware-platdrv: Cleanup setting of the adapter number

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

 



On Tue, Mar 12, 2019 at 03:55:53PM +0100, Hans de Goede wrote:
> i2c-designware-platdrv assumes that if the pdev has an apci-companion
> it should use a dynamic adapter-nr and otherwise it will use pdev->id
> as adapter-nr.
> 
> Before this commit the setting of the adapter.nr was somewhat convoluted,
> in the acpi_companion case it was set from dw_i2c_acpi_configure, in the
> non acpi_companion case it was set from dw_i2c_set_fifo_size based on
> tx_fifo_depth not being set yet indicating that dw_i2c_acpi_configure was
> not executed.
> 
> This cleans this up, directly setting the adapter-nr from
> dw_i2c_plat_probe for both cases.
> 

As has been discussed earlier, this is good one

Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

> Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
> ---
> Changes in v2:
> -Split out the code cleaning up the adapter.nr setting into a separate patch
> ---
>  drivers/i2c/busses/i2c-designware-platdrv.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
> index ead5e7de3e4d..30529839cbd2 100644
> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
> @@ -86,7 +86,6 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev)
>  	struct i2c_timings *t = &dev->timings;
>  	u32 ss_ht = 0, fp_ht = 0, hs_ht = 0, fs_ht = 0;
>  
> -	dev->adapter.nr = -1;
>  	dev->tx_fifo_depth = 32;
>  	dev->rx_fifo_depth = 32;
>  
> @@ -219,7 +218,7 @@ static void i2c_dw_configure_slave(struct dw_i2c_dev *dev)
>  	dev->mode = DW_IC_SLAVE;
>  }
>  
> -static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev, int id)
> +static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev)
>  {
>  	u32 param, tx_fifo_depth, rx_fifo_depth;
>  
> @@ -233,7 +232,6 @@ static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev, int id)
>  	if (!dev->tx_fifo_depth) {
>  		dev->tx_fifo_depth = tx_fifo_depth;
>  		dev->rx_fifo_depth = rx_fifo_depth;
> -		dev->adapter.nr = id;
>  	} else if (tx_fifo_depth >= 2) {
>  		dev->tx_fifo_depth = min_t(u32, dev->tx_fifo_depth,
>  				tx_fifo_depth);
> @@ -358,13 +356,17 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
>  				div_u64(clk_khz * t->sda_hold_ns + 500000, 1000000);
>  	}
>  
> -	dw_i2c_set_fifo_size(dev, pdev->id);
> +	dw_i2c_set_fifo_size(dev);
>  
>  	adap = &dev->adapter;
>  	adap->owner = THIS_MODULE;
>  	adap->class = I2C_CLASS_DEPRECATED;
>  	ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev));
>  	adap->dev.of_node = pdev->dev.of_node;
> +	if (has_acpi_companion(&pdev->dev))
> +		adap->nr = -1;
> +	else
> +		adap->nr = pdev->id;
>  
>  	dev_pm_set_driver_flags(&pdev->dev,
>  				DPM_FLAG_SMART_PREPARE |
> -- 
> 2.20.1
> 

-- 
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