All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] spi: Remove unneeded parentheses in spi_map_buf()
@ 2021-06-19 11:15 Andy Shevchenko
  2021-06-21 10:39 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2021-06-19 11:15 UTC (permalink / raw)
  To: Mark Brown, linux-spi, linux-kernel; +Cc: Andy Shevchenko

The boolean expression to get kmap_buf is hard to read due to
too many unneeded parentheses. Remove them for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 16b377581d16..0e4917a55eaa 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -873,9 +873,8 @@ int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
 	const bool vmalloced_buf = is_vmalloc_addr(buf);
 	unsigned int max_seg_size = dma_get_max_seg_size(dev);
 #ifdef CONFIG_HIGHMEM
-	const bool kmap_buf = ((unsigned long)buf >= PKMAP_BASE &&
-				(unsigned long)buf < (PKMAP_BASE +
-					(LAST_PKMAP * PAGE_SIZE)));
+	const bool kmap_buf = (unsigned long)buf >= PKMAP_BASE &&
+			      (unsigned long)buf < (PKMAP_BASE + LAST_PKMAP * PAGE_SIZE);
 #else
 	const bool kmap_buf = false;
 #endif
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] spi: Remove unneeded parentheses in spi_map_buf()
  2021-06-19 11:15 [PATCH v1 1/1] spi: Remove unneeded parentheses in spi_map_buf() Andy Shevchenko
@ 2021-06-21 10:39 ` Mark Brown
  2021-06-21 10:43   ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2021-06-21 10:39 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-spi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 564 bytes --]

On Sat, Jun 19, 2021 at 02:15:26PM +0300, Andy Shevchenko wrote:
> The boolean expression to get kmap_buf is hard to read due to
> too many unneeded parentheses. Remove them for good.

> -	const bool kmap_buf = ((unsigned long)buf >= PKMAP_BASE &&
> -				(unsigned long)buf < (PKMAP_BASE +
> -					(LAST_PKMAP * PAGE_SIZE)));
> +	const bool kmap_buf = (unsigned long)buf >= PKMAP_BASE &&
> +			      (unsigned long)buf < (PKMAP_BASE + LAST_PKMAP * PAGE_SIZE);

No, I think this makes things worse - to the extent there's an issue
here it's not excessive brackets.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] spi: Remove unneeded parentheses in spi_map_buf()
  2021-06-21 10:39 ` Mark Brown
@ 2021-06-21 10:43   ` Andy Shevchenko
  2021-06-21 11:59     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2021-06-21 10:43 UTC (permalink / raw)
  To: Mark Brown; +Cc: Andy Shevchenko, linux-spi, Linux Kernel Mailing List

On Mon, Jun 21, 2021 at 1:40 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Sat, Jun 19, 2021 at 02:15:26PM +0300, Andy Shevchenko wrote:
> > The boolean expression to get kmap_buf is hard to read due to
> > too many unneeded parentheses. Remove them for good.
>
> > -     const bool kmap_buf = ((unsigned long)buf >= PKMAP_BASE &&
> > -                             (unsigned long)buf < (PKMAP_BASE +
> > -                                     (LAST_PKMAP * PAGE_SIZE)));
> > +     const bool kmap_buf = (unsigned long)buf >= PKMAP_BASE &&
> > +                           (unsigned long)buf < (PKMAP_BASE + LAST_PKMAP * PAGE_SIZE);
>
> No, I think this makes things worse - to the extent there's an issue
> here it's not excessive brackets.

How? I can't see any issues here and dropping excessive brackets helps
to read it better. For example, the exterior brackets do nothing
except making it harder to read, i.e. the expression inside them is
already type of boolean and I have no clue what they are for.



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/1] spi: Remove unneeded parentheses in spi_map_buf()
  2021-06-21 10:43   ` Andy Shevchenko
@ 2021-06-21 11:59     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2021-06-21 11:59 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Andy Shevchenko, linux-spi, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

On Mon, Jun 21, 2021 at 01:43:41PM +0300, Andy Shevchenko wrote:
> On Mon, Jun 21, 2021 at 1:40 PM Mark Brown <broonie@kernel.org> wrote:
> >
> > On Sat, Jun 19, 2021 at 02:15:26PM +0300, Andy Shevchenko wrote:
> > > The boolean expression to get kmap_buf is hard to read due to
> > > too many unneeded parentheses. Remove them for good.

> > > -     const bool kmap_buf = ((unsigned long)buf >= PKMAP_BASE &&
> > > -                             (unsigned long)buf < (PKMAP_BASE +
> > > -                                     (LAST_PKMAP * PAGE_SIZE)));
> > > +     const bool kmap_buf = (unsigned long)buf >= PKMAP_BASE &&
> > > +                           (unsigned long)buf < (PKMAP_BASE + LAST_PKMAP * PAGE_SIZE);

> > No, I think this makes things worse - to the extent there's an issue
> > here it's not excessive brackets.

> How? I can't see any issues here and dropping excessive brackets helps
> to read it better. For example, the exterior brackets do nothing
> except making it harder to read, i.e. the expression inside them is
> already type of boolean and I have no clue what they are for.

This is purely a taste thing.  I think the >= and && being the same
length and the second condition being visually distinct from the first
don't help here.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-21 12:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-19 11:15 [PATCH v1 1/1] spi: Remove unneeded parentheses in spi_map_buf() Andy Shevchenko
2021-06-21 10:39 ` Mark Brown
2021-06-21 10:43   ` Andy Shevchenko
2021-06-21 11:59     ` Mark Brown

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.