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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 563F5C433FE for ; Wed, 23 Nov 2022 13:50:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237619AbiKWNuK (ORCPT ); Wed, 23 Nov 2022 08:50:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237248AbiKWNtm (ORCPT ); Wed, 23 Nov 2022 08:49:42 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 861D59039D; Wed, 23 Nov 2022 05:40:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669210803; x=1700746803; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=9srsKAsm31l1dTbkfAVTNzSDO2Kf610A6JWSfuub0kk=; b=O8w2xloMEqmWt0Oi58sjwSLMJUVXFoFozTFcy8wRZAAYgq7tWXu1PQp0 3NVBC6PVGoxo+5xzXZaJmVTHFILwV0VW0wMPuyEIzZJIHl6ZJOIFfNgIz /NY184QqgbHvTMmsjN6J16AVKDfB83AmcED+ZzYgQ+RTwodf4XQpUarr/ oN9/1ESKpC+i2iIdbcjZIxWMpD/o4iq2mRXsrF8BqiEjQRlotM9Fku5Ap S3z4ha7l5L+en/hmJcBl2lx3MqcCOzKsTtKchvR4F0kKVLhyCoWmkZ/yy qy2zoN1kkdOqRVhZYcMoClHGwVfbUCT87WEtg8RNiXMZuRz0d3XLrmKz6 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="312766696" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="312766696" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 05:40:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="641799230" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="641799230" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga002.jf.intel.com with ESMTP; 23 Nov 2022 05:39:59 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1oxpyo-00GIsS-0d; Wed, 23 Nov 2022 15:39:58 +0200 Date: Wed, 23 Nov 2022 15:39:57 +0200 From: Andy Shevchenko To: Gerald Loacker Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Nikita Yushchenko , Jakob Hauser , Michael Riesch Subject: Re: [PATCH v2 2/2] iio: magnetometer: add ti tmag5273 driver Message-ID: References: <20221121123542.1322367-1-gerald.loacker@wolfvision.net> <20221121123542.1322367-3-gerald.loacker@wolfvision.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Wed, Nov 23, 2022 at 10:58:47AM +0100, Gerald Loacker wrote: > Am 21.11.2022 um 15:04 schrieb Andy Shevchenko: > > On Mon, Nov 21, 2022 at 01:35:42PM +0100, Gerald Loacker wrote: ... > >> +static const struct { > >> + unsigned int scale_int; > >> + unsigned int scale_micro; > > > > Can we have a separate patch to define this one eventually in the (one of) IIO > > generic headers? It's a bit pity that every new driver seems to reinvent the > > wheel. > > > >> +} tmag5273_scale_table[4][2] = { > >> + { { 0, 0 }, { 0, 0 } }, > >> + { { 0, 12200 }, { 0, 24400 } }, > >> + { { 0, 40600 }, { 0, 81200 } }, > >> + { { 0, 0 }, { 0, 0 } }, > >> +}; > > > > I'm thinking of defining structs for all similar types of IIO output > formats in iio.h like this: > > > 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_val_fractional { > int dividend; > int divisor; > }; This one... > struct iio_val_fractional_log2 { > int dividend; > int divisor; > }; ...and this one repeat struct s32_fract (or u32_fract, whatever suits better). > Do you agree? Me, yes, but you need a blessing by maintainers of IIO. -- With Best Regards, Andy Shevchenko