Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

i2c: xiic: switch to devres managed APIs

Simplify the error code paths by switching to devres managed helper
functions.

Signed-off-by: Abdurrahman Hussain <abdurrahman@nexthop.ai>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20260223-i2c-xiic-v12-1-b6c9ce4e4f3c@nexthop.ai

authored by

Abdurrahman Hussain and committed by
Andi Shyti
50c63491 40890b5f

+12 -18
+12 -18
drivers/i2c/busses/i2c-xiic.c
··· 1423 1423 1424 1424 static int xiic_i2c_probe(struct platform_device *pdev) 1425 1425 { 1426 + struct device *dev = &pdev->dev; 1426 1427 struct xiic_i2c *i2c; 1427 1428 struct xiic_i2c_platform_data *pdata; 1428 1429 const struct of_device_id *match; ··· 1462 1461 snprintf(i2c->adap.name, sizeof(i2c->adap.name), 1463 1462 DRIVER_NAME " %s", pdev->name); 1464 1463 1465 - mutex_init(&i2c->lock); 1464 + ret = devm_mutex_init(dev, &i2c->lock); 1465 + if (ret) 1466 + return ret; 1467 + 1466 1468 spin_lock_init(&i2c->atomic_lock); 1467 1469 1468 1470 i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL); ··· 1476 1472 i2c->dev = &pdev->dev; 1477 1473 pm_runtime_set_autosuspend_delay(i2c->dev, XIIC_PM_TIMEOUT); 1478 1474 pm_runtime_use_autosuspend(i2c->dev); 1479 - pm_runtime_set_active(i2c->dev); 1480 - pm_runtime_enable(i2c->dev); 1475 + ret = devm_pm_runtime_set_active_enabled(dev); 1476 + if (ret) 1477 + return ret; 1481 1478 1482 1479 /* SCL frequency configuration */ 1483 1480 i2c->input_clk = clk_get_rate(i2c->clk); ··· 1494 1489 1495 1490 if (ret < 0) { 1496 1491 dev_err_probe(&pdev->dev, ret, "Cannot claim IRQ\n"); 1497 - goto err_pm_disable; 1492 + return ret; 1498 1493 } 1499 1494 1500 1495 i2c->singlemaster = ··· 1513 1508 i2c->endianness = BIG; 1514 1509 1515 1510 ret = xiic_reinit(i2c); 1516 - if (ret < 0) { 1517 - dev_err_probe(&pdev->dev, ret, "Cannot xiic_reinit\n"); 1518 - goto err_pm_disable; 1519 - } 1511 + if (ret) 1512 + return dev_err_probe(dev, ret, "Cannot xiic_reinit\n"); 1520 1513 1521 1514 /* add i2c adapter to i2c tree */ 1522 1515 ret = i2c_add_adapter(&i2c->adap); 1523 1516 if (ret) { 1524 1517 xiic_deinit(i2c); 1525 - goto err_pm_disable; 1518 + return ret; 1526 1519 } 1527 1520 1528 1521 if (pdata) { ··· 1533 1530 (unsigned long)res->start, irq, i2c->i2c_clk); 1534 1531 1535 1532 return 0; 1536 - 1537 - err_pm_disable: 1538 - pm_runtime_disable(&pdev->dev); 1539 - pm_runtime_set_suspended(&pdev->dev); 1540 - 1541 - return ret; 1542 1533 } 1543 1534 1544 1535 static void xiic_i2c_remove(struct platform_device *pdev) ··· 1552 1555 xiic_deinit(i2c); 1553 1556 1554 1557 pm_runtime_put_sync(i2c->dev); 1555 - pm_runtime_disable(&pdev->dev); 1556 - pm_runtime_set_suspended(&pdev->dev); 1557 - pm_runtime_dont_use_autosuspend(&pdev->dev); 1558 1558 } 1559 1559 1560 1560 static const struct dev_pm_ops xiic_dev_pm_ops = {