diff mbox series

[v2,net-next,1/1] ptp_ocp: use bits.h macros for all masks

Message ID 20210817122454.50616-1-andriy.shevchenko@linux.intel.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [v2,net-next,1/1] ptp_ocp: use bits.h macros for all masks | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 3 of 3 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 0 this patch: 1
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_allmodconfig_warn fail Errors and warnings before: 0 this patch: 1
netdev/header_inline success Link

Commit Message

Andy Shevchenko Aug. 17, 2021, 12:24 p.m. UTC
Currently we are using BIT(), but GENMASK(). Make use of the latter one
as well (far less error-prone, far more concise).

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/ptp/ptp_ocp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski Aug. 17, 2021, 1:48 p.m. UTC | #1
On Tue, 17 Aug 2021 15:24:54 +0300 Andy Shevchenko wrote:
> Currently we are using BIT(), but GENMASK(). Make use of the latter one
> as well (far less error-prone, far more concise).
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/ptp/ptp_ocp.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index caf9b37c5eb1..922f92637db8 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -1,6 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0-only
>  /* Copyright (c) 2020 Facebook */
>  
> +#include <linux/bits.h>
>  #include <linux/err.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> @@ -84,10 +85,10 @@ struct tod_reg {
>  #define TOD_CTRL_DISABLE_FMT_A	BIT(17)
>  #define TOD_CTRL_DISABLE_FMT_B	BIT(16)
>  #define TOD_CTRL_ENABLE		BIT(0)
> -#define TOD_CTRL_GNSS_MASK	((1U << 4) - 1)
> +#define TOD_CTRL_GNSS_MASK	GENMASK(3, 0)
>  #define TOD_CTRL_GNSS_SHIFT	24
>  
> -#define TOD_STATUS_UTC_MASK	0xff
> +#define TOD_STATUS_UTC_MASK	GENMASK(7, 0)
>  #define TOD_STATUS_UTC_VALID	BIT(8)
>  #define TOD_STATUS_LEAP_VALID	BIT(16)

GENMASK is unsigned long:

drivers/ptp/ptp_ocp.c: In function ‘ptp_ocp_tod_info’:
drivers/ptp/ptp_ocp.c:648:27: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long unsigned int’ [-Wformat=]
  648 |  dev_info(&bp->pdev->dev, "utc_offset: %d  valid:%d  leap_valid:%d\n",
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:19:22: note: in definition of macro ‘dev_fmt’
   19 | #define dev_fmt(fmt) fmt
      |                      ^~~
drivers/ptp/ptp_ocp.c:648:2: note: in expansion of macro ‘dev_info’
  648 |  dev_info(&bp->pdev->dev, "utc_offset: %d  valid:%d  leap_valid:%d\n",
      |  ^~~~~~~~
drivers/ptp/ptp_ocp.c:648:41: note: format string is defined here
  648 |  dev_info(&bp->pdev->dev, "utc_offset: %d  valid:%d  leap_valid:%d\n",
      |                                        ~^
      |                                         |
      |                                         int
      |                                        %ld
Andy Shevchenko Aug. 17, 2021, 4:46 p.m. UTC | #2
On Tue, Aug 17, 2021 at 06:48:14AM -0700, Jakub Kicinski wrote:
> On Tue, 17 Aug 2021 15:24:54 +0300 Andy Shevchenko wrote:
> > Currently we are using BIT(), but GENMASK(). Make use of the latter one
> > as well (far less error-prone, far more concise).

> GENMASK is unsigned long:

Ouch, thanks!
diff mbox series

Patch

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index caf9b37c5eb1..922f92637db8 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1,6 +1,7 @@ 
 // SPDX-License-Identifier: GPL-2.0-only
 /* Copyright (c) 2020 Facebook */
 
+#include <linux/bits.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -84,10 +85,10 @@  struct tod_reg {
 #define TOD_CTRL_DISABLE_FMT_A	BIT(17)
 #define TOD_CTRL_DISABLE_FMT_B	BIT(16)
 #define TOD_CTRL_ENABLE		BIT(0)
-#define TOD_CTRL_GNSS_MASK	((1U << 4) - 1)
+#define TOD_CTRL_GNSS_MASK	GENMASK(3, 0)
 #define TOD_CTRL_GNSS_SHIFT	24
 
-#define TOD_STATUS_UTC_MASK	0xff
+#define TOD_STATUS_UTC_MASK	GENMASK(7, 0)
 #define TOD_STATUS_UTC_VALID	BIT(8)
 #define TOD_STATUS_LEAP_VALID	BIT(16)