linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	ktsai-GubuWUlQtMwciDkP5Hr2oA@public.gmane.org,
	Srinivas Pandruvada
	<srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Subject: [RFC Patch v0 3/3] iio: Capella cm3218x: smbus alert processing
Date: Wed, 26 Mar 2014 17:42:12 -0700	[thread overview]
Message-ID: <1395880932-19124-3-git-send-email-srinivas.pandruvada@linux.intel.com> (raw)
In-Reply-To: <1395880932-19124-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

Added driver alert callback and modified existing polls to the
core calls.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/iio/light/cm3218x.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/light/cm3218x.c b/drivers/iio/light/cm3218x.c
index e422f68..774b199 100644
--- a/drivers/iio/light/cm3218x.c
+++ b/drivers/iio/light/cm3218x.c
@@ -23,6 +23,7 @@
 #include <linux/iio/events.h>
 #include <linux/init.h>
 #include <linux/acpi.h>
+#include <linux/i2c-smbus.h>
 
 /* Registers Address */
 #define CM3218x_REG_ADDR_CMD		0x00
@@ -130,6 +131,12 @@ static int cm3218x_get_lux(struct cm3218x_chip *chip);
 static int cm3218x_threshold_update(struct cm3218x_chip *chip, int percent);
 static int cm3218x_read_als_it(struct cm3218x_chip *chip, int *val2);
 
+/* alert callback for i2c driver */
+static void cm3218x_alert(struct i2c_client *client, unsigned int flag)
+{
+	dev_err(&client->dev, "SMBUS alert flag %d\n", flag);
+}
+
 /**
  * cm3218x_read_ara() - Read ARA register
  * @cm3218x:	pointer of struct cm3218x.
@@ -142,19 +149,7 @@ static int cm3218x_read_als_it(struct cm3218x_chip *chip, int *val2);
  */
 static int cm3218x_read_ara(struct cm3218x_chip *chip)
 {
-	struct i2c_client *client = chip->client;
-	int status;
-	unsigned short addr;
-
-	addr = client->addr;
-	client->addr = 0x0C;
-	status = i2c_smbus_read_byte(client);
-	client->addr = addr;
-
-	if (status < 0)
-		return -ENODEV;
-
-	return status;
+	return i2c_smbus_ara_poll(chip->client);
 }
 
 /**
@@ -760,6 +755,7 @@ static struct i2c_driver cm3218x_driver = {
 	.id_table	= cm3218x_id,
 	.probe		= cm3218x_probe,
 	.remove		= cm3218x_remove,
+	.alert		= cm3218x_alert,
 };
 
 module_i2c_driver(cm3218x_driver);
-- 
1.8.3.2

  parent reply	other threads:[~2014-03-27  0:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-27  0:42 [RFC Patch v0 1/3] i2c-smbus: Add poll interface for smbus alert Srinivas Pandruvada
     [not found] ` <1395880932-19124-1-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-27  0:42   ` [RFC Patch v0 2/3] i2c-smbus: Allow building with I2C_HELPER_AUTO support Srinivas Pandruvada
     [not found]     ` <1395880932-19124-2-git-send-email-srinivas.pandruvada-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-27  6:57       ` Jean Delvare
     [not found]         ` <20140327075712.5121d6ed-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2014-03-27 15:26           ` Srinivas Pandruvada
2014-03-27  0:42   ` Srinivas Pandruvada [this message]
2014-03-27  7:44   ` [RFC Patch v0 1/3] i2c-smbus: Add poll interface for smbus alert Jean Delvare
     [not found]     ` <20140327084456.26527b4d-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2014-03-27 15:39       ` Srinivas Pandruvada
2014-03-27 17:34       ` Jonathan Cameron
     [not found]         ` <53349D41.4090209@linux.intel.com>
     [not found]           ` <53349D41.4090209-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-03-29 10:15             ` Jonathan Cameron
     [not found]               ` <53369D37.8010004-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2014-03-31 15:26                 ` Srinivas Pandruvada

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=1395880932-19124-3-git-send-email-srinivas.pandruvada@linux.intel.com \
    --to=srinivas.pandruvada-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=ktsai-GubuWUlQtMwciDkP5Hr2oA@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).