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.5 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 9617AC433E0 for ; Mon, 10 Aug 2020 22:50:41 +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 5E86A20578 for ; Mon, 10 Aug 2020 22:50:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hsGveZ/0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=lechnology.com header.i=@lechnology.com header.b="RaEpa7qT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E86A20578 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=gxuSouS9VM18DwWzdxW2HAVINR1zvEJAgYJPZWr3fEc=; b=hsGveZ/0nCwGThK2Ro+tIIL3p 9DvHxMh5A/f/ai/CoYqD5ACppNG8vu3dXUspJNbDtdjIaO4EeYasI6M6F0hEJVeqf2Ll6zyDgAnao +tjnjVYRftVXcvregueukfJH7IR6gKfKVE4NugXBCxNCZ5JqWGfn5j6mMKEYnEyz/zfbPoLp9LbB6 F+F8+9MNGb2JG+WrHhlZaM4yyosyYsKljSsJptMUie2Ii/iQW5N74/bkvcJRJurgnRtAMsROFIx3f oqk71JSBNN8YgQAO4L//u/wnixVkuI8CJaL/a7BdqEi3c4yc3ktIA8MDMmADSjzlC3twy92JceLpP JEBb7nWIA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k5GbC-0005ko-Sw; Mon, 10 Aug 2020 22:48:58 +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 1k5Gb9-0005e5-SE for linux-arm-kernel@lists.infradead.org; Mon, 10 Aug 2020 22:48:57 +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=7BO2BV5ZL9NqupaOp8jHyF9nO1ZoO1djC1LGcXRvUvY=; b=RaEpa7qTSAHr/gGt2RlO6GMzlB I1P3WYliTKVqcaszmXdUAvTHxtBtLkg6jp5eKrRdsEKwDPrjL0lAeLNLxadiGlaT6J/7fFxaUz2v9 imMr7dGIoiEOPRoGUTDUcciqR6RknkQsq2m7+NxNoPhozDIJmRRlO8Jx5Q/e7Y0+S8JIyrI38z2Kc hKwM3rsrXL+UB5UtCmtCL82UAPgGIk7LddfLH1vH35tXPmhPQOeLDCL8H3NBgoMBIJpcIjtoOQHME HB4mIErsOu2khipwarZw7AP9ShLXPFPm4VCBJijtntN02ZU3z+HGTb74TK25mhke9x2xN+4rO8Clc XnC39Oog==; Received: from [2600:1700:4830:165f::19e] (port=45330) by vern.gendns.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1k5GaQ-0002v9-CL; Mon, 10 Aug 2020 18:48:10 -0400 Subject: Re: [PATCH v4 1/5] counter: Internalize sysfs interface code To: William Breathitt Gray References: <7209ac3d-d1ca-1b4c-b22c-8d98b13742e2@lechnology.com> <20200802210415.GA606173@shinobu> <4061c9e4-775e-b7a6-14fa-446de4fae537@lechnology.com> <20200809191500.GC6542@shinobu> From: David Lechner Message-ID: Date: Mon, 10 Aug 2020 17:48:07 -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: <20200809191500.GC6542@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-20200810_184856_018611_E672A242 X-CRM114-Status: GOOD ( 18.74 ) 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, David.Laight@ACULAB.COM, linux-arm-kernel@lists.infradead.org, mcoquelin.stm32@gmail.com, fabrice.gasnier@st.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 >>>>> >>>>> CPMAC ETHERNET DRIVER >>>>> M: Florian Fainelli >>>>> diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c >>>>> index 78766b6ec271..0f20920073d6 100644 >>>>> --- a/drivers/counter/104-quad-8.c >>>>> +++ b/drivers/counter/104-quad-8.c >>>>> @@ -621,7 +621,7 @@ static const struct iio_chan_spec quad8_channels[] = { >>>>> }; >>>>> >>>>> static int quad8_signal_read(struct counter_device *counter, >>>>> - struct counter_signal *signal, enum counter_signal_value *val) >>>>> + struct counter_signal *signal, u8 *val) >>>> >>>> I'm not a fan of replacing enum types with u8 everywhere in this patch. >>>> But if we have to for technical reasons (e.g. causes compiler error if >>>> we don't) then it would be helpful to add comments giving the enum type >>>> everywhere like this instance where u8 is actually an enum value. >>>> >>>> If we use u32 as the generic type for enums instead of u8, I think the >>>> compiler will happlily let us use enum type and u32 interchangeably and >>>> not complain. >>> >>> I switched to fixed-width types after the suggestion by David Laight: >>> https://lkml.org/lkml/2020/5/3/159. I'll CC David Laight just in case he >>> wants to chime in again. >>> >>> Enum types would be nice for making the valid values explicit, but there >>> is one benefit I have appreciated from the move to fixed-width types: >>> there has been a significant reduction of duplicate code; before, we had >>> a different read function for each different enum type, but now we use a >>> single function to handle them all. >> >> Yes, what I was trying to explain is that by using u32 instead of u8, I >> think we can actually do both. >> >> The function pointers in struct counter_device *counter would use u32 as a >> generic enum value in the declaration, but then the actual implementations >> could still use the proper enum type. > > Oh, I see what you mean now. So for example: > > int (*signal_read)(struct counter_device *counter, > struct counter_signal *signal, u8 *val) > > This will become instead: > > int (*signal_read)(struct counter_device *counter, > struct counter_signal *signal, u32 *val) > > Then in the driver callback implementation we use the enum type we need: > > enum counter_signal_level signal_level = COUNTER_SIGNAL_HIGH; > ... > *val = signal_level; > > Is that what you have in mind? > Yes. Additionally, if we have... int (*x_write)(struct counter_device *counter, ..., u32 val) We should be able to define the implementation as: static int my_driver_x_write(struct counter_device *counter, ..., enum some_type val) { ... } Not sure if it works if val is a pointer though. Little- endian systems would probably be fine, but maybe not big- endian combined with -fshort-enums compiler flag. int (*x_read)(struct counter_device *counter, ..., u32 *val) static int my_driver_x_read(struct counter_device *counter, ..., enum some_type *val) { ... } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel