From: Rosen Penev <rosenp@gmail.com>
To: linux-i2c@vger.kernel.org
Cc: Andi Shyti <andi.shyti@kernel.org>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] i2c: ibm: use devm to handle resources
Date: Thu, 19 Feb 2026 18:37:13 -0800 [thread overview]
Message-ID: <20260220023713.42966-1-rosenp@gmail.com> (raw)
Simplifies the driver slightly.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/i2c/busses/i2c-ibm_iic.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 6bf45d752ff9..87967088d59d 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -687,18 +687,15 @@ static int iic_probe(struct platform_device *ofdev)
const u32 *freq;
int ret;
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ dev = devm_kzalloc(&ofdev->dev, sizeof(*dev), GFP_KERNEL);
if (!dev)
return -ENOMEM;
platform_set_drvdata(ofdev, dev);
- dev->vaddr = of_iomap(np, 0);
- if (dev->vaddr == NULL) {
- dev_err(&ofdev->dev, "failed to iomap device\n");
- ret = -ENXIO;
- goto error_cleanup;
- }
+ dev->vaddr = devm_of_iomap(&ofdev->dev, np, 0, NULL);
+ if (dev->vaddr == NULL)
+ return dev_err_probe(&ofdev->dev, -ENXIO, "failed to iomap device\n");
init_waitqueue_head(&dev->wq);
@@ -736,8 +733,8 @@ static int iic_probe(struct platform_device *ofdev)
adap->algo = &iic_algo;
adap->timeout = HZ;
- ret = i2c_add_adapter(adap);
- if (ret < 0)
+ ret = devm_i2c_add_adapter(&ofdev->dev, adap);
+ if (ret < 0)
goto error_cleanup;
dev_info(&ofdev->dev, "using %s mode\n",
@@ -751,10 +748,6 @@ static int iic_probe(struct platform_device *ofdev)
free_irq(dev->irq, dev);
}
- if (dev->vaddr)
- iounmap(dev->vaddr);
-
- kfree(dev);
return ret;
}
@@ -765,15 +758,10 @@ static void iic_remove(struct platform_device *ofdev)
{
struct ibm_iic_private *dev = platform_get_drvdata(ofdev);
- i2c_del_adapter(&dev->adap);
-
if (dev->irq) {
iic_interrupt_mode(dev, 0);
free_irq(dev->irq, dev);
}
-
- iounmap(dev->vaddr);
- kfree(dev);
}
static const struct of_device_id ibm_iic_match[] = {
--
2.53.0
reply other threads:[~2026-02-20 2:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260220023713.42966-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=andi.shyti@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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