2023-12-29 14:52:56

by Ilpo Järvinen

[permalink] [raw]
Subject: [PATCH 1/1] net: mdio: mux-bcm-iproc: Use alignment helpers and SZ_4K

Instead of open coding, use IS_ALIGNED() and ALIGN_DOWN() when dealing
with alignment. Replace also literals with SZ_4K.

Signed-off-by: Ilpo Järvinen <[email protected]>
---
drivers/net/mdio/mdio-mux-bcm-iproc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mdio/mdio-mux-bcm-iproc.c b/drivers/net/mdio/mdio-mux-bcm-iproc.c
index a750bd4c77a0..1ce7d67ba72e 100644
--- a/drivers/net/mdio/mdio-mux-bcm-iproc.c
+++ b/drivers/net/mdio/mdio-mux-bcm-iproc.c
@@ -2,6 +2,7 @@
/*
* Copyright 2016 Broadcom
*/
+#include <linux/align.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
@@ -11,6 +12,7 @@
#include <linux/of_mdio.h>
#include <linux/phy.h>
#include <linux/platform_device.h>
+#include <linux/sizes.h>

#define MDIO_RATE_ADJ_EXT_OFFSET 0x000
#define MDIO_RATE_ADJ_INT_OFFSET 0x004
@@ -220,12 +222,12 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
md->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(md->base))
return PTR_ERR(md->base);
- if (res->start & 0xfff) {
+ if (!IS_ALIGNED(res->start, SZ_4K)) {
/* For backward compatibility in case the
* base address is specified with an offset.
*/
dev_info(&pdev->dev, "fix base address in dt-blob\n");
- res->start &= ~0xfff;
+ res->start = ALIGN_DOWN(res->start, SZ_4K);
res->end = res->start + MDIO_REG_ADDR_SPACE_SIZE - 1;
}

--
2.39.2



2024-01-03 17:31:46

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH 1/1] net: mdio: mux-bcm-iproc: Use alignment helpers and SZ_4K

On 12/29/23 06:52, Ilpo Järvinen wrote:
> Instead of open coding, use IS_ALIGNED() and ALIGN_DOWN() when dealing
> with alignment. Replace also literals with SZ_4K.
>
> Signed-off-by: Ilpo Järvinen <[email protected]>

Reviewed-by: Florian Fainelli <[email protected]>
--
Florian


Attachments:
smime.p7s (4.12 kB)
S/MIME Cryptographic Signature

2024-01-03 18:18:10

by Ray Jui

[permalink] [raw]
Subject: Re: [PATCH 1/1] net: mdio: mux-bcm-iproc: Use alignment helpers and SZ_4K

On Fri, Dec 29, 2023 at 6:53 AM Ilpo Järvinen <[email protected]>
wrote:

> Instead of open coding, use IS_ALIGNED() and ALIGN_DOWN() when dealing
> with alignment. Replace also literals with SZ_4K.
>
> Signed-off-by: Ilpo Järvinen <[email protected]>
> ---
> drivers/net/mdio/mdio-mux-bcm-iproc.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/mdio/mdio-mux-bcm-iproc.c
> b/drivers/net/mdio/mdio-mux-bcm-iproc.c
> index a750bd4c77a0..1ce7d67ba72e 100644
> --- a/drivers/net/mdio/mdio-mux-bcm-iproc.c
> +++ b/drivers/net/mdio/mdio-mux-bcm-iproc.c
> @@ -2,6 +2,7 @@
> /*
> * Copyright 2016 Broadcom
> */
> +#include <linux/align.h>
> #include <linux/clk.h>
> #include <linux/delay.h>
> #include <linux/device.h>
> @@ -11,6 +12,7 @@
> #include <linux/of_mdio.h>
> #include <linux/phy.h>
> #include <linux/platform_device.h>
> +#include <linux/sizes.h>
>
> #define MDIO_RATE_ADJ_EXT_OFFSET 0x000
> #define MDIO_RATE_ADJ_INT_OFFSET 0x004
> @@ -220,12 +222,12 @@ static int mdio_mux_iproc_probe(struct
> platform_device *pdev)
> md->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> if (IS_ERR(md->base))
> return PTR_ERR(md->base);
> - if (res->start & 0xfff) {
> + if (!IS_ALIGNED(res->start, SZ_4K)) {
> /* For backward compatibility in case the
> * base address is specified with an offset.
> */
> dev_info(&pdev->dev, "fix base address in dt-blob\n");
> - res->start &= ~0xfff;
> + res->start = ALIGN_DOWN(res->start, SZ_4K);
> res->end = res->start + MDIO_REG_ADDR_SPACE_SIZE - 1;
> }
>
> --
> 2.39.2
>

Acked-by: Ray Jui <[email protected]>

Thanks.


Attachments:
smime.p7s (4.10 kB)
S/MIME Cryptographic Signature

2024-01-04 01:01:42

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH 1/1] net: mdio: mux-bcm-iproc: Use alignment helpers and SZ_4K

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <[email protected]>:

On Fri, 29 Dec 2023 16:52:32 +0200 you wrote:
> Instead of open coding, use IS_ALIGNED() and ALIGN_DOWN() when dealing
> with alignment. Replace also literals with SZ_4K.
>
> Signed-off-by: Ilpo Järvinen <[email protected]>
> ---
> drivers/net/mdio/mdio-mux-bcm-iproc.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)

Here is the summary with links:
- [1/1] net: mdio: mux-bcm-iproc: Use alignment helpers and SZ_4K
https://git.kernel.org/netdev/net-next/c/73b2e2e3fe26

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html