* [PATCH RFT] spi: ep93xx: Convert to let spi core handle checking transfer speed
@ 2014-02-08 15:52 Axel Lin
2014-02-10 11:11 ` Mika Westerberg
2014-02-14 20:24 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2014-02-08 15:52 UTC (permalink / raw)
To: Mark Brown; +Cc: Mika Westerberg, linux-spi-u79uwXL29TY76Z2rM5mHXA
By setting master->max_speed_hz and master->min_speed_hz, spi core will handle
checking transfer speed. So we can remove the same checking in this driver.
Signed-off-by: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>
---
drivers/spi/spi-ep93xx.c | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c
index 1bfaed6..2f675d3 100644
--- a/drivers/spi/spi-ep93xx.c
+++ b/drivers/spi/spi-ep93xx.c
@@ -73,8 +73,6 @@
* @clk: clock for the controller
* @regs_base: pointer to ioremap()'d registers
* @sspdr_phys: physical address of the SSPDR register
- * @min_rate: minimum clock rate (in Hz) supported by the controller
- * @max_rate: maximum clock rate (in Hz) supported by the controller
* @wait: wait here until given transfer is completed
* @current_msg: message that is currently processed (or %NULL if none)
* @tx: current byte in transfer to transmit
@@ -95,8 +93,6 @@ struct ep93xx_spi {
struct clk *clk;
void __iomem *regs_base;
unsigned long sspdr_phys;
- unsigned long min_rate;
- unsigned long max_rate;
struct completion wait;
struct spi_message *current_msg;
size_t tx;
@@ -199,9 +195,9 @@ static void ep93xx_spi_disable_interrupts(const struct ep93xx_spi *espi)
* @div_scr: pointer to return the scr divider
*/
static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi,
- unsigned long rate,
- u8 *div_cpsr, u8 *div_scr)
+ u32 rate, u8 *div_cpsr, u8 *div_scr)
{
+ struct spi_master *master = platform_get_drvdata(espi->pdev);
unsigned long spi_clk_rate = clk_get_rate(espi->clk);
int cpsr, scr;
@@ -210,7 +206,7 @@ static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi,
* controller. Note that minimum value is already checked in
* ep93xx_spi_transfer_one_message().
*/
- rate = clamp(rate, espi->min_rate, espi->max_rate);
+ rate = clamp(rate, master->min_speed_hz, master->max_speed_hz);
/*
* Calculate divisors so that we can get speed according the
@@ -735,13 +731,6 @@ static int ep93xx_spi_transfer_one_message(struct spi_master *master,
struct spi_message *msg)
{
struct ep93xx_spi *espi = spi_master_get_devdata(master);
- struct spi_transfer *t;
-
- /* first validate each transfer */
- list_for_each_entry(t, &msg->transfers, transfer_list) {
- if (t->speed_hz < espi->min_rate)
- return -EINVAL;
- }
msg->state = NULL;
msg->status = 0;
@@ -917,8 +906,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
* Calculate maximum and minimum supported clock rates
* for the controller.
*/
- espi->max_rate = clk_get_rate(espi->clk) / 2;
- espi->min_rate = clk_get_rate(espi->clk) / (254 * 256);
+ master->max_speed_hz = clk_get_rate(espi->clk) / 2;
+ master->min_speed_hz = clk_get_rate(espi->clk) / (254 * 256);
espi->pdev = pdev;
espi->sspdr_phys = res->start + SSPDR;
--
1.8.1.2
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RFT] spi: ep93xx: Convert to let spi core handle checking transfer speed
2014-02-08 15:52 [PATCH RFT] spi: ep93xx: Convert to let spi core handle checking transfer speed Axel Lin
@ 2014-02-10 11:11 ` Mika Westerberg
2014-02-14 20:24 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mika Westerberg @ 2014-02-10 11:11 UTC (permalink / raw)
To: Axel Lin
Cc: Mark Brown, linux-spi-u79uwXL29TY76Z2rM5mHXA,
hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR
On Sat, Feb 8, 2014 at 5:52 PM, Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org> wrote:
>
> By setting master->max_speed_hz and master->min_speed_hz, spi core will handle
> checking transfer speed. So we can remove the same checking in this driver.
>
> Signed-off-by: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>
I don't have the hardware to test this anymore but the patch looks good to me.
Acked-by: Mika Westerberg <mika.westerberg-X3B1VOXEql0@public.gmane.org>
Adding Hartley to the loop in case he has some comments.
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFT] spi: ep93xx: Convert to let spi core handle checking transfer speed
2014-02-08 15:52 [PATCH RFT] spi: ep93xx: Convert to let spi core handle checking transfer speed Axel Lin
2014-02-10 11:11 ` Mika Westerberg
@ 2014-02-14 20:24 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2014-02-14 20:24 UTC (permalink / raw)
To: Axel Lin; +Cc: Mika Westerberg, linux-spi-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 235 bytes --]
On Sat, Feb 08, 2014 at 11:52:26PM +0800, Axel Lin wrote:
> By setting master->max_speed_hz and master->min_speed_hz, spi core will handle
> checking transfer speed. So we can remove the same checking in this driver.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-14 20:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-08 15:52 [PATCH RFT] spi: ep93xx: Convert to let spi core handle checking transfer speed Axel Lin
2014-02-10 11:11 ` Mika Westerberg
2014-02-14 20:24 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).