mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Horatiu Vultur <horatiu.vultur@microchip.com>
To: "Radu Pirea (NXP OSS)" <radu-nicolae.pirea@oss.nxp.com>
Cc: <andrew@lunn.ch>, <hkallweit1@gmail.com>, <linux@armlinux.org.uk>,
	<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <richardcochran@gmail.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<sebastian.tobuschat@nxp.com>
Subject: Re: [PATCH net-next v1 05/14] net: phy: nxp-c45-tja11xx: prepare the ground for TJA1120
Date: Mon, 19 Jun 2023 09:53:25 +0200	[thread overview]
Message-ID: <20230619075325.ywg4jv6h2hifqjx4@soft-dev3-1> (raw)
In-Reply-To: <20230616135323.98215-6-radu-nicolae.pirea@oss.nxp.com>

The 06/16/2023 16:53, Radu Pirea (NXP OSS) wrote:

Hi Radu,

> 
> 
> -struct nxp_c45_phy_stats {
> -       const char      *name;
> -       u8              mmd;
> -       u16             reg;
> -       u8              off;
> -       u16             mask;
> -};
> +static inline

It is recommended not to use inline inside .c files.

> +const struct nxp_c45_phy_data *nxp_c45_get_data(struct phy_device *phydev)
> +{
> +       return phydev->drv->driver_data;
> +}
> +
> +static inline
> +const struct nxp_c45_regmap *nxp_c45_get_regmap(struct phy_device *phydev)
> +{
> +       const struct nxp_c45_phy_data *phy_data = nxp_c45_get_data(phydev);
> +
> +       return phy_data ? phy_data->regmap : NULL;

From what I can see nxp_c45_get_data(phydev) can't return a NULL pointer
so then I don't think you need the above check. And then maybe you can
remove more of the checks in the code where you check for data to not be
NULL.
The reason why I say nxp_c45_get_data(phydev) can't return a NULL is
because few lines bellow you have:

.driver_data            = &tja1103_phy_data,

...

> +}
> @@ -806,6 +835,7 @@ static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts,
>         struct nxp_c45_phy *priv = container_of(mii_ts, struct nxp_c45_phy,
>                                                 mii_ts);
>         struct phy_device *phydev = priv->phydev;
> +       const struct nxp_c45_phy_data *data;
>         struct hwtstamp_config cfg;
> 
>         if (copy_from_user(&cfg, ifreq->ifr_data, sizeof(cfg)))
> @@ -814,6 +844,7 @@ static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts,
>         if (cfg.tx_type < 0 || cfg.tx_type > HWTSTAMP_TX_ON)
>                 return -ERANGE;
> 
> +       data = nxp_c45_get_data(phydev);
>         priv->hwts_tx = cfg.tx_type;
> 
>         switch (cfg.rx_filter) {
> @@ -831,27 +862,26 @@ static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts,
>         }
> 
>         if (priv->hwts_rx || priv->hwts_tx) {
> -               phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_EVENT_MSG_FILT,
> +               phy_write_mmd(phydev, MDIO_MMD_VEND1,
> +                             data->regmap->vend1_event_msg_filt,
>                               EVENT_MSG_FILT_ALL);
> -               phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
> -                                  VEND1_PORT_PTP_CONTROL,
> -                                  PORT_PTP_CONTROL_BYPASS);
> +               if (data && data->ptp_enable)

Like here

> +                       data->ptp_enable(phydev, true);
>         } else {
> -               phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_EVENT_MSG_FILT,
> +               phy_write_mmd(phydev, MDIO_MMD_VEND1,
> +                             data->regmap->vend1_event_msg_filt,
>                               EVENT_MSG_FILT_NONE);
> -               phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PORT_PTP_CONTROL,
> -                                PORT_PTP_CONTROL_BYPASS);
> +               if (data && data->ptp_enable)

And here and few other places bellow:

> +                       data->ptp_enable(phydev, false);
>         }
> 
>         if (nxp_c45_poll_txts(priv->phydev))
>                 goto nxp_c45_no_ptp_irq;
> 
>         if (priv->hwts_tx)
> -               phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
> -                                VEND1_PTP_IRQ_EN, PTP_IRQ_EGR_TS);
> +               nxp_c45_set_reg_field(phydev, &data->regmap->irq_egr_ts_en);
>         else
> -               phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
> -                                  VEND1_PTP_IRQ_EN, PTP_IRQ_EGR_TS);
> +               nxp_c45_clear_reg_field(phydev, &data->regmap->irq_egr_ts_en);
> 

...

> 
> +static const struct nxp_c45_phy_data tja1103_phy_data = {
> +       .regmap = &tja1103_regmap,
> +       .stats = tja1103_hw_stats,
> +       .n_stats = ARRAY_SIZE(tja1103_hw_stats),
> +       .ptp_clk_period = PTP_CLK_PERIOD_100BT1,
> +       .counters_enable = tja1103_counters_enable,
> +       .ptp_init = tja1103_ptp_init,
> +       .ptp_enable = tja1103_ptp_enable,
> +};
> +
>  static struct phy_driver nxp_c45_driver[] = {
>         {
>                 PHY_ID_MATCH_MODEL(PHY_ID_TJA_1103),
>                 .name                   = "NXP C45 TJA1103",
>                 .features               = PHY_BASIC_T1_FEATURES,
> +               .driver_data            = &tja1103_phy_data,
>                 .probe                  = nxp_c45_probe,
>                 .soft_reset             = nxp_c45_soft_reset,
>                 .config_aneg            = genphy_c45_config_aneg,
> --
> 2.34.1
> 
> 

-- 
/Horatiu

  parent reply	other threads:[~2023-06-19  7:53 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-16 13:53 [PATCH net-next v1 00/14] Add TJA1120 support Radu Pirea (NXP OSS)
2023-06-16 13:53 ` [PATCH net-next v1 01/14] net: phy: nxp-c45-tja11xx: fix the PTP interrupt enablig/disabling Radu Pirea (NXP OSS)
2023-06-16 20:36   ` Andrew Lunn
2023-06-19  8:42     ` Radu Pirea (OSS)
2023-06-16 13:53 ` [PATCH net-next v1 02/14] net: phy: nxp-c45-tja11xx: use phylib master/slave implementation Radu Pirea (NXP OSS)
2023-06-16 20:37   ` Andrew Lunn
2023-06-16 13:53 ` [PATCH net-next v1 03/14] net: phy: nxp-c45-tja11xx: remove RX BIST frame counters Radu Pirea (NXP OSS)
2023-06-16 20:39   ` Andrew Lunn
2023-06-22 12:21     ` Radu Pirea (OSS)
2023-06-16 13:53 ` [PATCH net-next v1 04/14] net: phy: nxp-c45-tja11xx: add *_reg_field functions Radu Pirea (NXP OSS)
2023-06-16 20:42   ` Andrew Lunn
2023-06-16 13:53 ` [PATCH net-next v1 05/14] net: phy: nxp-c45-tja11xx: prepare the ground for TJA1120 Radu Pirea (NXP OSS)
2023-06-16 19:35   ` Simon Horman
2023-06-19  7:53   ` Horatiu Vultur [this message]
2023-06-16 13:53 ` [PATCH net-next v1 06/14] net: phy: add 1000baseT1 to phy_basic_t1_features Radu Pirea (NXP OSS)
2023-06-16 20:49   ` Andrew Lunn
2023-06-19 11:01     ` Radu Pirea (OSS)
2023-06-16 13:53 ` [PATCH net-next v1 07/14] net: phy: nxp-c45-tja11xx: add TJA1120 support Radu Pirea (NXP OSS)
2023-06-16 13:53 ` [PATCH net-next v1 08/14] net: phy: nxp-c45-tja11xx: enable LTC sampling on both ext_ts edges Radu Pirea (NXP OSS)
2023-06-19  8:10   ` Horatiu Vultur
2023-06-19  8:36     ` Radu Pirea (OSS)
2023-06-16 13:53 ` [PATCH net-next v1 09/14] net: phy: nxp-c45-tja11xx: read egress ts on TJA1120 Radu Pirea (NXP OSS)
2023-06-16 13:53 ` [PATCH net-next v1 10/14] net: phy: nxp-c45-tja11xx: handle FUSA irq Radu Pirea (NXP OSS)
2023-06-16 20:55   ` Andrew Lunn
2023-06-19  6:31     ` Radu Pirea (OSS)
2023-06-16 13:53 ` [PATCH net-next v1 11/14] net: phy: nxp-c45-tja11xx: run cable test with the PHY in test mode Radu Pirea (NXP OSS)
2023-06-16 13:53 ` [PATCH net-next v1 12/14] net: phy: nxp-c45-tja11xx: read ext trig ts TJA1120 Radu Pirea (NXP OSS)
2023-06-19  8:49   ` Horatiu Vultur
2023-06-19 10:07     ` Radu Pirea (OSS)
2023-06-19 10:48       ` Horatiu Vultur
2023-06-20 14:31         ` Radu Pirea (OSS)
2023-06-16 13:53 ` [PATCH net-next v1 13/14] net: phy: nxp-c45-tja11xx: reset PCS if the link goes down Radu Pirea (NXP OSS)
2023-06-16 21:00   ` Andrew Lunn
2023-06-19  6:17     ` Radu Pirea (OSS)
2023-06-16 13:53 ` [PATCH net-next v1 14/14] net: phy: nxp-c45-tja11xx: timestamp reading workaround for TJA1120 Radu Pirea (NXP OSS)
2023-06-19  8:58   ` Horatiu Vultur
2023-06-19  9:46     ` Radu Pirea (OSS)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230619075325.ywg4jv6h2hifqjx4@soft-dev3-1 \
    --to=horatiu.vultur@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=radu-nicolae.pirea@oss.nxp.com \
    --cc=richardcochran@gmail.com \
    --cc=sebastian.tobuschat@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®