All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Welling <mwelling-EkmVulN54Sk@public.gmane.org>
To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2] spi: omap2-mcspi: Add support for GPIO chipselects
Date: Mon, 27 Apr 2015 20:21:50 -0500	[thread overview]
Message-ID: <20150428012150.GA12713@deathray> (raw)
In-Reply-To: <20150427195550.GE22845-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>

On Mon, Apr 27, 2015 at 08:55:50PM +0100, Mark Brown wrote:
> On Sun, Apr 26, 2015 at 10:44:30PM -0500, Michael Welling wrote:
> 
> > +	if (gpio_is_valid(spi->cs_gpio)) {
> > +		gpio_set_value(spi->cs_gpio, (cs_active) ?
> > +			!!(spi->mode & SPI_CS_HIGH) :
> > +			!(spi->mode & SPI_CS_HIGH));
> > +	}
> 
> Two problems here.  One is that the above logic statement is just not
> readable (the repitition of hecks, the ternery operator, the
> indentation...) and the other is that the core chipselect support
> already handles GPIO chipselects so you should really be converting the
> driver to use that.  At the very least the code needs to be legible
> though.

Before I send another patch how does this look?

	if (gpio_is_valid(spi->cs_gpio)) {
		if (cs_active)
			gpio_set_value(spi->cs_gpio, spi->mode & SPI_CS_HIGH);
		else
			gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
	}

If I were to attempt to convert the driver to use the core chipselect support,
how would I go about doing it?

Is there another driver that I can use for reference?
--
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

WARNING: multiple messages have this Message-ID (diff)
From: Michael Welling <mwelling@ieee.org>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] spi: omap2-mcspi: Add support for GPIO chipselects
Date: Mon, 27 Apr 2015 20:21:50 -0500	[thread overview]
Message-ID: <20150428012150.GA12713@deathray> (raw)
In-Reply-To: <20150427195550.GE22845@sirena.org.uk>

On Mon, Apr 27, 2015 at 08:55:50PM +0100, Mark Brown wrote:
> On Sun, Apr 26, 2015 at 10:44:30PM -0500, Michael Welling wrote:
> 
> > +	if (gpio_is_valid(spi->cs_gpio)) {
> > +		gpio_set_value(spi->cs_gpio, (cs_active) ?
> > +			!!(spi->mode & SPI_CS_HIGH) :
> > +			!(spi->mode & SPI_CS_HIGH));
> > +	}
> 
> Two problems here.  One is that the above logic statement is just not
> readable (the repitition of hecks, the ternery operator, the
> indentation...) and the other is that the core chipselect support
> already handles GPIO chipselects so you should really be converting the
> driver to use that.  At the very least the code needs to be legible
> though.

Before I send another patch how does this look?

	if (gpio_is_valid(spi->cs_gpio)) {
		if (cs_active)
			gpio_set_value(spi->cs_gpio, spi->mode & SPI_CS_HIGH);
		else
			gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
	}

If I were to attempt to convert the driver to use the core chipselect support,
how would I go about doing it?

Is there another driver that I can use for reference?

  parent reply	other threads:[~2015-04-28  1:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27  3:44 [PATCH v2] spi: omap2-mcspi: Add support for GPIO chipselects Michael Welling
2015-04-27  3:44 ` Michael Welling
     [not found] ` <1430106270-17142-1-git-send-email-mwelling-EkmVulN54Sk@public.gmane.org>
2015-04-27 19:55   ` Mark Brown
2015-04-27 19:55     ` Mark Brown
     [not found]     ` <20150427195550.GE22845-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-04-28  1:21       ` Michael Welling [this message]
2015-04-28  1:21         ` Michael Welling
2015-04-28  5:32         ` Martin Sperl
     [not found]           ` <55B19D93-B930-4363-9D44-0E97B4B836BF-d5rIkyn9cnPYtjvyW6yDsg@public.gmane.org>
2015-04-28 22:49             ` Michael Welling
2015-04-28 22:49               ` Michael Welling
2015-04-28 14:04         ` Ezequiel Garcia
2015-04-28 14:04           ` Ezequiel Garcia
2015-04-28 22:50           ` Michael Welling
2015-04-28 14:34         ` Mark Brown
     [not found]           ` <20150428143425.GS22845-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-04-28 23:06             ` Michael Welling
2015-04-28 23:06               ` Michael Welling
2015-04-29 10:47               ` 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=20150428012150.GA12713@deathray \
    --to=mwelling-ekmvuln54sk@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.