Message ID | 20220608120358.81147-3-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | ptp_ocp: set of small cleanups | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/cc_maintainers | success | CCed 3 of 3 maintainers |
netdev/build_clang | success | Errors and warnings before: 0 this patch: 0 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
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: 0 this patch: 0 |
netdev/checkpatch | warning | CHECK: Alignment should match open parenthesis |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On 08.06.2022 13:03, 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> LGTM Acked-by: Vadim Fedorenko <vfedorenko@novek.ru> > --- > drivers/ptp/ptp_ocp.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c > index 17930762fde9..926add7be9a2 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> > @@ -88,10 +89,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_ANNOUNCE BIT(12) > #define TOD_STATUS_LEAP_VALID BIT(16) > @@ -205,7 +206,7 @@ struct frequency_reg { > #define FREQ_STATUS_VALID BIT(31) > #define FREQ_STATUS_ERROR BIT(30) > #define FREQ_STATUS_OVERRUN BIT(29) > -#define FREQ_STATUS_MASK (BIT(24) - 1) > +#define FREQ_STATUS_MASK GENMASK(23, 0) > > struct ptp_ocp_flash_info { > const char *name; > @@ -674,9 +675,9 @@ static const struct ocp_selector ptp_ocp_clock[] = { > { } > }; > > +#define SMA_DISABLE BIT(16) > #define SMA_ENABLE BIT(15) > -#define SMA_SELECT_MASK ((1U << 15) - 1) > -#define SMA_DISABLE 0x10000 > +#define SMA_SELECT_MASK GENMASK(14, 0) > > static const struct ocp_selector ptp_ocp_sma_in[] = { > { .name = "10Mhz", .value = 0x0000 }, > @@ -3440,7 +3441,7 @@ ptp_ocp_tod_status_show(struct seq_file *s, void *data) > > val = ioread32(&bp->tod->utc_status); > seq_printf(s, "UTC status register: 0x%08X\n", val); > - seq_printf(s, "UTC offset: %d valid:%d\n", > + seq_printf(s, "UTC offset: %ld valid:%d\n", > val & TOD_STATUS_UTC_MASK, val & TOD_STATUS_UTC_VALID ? 1 : 0); > seq_printf(s, "Leap second info valid:%d, Leap second announce %d\n", > val & TOD_STATUS_LEAP_VALID ? 1 : 0,
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c index 17930762fde9..926add7be9a2 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> @@ -88,10 +89,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_ANNOUNCE BIT(12) #define TOD_STATUS_LEAP_VALID BIT(16) @@ -205,7 +206,7 @@ struct frequency_reg { #define FREQ_STATUS_VALID BIT(31) #define FREQ_STATUS_ERROR BIT(30) #define FREQ_STATUS_OVERRUN BIT(29) -#define FREQ_STATUS_MASK (BIT(24) - 1) +#define FREQ_STATUS_MASK GENMASK(23, 0) struct ptp_ocp_flash_info { const char *name; @@ -674,9 +675,9 @@ static const struct ocp_selector ptp_ocp_clock[] = { { } }; +#define SMA_DISABLE BIT(16) #define SMA_ENABLE BIT(15) -#define SMA_SELECT_MASK ((1U << 15) - 1) -#define SMA_DISABLE 0x10000 +#define SMA_SELECT_MASK GENMASK(14, 0) static const struct ocp_selector ptp_ocp_sma_in[] = { { .name = "10Mhz", .value = 0x0000 }, @@ -3440,7 +3441,7 @@ ptp_ocp_tod_status_show(struct seq_file *s, void *data) val = ioread32(&bp->tod->utc_status); seq_printf(s, "UTC status register: 0x%08X\n", val); - seq_printf(s, "UTC offset: %d valid:%d\n", + seq_printf(s, "UTC offset: %ld valid:%d\n", val & TOD_STATUS_UTC_MASK, val & TOD_STATUS_UTC_VALID ? 1 : 0); seq_printf(s, "Leap second info valid:%d, Leap second announce %d\n", val & TOD_STATUS_LEAP_VALID ? 1 : 0,
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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)