From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE910C388F7 for ; Sun, 25 Oct 2020 16:38:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74C2E22259 for ; Sun, 25 Oct 2020 16:38:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PiAHIHFL"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=lechnology.com header.i=@lechnology.com header.b="o4AC4Met" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74C2E22259 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lechnology.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dEsjD49S/ZkmpcLKKQuGkLkxfDuNmZbELY09A6CXxBE=; b=PiAHIHFLsH9/rcAkT+oU2+d22 khysn6SEaf6KUJNJ0TLxC1eFKe49f2HCxJOXQUXoXrD7gyUqXUmMaMMZ35lPcd235pizdXfpLnUci g/a4yWxFTQbDItht5pAxa5Gz2o1HG12phowY99cETQTHE2WfKqAk5hwjTvv0+5qlBpu9t9JPWj+67 Uctv5Yg3q41oZ5wFHfaDSRCzdvhcW1zpV1/5mfqx+KCno4iVxR6b8Lq4Ay+Adfcy4R9w5vhMgRcKi wWVhThVY1t5nb821tdeyPR8BJKmTToS4TxtSdh8sFHpi35BsOD6AgBXsPm4IeGjpCMaqQg1REwWol vE83+msDg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kWj1C-00066o-8I; Sun, 25 Oct 2020 16:37:18 +0000 Received: from vern.gendns.com ([98.142.107.122]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kWj18-00066D-K0 for linux-arm-kernel@lists.infradead.org; Sun, 25 Oct 2020 16:37:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NBfwltQtyYpg7GITsQ/G8RNoybCIgINYiN5thq4NeEg=; b=o4AC4MetqhXYPjVOnQ4oz2hZ/L fZeGe0nFQSh2RIXNFC638uS5DkWBm54/DizpesFLoggLIGkC02+2uY48Qb6pmYmX7kp5vJSiJn2k0 /aRfILZIrKt1LulmlU5LvKl7rlSLQPB28PXxLTJU0Ixfs7aQL1tNQQBXBt1xXZaT3WC86aLrGnCOl H8HPL8jJqYrhhwBgAdXeEc0nCp+74MSUVucnGxpHX/ACut1i5iWOkqX6lUoLbhKaOZNGCpZn1V++h f1Tl9H0pkhL2942lcYJrSzbowJ0NFg8NKlhYbQRTHl+hkcDtO38wb4NnU90aIw2Fkm2KrXLWyLfxl EDG+cnrA==; Received: from [2600:1700:4830:165f::19e] (port=37618) by vern.gendns.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1kWj13-0005Vi-VJ; Sun, 25 Oct 2020 12:37:10 -0400 Subject: Re: [PATCH v5 3/5] counter: Add character device interface To: William Breathitt Gray References: <00be1fccc672c5207f3b04fe4cc09c29e22641f4.1601170670.git.vilhelm.gray@gmail.com> <181eb08a-be0a-f7cc-259d-b2a0f279950b@lechnology.com> <20201018164905.GD231549@shinobu> <20201025125557.GA3458@shinobu> From: David Lechner Message-ID: Date: Sun, 25 Oct 2020 11:36:58 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201025125557.GA3458@shinobu> Content-Language: en-US X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201025_123714_841982_9CF194E2 X-CRM114-Status: GOOD ( 21.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.torgue@st.com, linux-iio@vger.kernel.org, patrick.havelange@essensium.com, alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mcoquelin.stm32@gmail.com, syednwaris@gmail.com, linux-stm32@st-md-mailman.stormreply.com, jic23@kernel.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org >>>>> diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c >>>>> index e66ed99dd5ea..cefef61f170d 100644 >>>>> --- a/drivers/counter/counter-sysfs.c >>>>> +++ b/drivers/counter/counter-sysfs.c >>>> >>>> >>>> Not sure why sysfs changes are in the chrdev patch. Are these >>>> changes related somehow? >>> >>> Sorry, I forgot to explain this in the cover letter. The changes here >>> are only useful for the character device interface. These changes >>> introduce the extensionZ_name and extensionZ_width sysfs attributes. >>> >>> In the character device interface, extensions are selected by their id >>> number, and the value returned depends on the type of data. The new >>> sysfs attributes introduced here allow users to match the id of an >>> extension with its name, as well as the bit width of the value returned >>> so that the user knows whether to use the value_u8 or value_u64 union >>> member in struct counter_event. >>> >> >> Are we sure that all value types will always be CPU-endian unsigned >> integers? Or should we make an enum to describe the data type instead >> of just the width? > > It should be safe to assume that the character device interface will > only ever return CPU-endian unsigned integers. The device driver should > handle the conversion of any strange endianness from the device before > the character device interface, while userspace is the one responsible > for interpreting the meaning of count in the context of the application. > > Let's create a scenario for the sake of example. Suppose we want to use > a counter device to track the vertical position of a component moved by > a linear actuator. The operator considers some vertical position as the > horizon, where anything above would be a positive position and anything > below a negative position. The counter device stores its count in > big-endian format; but the system CPU expects little-endian. > > The flow of data for this scenario would look like the following (where > BE = big-endian, LE = little-endian): > > +----------+ +---------------+ +--------+ > | Raw data | - BE -> | Device driver | -> LE -> | chrdev | - u64 -> > +----------+ +---------------+ +--------+ > > At this point, the userspace application would read the unsigned integer > from the character device and determine how to interpret the position -- > whether the count be converted to a signed value to represent a negative > physical position. > > Whether or not a position should be considered negative is dependent on > the user application and context. Because the character device does not > know the context of the user application, it should only provide > unsigned integers in order to ensure a standard interface for counter > devices; userspace will be responsible for interpreting those counts to > something meaningful for the context of their applications. > > William Breathitt Gray > Sounds reasonable to me. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel