diff mbox series

[net-next,05/13] net: fec: fec_restart(): introduce a define for FEC_ECR_SPEED

Message ID 20241016-fec-cleanups-v1-5-de783bd15e6a@pengutronix.de (mailing list archive)
State New
Headers show
Series net: fec: cleanups, update quirk, update IRQ naming | expand

Commit Message

Marc Kleine-Budde Oct. 16, 2024, 9:51 p.m. UTC
Instead of open coding the bit mask to configure for 1000 MBit/s add a
define for it.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/ethernet/freescale/fec_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Wei Fang Oct. 17, 2024, 1:47 a.m. UTC | #1
> -----Original Message-----
> From: Marc Kleine-Budde <mkl@pengutronix.de>
> Sent: 2024年10月17日 5:52
> To: Wei Fang <wei.fang@nxp.com>; Shenwei Wang <shenwei.wang@nxp.com>;
> Clark Wang <xiaoning.wang@nxp.com>; David S. Miller
> <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub
> Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Richard
> Cochran <richardcochran@gmail.com>
> Cc: imx@lists.linux.dev; netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
> kernel@pengutronix.de; Marc Kleine-Budde <mkl@pengutronix.de>
> Subject: [PATCH net-next 05/13] net: fec: fec_restart(): introduce a define for
> FEC_ECR_SPEED
> 
> Instead of open coding the bit mask to configure for 1000 MBit/s add a define
> for it.
> 
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
>  drivers/net/ethernet/freescale/fec_main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index
> c57039cc83228dcd980a8fdbc18cd3eab2dfe1a5..2ee7e4765ba3163fb0d158e
> 60b534b171da26c22 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -276,6 +276,7 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC
> address");
>  #define FEC_ECR_MAGICEN         BIT(2)
>  #define FEC_ECR_SLEEP           BIT(3)
>  #define FEC_ECR_EN1588          BIT(4)
> +#define FEC_ECR_SPEED           BIT(5)
>  #define FEC_ECR_BYTESWP         BIT(8)
>  /* FEC RCR bits definition */
>  #define FEC_RCR_LOOP            BIT(0)
> @@ -1160,7 +1161,7 @@ fec_restart(struct net_device *ndev)
>  		/* 1G, 100M or 10M */
>  		if (ndev->phydev) {
>  			if (ndev->phydev->speed == SPEED_1000)
> -				ecntl |= (1 << 5);
> +				ecntl |= FEC_ECR_SPEED;
>  			else if (ndev->phydev->speed == SPEED_100)
>  				rcntl &= ~FEC_RCR_10BASET;
>  			else
> 
> --
> 2.45.2
> 

Thanks

Reviewed-by: Wei Fang <wei.fang@nxp.com>
Frank Li Oct. 17, 2024, 2:05 a.m. UTC | #2
On Wed, Oct 16, 2024 at 11:51:53PM +0200, Marc Kleine-Budde wrote:
> Instead of open coding the bit mask to configure for 1000 MBit/s add a
> define for it.

Replace "1 << 5" for configuring 1000 MBit/s with a defined constant to
improve code readability and maintainability.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
>  drivers/net/ethernet/freescale/fec_main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index c57039cc83228dcd980a8fdbc18cd3eab2dfe1a5..2ee7e4765ba3163fb0d158e60b534b171da26c22 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -276,6 +276,7 @@ MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
>  #define FEC_ECR_MAGICEN         BIT(2)
>  #define FEC_ECR_SLEEP           BIT(3)
>  #define FEC_ECR_EN1588          BIT(4)
> +#define FEC_ECR_SPEED           BIT(5)
>  #define FEC_ECR_BYTESWP         BIT(8)
>  /* FEC RCR bits definition */
>  #define FEC_RCR_LOOP            BIT(0)
> @@ -1160,7 +1161,7 @@ fec_restart(struct net_device *ndev)
>  		/* 1G, 100M or 10M */
>  		if (ndev->phydev) {
>  			if (ndev->phydev->speed == SPEED_1000)
> -				ecntl |= (1 << 5);
> +				ecntl |= FEC_ECR_SPEED;
>  			else if (ndev->phydev->speed == SPEED_100)
>  				rcntl &= ~FEC_RCR_10BASET;
>  			else
>
> --
> 2.45.2
>
>
Marc Kleine-Budde Oct. 17, 2024, 6:56 a.m. UTC | #3
On 16.10.2024 22:05:36, Frank Li wrote:
> On Wed, Oct 16, 2024 at 11:51:53PM +0200, Marc Kleine-Budde wrote:
> > Instead of open coding the bit mask to configure for 1000 MBit/s add a
> > define for it.
> 
> Replace "1 << 5" for configuring 1000 MBit/s with a defined constant to
> improve code readability and maintainability.

Fixed,
Marc
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index c57039cc83228dcd980a8fdbc18cd3eab2dfe1a5..2ee7e4765ba3163fb0d158e60b534b171da26c22 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -276,6 +276,7 @@  MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");
 #define FEC_ECR_MAGICEN         BIT(2)
 #define FEC_ECR_SLEEP           BIT(3)
 #define FEC_ECR_EN1588          BIT(4)
+#define FEC_ECR_SPEED           BIT(5)
 #define FEC_ECR_BYTESWP         BIT(8)
 /* FEC RCR bits definition */
 #define FEC_RCR_LOOP            BIT(0)
@@ -1160,7 +1161,7 @@  fec_restart(struct net_device *ndev)
 		/* 1G, 100M or 10M */
 		if (ndev->phydev) {
 			if (ndev->phydev->speed == SPEED_1000)
-				ecntl |= (1 << 5);
+				ecntl |= FEC_ECR_SPEED;
 			else if (ndev->phydev->speed == SPEED_100)
 				rcntl &= ~FEC_RCR_10BASET;
 			else