Skip to contentSkip to conversation

serial: 8250_bcm7271: Replace custom unit definitions

PATCH In review Andy Shevchenko 3 participants 6 messages Feb 15, 2024

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

PATCH 1/1 serial: 8250_bcm7271: Replace custom unit definitions

Replace custom unit definitions that are available via units.h.

---
 drivers/tty/serial/8250/8250_bcm7271.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/tty/serial/8250/8250_bcm7271.c +8 -9
index 504c4c020857..1532fa2e8ec4 100644
@@ -22,6 +22,7 @@
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <linux/debugfs.h>
+#include <linux/units.h>
 
 #include "8250.h"
 
@@ -187,21 +188,19 @@
 #define TX_BUF_SIZE 4096
 #define RX_BUF_SIZE 4096
 #define RX_BUFS_COUNT 2
-#define KHZ    1000
-#define MHZ(x) ((x) * KHZ * KHZ)
 
 static const u32 brcmstb_rate_table[] = {
-	MHZ(81),
-	MHZ(108),
-	MHZ(64),		/* Actually 64285715 for some chips */
-	MHZ(48),
+	81 * HZ_PER_MHZ,
+	108 * HZ_PER_MHZ,
+	64 * HZ_PER_MHZ,		/* Actually 64285715 for some chips */
+	48 * HZ_PER_MHZ,
 };
 
 static const u32 brcmstb_rate_table_7278[] = {
-	MHZ(81),
-	MHZ(108),
+	81 * HZ_PER_MHZ,
+	108 * HZ_PER_MHZ,
 	0,
-	MHZ(48),
+	48 * HZ_PER_MHZ,
 };
 
 struct brcmuart_priv {
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
#2 lore raw
In reply to Andy Shevchenko
Quoted 25 lines · Andy Shevchenko

Replace custom unit definitions that are available via units.h.

---
  drivers/tty/serial/8250/8250_bcm7271.c | 17 ++++++++---------
  1 file changed, 8 insertions(+), 9 deletions(-)
drivers/tty/serial/8250/8250_bcm7271.c +1 -2
index 504c4c020857..1532fa2e8ec4 100644
@@ -22,6 +22,7 @@
  #include <linux/delay.h>
  #include <linux/clk.h>
  #include <linux/debugfs.h>
+#include <linux/units.h>
 
  #include "8250.h"
 
@@ -187,21 +188,19 @@
  #define TX_BUF_SIZE 4096
  #define RX_BUF_SIZE 4096
  #define RX_BUFS_COUNT 2
-#define KHZ    1000
-#define MHZ(x) ((x) * KHZ * KHZ)

drivers/tty/serial/8250/8250_bcm7271.c line 196

Quoted 10 lines
drivers/tty/serial/8250/8250_bcm7271.c +4 -4
 
  static const u32 brcmstb_rate_table[] = {
-	MHZ(81),
-	MHZ(108),
-	MHZ(64),		/* Actually 64285715 for some chips */
-	MHZ(48),
+	81 * HZ_PER_MHZ,
+	108 * HZ_PER_MHZ,
+	64 * HZ_PER_MHZ,		/* Actually 64285715 for some chips */
+	48 * HZ_PER_MHZ,

The previous notation was IMHO more readable, can we meet in the middle and do:

#define MHZ(x) ((x) * HZ_PER_MHZ

and avoid touching the tables entirely?

Signature · 1 line
Florian
#3 lore raw
Quoted 1 line · Florian Fainelli

On 2/15/24 08:02, Andy Shevchenko wrote:

...

Quoted 5 lines
Quoted 5 lines
drivers/tty/serial/8250/8250_bcm7271.c +0 -4
-#define KHZ    1000
-#define MHZ(x) ((x) * KHZ * KHZ)
  static const u32 brcmstb_rate_table[] = {
-	MHZ(81),
-	MHZ(108),
Quoted 8 lines

drivers/tty/serial/8250/8250_bcm7271.c line 196

Quoted 6 lines
drivers/tty/serial/8250/8250_bcm7271.c +4 -2
-	MHZ(64),		/* Actually 64285715 for some chips */
-	MHZ(48),
+	81 * HZ_PER_MHZ,
+	108 * HZ_PER_MHZ,
+	64 * HZ_PER_MHZ,		/* Actually 64285715 for some chips */
+	48 * HZ_PER_MHZ,

The previous notation was IMHO more readable,

I tend to disagree as we read in plain text "frequency is 64 MHz", the patch follows natural language.

Quoted 5 lines

can we meet in the middle and do:

#define MHZ(x) ((x) * HZ_PER_MHZ

and avoid touching the tables entirely?

I don't like the intermediate layer which hides the implementation of MHZ(). What does it do exactly? You need to look at the internals, with the patch applied you immediately see that these are just constants.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
Reviewed-by
#4 lore raw
Quoted 24 lines · Andy Shevchenko
Quoted 1 line · Florian Fainelli

On 2/15/24 08:02, Andy Shevchenko wrote:

...

Quoted 5 lines
Quoted 5 lines
drivers/tty/serial/8250/8250_bcm7271.c +0 -4
-#define KHZ    1000
-#define MHZ(x) ((x) * KHZ * KHZ)
   static const u32 brcmstb_rate_table[] = {
-	MHZ(81),
-	MHZ(108),
Quoted 8 lines

drivers/tty/serial/8250/8250_bcm7271.c line 196

Quoted 6 lines
drivers/tty/serial/8250/8250_bcm7271.c +4 -2
-	MHZ(64),		/* Actually 64285715 for some chips */
-	MHZ(48),
+	81 * HZ_PER_MHZ,
+	108 * HZ_PER_MHZ,
+	64 * HZ_PER_MHZ,		/* Actually 64285715 for some chips */
+	48 * HZ_PER_MHZ,

The previous notation was IMHO more readable,

I tend to disagree as we read in plain text "frequency is 64 MHz", the patch follows natural language.

Quoted 2 lines

can we meet in the middle and do:

Quoted 8 lines
Quoted 3 lines

#define MHZ(x) ((x) * HZ_PER_MHZ

and avoid touching the tables entirely?

I don't like the intermediate layer which hides the implementation of MHZ(). What does it do exactly? You need to look at the internals, with the patch applied you immediately see that these are just constants.

OK, I suppose today's color is blue for the bike shed.

Signature · 1 line
Florian
#5 lore raw
Quoted 3 lines · Florian Fainelli
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Florian Fainelli

On 2/15/24 08:02, Andy Shevchenko wrote:

...

Quoted 21 lines
Quoted 21 lines
Quoted 5 lines
Quoted 5 lines
drivers/tty/serial/8250/8250_bcm7271.c +0 -4
-#define KHZ    1000
-#define MHZ(x) ((x) * KHZ * KHZ)
   static const u32 brcmstb_rate_table[] = {
-	MHZ(81),
-	MHZ(108),
Quoted 8 lines

drivers/tty/serial/8250/8250_bcm7271.c line 196

Quoted 6 lines
drivers/tty/serial/8250/8250_bcm7271.c +4 -2
-	MHZ(64),		/* Actually 64285715 for some chips */
-	MHZ(48),
+	81 * HZ_PER_MHZ,
+	108 * HZ_PER_MHZ,
+	64 * HZ_PER_MHZ,		/* Actually 64285715 for some chips */
+	48 * HZ_PER_MHZ,

The previous notation was IMHO more readable,

I tend to disagree as we read in plain text "frequency is 64 MHz", the patch follows natural language.

Quoted 4 lines

can we meet in the middle and do:

#define MHZ(x) ((x) * HZ_PER_MHZ

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

and avoid touching the tables entirely?

I don't like the intermediate layer which hides the implementation of MHZ(). What does it do exactly? You need to look at the internals, with the patch applied you immediately see that these are just constants.

OK, I suppose today's color is blue for the bike shed.

Sky is blue and sun is shining and I am happy person :-)

Quoted 1 line

Thank you!

Signature · 2 lines
With Best Regards,
Andy Shevchenko