Re: [PATCH v2 2/3] net: stmmac: Add interconnect support

From: Andrew Lunn
Date: Fri Jun 28 2024 - 18:24:26 EST


> > Sorry, PTR_ERR().
> >
> > In general, a cast to a void * is a red flag and will get looked
> > at. It is generally wrong. So you might want to fixup where ever you
> > copied this from.
> >
> > Andrew

> the return type of stmmac_probe_config_dt is a pointer of type plat_stmmacenet_data,
> as PTR_ERR would give long integer value i don't think it would be ideal to
> return an integer value here, if casting plat->axi_icc_path to a void * doesn't look
> good, let me if the below solution is better or not?

> plat->axi_icc_path = devm_of_icc_get(&pdev->dev, "axi");
> if (IS_ERR(plat->axi_icc_path)) {
> rc = PTR_ERR(plat->axi_icc_path);
> ret = ERR_PTR(rc);

Don't you think this looks ugly?

If it looks ugly, it is probably wrong. You cannot be the first person
to find the return type of an error is wrong. So a quick bit of
searching found ERR_CAST().

Andrew