summaryrefslogtreecommitdiff
path: root/drivers/staging/greybus/i2c.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2015-01-21 18:12:36 +0530
committerGreg Kroah-Hartman <greg@kroah.com>2015-01-22 11:29:39 +0800
commit36e79dec96f652110ae2b06bfcf9e67e1b770787 (patch)
tree333e41723bf440abb77c0dc1ea89cbacf198a480 /drivers/staging/greybus/i2c.c
parent530430b717f02843fe1f2e77e6f52a41e05d6c3a (diff)
greybus: create get_version() routines with the help of a macro
This gets rid of lots of duplication of code. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/staging/greybus/i2c.c')
-rw-r--r--drivers/staging/greybus/i2c.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/drivers/staging/greybus/i2c.c b/drivers/staging/greybus/i2c.c
index c967ae3161c5..589691d05750 100644
--- a/drivers/staging/greybus/i2c.c
+++ b/drivers/staging/greybus/i2c.c
@@ -87,30 +87,8 @@ struct gb_i2c_transfer_response {
__u8 data[0]; /* inbound data */
};
-/*
- * This request only uses the connection field, and if successful,
- * fills in the major and minor protocol version of the target.
- */
-static int gb_i2c_proto_version_operation(struct gb_i2c_device *gb_i2c_dev)
-{
- struct gb_i2c_proto_version_response response;
- int ret;
-
- ret = gb_operation_sync(gb_i2c_dev->connection,
- GB_I2C_TYPE_PROTOCOL_VERSION,
- NULL, 0, &response, sizeof(response));
- if (ret)
- return ret;
-
- if (response.major > GB_I2C_VERSION_MAJOR) {
- pr_err("unsupported major version (%hhu > %hhu)\n",
- response.major, GB_I2C_VERSION_MAJOR);
- return -ENOTSUPP;
- }
- gb_i2c_dev->version_major = response.major;
- gb_i2c_dev->version_minor = response.minor;
- return 0;
-}
+/* Define get_version() routine */
+define_get_version(gb_i2c_device, I2C);
/*
* Map Greybus i2c functionality bits into Linux ones
@@ -361,7 +339,7 @@ static int gb_i2c_device_setup(struct gb_i2c_device *gb_i2c_dev)
int ret;
/* First thing we need to do is check the version */
- ret = gb_i2c_proto_version_operation(gb_i2c_dev);
+ ret = get_version(gb_i2c_dev);
if (ret)
return ret;