From: Brendan Higgins <brendanhiggins@google.com>
To: linux-i2c@vger.kernel.org
Cc: Brendan Higgins <brendanhiggins@google.com>
Subject: [PATCH] i2c: slave framework support for SMBus Alert
Date: Tue, 9 Aug 2016 17:02:53 -0700 [thread overview]
Message-ID: <1470787373-26738-2-git-send-email-brendanhiggins@google.com> (raw)
In-Reply-To: <1470787373-26738-1-git-send-email-brendanhiggins@google.com>
Currently, only handling SMBus alerts as a SMBus master is supported.
This adds support for the generation of SMBus Alerts as a slave.
Signed-off-by: Brendan Higgins <brendanhiggins@google.com>
---
drivers/i2c/i2c-core.c | 22 ++++++++++++++++++++++
include/linux/i2c.h | 5 +++++
2 files changed, 27 insertions(+)
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index e584d88..9d49cee 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -3252,6 +3252,28 @@ int i2c_slave_unregister(struct i2c_client *client)
return ret;
}
EXPORT_SYMBOL_GPL(i2c_slave_unregister);
+
+int i2c_slave_smbus_alert(struct i2c_client *client)
+{
+ int ret;
+
+ if (!client->adapter->algo->smbus_alert_slave) {
+ dev_err(&client->dev, "%s: not supported by adapter\n",
+ __func__);
+ return -EOPNOTSUPP;
+ }
+
+ i2c_lock_adapter(client->adapter);
+ ret = client->adapter->algo->smbus_alert_slave(client);
+ i2c_unlock_adapter(client->adapter);
+
+ if (ret != 0)
+ dev_err(&client->dev, "%s: adapter returned error %d\n",
+ __func__, ret);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(i2c_slave_smbus_alert);
#endif
MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 200cf13b..43b98f5 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -271,6 +271,8 @@ static inline int i2c_slave_event(struct i2c_client *client,
{
return client->slave_cb(client, event, val);
}
+
+extern int i2c_slave_smbus_alert(struct i2c_client *client);
#endif
/**
@@ -381,6 +383,8 @@ i2c_register_board_info(int busnum, struct i2c_board_info const *info,
* from the I2C_FUNC_* flags.
* @reg_slave: Register given client to I2C slave mode of this adapter
* @unreg_slave: Unregister given client from I2C slave mode of this adapter
+ * @smbus_alert_slave: Create an smbus alert from the I2C slave mode of this
+ * adapter
*
* The following structs are for those who like to implement new bus drivers:
* i2c_algorithm is the interface to a class of hardware solutions which can
@@ -410,6 +414,7 @@ struct i2c_algorithm {
#if IS_ENABLED(CONFIG_I2C_SLAVE)
int (*reg_slave)(struct i2c_client *client);
int (*unreg_slave)(struct i2c_client *client);
+ int (*smbus_alert_slave)(struct i2c_client *client);
#endif
};
--
2.8.0.rc3.226.g39d4020
next prev parent reply other threads:[~2016-08-10 0:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-10 0:02 [PATCH] i2c: slave framework support for SMBus Alert Brendan Higgins
2016-08-10 0:02 ` Brendan Higgins [this message]
2016-08-10 8:26 ` 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=1470787373-26738-2-git-send-email-brendanhiggins@google.com \
--to=brendanhiggins@google.com \
--cc=linux-i2c@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 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.