Re: [PATCH net 1/1] ptp: clockmatrix: support 32-bit address space

From: Simon Horman
Date: Wed Sep 06 2023 - 13:40:18 EST


On Wed, Sep 06, 2023 at 12:54:05PM -0400, Min Li wrote:
> From: Min Li <min.li.xe@xxxxxxxxxxx>

Hi Min Li,

A patch description should go here, describing the motivation for the
change.

It does seem to me that this is an enhancement rather than a bug fix.
And as such is more appropriate for 'net-next' rather than 'net'.
i.e. Subject: [PATCH net-next] ...

If the patch is for net-next then it will need to be resubmitted,
as per the form letter below. If, on the other hand it is for net,
a Fixes tag is most likely warranted.

## Form letter - net-next-closed

The merge window for v6.6 has begun and therefore net-next is closed
for new drivers, features, code refactoring and optimizations.
We are currently accepting bug fixes only.

Please repost when net-next reopens after Sept 11th.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle

>
> Signed-off-by: Min Li <min.li.xe@xxxxxxxxxxx>
> ---
> drivers/ptp/ptp_clockmatrix.c | 72 ++--
> drivers/ptp/ptp_clockmatrix.h | 33 +-
> include/linux/mfd/idt8a340_reg.h | 542 ++++++++++++++++---------------
> 3 files changed, 340 insertions(+), 307 deletions(-)
>
> diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
> index f6f9d4adce04..875841892842 100644
> --- a/drivers/ptp/ptp_clockmatrix.c
> +++ b/drivers/ptp/ptp_clockmatrix.c
> @@ -41,7 +41,7 @@ module_param(firmware, charp, 0);
> static int _idtcm_adjfine(struct idtcm_channel *channel, long scaled_ppm);
>
> static inline int idtcm_read(struct idtcm *idtcm,
> - u16 module,
> + u32 module,
> u16 regaddr,
> u8 *buf,
> u16 count)
> @@ -50,7 +50,7 @@ static inline int idtcm_read(struct idtcm *idtcm,
> }
>
> static inline int idtcm_write(struct idtcm *idtcm,
> - u16 module,
> + u32 module,
> u16 regaddr,
> u8 *buf,
> u16 count)
> @@ -62,7 +62,8 @@ static int contains_full_configuration(struct idtcm *idtcm,
> const struct firmware *fw)
> {
> struct idtcm_fwrc *rec = (struct idtcm_fwrc *)fw->data;
> - u16 scratch = IDTCM_FW_REG(idtcm->fw_ver, V520, SCRATCH);
> + u16 scratch = SCSR_ADDR(IDTCM_FW_REG(idtcm->fw_ver, V520, SCRATCH));

I think you also need a similar change in idtcm_load_firmware().

diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
index 875841892842..69c170133a25 100644
--- a/drivers/ptp/ptp_clockmatrix.c
+++ b/drivers/ptp/ptp_clockmatrix.c
@@ -1254,7 +1254,7 @@ static void display_pll_and_masks(struct idtcm *idtcm)
static int idtcm_load_firmware(struct idtcm *idtcm,
struct device *dev)
{
- u16 scratch = IDTCM_FW_REG(idtcm->fw_ver, V520, SCRATCH);
+ u16 scratch = SCSR_ADDR(IDTCM_FW_REG(idtcm->fw_ver, V520, SCRATCH));
char fname[128] = FW_FILENAME;
const struct firmware *fw;
struct idtcm_fwrc *rec;

As flagged by Smatch and clang-16 W=1.

> + u16 gpio_control = SCSR_ADDR(GPIO_USER_CONTROL);
> s32 full_count;
> s32 count = 0;
> u16 regaddr;

...

--
pw-bot: defer