spi: make sure all transfer has proper speed set
Subsystems (3)
Laxman Dewangan
maintainerPATCH 1/2 spi: make sure all transfer has proper speed set
When spi client does the spi transfer and if it does not set the speed for each transfer then set it as default of spi device in spi core before calling low level transfer.
This will remove the extra check in low level driver for setting speed.
--- drivers/spi/spi.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/spi/spi.c +4 -2
@@ -1366,12 +1366,14 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) }/** -* Set transfer bits_per_word as spi device default if it is not -* set for this transfer. +* Set transfer bits_per_word and max speed as spi device default if +* it is not set for this transfer. */ list_for_each_entry (xfer, &message->transfers, transfer_list) {if (!xfer->bits_per_word) xfer->bits_per_word = spi->bits_per_word; +if (!xfer->speed_hz) + xfer->speed_hz = spi->max_speed_hz; } message->spi = spi;
Signature · 9 lines
1.7.1.1 ------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812
Laxman Dewangan
maintainerPATCH 2/2 spi: tegra: remove checks for valid speed
SPI core make sure that all transfer has proper speed set before calling low level spi transfer. Hence, it is not require to have check in spi driver.
Remove the check for speed validity from transfer and use it directly.
--- drivers/spi/spi-tegra20-sflash.c | 14 +++++++++++--- drivers/spi/spi-tegra20-slink.c | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/spi/spi-tegra20-sflash.c +11 -3
@@ -269,9 +269,7 @@ static int tegra_sflash_start_transfer_one(struct spi_device *spi,u32 speed;unsigned long command; - speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz; -if (!speed) - speed = tsd->spi_max_frequency; + speed = t->speed_hz;if (speed != tsd->cur_speed) {clk_set_rate (tsd->clk, speed); tsd->cur_speed = speed;
@@ -319,6 +317,15 @@ static int tegra_sflash_start_transfer_one(struct spi_device *spi,return tegra_sflash_start_cpu_based_transfer (tsd, t); } +static int tegra_sflash_setup (struct spi_device *spi) +{ +struct tegra_sflash_data *tsd =spi_master_get_devdata (spi->master); + +/* Set speed to the spi max fequency if spi device has not set */ + spi->max_speed_hz = spi->max_speed_hz ? : tsd->spi_max_frequency; +return 0 ; +} +static int tegra_sflash_transfer_one_message (struct spi_master *master,struct spi_message *msg) {
@@ -492,6 +499,7 @@ static int tegra_sflash_probe(struct platform_device *pdev)/* the spi->mode bits understood by this driver: */ master->mode_bits =SPI_CPOL |SPI_CPHA ; + master->setup = tegra_sflash_setup; master->transfer_one_message = tegra_sflash_transfer_one_message; master->num_chipselect =MAX_CHIP_SELECT ; master->bus_num =-1 ;
drivers/spi/spi-tegra20-slink.c +3 -3
@@ -728,9 +728,7 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,unsigned long command2; bits_per_word = t->bits_per_word; - speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz; -if (!speed) - speed = tspi->spi_max_frequency; + speed = t->speed_hz;if (speed != tspi->cur_speed) {clk_set_rate (tspi->clk, speed *4 ); tspi->cur_speed = speed;
@@ -841,6 +839,8 @@ static int tegra_slink_setup(struct spi_device *spi)BUG_ON (spi->chip_select >=MAX_CHIP_SELECT ); +/* Set speed to the spi max fequency if spi device has not set */ + spi->max_speed_hz = spi->max_speed_hz ? : tspi->spi_max_frequency; ret =pm_runtime_get_sync (tspi->dev);if (ret <0 ) {dev_err (tspi->dev,"pm runtime failed, e = %d\n" , ret);
Signature · 9 lines
1.7.1.1 ------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812
Grant Likely
AppliedRe: [PATCH 2/2] spi: tegra: remove checks for valid speed
Quoted 7 lines · Laxman Dewangan
SPI core make sure that all transfer has proper speed set before calling low level spi transfer. Hence, it is not require to have check in spi driver.
Remove the check for speed validity from transfer and use it directly.
Signed-off-by Laxman Dewangan <[email protected]>
Applied, thanks.
g.
Quoted 71 lines
--- drivers/spi/spi-tegra20-sflash.c | 14 +++++++++++--- drivers/spi/spi-tegra20-slink.c | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-)drivers/spi/spi-tegra20-sflash.c +11
-3@@ -269,9 +269,7 @@ static int tegra_sflash_start_transfer_one(struct spi_device *spi,u32 speed;unsigned long command; - speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz; -if (!speed) - speed = tsd->spi_max_frequency; + speed = t->speed_hz;if (speed != tsd->cur_speed) {clk_set_rate (tsd->clk, speed); tsd->cur_speed = speed;@@ -319,6 +317,15 @@ static int tegra_sflash_start_transfer_one(struct spi_device *spi,return tegra_sflash_start_cpu_based_transfer (tsd, t); } +static int tegra_sflash_setup (struct spi_device *spi) +{ +struct tegra_sflash_data *tsd =spi_master_get_devdata (spi->master); + +/* Set speed to the spi max fequency if spi device has not set */ + spi->max_speed_hz = spi->max_speed_hz ? : tsd->spi_max_frequency; +return 0 ; +} +static int tegra_sflash_transfer_one_message (struct spi_master *master,struct spi_message *msg) {@@ -492,6 +499,7 @@ static int tegra_sflash_probe(struct platform_device *pdev)/* the spi->mode bits understood by this driver: */ master->mode_bits =SPI_CPOL |SPI_CPHA ; + master->setup = tegra_sflash_setup; master->transfer_one_message = tegra_sflash_transfer_one_message; master->num_chipselect =MAX_CHIP_SELECT ; master->bus_num =-1 ;drivers/spi/spi-tegra20-slink.c +3
-3@@ -728,9 +728,7 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,unsigned long command2; bits_per_word = t->bits_per_word; - speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz; -if (!speed) - speed = tspi->spi_max_frequency; + speed = t->speed_hz;if (speed != tspi->cur_speed) {clk_set_rate (tspi->clk, speed *4 ); tspi->cur_speed = speed;@@ -841,6 +839,8 @@ static int tegra_slink_setup(struct spi_device *spi)BUG_ON (spi->chip_select >=MAX_CHIP_SELECT ); +/* Set speed to the spi max fequency if spi device has not set */ + spi->max_speed_hz = spi->max_speed_hz ? : tspi->spi_max_frequency; ret =pm_runtime_get_sync (tspi->dev);if (ret <0 ) {dev_err (tspi->dev,"pm runtime failed, e = %d\n" , ret);Signature · 1 line
1.7.1.1
Signature · 8 lines
Grant Likely, B.Sc, P.Eng. Secret Lab Technologies, Ltd. ------------------------------------------------------------------------------ Free Next-Gen Firewall Hardware Offer Buy your Sophos next-gen firewall before the end March 2013 and get the hardware for free! Learn more. http://p.sf.net/sfu/sophos-d2d-feb
Grant Likely
AppliedQuoted 8 lines · Laxman Dewangan
When spi client does the spi transfer and if it does not set the speed for each transfer then set it as default of spi device in spi core before calling low level transfer.
This will remove the extra check in low level driver for setting speed.
Signed-off-by Laxman Dewangan <[email protected]>
Applied, thanks.
g.
Quoted 28 lines
--- drivers/spi/spi.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)drivers/spi/spi.c +4
-2@@ -1366,12 +1366,14 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message) }/** -* Set transfer bits_per_word as spi device default if it is not -* set for this transfer. +* Set transfer bits_per_word and max speed as spi device default if +* it is not set for this transfer. */ list_for_each_entry (xfer, &message->transfers, transfer_list) {if (!xfer->bits_per_word) xfer->bits_per_word = spi->bits_per_word; +if (!xfer->speed_hz) + xfer->speed_hz = spi->max_speed_hz; } message->spi = spi;Signature · 1 line
1.7.1.1
Signature · 2 lines
Grant Likely, B.Sc, P.Eng. Secret Lab Technologies, Ltd.