From: Pavel Machek <pavel@ucw.cz>
To: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Greg KH <greg@kroah.com>,
kernel list <linux-kernel@vger.kernel.org>,
linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
kyungmin.park@samsung.com, b.zolnierkie@samsung.com,
cooloney@gmail.com, rpurdie@rpsys.net, sakari.ailus@iki.fi,
s.nawrocki@samsung.com
Subject: Re: Reading /sys with side effects (was Re: [PATCH 1/2] Documentation: leds: Add description of LED Flash class extension)
Date: Mon, 2 Feb 2015 14:51:03 +0100 [thread overview]
Message-ID: <20150202135103.GB26985@amd> (raw)
In-Reply-To: <54CF65CB.3060207@samsung.com>
Hi!
> >[Actually, you could _always_ do two reads on those devices, discard
> >first result, and return the second. But I'm not sure how hardware
> >will like that.]
>
> This would be the most sensible option.
>
>
> However, let's analyze the typical use cases for flash strobing:
>
>
> -------------------------------------------------------------
>
>
> >>>>>>>> Version without faults caching:
>
> ============
> Driver side:
> ============
>
> read_faults()
> faults = read_i2c(); //read faults
> if faults
> write_i2c(); //clear faults, only for some devices
> faults = read_i2c(); //read faults
> return faults
>
> ================
> User space side:
> ================
>
> 1. faults = `cat flash_faults` //read_faults()
> 2. if faults then
> print "Unable to strobe the flash LED due to faults"
> else
> echo 1 > flash_strobe
>
>
> >>>>>>>> Version with faults caching:
>
> ============
> Driver side:
> ============
>
> read_faults()
> faults |= read_i2c(); //read faults
>
> clear_faults()
> write_i2c(); //clear faults
> faults = 0;
>
>
> ================
> User space side:
> ================
>
> 1. faults = `cat flash_faults` //read_faults()
> 2. if faults then
> echo 0 > flash_faults //clear_faults()
> faults = `cat flash_faults` //read_faults()
> 3, if !faults
> echo 1 > flash_strobe
> else
> print "Unable to strobe the flash LED due to faults"
>
>
> -------------------------------------------------------------
>
> From the above it seems that version with clearing faults on read
> results in the simpler flash strobing procedure on userspace side,
> by the cost of additional bus access on the driver side.
I like caching version more (as it will allow by-hand debugging of
"why did not flash fire? Aha, lets see in the file, there was fault),
but both should be acceptable.
> we don't need additional attribute, just writing the flash_faults
> attribute can do the clearing.
Yes, writing flash_faults to clear is acceptable.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next prev parent reply other threads:[~2015-02-02 13:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-27 8:07 [PATCH 1/2] Documentation: leds: Add description of LED Flash class extension Jacek Anaszewski
2015-01-27 8:07 ` [PATCH 2/2] DT: leds: Add led-sources property Jacek Anaszewski
2015-01-29 14:55 ` Jacek Anaszewski
2015-01-29 20:28 ` Pavel Machek
2015-01-29 21:03 ` Rob Herring
2015-01-29 22:14 ` Bryan Wu
[not found] ` <CAK5ve-LKBfjRzxK_b0ByEF5uWHfAaBGS2OPznOiYNg9+FJP5Gg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-29 22:30 ` Pavel Machek
2015-01-29 22:59 ` Bryan Wu
2015-01-27 22:37 ` Reading /sys with side effects (was Re: [PATCH 1/2] Documentation: leds: Add description of LED Flash class extension) Pavel Machek
2015-01-28 8:43 ` Jacek Anaszewski
[not found] ` <54C8A130.8000807-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-01-29 21:14 ` Pavel Machek
2015-01-30 8:55 ` Jacek Anaszewski
2015-01-30 16:40 ` Greg KH
2015-02-02 9:07 ` Jacek Anaszewski
2015-02-02 9:44 ` Pavel Machek
2015-02-02 11:55 ` Jacek Anaszewski
2015-02-02 13:51 ` Pavel Machek [this message]
2015-02-02 14:51 ` Jacek Anaszewski
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=20150202135103.GB26985@amd \
--to=pavel@ucw.cz \
--cc=b.zolnierkie@samsung.com \
--cc=cooloney@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=greg@kroah.com \
--cc=j.anaszewski@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=rpurdie@rpsys.net \
--cc=s.nawrocki@samsung.com \
--cc=sakari.ailus@iki.fi \
/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).