Message ID | 20221125083526.2422900-2-gerald.loacker@wolfvision.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3859223wrr; Fri, 25 Nov 2022 00:44:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf6bEtX1mnWu+bCT2YSAwLf2xpEgPSfk9tujtRzbDokYi3I+x5h11Cv2GXWJbdZEn2DOOIbW X-Received: by 2002:aa7:8b56:0:b0:56c:6f8:fe14 with SMTP id i22-20020aa78b56000000b0056c06f8fe14mr38937373pfd.75.1669365848220; Fri, 25 Nov 2022 00:44:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669365848; cv=pass; d=google.com; s=arc-20160816; b=E2SwlFGUjLYp2gGZUMUa4dN6kK2DTBgzXo9CaJOdLDx/0kLNkbm+O8SFVSf4Qvj+6/ rg/HOvXd20psEliywMjfYgB8QeJnCUTmf/qdEtgDPvGYZCdv8+DkPt6cjyrVlUCJlRuP owYIVPlC3uEdYeqUkHbz3FnTTvbqWLlc/eQXXIitdCj5HoJRuaRBcfLt/3oz66r7Ew/U pMF1/xnliXH1JexJVnCH3u7AlBqT1xN0jkoDMXObRUgonW8Jh8Id8BwrHh/e7rQ0aMQI QQAFAOqmNf0Gm1DCHCQbt3i3ipcB4IRU4qxxDE/OtM8CwEP3SAyQ8B1cxdtn2M31LsvR VAIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UHZrtVTVx7BdBWrx8k8G0wo6sQRpsya9kqz08AJ3VSM=; b=WuNb58K6rlAkXN6GEzc9sgnfGHMUANZwaicncvsbJ9PKnWF9ADjLCrJ78SBP8YExxx Htj3GR6sKqggrWBQej+ATHbZMz9G42q0ZnFcUAaFBTR7ZKdV1qIRvy3A+16wKdM3TtPK 7WTZmhlKMVOJ1cG0W0fPAS4L3NWQxtgImXrcFW/+ctEgOXDe7A6D2vtI8d/MyGYbRJKP dKvRdO7akH9TmLvjYxzeyHUerKk+IEkE4cG6SNX7rTZ3qJZzgXH3dykd8jh/D6XBo8jp ajH012092aaGWTaUvTppIFqSJDE1SI3/lqLE6To+EJUu5kfxZRnkd+EDJpDvy69A2olx /5QA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=csIRdBle; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020a1709029f9000b0017680ae3a9csi2970019plq.534.2022.11.25.00.43.55; Fri, 25 Nov 2022 00:44:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wolfvision.net header.s=selector2 header.b=csIRdBle; arc=pass (i=1 spf=pass spfdomain=wolfvision.net dkim=pass dkdomain=wolfvision.net dmarc=pass fromdomain=wolfvision.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wolfvision.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229839AbiKYIfx (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Fri, 25 Nov 2022 03:35:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbiKYIfr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 25 Nov 2022 03:35:47 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70054.outbound.protection.outlook.com [40.107.7.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9544D31371; Fri, 25 Nov 2022 00:35:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gflwdJWoRH304oGhg05fr/G2/WIP0AkJVAUn+bBICNVLj574vnWuDNcxPj9mtq0enq2csiyhyznDBSHh0yI7FiR0c70z9LrOn48TEJJmykkixIPFjZRmyOPX0RLZwiLT5Cu5XP+38s/0ZfgBLvZ9XfZw6jDSBLem84q5mG+trIy7z7yzBzvHS9JIiP0Dx74PODVFwAYaQW6OO5gOKOI1Q+z9u6DvsbyCefB5ySS3g26nGGYggMrfe9+J1B3RosCHNR5bPwvlEW5Hfixqle58ViidNwHS68Asfwx3/uIGZ9pQ8di4TVYIffUA4sHSR6g3ZMIjZIR4xcC/enSBeW4Gng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UHZrtVTVx7BdBWrx8k8G0wo6sQRpsya9kqz08AJ3VSM=; b=nTbb5NBih6tq1ybKZ32wRbSrqNmJzZh3DTLyNaqzfnUYeIbWe3LkuCUcqXiinkg7LEsrGLDTV2KN+Ra6SUJZQ2SpEf18wzX+nBJTQK0TlXjib9Mmc0sRXqc+tjuhOQFtMPg17VlV7eDfpIVSbQc9xkAGd57byv+aVFo9BitQROkq9rc9ROS35XSR+wXSeWlvQQKGid008baa7MGIh8cY+j/nrJ9ZOd4EYTHSJHKymFIAWpDeCEp1H7+Q2LJobC42pithXkwf8RaLhJpzvGUA6VYD7Z7RoHyFy655B9ISNb14gTKugWztAxgtFFn6W7VuaFg+qF7+qim5bpqjWGYgtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UHZrtVTVx7BdBWrx8k8G0wo6sQRpsya9kqz08AJ3VSM=; b=csIRdBleuQn5ST8q8EGUQfHnH/8V9qc3WC+l4UNN+oUJtkXDDYlT9Ua0Af0siJDpdocWFAEhRc+zklq9FrTYICiBJ6fW1wSKzT3mLCG+fVBrVACt6FTXi+fiB5AF9DUyF6mJI/Xr4B/6a8jjNodDK3GiZ6M3ZuHKuFYciixPXLI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VI1PR08MB4544.eurprd08.prod.outlook.com (2603:10a6:803:100::13) by PAXPR08MB6751.eurprd08.prod.outlook.com (2603:10a6:102:136::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.5; Fri, 25 Nov 2022 08:35:43 +0000 Received: from VI1PR08MB4544.eurprd08.prod.outlook.com ([fe80::bcc7:bc51:bf44:1454]) by VI1PR08MB4544.eurprd08.prod.outlook.com ([fe80::bcc7:bc51:bf44:1454%6]) with mapi id 15.20.5857.019; Fri, 25 Nov 2022 08:35:43 +0000 From: Gerald Loacker <gerald.loacker@wolfvision.net> To: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron <jic23@kernel.org>, Lars-Peter Clausen <lars@metafoo.de>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Jakob Hauser <jahau@rocketmail.com>, Linus Walleij <linus.walleij@linaro.org>, Nikita Yushchenko <nikita.yoush@cogentembedded.com>, Michael Riesch <michael.riesch@wolfvision.net>, Gerald Loacker <gerald.loacker@wolfvision.net> Subject: [PATCH v3 1/3] iio: add struct declarations for iio types Date: Fri, 25 Nov 2022 09:35:24 +0100 Message-Id: <20221125083526.2422900-2-gerald.loacker@wolfvision.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221125083526.2422900-1-gerald.loacker@wolfvision.net> References: <20221125083526.2422900-1-gerald.loacker@wolfvision.net> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: VI1PR0501CA0011.eurprd05.prod.outlook.com (2603:10a6:800:92::21) To VI1PR08MB4544.eurprd08.prod.outlook.com (2603:10a6:803:100::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR08MB4544:EE_|PAXPR08MB6751:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a9d7e45-6df8-4d93-799a-08dacec00a6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bhu+6pxahRRmp7YhQTKMJXuk0i4Qd7zwTsS09iYufI7lnTwQy3ZPJsuERcNQaEILiScSkBd58CQAC6nkixEOgg7Bh/vJlKGviWG79ciOQwbFIPPHLpdtHQEkUs/U3xFTsLXJyEXlfg9A08J/sUrwkXHCJEdOviQxLzBbmVwQeRGwmj5t4aDPsUq8HdWa+HT0fdyc7b1DaLJzPVHB/o348wnjJxv5iUpIxBT4wMtXgyT6iEHqHhUq3HyGily6nqo+fDSkXI6o9RU0d00kUzOLzygufLKk8BgsUnfcNL+uEMzVaWuC5Kh19HIdLOGgUEwf2i4zNdJrLdBN4FKyp3d5/4Ly1Lr0NysJ5H5XvaSYUHZrJkFWdixIxMfHFyoxg2lGfXZKhKGSCCOA8lwaHSaibeydqVrmDoHSjGGtTlsVCnf+UbOOFbyzmyakBCByUTew5r6BU8bFGEZveWRyBx4RPMdznb2yKXQsBIo1Uw/upAN6BubqiCe0tSGQMPOqDEuYdt1lJCWYI726C56oun8Fqc+hlbsc35wFtxOLTcRqz1P0VoKIA35Q2Je16tHcpw/0okVa46nSbFAMUO9+NRMlXbL/fmL/Wk1GYrh0+5WhQqBG1e6kAX7Vm7MINriddZFFWDGNSJuzBDDmEm5IOKYHKrQOQI26v1XYMEFTHf7OrWH4yISXmQnSEJbsGYTdJWRLMbE6zPGJPwIYvITBeWHy2w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB4544.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(346002)(376002)(136003)(396003)(39840400004)(451199015)(478600001)(6486002)(186003)(44832011)(4744005)(7416002)(41300700001)(2616005)(1076003)(316002)(54906003)(38100700002)(38350700002)(36756003)(6506007)(6666004)(107886003)(52116002)(26005)(6512007)(86362001)(4326008)(66946007)(66556008)(8676002)(66476007)(5660300002)(8936002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sOgAZSXJNO3hV/W4yGDjgfMPrO7H9ax+xipPaFxiJ2Vj8d2KaZXduUVX19B+kl+xSmfegejRTw95ck/fPi3YYSGZAsSfpSgrlmNQE5ekTqcPTfdAEYLSjIMhgQoowoEufLYpEp9PxhuIqIhZ7NNF4/M+NoB36U4VZZ/jVLnzAx+JOzPe6O4DGfHPp6kOkNQj/PJeRsmOG4dLtJ65HNjcQ5+HqYpRpITUkzLU1BjEyIDk8IWe6TkXu7aQNH1+5gLN+86qXTGjybykWHdatM/z1K5/x1MzREFQ/C64nDgMz6yw++bIv9cddxYdT7AAMhV6kObkYusrRaDqgSqTsTGe47DLeukp21AfL6eqGzw8FKg67YdUCw+x55MbuRjKKazMXdK2Tv8+IlG0sXJ7WObAbnKXteWxsJTyvOoKrM6ZWZheINfwKYiuqu+8DisL8Lzu0mttaegoWNCCLLtfbWwlREcbF0Ntwzshc2F1SRl6mWSiDaPf4rCEzuWkL3sAYiHraJMrQRmMINpc60R6xfsskvu7W8BGkCZunaeONdy+DE3Ka0iOdpFYmWP/DyvPzOakRYZKWb/l49eJoo9WBUAZjnROnn3DvgWUTCm2KYunaffmiv1+q1JdwBAHVavdIDHHmsgYV5u27IE5BH25c2Ny19iPyOrlXBWp8uqPvZF4oSZTq5jhmqy4GNwjf5LL7hK4bae0EJm0SMxdBo/oBMnu8QxK197xKp+KMy6YRhpkMiWJZXoJCVZ30F0dfIuaqi1bQzo0+spdPi5FpKfMeKPv1pHMTheQNmULeCCW8qpbXXuvGnUsBNBCOQ1WzrwpGR1idr9VaNJ43esWDyhwz+v5ExK2uMIA7R5ciID2+Yo3Bmhiys0MSwl/LrHfuifIOdPV2rwLdvuM2B6X9UXAQOVLTMm/sN+rNp28G9wLHmC+ogi2qeC6PU8eF9leuG2gyP40CMk+4ngonAHTRGjFS4B192tLgD8hBLa67gwKS3fHXJXejWYUC28C+VG4tur3jCxbvCJ4TLhGS5YFtZgIA6YgZR8lRge/EaKdU2vVvK75pn1veL9QDQKxFe0ZTbzSMMMkpG1uqBi10M4MVyEBiSdhvkOTWHMytBrN8fQ2HxZK8o3WlXEtlDDpf0g8gz1jxYBvixi73guMC1M1z+pU+bLTMSlil8uIV+Jb8bqljyKDMKrARXSW3OAvE15qIxmmCs7f3l3FEUwuVufYExLaL73KNAqWCoWEcC4RlKjg/dKAmegmOxVu752PiHWa+DPao4FIBVsdUxxpWMKZ0RThLmmh4JKwA45+j4Ik7/22KQdvA9qxvkBQy+MORVaDsNDoFYLsrOLt+++0J4eZlEapf/XybER2GT2FnEsSu5VG11vhtzIfV8iQxS2gCnQmBwRguRLGsvxFvpzScIir99L9v/ALyMt2OMUCcp2HuXLddtlf4gPln+SzqYEE4lmCmOE4C6tjZ3jvIPR5r06PeU5RSRlcjfKixu/WsOSjaVSYzhkZQ04ze3gZAuJRmbEe3liP4Z0AiRi540xchZ3QixBs9c7PRrkZUUAW1qgk5Y+zox+nWsqtmhgTSvpbP+kSy0neC0ks5p1dNffAy+vvjNwiycqsdg== X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 7a9d7e45-6df8-4d93-799a-08dacec00a6a X-MS-Exchange-CrossTenant-AuthSource: VI1PR08MB4544.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2022 08:35:43.1545 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dakzInhTz8qaX0SHT/a2clmAV0hqVgMAvndML8q9jSSP0ocKNroDPp86KxQNF4Zm2y66O48HX0pWgZ94LB5EP5pNblhYksf5HT3jFSXRefM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6751 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750456963504760865?= X-GMAIL-MSGID: =?utf-8?q?1750456963504760865?= |
Series |
add ti tmag5273 driver
|
|
Commit Message
Gerald Loacker
Nov. 25, 2022, 8:35 a.m. UTC
Add structs for iio type arrays such as IIO_AVAIL_LIST which can be used
instead of int arrays.
Signed-off-by: Gerald Loacker <gerald.loacker@wolfvision.net>
---
include/linux/iio/iio.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
Comments
On Fri, Nov 25, 2022 at 09:35:24AM +0100, Gerald Loacker wrote: > Add structs for iio type arrays such as IIO_AVAIL_LIST which can be used > instead of int arrays. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> And thank you for doing this! Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> (one comment below) > Signed-off-by: Gerald Loacker <gerald.loacker@wolfvision.net> > --- > include/linux/iio/iio.h | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h > index f0ec8a5e5a7a..eaf6727445a6 100644 > --- a/include/linux/iio/iio.h > +++ b/include/linux/iio/iio.h > @@ -383,6 +383,21 @@ s64 iio_get_time_ns(const struct iio_dev *indio_dev); > > struct iio_trigger; /* forward declaration */ > > +struct iio_val_int_plus_micro { > + int val_int; > + int val_micro; > +}; > + > +struct iio_val_int_plus_nano { > + int val_int; > + int val_nano; > +}; > + > +struct iio_val_int_plus_micro_db { > + int val_int; int val_int_db; ? > + int val_micro_db; > +}; Actually why can't we simply do typedef iio_val_int_plus_micro_db iio_val_int_plus_micro; ? > /** > * struct iio_info - constant information about device > * @event_attrs: event control attributes > -- > 2.37.2 >
On Fri, Nov 25, 2022 at 12:45:06PM +0200, Andy Shevchenko wrote: > On Fri, Nov 25, 2022 at 09:35:24AM +0100, Gerald Loacker wrote: ... > > +struct iio_val_int_plus_micro { > > + int val_int; > > + int val_micro; > > +}; Thinking more about naming, why not drop val_ completely? int integer; int micro; ? > > +struct iio_val_int_plus_nano { > > + int val_int; > > + int val_nano; > > +}; > > + > > +struct iio_val_int_plus_micro_db { > > + int val_int; > > int val_int_db; ? > > > + int val_micro_db; > > +}; > > Actually why can't we simply do > > typedef iio_val_int_plus_micro_db iio_val_int_plus_micro; > > ?
Am 25.11.2022 um 12:01 schrieb Andy Shevchenko: > On Fri, Nov 25, 2022 at 12:45:06PM +0200, Andy Shevchenko wrote: >> On Fri, Nov 25, 2022 at 09:35:24AM +0100, Gerald Loacker wrote: > > ... > >>> +struct iio_val_int_plus_micro { >>> + int val_int; >>> + int val_micro; >>> +}; > > Thinking more about naming, why not drop val_ completely? > > int integer; > int micro; > > ? > Yes, this sounds good to me. I think of adding only typedef struct { int integer; int micro; } iio_val_int_plus_micro; for now, and one can add similar structures when needed, like typedef struct { int integer; int nano; } iio_val_int_plus_nano; or typedef iio_val_int_plus_micro iio_val_int_plus_micro_db; If you think it's better to add them all, I can do that, of course. >>> +struct iio_val_int_plus_nano { >>> + int val_int; >>> + int val_nano; >>> +}; >>> + >>> +struct iio_val_int_plus_micro_db { >>> + int val_int; >> >> int val_int_db; ? >> >>> + int val_micro_db; >>> +}; >> >> Actually why can't we simply do >> >> typedef iio_val_int_plus_micro_db iio_val_int_plus_micro; >> >> ? >
On Mon, Nov 28, 2022 at 01:18:04PM +0100, Gerald Loacker wrote: > Am 25.11.2022 um 12:01 schrieb Andy Shevchenko: > > On Fri, Nov 25, 2022 at 12:45:06PM +0200, Andy Shevchenko wrote: > >> On Fri, Nov 25, 2022 at 09:35:24AM +0100, Gerald Loacker wrote: ... > >>> +struct iio_val_int_plus_micro { > >>> + int val_int; > >>> + int val_micro; > >>> +}; > > > > Thinking more about naming, why not drop val_ completely? > > > > int integer; > > int micro; > > > > ? > > Yes, this sounds good to me. I think of adding only > > typedef struct { > int integer; > int micro; > } iio_val_int_plus_micro; > > for now, and one can add similar structures when needed, like > > typedef struct { > int integer; > int nano; > } iio_val_int_plus_nano; It's a rule to use _t for typedef:s in the kernel. That's why I suggested to leave struct definition and only typedef the same structures (existing) to new names (if needed). > or > typedef iio_val_int_plus_micro iio_val_int_plus_micro_db; This is better as explained above. > If you think it's better to add them all, I can do that, of course. > > >>> +struct iio_val_int_plus_nano { > >>> + int val_int; > >>> + int val_nano; > >>> +}; > >>> + > >>> +struct iio_val_int_plus_micro_db { > >>> + int val_int; > >> > >> int val_int_db; ? > >> > >>> + int val_micro_db; > >>> +}; > >> > >> Actually why can't we simply do > >> > >> typedef iio_val_int_plus_micro_db iio_val_int_plus_micro; > >> > >> ?
Hi Gerald, Andy, On 11/28/22 14:27, Andy Shevchenko wrote: > On Mon, Nov 28, 2022 at 01:18:04PM +0100, Gerald Loacker wrote: >> Am 25.11.2022 um 12:01 schrieb Andy Shevchenko: >>> On Fri, Nov 25, 2022 at 12:45:06PM +0200, Andy Shevchenko wrote: >>>> On Fri, Nov 25, 2022 at 09:35:24AM +0100, Gerald Loacker wrote: > > ... > >>>>> +struct iio_val_int_plus_micro { >>>>> + int val_int; >>>>> + int val_micro; >>>>> +}; >>> >>> Thinking more about naming, why not drop val_ completely? >>> >>> int integer; >>> int micro; >>> >>> ? >> >> Yes, this sounds good to me. I think of adding only >> >> typedef struct { >> int integer; >> int micro; >> } iio_val_int_plus_micro; I think we actually want struct iio_val_int_plus_micro { int integer; int micro; }; here, right? >> for now, and one can add similar structures when needed, like >> >> typedef struct { >> int integer; >> int nano; >> } iio_val_int_plus_nano; +1 for introducing things when they are actually used. > It's a rule to use _t for typedef:s in the kernel. That's why > I suggested to leave struct definition and only typedef the same structures > (existing) to new names (if needed). Andy, excuse our ignorance but we are not sure how this typedef approach is supposed to look like... >> or > >> typedef iio_val_int_plus_micro iio_val_int_plus_micro_db; ... because #include <stdio.h> struct iio_val_int_plus_micro { int integer; int micro; }; typedef iio_val_int_plus_micro iio_val_int_plus_micro_db; int main() { struct iio_val_int_plus_micro a = { .integer = 100, .micro = 10, }; struct iio_val_int_plus_micro_db b = { .integer = 20, .micro = 10, }; return 0; } won't compile. > This is better as explained above. > >> If you think it's better to add them all, I can do that, of course. Anyway, seeing that only struct iio_val_int_plus_micro is used at the moment, I believe the best path forward is to introduce only this struct and move on. Best regards, Michael >>>>> +struct iio_val_int_plus_nano { >>>>> + int val_int; >>>>> + int val_nano; >>>>> +}; >>>>> + >>>>> +struct iio_val_int_plus_micro_db { >>>>> + int val_int; >>>> >>>> int val_int_db; ? >>>> >>>>> + int val_micro_db; >>>>> +}; >>>> >>>> Actually why can't we simply do >>>> >>>> typedef iio_val_int_plus_micro_db iio_val_int_plus_micro; >>>> >>>> ? >
On Mon, Nov 28, 2022 at 02:48:48PM +0100, Michael Riesch wrote: > On 11/28/22 14:27, Andy Shevchenko wrote: > > On Mon, Nov 28, 2022 at 01:18:04PM +0100, Gerald Loacker wrote: > >> Am 25.11.2022 um 12:01 schrieb Andy Shevchenko: ... > > It's a rule to use _t for typedef:s in the kernel. That's why > > I suggested to leave struct definition and only typedef the same structures > > (existing) to new names (if needed). > > Andy, excuse our ignorance but we are not sure how this typedef approach > is supposed to look like... > > >> or > > > >> typedef iio_val_int_plus_micro iio_val_int_plus_micro_db; > > ... because > > #include <stdio.h> > > struct iio_val_int_plus_micro { > int integer; > int micro; > }; > > typedef iio_val_int_plus_micro iio_val_int_plus_micro_db; > > int main() > { > struct iio_val_int_plus_micro a = { .integer = 100, .micro = 10, }; > struct iio_val_int_plus_micro_db b = { .integer = 20, .micro = 10, }; > return 0; > } > > won't compile. I see. Thanks for pointing this out. Then the question is why do we need the two same structures with different names?
Hi Andy, On 11/28/22 15:05, Andy Shevchenko wrote: > On Mon, Nov 28, 2022 at 02:48:48PM +0100, Michael Riesch wrote: >> On 11/28/22 14:27, Andy Shevchenko wrote: >>> On Mon, Nov 28, 2022 at 01:18:04PM +0100, Gerald Loacker wrote: >>>> Am 25.11.2022 um 12:01 schrieb Andy Shevchenko: > > ... > >>> It's a rule to use _t for typedef:s in the kernel. That's why >>> I suggested to leave struct definition and only typedef the same structures >>> (existing) to new names (if needed). >> >> Andy, excuse our ignorance but we are not sure how this typedef approach >> is supposed to look like... >> >>>> or >>> >>>> typedef iio_val_int_plus_micro iio_val_int_plus_micro_db; >> >> ... because >> >> #include <stdio.h> >> >> struct iio_val_int_plus_micro { >> int integer; >> int micro; >> }; >> >> typedef iio_val_int_plus_micro iio_val_int_plus_micro_db; >> >> int main() >> { >> struct iio_val_int_plus_micro a = { .integer = 100, .micro = 10, }; >> struct iio_val_int_plus_micro_db b = { .integer = 20, .micro = 10, }; >> return 0; >> } >> >> won't compile. > > I see. Thanks for pointing this out. > > Then the question is why do we need the two same structures with different > names? Most probably we don't need "struct iio_val_int_plus_micro_db" at all since IIO_VAL_INT_PLUS_MICRO_DB and IIO_VAL_INT_PLUS_MICRO get the same treatment in industrialio-core.c. At least it should not be introduced in the scope of this series. In the end this is up to whoever writes the first driver using the common data structures and IIO_VAL_INT_PLUS_MICRO_DB. Best regards, Michael
On Mon, 28 Nov 2022 15:26:51 +0100 Michael Riesch <michael.riesch@wolfvision.net> wrote: > Hi Andy, > > On 11/28/22 15:05, Andy Shevchenko wrote: > > On Mon, Nov 28, 2022 at 02:48:48PM +0100, Michael Riesch wrote: > >> On 11/28/22 14:27, Andy Shevchenko wrote: > >>> On Mon, Nov 28, 2022 at 01:18:04PM +0100, Gerald Loacker wrote: > >>>> Am 25.11.2022 um 12:01 schrieb Andy Shevchenko: > > > > ... > > > >>> It's a rule to use _t for typedef:s in the kernel. That's why > >>> I suggested to leave struct definition and only typedef the same structures > >>> (existing) to new names (if needed). > >> > >> Andy, excuse our ignorance but we are not sure how this typedef approach > >> is supposed to look like... > >> > >>>> or > >>> > >>>> typedef iio_val_int_plus_micro iio_val_int_plus_micro_db; > >> > >> ... because > >> > >> #include <stdio.h> > >> > >> struct iio_val_int_plus_micro { > >> int integer; > >> int micro; > >> }; > >> > >> typedef iio_val_int_plus_micro iio_val_int_plus_micro_db; > >> > >> int main() > >> { > >> struct iio_val_int_plus_micro a = { .integer = 100, .micro = 10, }; > >> struct iio_val_int_plus_micro_db b = { .integer = 20, .micro = 10, }; > >> return 0; > >> } > >> > >> won't compile. > > > > I see. Thanks for pointing this out. > > > > Then the question is why do we need the two same structures with different > > names? > > Most probably we don't need "struct iio_val_int_plus_micro_db" at all > since IIO_VAL_INT_PLUS_MICRO_DB and IIO_VAL_INT_PLUS_MICRO get the same > treatment in industrialio-core.c. At least it should not be introduced > in the scope of this series. In the end this is up to whoever writes the > first driver using the common data structures and IIO_VAL_INT_PLUS_MICRO_DB. They get same treatment today because we don't attempt to deal with IIO_VAL_INT_PLUS_MICRO_DB in conjunction with any of the analog circuit type front ends yet. Mind you, even though the handling in iio-rescale.c will be different if anyone ever adds support for the DB form (I shudder at the maths of combining this with other scale factors), I don't see the possibility meaning we need a different structure. Jonathan > > Best regards, > Michael >
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index f0ec8a5e5a7a..eaf6727445a6 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -383,6 +383,21 @@ s64 iio_get_time_ns(const struct iio_dev *indio_dev); struct iio_trigger; /* forward declaration */ +struct iio_val_int_plus_micro { + int val_int; + int val_micro; +}; + +struct iio_val_int_plus_nano { + int val_int; + int val_nano; +}; + +struct iio_val_int_plus_micro_db { + int val_int; + int val_micro_db; +}; + /** * struct iio_info - constant information about device * @event_attrs: event control attributes