diff mbox series

[20/30] net: eepro100: Fix EE_*_CMD macros

Message ID 20200523163837.407592-20-marek.vasut+renesas@gmail.com
State New
Delegated to: Joe Hershberger
Headers show
Series [01/30] net: eepro100: Remove EEPRO100_SROM_WRITE | expand

Commit Message

Marek Vasut May 23, 2020, 4:38 p.m. UTC
Those macros depended on specific variable names to be declared
at their usage sites, fix this by adding an argument to those
macros and also protect the argument with braces.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
---
 drivers/net/eepro100.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Ramon Fried May 23, 2020, 5:22 p.m. UTC | #1
On Sat, May 23, 2020 at 7:44 PM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Those macros depended on specific variable names to be declared
> at their usage sites, fix this by adding an argument to those
> macros and also protect the argument with braces.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> ---
>  drivers/net/eepro100.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
> index 861d39cf9f..a8d617c7e8 100644
> --- a/drivers/net/eepro100.c
> +++ b/drivers/net/eepro100.c
> @@ -96,10 +96,10 @@
>  #define EE_DATA_BITS           16
>
>  /* The EEPROM commands include the alway-set leading bit. */
> -#define EE_EWENB_CMD           (4 << addr_len)
> -#define EE_WRITE_CMD           (5 << addr_len)
> -#define EE_READ_CMD            (6 << addr_len)
> -#define EE_ERASE_CMD           (7 << addr_len)
> +#define EE_EWENB_CMD(addr_len) (4 << (addr_len))
> +#define EE_WRITE_CMD(addr_len) (5 << (addr_len))
> +#define EE_READ_CMD(addr_len)  (6 << (addr_len))
> +#define EE_ERASE_CMD(addr_len) (7 << (addr_len))
>
>  /* Receive frame descriptors. */
>  struct eepro100_rxfd {
> @@ -433,7 +433,7 @@ static int eepro100_txcmd_send(struct eth_device *dev,
>  static int read_eeprom(struct eth_device *dev, int location, int addr_len)
>  {
>         unsigned short retval = 0;
> -       int read_cmd = location | EE_READ_CMD;
> +       int read_cmd = location | EE_READ_CMD(addr_len);
>         int i;
>
>         OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);
> --
> 2.25.1
>

Reviewed-By: Ramon Fried <rfried.dev@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 861d39cf9f..a8d617c7e8 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -96,10 +96,10 @@ 
 #define EE_DATA_BITS		16
 
 /* The EEPROM commands include the alway-set leading bit. */
-#define EE_EWENB_CMD		(4 << addr_len)
-#define EE_WRITE_CMD		(5 << addr_len)
-#define EE_READ_CMD		(6 << addr_len)
-#define EE_ERASE_CMD		(7 << addr_len)
+#define EE_EWENB_CMD(addr_len)	(4 << (addr_len))
+#define EE_WRITE_CMD(addr_len)	(5 << (addr_len))
+#define EE_READ_CMD(addr_len)	(6 << (addr_len))
+#define EE_ERASE_CMD(addr_len)	(7 << (addr_len))
 
 /* Receive frame descriptors. */
 struct eepro100_rxfd {
@@ -433,7 +433,7 @@  static int eepro100_txcmd_send(struct eth_device *dev,
 static int read_eeprom(struct eth_device *dev, int location, int addr_len)
 {
 	unsigned short retval = 0;
-	int read_cmd = location | EE_READ_CMD;
+	int read_cmd = location | EE_READ_CMD(addr_len);
 	int i;
 
 	OUTW(dev, EE_ENB & ~EE_CS, SCB_EEPROM);