Skip to contentSkip to conversation

mtd: rawnand: tegra: Simplify maximum determination in tegra_nand_setup_timing()

PATCH In review Markus Elfring 2 participants 7 messages Feb 28, 2025 – Mar 4, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: tegra: Simplify maximum determination in tegra_nand_setup_timing()

From: Markus Elfring <[email protected]>
Date: Fri, 28 Feb 2025 19:19:45 +0100

Reduce nested max() calls by a single max3() call in this function implementation.

The source code was transformed by using the Coccinelle software.

---
 drivers/mtd/nand/raw/tegra_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/tegra_nand.c +2 -2
index 7f9eb5f042a7..c03f11e5e18c 100644
@@ -793,8 +793,8 @@ static void tegra_nand_setup_timing(struct tegra_nand_controller *ctrl,
 				timings->tRC_min), period);
 	reg |= TIMING_TCR_TAR_TRR(OFFSET(val, 3));
 
-	val = DIV_ROUND_UP(max(max(timings->tCS_min, timings->tCH_min),
-			       max(timings->tALS_min, timings->tALH_min)),
+	val = DIV_ROUND_UP(max3(timings->tCS_min, timings->tCH_min,
+				max(timings->tALS_min, timings->tALH_min)),
 			   period);
 	reg |= TIMING_TCS(OFFSET(val, 2));
 

--
2.48.1

maintainer
#1 lore raw

Hi,

Quoted 9 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 28 Feb 2025 19:19:45 +0100

Reduce nested max() calls by a single max3() call in this function implementation.

The source code was transformed by using the Coccinelle software.

I am sorry, I do not see what gets simplified. max(max(a,b),max(c,d)) looks simpler than max3(a,b,max(c,d)). Does it bring something in terms of optimization?

Thanks,
Miquèl

#2 lore raw
Quoted 2 lines

I am sorry, I do not see what gets simplified. max(max(a,b),max(c,d)) looks simpler than max3(a,b,max(c,d)).

You would eventually like to express that a maximum should be determined from three (or even four?) values.
https://elixir.bootlin.com/linux/v6.14-rc4/source/include/linux/minmax.h#L147

Quoted 2 lines

Does it bring something in terms
of optimization?

Corresponding effects depend on various factors, don't they?

Regards,
Markus

maintainer
#3 lore raw
Quoted 5 lines · Markus Elfring
Quoted 2 lines

I am sorry, I do not see what gets simplified. max(max(a,b),max(c,d)) looks simpler than max3(a,b,max(c,d)).

You would eventually like to express that a maximum should be determined from three (or even four?) values.

If there was a max4(), why not, but in this case I don't see the point.

Quoted 6 lines

https://elixir.bootlin.com/linux/v6.14-rc4/source/include/linux/minmax.h#L147

Quoted 2 lines

Does it bring something in terms
of optimization?

Corresponding effects depend on various factors, don't they?

Ok, so I'll assume the answer to my question is "no".

Thanks,
Miquèl

#4 lore raw
Quoted 4 lines
Quoted 2 lines

You would eventually like to express that a maximum should be determined from three (or even four?) values.

If there was a max4(), why not, but in this case I don't see the point.

Do you miss such a programming interface so far? Would you be looking for corresponding software adjustments?

Regards,
Markus

maintainer
#5 lore raw
Quoted 5 lines · Markus Elfring
Quoted 4 lines
Quoted 2 lines

You would eventually like to express that a maximum should be determined from three (or even four?) values.

If there was a max4(), why not, but in this case I don't see the point.

Do you miss such a programming interface so far?

No I do not.

Quoted 1 line

Would you be looking for corresponding software adjustments?

Not necessarily, unless there is some performance improvement.

Thanks,
Miquèl

maintainer
#6 lore raw
In reply to Markus Elfring

Sorry for not being clear.

Quoted 5 lines · Markus Elfring
Quoted 4 lines
Quoted 2 lines

You would eventually like to express that a maximum should be determined from three (or even four?) values.

If there was a max4(), why not, but in this case I don't see the point.

Do you miss such a programming interface so far?

No.

Quoted 1 line

Would you be looking for corresponding software adjustments?

No.

Thanks,
Miquèl