From: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
To: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>
Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] spi: xcomm: Remove duplicate code to set default bits_per_word and max speed
Date: Mon, 03 Mar 2014 09:54:21 +0100 [thread overview]
Message-ID: <5314433D.10104@metafoo.de> (raw)
In-Reply-To: <1393771721.4044.7.camel@phoenix>
On 03/02/2014 03:48 PM, Axel Lin wrote:
> In the implementation of __spi_validate(), spi core will set transfer
> bits_per_word and max speed as spi device default if it is not set for
> this transfer. So we can remove the same logic in spi_xcomm_setup_transfer().
> Also remove a redundant code to initialize is_first variable.
>
> Signed-off-by: Axel Lin <axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org>
Acked-by: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
> ---
> drivers/spi/spi-xcomm.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/spi/spi-xcomm.c b/drivers/spi/spi-xcomm.c
> index 350a76b..bb478dc 100644
> --- a/drivers/spi/spi-xcomm.c
> +++ b/drivers/spi/spi-xcomm.c
> @@ -73,15 +73,13 @@ static void spi_xcomm_chipselect(struct spi_xcomm *spi_xcomm,
> static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm,
> struct spi_device *spi, struct spi_transfer *t, unsigned int *settings)
> {
> - unsigned int speed;
> -
> if (t->len > 62)
> return -EINVAL;
>
> - speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz;
> + if (t->speed_hz != spi_xcomm->current_speed) {
> + unsigned int divider;
>
> - if (speed != spi_xcomm->current_speed) {
> - unsigned int divider = DIV_ROUND_UP(SPI_XCOMM_CLOCK, speed);
> + divider = DIV_ROUND_UP(SPI_XCOMM_CLOCK, t->speed_hz);
> if (divider >= 64)
> *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_64;
> else if (divider >= 16)
> @@ -89,7 +87,7 @@ static int spi_xcomm_setup_transfer(struct spi_xcomm *spi_xcomm,
> else
> *settings |= SPI_XCOMM_SETTINGS_CLOCK_DIV_4;
>
> - spi_xcomm->current_speed = speed;
> + spi_xcomm->current_speed = t->speed_hz;
> }
>
> if (spi->mode & SPI_CPOL)
> @@ -147,8 +145,6 @@ static int spi_xcomm_transfer_one(struct spi_master *master,
> int status = 0;
> bool is_last;
>
> - is_first = true;
> -
> spi_xcomm_chipselect(spi_xcomm, spi, true);
>
> list_for_each_entry(t, &msg->transfers, transfer_list) {
>
--
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
next prev parent reply other threads:[~2014-03-03 8:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-02 14:48 [PATCH] spi: xcomm: Remove duplicate code to set default bits_per_word and max speed Axel Lin
2014-03-03 8:54 ` Lars-Peter Clausen [this message]
2014-03-04 3:19 ` Mark Brown
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=5314433D.10104@metafoo.de \
--to=lars-qo5elluwu/uelga04laivw@public.gmane.org \
--cc=axel.lin-8E1dMatC8ynQT0dZR+AlfA@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@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).