Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp902562rwb; Thu, 18 Aug 2022 14:32:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR4L0Asw3T3bm9++lDxOriYoVk3Qw5AMvjFw5BLUQFbeZ1UGC1fFKszSvXkU7VV0vNVcNfdw X-Received: by 2002:aa7:d0d1:0:b0:445:e46f:3703 with SMTP id u17-20020aa7d0d1000000b00445e46f3703mr3739961edo.55.1660858322037; Thu, 18 Aug 2022 14:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660858322; cv=none; d=google.com; s=arc-20160816; b=EyM2M43hxmzPKeTlgjGTFEHAm2C6DoAD07ho/493KHtqJawZJM9FctX9Mm6itiLDke l+Smh+V8ICFRdRJOoxUaK/QYPDM/iwlbB6TdQUsa0yPl1qhQoYWBDQ/pTXpUlqC7mn1W QD9k/fG7fXOhSjstD3A12VKLarEUwJxmzwUW26GcjHc1wgdUEp4v/vAbT2o2cOWChFmQ 2apaiKWzpsNv36SOcdGXgzVgcZV9hh4T0yZ8FnD3wAwby+KOb02JEf27FDz+huKnTtyJ sly0hLdkyPzt4g+7MzsZ1jGaYQzmy20hy6L4gA6DRMoMDY117Mxm7kZdugKj+WAIugJ8 z6Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=uVnop+y6LkvhGoNmEB83d5x0Yo/TCr48nPsOM7D1YFs=; b=P+yTnBOXpuys5H8ArsZ4eJKtZdJIxliAnq2WAi9yk0As38YQo+h7Xw7AqF6PSxu2XJ g3pSX1GyPPzABtAAQdjSXpbLBsRmwixj93/9uNjvONZJ2aDJ3fB+OF9iYgQmlx8JErSE JXgM3APJgkLw0wJ/MV94t4Rwc+lgcNgvWVf47lBuFR8rxj+SQ2O2/SU2ERjLinElOnHo khHmUwqLsMRIRKodfwpkluTYHO7h/AwZSuGYc6wSexSeQNz0OtHlC0evlmihxO/9hWBR DUOJYKa6qkn5unnNiU3EM00FFJWzkU04m+dJ61gEhN6Aekf+6evjSDwuBXkQmQHaDvSS lMgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ioOoH70n; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb3-20020a1709076d8300b007309b0ab2b4si1760501ejc.518.2022.08.18.14.31.36; Thu, 18 Aug 2022 14:32:02 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=ioOoH70n; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244178AbiHRURi (ORCPT + 99 others); Thu, 18 Aug 2022 16:17:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237465AbiHRURd (ORCPT ); Thu, 18 Aug 2022 16:17:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EA6CDC4 for ; Thu, 18 Aug 2022 13:17:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9881961499 for ; Thu, 18 Aug 2022 20:17:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 388FDC433D6; Thu, 18 Aug 2022 20:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660853852; bh=dTnWbyCxLymb2y1IHt7bcbwYUVC/MlbgC6SiikPfI7w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ioOoH70nKp3OLMN+CcodyBGS+0qN5EyYBBGsWnNQurWVhGhj9POL1hxSojRT/aChR R8QCX9ToM2NQffQJ2JcoQ/4L8IYb0BRTCpz7f13XfZqdyrlR/cEqKJ6eJr1wpNdngB f5cB+gPsJofCD8C2tDtCUBYnHlvZG8NcIFBawrCAYeFdRjWbyukWWLcCOxFNFbDyN0 qP7fc4kmrmO6UXSw/MTnxdd1uB3n2PBuqZctp225J1HNEUyvK3V3IreWX+CvRibhLQ WvdC0HgutL9lRJ2DeV8KRkXhk48CtHXDOnylONvS2KS7iri3l5ZEF1wF7FFhE5yo9n vmiGU6boi2RcA== Date: Thu, 18 Aug 2022 22:17:25 +0200 From: Marek =?UTF-8?B?QmVow7pu?= To: Andy Shevchenko Cc: Vinod Koul , Kishon Vijay Abraham I , Linux Phy , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Gregory Clement , Kees Cook , Linux Kernel Mailing List , Pali =?UTF-8?B?Um9o?= =?UTF-8?B?w6Fy?= , josef.schlehofer@nic.cz Subject: Re: [PATCH linux-phy v2 2/4] device property: Add {fwnode/device}_get_tx_p2p_amplitude() Message-ID: <20220818221725.0601efa6@thinkpad> In-Reply-To: References: <20220817200335.911-1-kabel@kernel.org> <20220817200335.911-3-kabel@kernel.org> <20220818214137.29ccb13a@thinkpad> X-Mailer: Claws Mail 3.19.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 Aug 2022 23:10:09 +0300 Andy Shevchenko wrote: > Yes, I have no objection to put it there, just that the above > justification doesn't allow it to be in the generic code (yes, we may > still have some awkward APIs in the property.c and ideally they should > be moved to the respective subsystems). OK > > > You may count the values and read them all, > > > > What do you mean? Count the values and read them all via one > > call to fwnode_property_string_array_count() ? > > No, you obviously may not read them via string_array APIs, esp. one > that is related to counting. > > Count the vals first, read them all (it seems you need it in all > branches of your flow). Then count names and compare them to the > number of values, and so on... Also try to assign "default" only once. 1. there is one branch where I don't need to read the values: when the "-names" property does not exist, the DT binding documentation says that the value property should only contain one value, the default one. So in that case I early return return fwnode_property_read_u32(fwnode, vals_prop, amplitude); 2. I thought that I shouldn't check whether the size of the "tx-p2p-microvolt-names" array is equal to the size of "tx-p2p-microvolt". Rob Herring says (if I understand correctly) that kernel shouldn't validate device-tree, that we have dt-schema for that... Marek