RE: [PATCH 1/2] net: fec: Propagate PTP initialization errors

Wei Fang <[email protected]>
Newsgroups org.kernel.vger.netdev,dev.linux.lists.imx,org.kernel.vger.linux-kernel
Message-ID <GV2PR04MB1173976A5DA80B2816493C84788A32@GV2PR04MB11739.eurprd04.prod.outlook.com>
> -void fec_ptp_init(struct platform_device *pdev, int irq_idx)
> +int fec_ptp_init(struct platform_device *pdev, int irq_idx)
>  {
>  	struct net_device *ndev = platform_get_drvdata(pdev);
>  	struct fec_enet_private *fep = netdev_priv(ndev);
> @@ -779,26 +779,29 @@ void fec_ptp_init(struct platform_device *pdev, int
> irq_idx)
>  		      HRTIMER_MODE_REL);
> 
>  	irq = platform_get_irq_byname_optional(pdev, "pps");
> -	if (irq < 0)
> +	if (irq < 0) {
>  		irq = platform_get_irq_optional(pdev, irq_idx);
> -	/* Failure to get an irq is not fatal,
> -	 * only the PTP_CLOCK_PPS clock events should stop
> -	 */
> -	if (irq >= 0) {
> +		if (irq < 0 && irq != -ENXIO)
> +			return irq;
> +	}
> +
> +	if (irq > 0) {
>  		ret = devm_request_irq(&pdev->dev, irq, fec_pps_interrupt,
>  				       0, pdev->name, ndev);
>  		if (ret < 0)
> -			dev_warn(&pdev->dev, "request for pps irq failed(%d)\n",
> -				 ret);

Why remove the diagnostic log?

> +			return ret;
>  	}
> 
>  	fep->ptp_clock = ptp_clock_register(&fep->ptp_caps, &pdev->dev);
>  	if (IS_ERR(fep->ptp_clock)) {
>  		fep->ptp_clock = NULL;
>  		dev_err(&pdev->dev, "ptp_clock_register failed\n");
> +		return PTR_ERR(fep->ptp_clock);

fep->ptp_clock is set to NULL on the line immediately before
PTR_ERR(fep->ptp_clock) is evaluated, so PTR_ERR receives NULL rather
than the original ERR_PTR value.

>  	}
> 
>  	schedule_delayed_work(&fep->time_keep, HZ);
> +
> +	return 0;
>  }
> 
>  void fec_ptp_save_state(struct fec_enet_private *fep)
> --
> 2.43.0

Additionally, the second patch can be merged with this patch. There is no
need to use two separate patches.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.