Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965003AbbBBNvL (ORCPT ); Mon, 2 Feb 2015 08:51:11 -0500 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:58713 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964971AbbBBNvG (ORCPT ); Mon, 2 Feb 2015 08:51:06 -0500 Date: Mon, 2 Feb 2015 14:51:03 +0100 From: Pavel Machek To: Jacek Anaszewski Cc: Greg KH , kernel list , 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) Message-ID: <20150202135103.GB26985@amd> References: <1422346028-16739-1-git-send-email-j.anaszewski@samsung.com> <20150127221958.GA18993@amd> <54C8A130.8000807@samsung.com> <20150129211420.GA21140@amd> <54CB4702.1090508@samsung.com> <20150130164027.GA25830@kroah.com> <54CF3E36.9000108@samsung.com> <20150202094435.GA6686@amd> <54CF65CB.3060207@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54CF65CB.3060207@samsung.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2394 Lines: 91 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 -- 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/