Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1210375 > unrolled thread
| Started by | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| First post | 2015-08-20 12:10 +0200 |
| Last post | 2015-08-21 01:50 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v2 0/4] regmap: i2c block support Markus Pargmann <mpa@pengutronix.de> - 2015-08-20 12:10 +0200
[PATCH v2 4/4] regmap-i2c: Add smbus i2c block support Markus Pargmann <mpa@pengutronix.de> - 2015-08-20 12:10 +0200
[PATCH v2 2/4] regmap: regmap max_raw_read/write getter functions Markus Pargmann <mpa@pengutronix.de> - 2015-08-20 12:10 +0200
[PATCH v2 3/4] regmap: Add raw_write/read checks for max_raw_write/read sizes Markus Pargmann <mpa@pengutronix.de> - 2015-08-20 12:10 +0200
Re: [PATCH v2 0/4] regmap: i2c block support Mark Brown <broonie@kernel.org> - 2015-08-21 01:50 +0200
| From | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| Date | 2015-08-20 12:10 +0200 |
| Subject | [PATCH v2 0/4] regmap: i2c block support |
| Message-ID | <pZuXf-1Hx-3@gated-at.bofh.it> |
Hi, This series adds support for i2c block read/writes. To support the maximum 32 byte read/write operations, the regmap core is extended by max_raw_read and max_raw_write. bulk operations are splitted depending of the size of max_raw_read/write. These patches were included in the previous series "Regmap max_raw_io and bmc150 SPI support". The patches are based on "regmap: fixes". I am not able to perform any tests for the last patch of this series as I don't have hardware to test this on. Changes in v2: - max_raw_io splitted into max_raw_read/write - Use E2BIG as error value in the block read/write functions Best Regards, Markus Markus Pargmann (4): regmap: Introduce max_raw_read/write for regmap_bulk_read/write regmap: regmap max_raw_read/write getter functions regmap: Add raw_write/read checks for max_raw_write/read sizes regmap-i2c: Add smbus i2c block support drivers/base/regmap/internal.h | 4 ++ drivers/base/regmap/regmap-i2c.c | 49 +++++++++++++++++ drivers/base/regmap/regmap.c | 113 +++++++++++++++++++++++++++++++++------ include/linux/regmap.h | 6 +++ 4 files changed, 157 insertions(+), 15 deletions(-) -- 2.4.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| Date | 2015-08-20 12:10 +0200 |
| Subject | [PATCH v2 4/4] regmap-i2c: Add smbus i2c block support |
| Message-ID | <pZuXh-1Hx-31@gated-at.bofh.it> |
| In reply to | #1210375 |
This allows to read/write up to 32 bytes of data and is to be prefered
if supported before the register read/write smbus support.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
drivers/base/regmap/regmap-i2c.c | 49 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/base/regmap/regmap-i2c.c b/drivers/base/regmap/regmap-i2c.c
index 4b76e33110a2..ddb9b0efb724 100644
--- a/drivers/base/regmap/regmap-i2c.c
+++ b/drivers/base/regmap/regmap-i2c.c
@@ -209,11 +209,60 @@ static struct regmap_bus regmap_i2c = {
.val_format_endian_default = REGMAP_ENDIAN_BIG,
};
+static int regmap_i2c_smbus_i2c_write(void *context, const void *data,
+ size_t count)
+{
+ struct device *dev = context;
+ struct i2c_client *i2c = to_i2c_client(dev);
+
+ if (count < 1)
+ return -EINVAL;
+ if (count >= I2C_SMBUS_BLOCK_MAX)
+ return -E2BIG;
+
+ --count;
+ return i2c_smbus_write_i2c_block_data(i2c, ((u8 *)data)[0], count,
+ ((u8 *)data + 1));
+}
+
+static int regmap_i2c_smbus_i2c_read(void *context, const void *reg,
+ size_t reg_size, void *val,
+ size_t val_size)
+{
+ struct device *dev = context;
+ struct i2c_client *i2c = to_i2c_client(dev);
+ int ret;
+
+ if (reg_size != 1 || val_size < 1)
+ return -EINVAL;
+ if (val_size >= I2C_SMBUS_BLOCK_MAX)
+ return -E2BIG;
+
+ ret = i2c_smbus_read_i2c_block_data(i2c, ((u8 *)reg)[0], val_size, val);
+ if (ret == val_size)
+ return 0;
+ else if (ret < 0)
+ return ret;
+ else
+ return -EIO;
+}
+
+static struct regmap_bus regmap_i2c_smbus_i2c_block = {
+ .write = regmap_i2c_smbus_i2c_write,
+ .read = regmap_i2c_smbus_i2c_read,
+ .max_raw_read = I2C_SMBUS_BLOCK_MAX,
+ .max_raw_write = I2C_SMBUS_BLOCK_MAX,
+};
+
static const struct regmap_bus *regmap_get_i2c_bus(struct i2c_client *i2c,
const struct regmap_config *config)
{
if (i2c_check_functionality(i2c->adapter, I2C_FUNC_I2C))
return ®map_i2c;
+ else if (config->reg_bits == 8 &&
+ i2c_check_functionality(i2c->adapter,
+ I2C_FUNC_SMBUS_I2C_BLOCK))
+ return ®map_i2c_smbus_i2c_block;
else if (config->val_bits == 16 && config->reg_bits == 8 &&
i2c_check_functionality(i2c->adapter,
I2C_FUNC_SMBUS_WORD_DATA))
--
2.4.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| Date | 2015-08-20 12:10 +0200 |
| Subject | [PATCH v2 2/4] regmap: regmap max_raw_read/write getter functions |
| Message-ID | <pZuXh-1Hx-35@gated-at.bofh.it> |
| In reply to | #1210375 |
Add functions to access the maximum size we can read/write using
regmap_raw_read/write().
This helps drivers that need to know how much they can write with the
raw functions without problems. There are some devices (e.g. bmc150)
that have fifos as registers which need to be read in specific chunks
otherwise samples are dropped.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
drivers/base/regmap/regmap.c | 22 ++++++++++++++++++++++
include/linux/regmap.h | 2 ++
2 files changed, 24 insertions(+)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index bb2bfadfb4a3..99f5f1165b60 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1390,6 +1390,28 @@ bool regmap_can_raw_write(struct regmap *map)
}
EXPORT_SYMBOL_GPL(regmap_can_raw_write);
+/**
+ * regmap_get_raw_read_max - Get the maximum size we can read
+ *
+ * @map: Map to check.
+ */
+size_t regmap_get_raw_read_max(struct regmap *map)
+{
+ return map->max_raw_read;
+}
+EXPORT_SYMBOL_GPL(regmap_get_raw_read_max);
+
+/**
+ * regmap_get_raw_write_max - Get the maximum size we can read
+ *
+ * @map: Map to check.
+ */
+size_t regmap_get_raw_write_max(struct regmap *map)
+{
+ return map->max_raw_write;
+}
+EXPORT_SYMBOL_GPL(regmap_get_raw_write_max);
+
static int _regmap_bus_formatted_write(void *context, unsigned int reg,
unsigned int val)
{
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 6c9de3e8dd6e..9a49a2e22cc0 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -443,6 +443,8 @@ int regmap_get_max_register(struct regmap *map);
int regmap_get_reg_stride(struct regmap *map);
int regmap_async_complete(struct regmap *map);
bool regmap_can_raw_write(struct regmap *map);
+size_t regmap_get_raw_read_max(struct regmap *map);
+size_t regmap_get_raw_write_max(struct regmap *map);
int regcache_sync(struct regmap *map);
int regcache_sync_region(struct regmap *map, unsigned int min,
--
2.4.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| Date | 2015-08-20 12:10 +0200 |
| Subject | [PATCH v2 3/4] regmap: Add raw_write/read checks for max_raw_write/read sizes |
| Message-ID | <pZuXh-1Hx-51@gated-at.bofh.it> |
| In reply to | #1210375 |
Check in regmap_raw_read() and regmap_raw_write() for correct maximum
sizes of the operations. Return -E2BIG if this size is not supported
because it is too big.
Also this patch causes an uninitialized variable warning so it
initializes ret (although not necessary).
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
drivers/base/regmap/regmap.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 99f5f1165b60..77c9f235bf3d 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1581,6 +1581,8 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
return -EINVAL;
if (val_len % map->format.val_bytes)
return -EINVAL;
+ if (map->max_raw_write && map->max_raw_write > val_len)
+ return -E2BIG;
map->lock(map->lock_arg);
@@ -2251,6 +2253,10 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
ret = -ENOTSUPP;
goto out;
}
+ if (map->max_raw_read && map->max_raw_read < val_len) {
+ ret = -E2BIG;
+ goto out;
+ }
/* Physical block read if there's no cache involved */
ret = _regmap_raw_read(map, reg, val, val_len);
--
2.4.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2015-08-21 01:50 +0200 |
| Message-ID | <pZHKO-3f1-1@gated-at.bofh.it> |
| In reply to | #1210375 |
[Multipart message — attachments visible in raw view] — view raw
On Thu, Aug 20, 2015 at 12:00:03PM +0200, Markus Pargmann wrote: > Hi, > > This series adds support for i2c block read/writes. To support the maximum 32 > byte read/write operations, the regmap core is extended by max_raw_read and > max_raw_write. bulk operations are splitted depending of the size of > max_raw_read/write. This looks basically fine but depends on the previous fixes series AFAICT.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web