linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	Laxman Dewangan
	<ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
	swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/2] spi: tegra: remove checks for valid speed
Date: Tue, 05 Feb 2013 13:12:04 +0000	[thread overview]
Message-ID: <20130205131204.6D47D3E0E27@localhost> (raw)
In-Reply-To: <1357325235-25485-2-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

On Sat, 5 Jan 2013 00:17:15 +0530, Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
> 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 <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Applied, thanks.

g.

> ---
>  drivers/spi/spi-tegra20-sflash.c |   14 +++++++++++---
>  drivers/spi/spi-tegra20-slink.c  |    6 +++---
>  2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c
> index 448a8cc..9a42c15 100644
> --- a/drivers/spi/spi-tegra20-sflash.c
> +++ b/drivers/spi/spi-tegra20-sflash.c
> @@ -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;
> diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
> index 651167f..29039f1 100644
> --- a/drivers/spi/spi-tegra20-slink.c
> +++ b/drivers/spi/spi-tegra20-slink.c
> @@ -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);
> -- 
> 1.7.1.1
> 

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

  parent reply	other threads:[~2013-02-05 13:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-04 18:47 [PATCH 1/2] spi: make sure all transfer has proper speed set Laxman Dewangan
     [not found] ` <1357325235-25485-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-04 18:47   ` [PATCH 2/2] spi: tegra: remove checks for valid speed Laxman Dewangan
     [not found]     ` <1357325235-25485-2-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-02-05 13:12       ` Grant Likely [this message]
2013-02-05 13:11 ` [PATCH 1/2] spi: make sure all transfer has proper speed set Grant Likely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130205131204.6D47D3E0E27@localhost \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).