diff mbox series

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

Message ID 20231229145232.6163-1-ilpo.jarvinen@linux.intel.com (mailing list archive)
State Accepted
Commit 73b2e2e3fe26f97010444e29536b3e815bbc57da
Delegated to: Netdev Maintainers
Headers show
Series [1/1] net: mdio: mux-bcm-iproc: Use alignment helpers and SZ_4K | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1113 this patch: 1113
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 1140 this patch: 1140
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1140 this patch: 1140
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ilpo Järvinen Dec. 29, 2023, 2:52 p.m. UTC
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 <ilpo.jarvinen@linux.intel.com>
---
 drivers/net/mdio/mdio-mux-bcm-iproc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Florian Fainelli Jan. 3, 2024, 5:31 p.m. UTC | #1
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 <ilpo.jarvinen@linux.intel.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Ray Jui Jan. 3, 2024, 6:17 p.m. UTC | #2
On Fri, Dec 29, 2023 at 6:53 AM Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
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 <ilpo.jarvinen@linux.intel.com>
> ---
>  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 <ray.jui@broadcom.com>

Thanks.
patchwork-bot+netdevbpf@kernel.org Jan. 4, 2024, 1 a.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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 <ilpo.jarvinen@linux.intel.com>
> ---
>  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!
diff mbox series

Patch

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;
 	}