All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-i2c@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Peter Rosin <peda@axentia.se>,
	Stefan Lengfeld <contact@stefanchrist.eu>,
	linux-omap@vger.kernel.org, linux-tegra@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH 08/12] i2c: ocores: refactor setup for polling
Date: Wed,  3 Apr 2019 14:40:15 +0200	[thread overview]
Message-ID: <20190403124019.8947-9-wsa+renesas@sang-engineering.com> (raw)
In-Reply-To: <20190403124019.8947-1-wsa+renesas@sang-engineering.com>

By properly setting up the algorithm at probe time, we can skip the
check at every transfer. This allows us to get rid of the flags
completely.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Andrew Lunn <andrew@lunn.ch>
---
 drivers/i2c/busses/i2c-ocores.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 4e1a077fb688..1b99f467aae0 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -26,8 +26,6 @@
 #include <linux/spinlock.h>
 #include <linux/jiffies.h>
 
-#define OCORES_FLAG_POLL BIT(0)
-
 /*
  * 'process_lock' exists because ocores_process() and ocores_process_timeout()
  * can't run in parallel.
@@ -37,7 +35,6 @@ struct ocores_i2c {
 	int iobase;
 	u32 reg_shift;
 	u32 reg_io_width;
-	unsigned long flags;
 	wait_queue_head_t wait;
 	struct i2c_adapter adap;
 	struct i2c_msg *msg;
@@ -403,11 +400,7 @@ static int ocores_xfer_polling(struct i2c_adapter *adap,
 static int ocores_xfer(struct i2c_adapter *adap,
 		       struct i2c_msg *msgs, int num)
 {
-	struct ocores_i2c *i2c = i2c_get_adapdata(adap);
-
-	if (i2c->flags & OCORES_FLAG_POLL)
-		return ocores_xfer_polling(adap, msgs, num);
-	return ocores_xfer_core(i2c, msgs, num, false);
+	return ocores_xfer_core(i2c_get_adapdata(adap), msgs, num, false);
 }
 
 static int ocores_init(struct device *dev, struct ocores_i2c *i2c)
@@ -447,7 +440,7 @@ static u32 ocores_func(struct i2c_adapter *adap)
 	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
-static const struct i2c_algorithm ocores_algorithm = {
+static struct i2c_algorithm ocores_algorithm = {
 	.master_xfer = ocores_xfer,
 	.functionality = ocores_func,
 };
@@ -673,13 +666,13 @@ static int ocores_i2c_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq == -ENXIO) {
-		i2c->flags |= OCORES_FLAG_POLL;
+		ocores_algorithm.master_xfer = ocores_xfer_polling;
 	} else {
 		if (irq < 0)
 			return irq;
 	}
 
-	if (!(i2c->flags & OCORES_FLAG_POLL)) {
+	if (ocores_algorithm.master_xfer != ocores_xfer_polling) {
 		ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0,
 				       pdev->name, i2c);
 		if (ret) {
-- 
2.11.0

WARNING: multiple messages have this Message-ID (diff)
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-i2c@vger.kernel.org
Cc: Andrew Lunn <andrew@lunn.ch>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	linux-tegra@vger.kernel.org,
	Stefan Lengfeld <contact@stefanchrist.eu>,
	linux-omap@vger.kernel.org, Peter Rosin <peda@axentia.se>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 08/12] i2c: ocores: refactor setup for polling
Date: Wed,  3 Apr 2019 14:40:15 +0200	[thread overview]
Message-ID: <20190403124019.8947-9-wsa+renesas@sang-engineering.com> (raw)
In-Reply-To: <20190403124019.8947-1-wsa+renesas@sang-engineering.com>

By properly setting up the algorithm at probe time, we can skip the
check at every transfer. This allows us to get rid of the flags
completely.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Andrew Lunn <andrew@lunn.ch>
---
 drivers/i2c/busses/i2c-ocores.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 4e1a077fb688..1b99f467aae0 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -26,8 +26,6 @@
 #include <linux/spinlock.h>
 #include <linux/jiffies.h>
 
-#define OCORES_FLAG_POLL BIT(0)
-
 /*
  * 'process_lock' exists because ocores_process() and ocores_process_timeout()
  * can't run in parallel.
@@ -37,7 +35,6 @@ struct ocores_i2c {
 	int iobase;
 	u32 reg_shift;
 	u32 reg_io_width;
-	unsigned long flags;
 	wait_queue_head_t wait;
 	struct i2c_adapter adap;
 	struct i2c_msg *msg;
@@ -403,11 +400,7 @@ static int ocores_xfer_polling(struct i2c_adapter *adap,
 static int ocores_xfer(struct i2c_adapter *adap,
 		       struct i2c_msg *msgs, int num)
 {
-	struct ocores_i2c *i2c = i2c_get_adapdata(adap);
-
-	if (i2c->flags & OCORES_FLAG_POLL)
-		return ocores_xfer_polling(adap, msgs, num);
-	return ocores_xfer_core(i2c, msgs, num, false);
+	return ocores_xfer_core(i2c_get_adapdata(adap), msgs, num, false);
 }
 
 static int ocores_init(struct device *dev, struct ocores_i2c *i2c)
@@ -447,7 +440,7 @@ static u32 ocores_func(struct i2c_adapter *adap)
 	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
-static const struct i2c_algorithm ocores_algorithm = {
+static struct i2c_algorithm ocores_algorithm = {
 	.master_xfer = ocores_xfer,
 	.functionality = ocores_func,
 };
@@ -673,13 +666,13 @@ static int ocores_i2c_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq == -ENXIO) {
-		i2c->flags |= OCORES_FLAG_POLL;
+		ocores_algorithm.master_xfer = ocores_xfer_polling;
 	} else {
 		if (irq < 0)
 			return irq;
 	}
 
-	if (!(i2c->flags & OCORES_FLAG_POLL)) {
+	if (ocores_algorithm.master_xfer != ocores_xfer_polling) {
 		ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0,
 				       pdev->name, i2c);
 		if (ret) {
-- 
2.11.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2019-04-03 12:40 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-03 12:40 [PATCH 00/12] i2c: core: introduce atomic transfers Wolfram Sang
2019-04-03 12:40 ` Wolfram Sang
2019-04-03 12:40 ` [PATCH 01/12] i2c: remove use of in_atomic() Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-15 12:40   ` Andy Shevchenko
2019-04-15 12:40     ` Andy Shevchenko
2019-04-15 21:55   ` Stefan Lengfeld
2019-04-15 21:55     ` Stefan Lengfeld
2019-04-15 21:55     ` Stefan Lengfeld
2019-04-16 10:48     ` Wolfram Sang
2019-04-16 10:48       ` Wolfram Sang
2019-04-03 12:40 ` [PATCH 02/12] i2c: core: use I2C locking behaviour also for SMBUS Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-15 12:39   ` Andy Shevchenko
2019-04-15 12:39     ` Andy Shevchenko
2019-04-15 12:39     ` Andy Shevchenko
2019-04-03 12:40 ` [PATCH 03/12] i2c: core: introduce callbacks for atomic transfers Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-15 12:39   ` Andy Shevchenko
2019-04-15 12:39     ` Andy Shevchenko
2019-04-15 21:57   ` Stefan Lengfeld
2019-04-15 21:57     ` Stefan Lengfeld
2019-04-03 12:40 ` [PATCH 04/12] i2c: mux: populate the new *_atomic callbacks Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-03 15:17   ` Peter Rosin
2019-04-03 15:17     ` Peter Rosin
2019-04-03 15:17     ` Peter Rosin
2019-04-15 12:04     ` Wolfram Sang
2019-04-15 12:04       ` Wolfram Sang
2019-04-15 12:04       ` Wolfram Sang
2019-04-15 12:44   ` Andy Shevchenko
2019-04-15 12:44     ` Andy Shevchenko
2019-04-03 12:40 ` [PATCH 05/12] i2c: demux: handle the new atomic callbacks Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-15 12:37   ` Andy Shevchenko
2019-04-15 12:37     ` Andy Shevchenko
2019-04-03 12:40 ` [PATCH 06/12] i2c: omap: Add the master_xfer_irqless hook Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-15 22:05   ` Stefan Lengfeld
2019-04-15 22:05     ` Stefan Lengfeld
2019-04-16 10:52     ` Wolfram Sang
2019-04-16 10:52       ` Wolfram Sang
2019-04-03 12:40 ` [PATCH 07/12] i2c: tegra-bpmp: convert to use new atomic callbacks Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-03 12:40 ` Wolfram Sang [this message]
2019-04-03 12:40   ` [PATCH 08/12] i2c: ocores: refactor setup for polling Wolfram Sang
2019-04-05 15:09   ` Peter Korsgaard
2019-04-05 15:09     ` Peter Korsgaard
2019-04-05 19:00   ` Andrew Lunn
2019-04-05 19:00     ` Andrew Lunn
2019-04-03 12:40 ` [PATCH 09/12] i2c: ocores: enable atomic xfers Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-05 19:20   ` Andrew Lunn
2019-04-05 19:20     ` Andrew Lunn
2019-04-03 12:40 ` [PATCH 10/12] i2c: stu300: use xfer_atomic callback to bail out early Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-04 15:38   ` Linus Walleij
2019-04-04 15:38     ` Linus Walleij
2019-04-03 12:40 ` [PATCH 11/12] i2c: algo: bit: add flag to whitelist atomic transfers Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-03 12:40 ` [PATCH 12/12] i2c: gpio: flag atomic capability if possible Wolfram Sang
2019-04-03 12:40   ` Wolfram Sang
2019-04-04 15:40   ` Linus Walleij
2019-04-04 15:40     ` Linus Walleij
2019-04-15 12:38   ` Andy Shevchenko
2019-04-15 12:38     ` Andy Shevchenko
2019-04-03 13:15 ` [PATCH 00/12] i2c: core: introduce atomic transfers Andy Shevchenko
2019-04-03 13:15   ` Andy Shevchenko
2019-04-15 12:06   ` Wolfram Sang
2019-04-15 12:06     ` Wolfram Sang
2019-04-15 12:35     ` Andy Shevchenko
2019-04-15 12:35       ` Andy Shevchenko
2019-04-15 12:48       ` Andy Shevchenko
2019-04-15 12:48         ` Andy Shevchenko
2019-04-15 12:50         ` Wolfram Sang
2019-04-15 12:50           ` Wolfram Sang
2019-04-15 12:10 ` Wolfram Sang
2019-04-15 12:10   ` Wolfram Sang

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=20190403124019.8947-9-wsa+renesas@sang-engineering.com \
    --to=wsa+renesas@sang-engineering.com \
    --cc=andrew@lunn.ch \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=contact@stefanchrist.eu \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=peda@axentia.se \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.