public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andi Shyti <andi.shyti@kernel.org>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jean Delvare <jdelvare@suse.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 06/11] i2c: isch: Utilize temporary variable to hold device pointer
Date: Mon, 16 Sep 2024 15:01:33 +0300	[thread overview]
Message-ID: <20240916120237.1385982-7-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com>

Introduce a temporary variable to hold a device pointer.
It can be utilized in the ->probe() and save a bit of LoCs.
To make it consistent, rename currently used dev to pdev.

While at it, convert the only error message to dev_err_probe().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-isch.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c
index d752f822b52e..d0098b7139a0 100644
--- a/drivers/i2c/busses/i2c-isch.c
+++ b/drivers/i2c/busses/i2c-isch.c
@@ -270,27 +270,26 @@ static const struct i2c_algorithm smbus_algorithm = {
 	.functionality	= sch_func,
 };
 
-static int smbus_sch_probe(struct platform_device *dev)
+static int smbus_sch_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct sch_i2c *priv;
 	struct resource *res;
 
-	priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
-	res = platform_get_resource(dev, IORESOURCE_IO, 0);
+	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
 	if (!res)
 		return -EBUSY;
 
-	priv->smba = devm_ioport_map(&dev->dev, res->start, resource_size(res));
-	if (!priv->smba) {
-		dev_err(&dev->dev, "SMBus region %pR already in use!\n", res);
-		return -EBUSY;
-	}
+	priv->smba = devm_ioport_map(dev, res->start, resource_size(res));
+	if (!priv->smba)
+		return dev_err_probe(dev, -EBUSY, "SMBus region %pR already in use!\n", res);
 
 	/* set up the sysfs linkage to our parent device */
-	priv->adapter.dev.parent = &dev->dev;
+	priv->adapter.dev.parent = dev;
 	priv->adapter.owner = THIS_MODULE,
 	priv->adapter.class = I2C_CLASS_HWMON,
 	priv->adapter.algo = &smbus_algorithm,
@@ -298,7 +297,7 @@ static int smbus_sch_probe(struct platform_device *dev)
 	snprintf(priv->adapter.name, sizeof(priv->adapter.name),
 		 "SMBus SCH adapter at %04x", (unsigned short)res->start);
 
-	return devm_i2c_add_adapter(&dev->dev, &priv->adapter);
+	return devm_i2c_add_adapter(dev, &priv->adapter);
 }
 
 static struct platform_driver smbus_sch_driver = {
-- 
2.43.0.rc1.1336.g36b5255a03ac


  parent reply	other threads:[~2024-09-16 12:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-16 12:01 [PATCH v2 00/11] i2c: isch: Put the driver into shape Andy Shevchenko
2024-09-16 12:01 ` [PATCH v2 01/11] i2c: isch: Pass pointer to struct i2c_adapter down Andy Shevchenko
2024-09-16 12:01 ` [PATCH v2 02/11] i2c: isch: Use string_choices API instead of ternary operator Andy Shevchenko
2024-09-16 12:01 ` [PATCH v2 03/11] i2c: isch: Switch to memory mapped IO accessors Andy Shevchenko
2024-09-16 12:01 ` [PATCH v2 04/11] i2c: isch: Use custom private data structure Andy Shevchenko
2024-09-16 12:01 ` [PATCH v2 05/11] i2c: isch: switch i2c registration to devm functions Andy Shevchenko
2024-09-16 12:01 ` Andy Shevchenko [this message]
2024-09-16 12:01 ` [PATCH v2 07/11] i2c: isch: Use read_poll_timeout() Andy Shevchenko
2024-09-16 12:01 ` [PATCH v2 08/11] i2c: isch: Unify the name of the variable to hold an error code Andy Shevchenko
2024-09-16 12:01 ` [PATCH v2 09/11] i2c: isch: Don't use "proxy" headers Andy Shevchenko
2024-09-16 12:01 ` [PATCH v2 10/11] i2c: isch: Prefer to use octal permission Andy Shevchenko
2024-09-16 12:01 ` [PATCH v2 11/11] i2c: isch: Convert to kernel-doc Andy Shevchenko
2024-09-16 14:40 ` [PATCH v2 00/11] i2c: isch: Put the driver into shape Andi Shyti

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=20240916120237.1385982-7-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=andi.shyti@kernel.org \
    --cc=jdelvare@suse.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    /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