forked from mirrors/linux
		
	spi: add power control when set_cs_timing
As to set_cs_timing takes effect immediately, power spi is needed when call spi_set_cs_timing. Signed-off-by: leilk.liu <leilk.liu@mediatek.com> Link: https://lore.kernel.org/r/20210207030953.9297-2-leilk.liu@mediatek.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
		
							parent
							
								
									c64e7efe46
								
							
						
					
					
						commit
						4cea6b8cc3
					
				
					 1 changed files with 22 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -3460,11 +3460,30 @@ EXPORT_SYMBOL_GPL(spi_setup);
 | 
			
		|||
int spi_set_cs_timing(struct spi_device *spi, struct spi_delay *setup,
 | 
			
		||||
		      struct spi_delay *hold, struct spi_delay *inactive)
 | 
			
		||||
{
 | 
			
		||||
	struct device *parent = spi->controller->dev.parent;
 | 
			
		||||
	size_t len;
 | 
			
		||||
	int status;
 | 
			
		||||
 | 
			
		||||
	if (spi->controller->set_cs_timing)
 | 
			
		||||
	if (spi->controller->set_cs_timing) {
 | 
			
		||||
		if (spi->controller->auto_runtime_pm) {
 | 
			
		||||
			status = pm_runtime_get_sync(parent);
 | 
			
		||||
			if (status < 0) {
 | 
			
		||||
				pm_runtime_put_noidle(parent);
 | 
			
		||||
				dev_err(&spi->controller->dev, "Failed to power device: %d\n",
 | 
			
		||||
					status);
 | 
			
		||||
				return status;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			status = spi->controller->set_cs_timing(spi, setup,
 | 
			
		||||
								hold, inactive);
 | 
			
		||||
			pm_runtime_mark_last_busy(parent);
 | 
			
		||||
			pm_runtime_put_autosuspend(parent);
 | 
			
		||||
			return status;
 | 
			
		||||
		} else {
 | 
			
		||||
			return spi->controller->set_cs_timing(spi, setup, hold,
 | 
			
		||||
							      inactive);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((setup && setup->unit == SPI_DELAY_UNIT_SCK) ||
 | 
			
		||||
	    (hold && hold->unit == SPI_DELAY_UNIT_SCK) ||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue