From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: Clifford Wolf <clifford-cPpHkPqGOEfk7+2FdBfRIA@public.gmane.org>
Subject: [PATCH] i2c-dev: Clarify the unit of ioctl I2C_TIMEOUT
Date: Fri, 20 Feb 2009 13:21:37 +0100 [thread overview]
Message-ID: <20090220132137.6a86dda6@hyperion.delvare> (raw)
The unit in which user-space can set the bus timeout value is jiffies
for historical reasons (back when HZ was always 100.) This is however
not good because user-space doesn't know how long a jiffy lasts. The
timeout value should instead be set in a fixed time unit. Given the
original value of HZ, this unit should be 10 ms, for compatibility.
Signed-off-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
---
drivers/i2c/i2c-dev.c | 6 +++++-
include/linux/i2c-dev.h | 2 +-
include/linux/i2c.h | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
--- linux-2.6.29-rc5.orig/drivers/i2c/i2c-dev.c 2009-01-06 20:24:44.000000000 +0100
+++ linux-2.6.29-rc5/drivers/i2c/i2c-dev.c 2009-02-20 12:59:38.000000000 +0100
@@ -35,6 +35,7 @@
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <linux/smp_lock.h>
+#include <linux/jiffies.h>
#include <asm/uaccess.h>
static struct i2c_driver i2cdev_driver;
@@ -422,7 +423,10 @@ static long i2cdev_ioctl(struct file *fi
client->adapter->retries = arg;
break;
case I2C_TIMEOUT:
- client->adapter->timeout = arg;
+ /* For historical reasons, user-space sets the timeout
+ * value in units of 10 ms.
+ */
+ client->adapter->timeout = msecs_to_jiffies(arg * 10);
break;
default:
/* NOTE: returning a fault code here could cause trouble
--- linux-2.6.29-rc5.orig/include/linux/i2c-dev.h 2008-04-17 04:49:44.000000000 +0200
+++ linux-2.6.29-rc5/include/linux/i2c-dev.h 2009-02-20 12:48:08.000000000 +0100
@@ -33,7 +33,7 @@
*/
#define I2C_RETRIES 0x0701 /* number of times a device address should
be polled when not acknowledging */
-#define I2C_TIMEOUT 0x0702 /* set timeout in jiffies - call with int */
+#define I2C_TIMEOUT 0x0702 /* set timeout in units of 10 ms */
/* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses
* are NOT supported! (due to code brokenness)
--- linux-2.6.29-rc5.orig/include/linux/i2c.h 2009-01-29 08:27:20.000000000 +0100
+++ linux-2.6.29-rc5/include/linux/i2c.h 2009-02-20 12:47:39.000000000 +0100
@@ -361,7 +361,7 @@ struct i2c_adapter {
struct mutex bus_lock;
struct mutex clist_lock;
- int timeout;
+ int timeout; /* in jiffies */
int retries;
struct device dev; /* the adapter device */
--
Jean Delvare
next reply other threads:[~2009-02-20 12:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-20 12:21 Jean Delvare [this message]
[not found] ` <20090220132137.6a86dda6-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-20 12:28 ` [PATCH] i2c-dev: Clarify the unit of ioctl I2C_TIMEOUT Wolfram Sang
[not found] ` <20090220122839.GA3042-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2009-02-20 12:39 ` Jean Delvare
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=20090220132137.6a86dda6@hyperion.delvare \
--to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
--cc=clifford-cPpHkPqGOEfk7+2FdBfRIA@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