Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932866AbbBBJHK (ORCPT ); Mon, 2 Feb 2015 04:07:10 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:36727 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932601AbbBBJHH (ORCPT ); Mon, 2 Feb 2015 04:07:07 -0500 X-AuditID: cbfec7f4-b7f126d000001e9a-3f-54cf3da7d903 Message-id: <54CF3E36.9000108@samsung.com> Date: Mon, 02 Feb 2015 10:07:02 +0100 From: Jacek Anaszewski User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 MIME-version: 1.0 To: Greg KH Cc: Pavel Machek , 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) 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> In-reply-to: <20150130164027.GA25830@kroah.com> Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDLMWRmVeSWpSXmKPExsVy+t/xK7rLbc+HGDQvZLLYOGM9q8XRnROZ LOYfOcdqcW7BDEaLs01v2C0u75rDZrH1zTpGi7unjrJZ7N71lNXi8Jt2Vosz+1eyOXB77Jx1 l93j8NeFLB5vHwZ47Jn/g9Wjb8sqRo8Vq7+ze3zeJBfAHsVlk5Kak1mWWqRvl8CVsfHCDuaC LuWKW0tCGhj7ZLoYOTkkBEwkdt9/wwphi0lcuLeerYuRi0NIYCmjxO6rvYwQzkdGiQPtf9hB qngFtCS2f24Ds1kEVCVOtf5nA7HZBAwlfr54zQRiiwpESPw5vY8Vol5Q4sfkeywgtoiAjETH kj3sIEOZBSYxSayZ28kIkhAWaGWUOHuSB2LbS0aJw883MYMkOAX0JU50zAfbwCxgLbFy0jZG CFteYvOat8wTGAVmIVkyC0nZLCRlCxiZVzGKppYmFxQnpeca6hUn5haX5qXrJefnbmKExMiX HYyLj1kdYhTgYFTi4X3AfS5EiDWxrLgy9xCjBAezkgivhsX5ECHelMTKqtSi/Pii0pzU4kOM TBycUg2M9ryq899bZhum9nAE5fL+Ln3aNuff/B4Vs6rQ5b6Jybo9CyqKrRgXi/01Wne6S12z 5m3eGVmBbocnU6fWTTOYGeV1RnaG+qPQX2yG5gv+BZ6Ii92b7XJoY49G1tMD7ku0uBSfrfBg 1G913FLO5vdebPvswMJYnuXJcb7rMz3vC3odmRkX5aDEUpyRaKjFXFScCABjr+AQbwIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4642 Lines: 98 On 01/30/2015 05:40 PM, Greg KH wrote: > On Fri, Jan 30, 2015 at 09:55:30AM +0100, Jacek Anaszewski wrote: >> Hi Pavel, >> >> On 01/29/2015 10:14 PM, Pavel Machek wrote: >>> Hi! >>> >>>>>> + - flash_fault - list of flash faults that may have occurred: >>>>>> + * led-over-voltage - flash controller voltage to the flash LED >>>>>> + has exceededthe limit specific to the flash controller >>>>>> + * flash-timeout-exceeded - the flash strobe was still on when >>>>>> + the timeout set by the user has expired; not all flash >>>>>> + controllers may set this in all such conditions >>>>>> + * controller-over-temperature - the flash controller has >>>>>> + overheated >>>>>> + * controller-short-circuit - the short circuit protection >>>>>> + of the flash controller has been triggered >>>>>> + * led-power-supply-over-current - current in the LED power >>>>>> + supply has exceeded the limit specific to the flash >>>>>> + controller >>>>>> + * indicator-led-fault - the flash controller has detected >>>>>> + a short or open circuit condition on the indicator LED >>>>>> + * led-under-voltage - flash controller voltage to the flash >>>>>> + LED has been below the minimum limit specific to >>>>>> + the flash >>>>>> + * controller-under-voltage - the input voltage of the flash >>>>>> + controller is below the limit under which strobing the >>>>>> + flash at full current will not be possible. The condition >>>>>> + persists until this flag is no longer set >>>>>> + * led-over-temperature - the temperature of the LED has exceeded >>>>>> + its allowed upper limit >>>>>> + >>>>>> + Flash faults are cleared, if possible, by reading the attribute. >>>>> >>>>> That's bad. Now you can no longer present flash_fault file as readable >>>>> to non-root users, and grep -ri foo /sys will interfere with your >>>>> camera application. >>>>> >>>>> Bad interface, just fix it. >>>> >>>> In my opinion it isn't crucial for the user to be aware of the >>>> fact that some non-persistent fault happened right after strobing the >>>> flash (e.g. over temperature). >>>> >>>> I cannot see anything harmful in the situation when someone does grep >>>> on /sys and clears non-persistent fault on a flash LED device. >>> >>> So why export the faults at all? >> >> Faults may prevent strobing the flash in case of some devices. >> The example of such a device is ADP1663 (drivers/media/i2c/adp1653.c). >> This driver reads the faults before strobing the flash and if a >> fault preventing strobing has occurred it returns -EBUSY. >> >> If this driver was made a LED Flash class driver, then it would >> expose flash_faults attribute. The driver would probably need >> redesigning - checking the faults before strobing would have to be >> avoided and it should be left to the userspace. > > That's fine, but Pavel's point is that you shouldn't "clear a fault" by > reading a sysfs file as you don't control who reads all sysfs files > (hint, libudev might cache all attributes when they are found / change, > which could prevent anyone else from seeing that fault.) > > So please fix this, make a write to clear a fault or some other such > explicit action, not a simple read. That's not an acceptable api. I am aware what Pavel'a point was, I just presented the arguments justifying existence of the flash_faults attribute at all. In my opinion flash_faults attribute should report the current state of the device. For the devices which clear the faults on I2C readout the faults read would have to be cached in the driver, until they are explicitly cleared, to keep the sysfs interface consistent. Nonetheless, there can be also devices which don't require clearing the faults - they are reported only when the actual condition occurs, e.g. over temperature or under voltage. When the related value gets back to the acceptable level the fault is no longer reported by the device. In this case some faults will remain unnoticed by the user space. This is the argument in favour of my statement that caching the faults does not make a sense and is not crucial. The user's vital interest is to know whether the flash LED is operational right before strobing. Since we cannot guarantee reporting all the faults that occurred for all possible flash LED devices, the only sensible solution is to report only the currently valid fault. -- Best Regards, Jacek Anaszewski -- 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/