From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EED9835AC00 for ; Mon, 13 Jul 2026 19:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783971633; cv=none; b=jCnFNBIDfX5ueAYSXNh644lgq7ZfvBds6Bqm94y2OrXzFBpW2HF+dxtIMKoHph2Ph3MD86O3NZyANUUpWLSOANUo85sU8GS66DcObSxJrbsY5DFMr6nZsuzTaVZ6dsPrdf+XfjBs7byDRT8HE2WVECwRYL8QA9XtI11qcDaIU2A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783971633; c=relaxed/simple; bh=OzNlGnYi9Q21pWLQDCHdgjEM5JLFkymdE6BoRXE4Svo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Rx0J+MV/q0/muU5+ROUgrrAS5Yctq+m15hULef9es1KUBnFfwulmfKj3lqzAaFn4Hp65XjYoV3ed/UDOXfX+9bChusnFY4kUHK1Wi9PyfNcALM8rSfnqYGRxu1N2KVVjV99ZQ9A3m7DCIj8wBPNBbo7IH22bI8eQDcjN1AAlLmE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b=ZUEuJUZW; arc=none smtp.client-ip=209.85.210.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre.com header.i=@baylibre.com header.b="ZUEuJUZW" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-7e9f829d75aso207448a34.0 for ; Mon, 13 Jul 2026 12:40:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre.com; s=google; t=1783971630; x=1784576430; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YzkRgDINkoy1AhrvZYmCykpgao/Mcghq5LHWpOQp6yw=; b=ZUEuJUZWQUzblZNkOdz64PLXhQGw5g5RLbOzvnruxFNMSbc/cf14VeLfixWEhD2JkD EZD6C9SPLzlDt/F7se6xqWwwLIQUBhChmx4lIx4p1K84HcWOSk398L/GhWqMGDxR54KX qfX8qtsirEdeQtiJ3iq6nVByOZ9tpab2wAdCJmhj0AJgUQfbpSMmlxCXFR89o7L7Acrw PIoshaq1VVHo22HyY15O++xRJDqGqLp0v82LZn8DB2AuiVYSzLj88GBo7rCAFkmgqlF8 GM2L8c7hyY358BmsDknq1eybNsLtDntdFEcshfczpEnEPP+Kf4yvX/AD2JxA+KLFGAY/ WApQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783971630; x=1784576430; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YzkRgDINkoy1AhrvZYmCykpgao/Mcghq5LHWpOQp6yw=; b=RPqjlkKSCHuYOTBe5kIa9LpYsTZx4YkhAAwFXeof63o6XOy7j4RD0ZBwXh8hpV0lgG diqBHx3LonwAa2Qn9JAVefLYewDo9+Atkaeo0w6lVWh+kLbKYKssrszhSMCr7ULJbOBm x8hg3Ym6vlH66bgf7VjRhuWQzJKMdeYbjL+zXNp7OJPGJn1rNk7pt+IxokkGG/vFavKp itFF7SBmvFLGEdeKIGIUTmjXHnrScZM2KxbhpklR8Mj0HN9UXfS6D6ew76Gr1xzPrA84 IS0UjFMKT+kYMbZ5cUYuRiT8Qj98bRFeWfi7wPQ+a/QZNSlME1TVQUYddd/gvH8r1Ty0 X65w== X-Forwarded-Encrypted: i=1; AFNElJ9EsxbRbRAAQKdjZyAnl2ZbQ6dQOT2fx6nxR1j5/0MrIO3Hhl6JMfZFYvMMDZYZwdOWNXblYMTvMxMEQLk=@vger.kernel.org X-Gm-Message-State: AOJu0YwsUPJt1KZpPii3TfcBZscxk0L4rmqiNp5hXmQyZacAzeFajcZH 6jwVmBjPCxmtu2Y7nng+VlYOGV6kD1cZQYFRdr1nfSg5e3AG1i0i9nnrB0rvDsNNd2g= X-Gm-Gg: AfdE7cl65Y45XIc6j4Nh2GfLLTZwFb/aqgwgaZ0iu/v0CNZI8KSlpoHgOO8jpPOTNti 7hyqxLU/PQ6MybGwvLUeEKTU2y7/wXERs3nBZUFFPecp9H8zi7vXUd1KFG680DZI6+X9eY9cxAh pvGTkZ807PJKNbgNdZDN7VvF5ewGS9ar95HkcToSHUv4MwCzzL2tYE8zUfgAJFHyEiyVcNUBsqW UmCjw5PNNSSGTOoQ8/WLVdc/nQF0qs/48JIHw45BO6Cy5y10+CDofJvPkSN/ovNdn1hbjEZSIom PHYdj0PGa8TBijSdPEmIf7LI58ZvZeHzAFFbSYRSPowQFN6PaIVrML2lN6R87ybzRqIPSRz2iTB GD7Ga54uD83HGi8x3DBN1o7bWOj+ab598BgoQ2/2Q7K4rmUot6MXMc8Te3O8hHdYxBofG7CrSfQ +uBeRyvmo1VmE3Kp9kWcknAX3LgGCpphhyKJgl5T+PMzXeIbJzIhbhoiDaKyu0zEk= X-Received: by 2002:a05:6830:67e3:b0:7e9:f1f2:720c with SMTP id 46e09a7af769-7ec098b0a19mr6684100a34.32.1783971629759; Mon, 13 Jul 2026 12:40:29 -0700 (PDT) Received: from ?IPV6:2600:8803:e7e4:500:610b:e45c:5e0c:e14b? ([2600:8803:e7e4:500:610b:e45c:5e0c:e14b]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7ebcaf73c87sm14018192a34.7.2026.07.13.12.40.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jul 2026 12:40:28 -0700 (PDT) Message-ID: Date: Mon, 13 Jul 2026 14:40:27 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 8/8] iio: adc: ti-ads112c14: add measurement channel support To: Andy Shevchenko Cc: Jonathan Cameron , =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chris Hall , Patrick Edwards , Kurt Borja , Nguyen Minh Tien , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260710-iio-adc-ti-ads122c14-v3-0-746d52cbf1d0@baylibre.com> <20260710-iio-adc-ti-ads122c14-v3-8-746d52cbf1d0@baylibre.com> Content-Language: en-US From: David Lechner In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 7/11/26 8:00 AM, Andy Shevchenko wrote: > On Fri, Jul 10, 2026 at 05:50:41PM -0500, David Lechner (TI) wrote: >> Add support for parsing devicetree properties for measurement channels >> and doing direct reads on these. >> >> There are quite a lot of conditions that have to be met for each >> measurement to be made, so quite a bit of state and algorithms are >> required to handle it. >> >> Channels are created dynamically since the number of possibilities is >> unreasonably large. > > ... > >> +struct ads112c14_measurement { >> + const char *label; >> + u32 vref_source; >> + u8 iunit; >> + u8 idac1_mag; >> + u8 idac2_mag; >> + u8 idac1_mux; >> + u8 idac2_mux; > > I would group this slightly differently: > > u8 idac1_mag; > u8 idac2_mag; > u8 idac1_mux; > u8 idac2_mux; > u8 iunit; > > I haven't seen the code, but names suggest that most likely one would read > *[12] together or close enough, and less probably mixed with 'iunit' reads. > Current layout might lead to interesting code generation complications on > the unaligned-intolerable architectures. iunit is scaling factor for *_mag, so logically gets grouped with those. (These are all datasheet register field names.) > >> + u8 iadc_count; >> + u8 gain_val; >> + u8 burnout; >> + bool global_chop; >> + bool bipolar; > >> + s64 scale_available[ARRAY_SIZE(ads112c14_pga_gains_x10)]; > > Also this can be moved upper, but I think it won't save any bytes in this > layout. > >> +}; > > ... > >> struct ads112c14_data { >> const struct ads112c14_chip_info *chip_info; >> struct regmap *regmap; >> + u32 avdd_uV; >> + u32 ext_ref_uV; > >> + bool refp_is_avdd; >> + bool refn_is_gnd; > > Here is a definite gain in memory if booleans combined with u8 below > >> + u32 ext_ref_ohms; >> + struct ads112c14_measurement *measurements; >> + u32 num_measurements; > > Something like > > struct ads112c14_measurement *measurements; > u32 num_measurements; > u32 avdd_uV; > u32 ext_ref_uV; > u32 ext_ref_ohms; > bool refp_is_avdd; > bool refn_is_gnd; > > ? (Don't forget to run `pahole`.) We've had the discussion before [1]. I don't think it is worth the effort for structs that only get used once and doesn't have performance implications. [1]: https://lore.kernel.org/linux-iio/20240318124041.0000032d@Huawei.com/ > >> u8 sys_mon_chan_short_gain_val; >> s64 sys_mon_chan_short_scale_available[ARRAY_SIZE(ads112c14_pga_gains_x10)]; >> }; >