Skip to content

Commit

Permalink
net: ethernet: renesas: rcar_gen4_ptp: Fail on unknown register layout
Browse files Browse the repository at this point in the history
Instead of printing a warning and proceeding with an unknown register
layout return an error. The only call site is already prepared to
propagate the error.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Niklas Söderlund authored and Paolo Abeni committed Nov 23, 2023
1 parent d73dcff commit 9f39957
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions drivers/net/ethernet/renesas/rcar_gen4_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,30 @@ static struct ptp_clock_info rcar_gen4_ptp_info = {
.enable = rcar_gen4_ptp_enable,
};

static void rcar_gen4_ptp_set_offs(struct rcar_gen4_ptp_private *ptp_priv,
enum rcar_gen4_ptp_reg_layout layout)
static int rcar_gen4_ptp_set_offs(struct rcar_gen4_ptp_private *ptp_priv,
enum rcar_gen4_ptp_reg_layout layout)
{
WARN_ON(layout != RCAR_GEN4_PTP_REG_LAYOUT_S4);
if (layout != RCAR_GEN4_PTP_REG_LAYOUT_S4)
return -EINVAL;

ptp_priv->offs = &s4_offs;

return 0;
}

int rcar_gen4_ptp_register(struct rcar_gen4_ptp_private *ptp_priv,
enum rcar_gen4_ptp_reg_layout layout, u32 clock)
{
int ret;

if (ptp_priv->initialized)
return 0;

spin_lock_init(&ptp_priv->lock);

rcar_gen4_ptp_set_offs(ptp_priv, layout);
ret = rcar_gen4_ptp_set_offs(ptp_priv, layout);
if (ret)
return ret;

ptp_priv->default_addend = clock;
iowrite32(ptp_priv->default_addend, ptp_priv->addr + ptp_priv->offs->increment);
Expand Down

0 comments on commit 9f39957

Please sign in to comment.