Re: [PATCH net-next 1/3] net: mdio: mdio-bcm-unimac: Manage clock around I/O accesses

From: kernel test robot
Date: Sat Feb 17 2024 - 05:45:04 EST


Hi Florian,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url: https://github.com/intel-lab-lkp/linux/commits/Florian-Fainelli/net-mdio-mdio-bcm-unimac-Manage-clock-around-I-O-accesses/20240217-024738
base: net-next/main
patch link: https://lore.kernel.org/r/20240216184237.259954-2-florian.fainelli%40broadcom.com
patch subject: [PATCH net-next 1/3] net: mdio: mdio-bcm-unimac: Manage clock around I/O accesses
config: arm-defconfig (https://download.01.org/0day-ci/archive/20240217/202402171801.J560K7Fo-lkp@xxxxxxxxx/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240217/202402171801.J560K7Fo-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402171801.J560K7Fo-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> drivers/net/mdio/mdio-bcm-unimac.c:286:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (IS_ERR(priv->clk))
^~~~~~~~~~~~~~~~~
drivers/net/mdio/mdio-bcm-unimac.c:313:9: note: uninitialized use occurs here
return ret;
^~~
drivers/net/mdio/mdio-bcm-unimac.c:286:2: note: remove the 'if' if its condition is always false
if (IS_ERR(priv->clk))
^~~~~~~~~~~~~~~~~~~~~~
drivers/net/mdio/mdio-bcm-unimac.c:243:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
1 warning generated.


vim +286 drivers/net/mdio/mdio-bcm-unimac.c

235
236 static int unimac_mdio_probe(struct platform_device *pdev)
237 {
238 struct unimac_mdio_pdata *pdata = pdev->dev.platform_data;
239 struct unimac_mdio_priv *priv;
240 struct device_node *np;
241 struct mii_bus *bus;
242 struct resource *r;
243 int ret;
244
245 np = pdev->dev.of_node;
246
247 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
248 if (!priv)
249 return -ENOMEM;
250
251 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
252 if (!r)
253 return -EINVAL;
254
255 /* Just ioremap, as this MDIO block is usually integrated into an
256 * Ethernet MAC controller register range
257 */
258 priv->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
259 if (!priv->base) {
260 dev_err(&pdev->dev, "failed to remap register\n");
261 return -ENOMEM;
262 }
263
264 if (of_property_read_u32(np, "clock-frequency", &priv->clk_freq))
265 priv->clk_freq = 0;
266
267 priv->mii_bus = mdiobus_alloc();
268 if (!priv->mii_bus)
269 return -ENOMEM;
270
271 bus = priv->mii_bus;
272 bus->priv = priv;
273 if (pdata) {
274 bus->name = pdata->bus_name;
275 priv->wait_func = pdata->wait_func;
276 priv->wait_func_data = pdata->wait_func_data;
277 bus->phy_mask = ~pdata->phy_mask;
278 priv->clk = pdata->clk;
279 } else {
280 bus->name = "unimac MII bus";
281 priv->wait_func_data = priv;
282 priv->wait_func = unimac_mdio_poll;
283 priv->clk = devm_clk_get_optional(&pdev->dev, NULL);
284 }
285
> 286 if (IS_ERR(priv->clk))
287 goto out_mdio_free;
288
289 bus->parent = &pdev->dev;
290 bus->read = unimac_mdio_read;
291 bus->write = unimac_mdio_write;
292 bus->reset = unimac_mdio_reset;
293 snprintf(bus->id, MII_BUS_ID_SIZE, "%s-%d", pdev->name, pdev->id);
294
295 ret = unimac_mdio_clk_set(priv);
296 if (ret)
297 goto out_mdio_free;
298
299 ret = of_mdiobus_register(bus, np);
300 if (ret) {
301 dev_err(&pdev->dev, "MDIO bus registration failed\n");
302 goto out_mdio_free;
303 }
304
305 platform_set_drvdata(pdev, priv);
306
307 dev_info(&pdev->dev, "Broadcom UniMAC MDIO bus\n");
308
309 return 0;
310
311 out_mdio_free:
312 mdiobus_free(bus);
313 return ret;
314 }
315

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki