All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
To: Rodolfo Giometti <giometti-k2GhghHVRtY@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>,
	Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
Subject: Re: [PATCH 1/2] i2c: add "reset" sysfs entry for adapters.
Date: Mon, 9 Feb 2009 14:55:46 +0000	[thread overview]
Message-ID: <20090209145546.GO8032@fluff.org.uk> (raw)
In-Reply-To: <1233933798-17673-1-git-send-email-giometti-k2GhghHVRtY@public.gmane.org>

On Fri, Feb 06, 2009 at 04:23:17PM +0100, Rodolfo Giometti wrote:
> It could happen that an i2c adapter may lock the bus due due
> electrical problems, so the user may recover this stale state by using:
> 
> 	$ echo 1 > /sys/class/i2c-adapter/i2c-0/reset
> 
> Signed-off-by: Rodolfo Giometti <giometti-k2GhghHVRtY@public.gmane.org>

There doesn't seem to be any locking to stop issuing a reset during
an extant transaction... should the controller driver deal with
cancelling any outstanding transactions?

> ---
>  drivers/i2c/i2c-core.c |   21 +++++++++++++++++++++
>  include/linux/i2c.h    |    2 ++
>  2 files changed, 23 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index b1c9abe..b0c4053 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -393,8 +393,29 @@ show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf)
>  	return sprintf(buf, "%s\n", adap->name);
>  }
>  
> +static ssize_t
> +write_adapter_reset(struct device *dev, struct device_attribute *attr,
> +				const char *buf, size_t count)
> +{
> +	struct i2c_adapter *adap = to_i2c_adapter(dev);
> +	unsigned long val;
> +	int ret;
> +
> +	if (!adap->reset)
> +		return -EINVAL;
> +
> +	ret = strict_strtoul(buf, 10, &val);
> +	if (ret || val != 1)
> +		return -EINVAL;
> +
> +	adap->reset(adap);
> +
> +	return count;
> +}
> +
>  static struct device_attribute i2c_adapter_attrs[] = {
>  	__ATTR(name, S_IRUGO, show_adapter_name, NULL),
> +	__ATTR(reset, S_IWUSR, NULL, write_adapter_reset),
>  	{ },
>  };
>  
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index fcfbfea..0f84345 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -369,6 +369,8 @@ struct i2c_adapter {
>  	struct list_head clients;	/* DEPRECATED */
>  	char name[48];
>  	struct completion dev_released;
> +
> +	void (*reset)(struct i2c_adapter *);	/* user request adap reset */
>  };
>  #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
>  
> -- 
> 1.5.6.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben (ben-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'

  parent reply	other threads:[~2009-02-09 14:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-06 15:23 [PATCH 1/2] i2c: add "reset" sysfs entry for adapters Rodolfo Giometti
     [not found] ` <1233933798-17673-1-git-send-email-giometti-k2GhghHVRtY@public.gmane.org>
2009-02-06 15:23   ` [PATCH 2/2] i2c pxa: add the force reset method Rodolfo Giometti
2009-02-09 14:55   ` Ben Dooks [this message]
     [not found]     ` <20090209145546.GO8032-elnMNo+KYs3pIgCt6eIbzw@public.gmane.org>
2009-02-09 15:02       ` [PATCH 1/2] i2c: add "reset" sysfs entry for adapters Rodolfo Giometti
     [not found]         ` <20090209150255.GA7975-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org>
2009-02-09 15:28           ` Jean Delvare
     [not found]             ` <20090209162838.7cfeee94-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-09 15:37               ` Rodolfo Giometti
2009-02-09 16:17   ` Jean Delvare
     [not found]     ` <20090209171720.76efd2c8-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-09 20:41       ` Rodolfo Giometti
     [not found]         ` <20090209204108.GH7975-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org>
2009-02-10 10:44           ` Jean Delvare
     [not found]             ` <20090210114438.67bfb5fb-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-02-11 13:00               ` Rodolfo Giometti
     [not found]                 ` <20090211130028.GM8639-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org>
2009-02-11 13:40                   ` Wolfram Sang
2009-02-13 17:39                   ` Jean Delvare
2009-02-10 10:33   ` 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=20090209145546.GO8032@fluff.org.uk \
    --to=ben-linux-elnmno+kys3ytjvyw6ydsg@public.gmane.org \
    --cc=giometti-k2GhghHVRtY@public.gmane.org \
    --cc=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 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.