From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH 2/2] libi2c: Use I2C_SMBUS_BLOCK_MAX
Date: Fri, 22 Jun 2012 16:59:39 +0200 [thread overview]
Message-ID: <20120622165939.1cef58bb@endymion.delvare> (raw)
Use I2C_SMBUS_BLOCK_MAX instead of hardcoding 32.
---
lib/smbus.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
--- i2c-tools.orig/lib/smbus.c 2012-06-22 16:09:54.426235336 +0200
+++ i2c-tools/lib/smbus.c 2012-06-22 16:10:18.169262240 +0200
@@ -151,8 +151,8 @@ __s32 i2c_smbus_write_block_data(int fil
{
union i2c_smbus_data data;
int i;
- if (length > 32)
- length = 32;
+ if (length > I2C_SMBUS_BLOCK_MAX)
+ length = I2C_SMBUS_BLOCK_MAX;
for (i = 1; i <= length; i++)
data.block[i] = values[i-1];
data.block[0] = length;
@@ -161,21 +161,22 @@ __s32 i2c_smbus_write_block_data(int fil
}
/* Returns the number of read bytes */
-/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you
- ask for less than 32 bytes, your code will only work with kernels
- 2.6.23 and later. */
+/* Until kernel 2.6.22, the length is hardcoded to 32 bytes
+ (I2C_SMBUS_BLOCK_MAX.) If you ask for less than 32 bytes, your code
+ will only work with kernels 2.6.23 and later. */
__s32 i2c_smbus_read_i2c_block_data(int file, __u8 command, __u8 length,
__u8 *values)
{
union i2c_smbus_data data;
int i, err;
- if (length > 32)
- length = 32;
+ if (length > I2C_SMBUS_BLOCK_MAX)
+ length = I2C_SMBUS_BLOCK_MAX;
data.block[0] = length;
err = i2c_smbus_access(file, I2C_SMBUS_READ, command,
- length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :
+ length == I2C_SMBUS_BLOCK_MAX ?
+ I2C_SMBUS_I2C_BLOCK_BROKEN :
I2C_SMBUS_I2C_BLOCK_DATA, &data);
if (err < 0)
return err;
@@ -190,8 +191,8 @@ __s32 i2c_smbus_write_i2c_block_data(int
{
union i2c_smbus_data data;
int i;
- if (length > 32)
- length = 32;
+ if (length > I2C_SMBUS_BLOCK_MAX)
+ length = I2C_SMBUS_BLOCK_MAX;
for (i = 1; i <= length; i++)
data.block[i] = values[i-1];
data.block[0] = length;
@@ -206,8 +207,8 @@ __s32 i2c_smbus_block_process_call(int f
union i2c_smbus_data data;
int i, err;
- if (length > 32)
- length = 32;
+ if (length > I2C_SMBUS_BLOCK_MAX)
+ length = I2C_SMBUS_BLOCK_MAX;
for (i = 1; i <= length; i++)
data.block[i] = values[i-1];
data.block[0] = length;
--
Jean Delvare
reply other threads:[~2012-06-22 14:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20120622165939.1cef58bb@endymion.delvare \
--to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
--cc=linux-i2c-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).