spi: Remove unneeded parentheses in spi_map_buf()
PATCH 1/1 spi: Remove unneeded parentheses in spi_map_buf()
The boolean expression to get kmap_buf is hard to read due to too many unneeded parentheses. Remove them for good.
--- drivers/spi/spi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/spi/spi.c +2 -3
@@ -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
Signature · 1 line
2.30.2
Mark Brown
maintainerdrivers/spi/spi.c int spi_map_buf(struct spi_controller *ctlr, struct device *dev, · line 877
Quoted 8 lines · Andy Shevchenko
The boolean expression to get
kmap_bufis hard to read due to too many unneeded parentheses. Remove them for good.drivers/spi/spi.c +2
-3-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.
Quoted 5 lines · Mark Brown
Quoted 2 lines · Andy Shevchenko
The boolean expression to get
kmap_bufis hard to read due to too many unneeded parentheses. Remove them for good.
Quoted 8 lines
drivers/spi/spi.c int spi_map_buf(struct spi_controller *ctlr, struct device *dev, · line 877
Quoted 5 lines
drivers/spi/spi.c +2
-3-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.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Mark Brown
maintainerQuoted 12 lines · Andy Shevchenko
Quoted 10 lines · Mark Brown
Quoted 8 lines · Andy Shevchenko
The boolean expression to get
kmap_bufis hard to read due to too many unneeded parentheses. Remove them for good.drivers/spi/spi.c +2
-3-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 );
Quoted 7 lines
Quoted 2 lines
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.