Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3404927rdg; Tue, 17 Oct 2023 13:46:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfP9uVJwcdsN2XuCXLY6SJhpwH/14w15wWtcgwt4Oy/8FUZVn9YxesD4MgoaMv63T2lfWi X-Received: by 2002:a05:6e02:1ba4:b0:351:59db:a20e with SMTP id n4-20020a056e021ba400b0035159dba20emr4390788ili.18.1697575587261; Tue, 17 Oct 2023 13:46:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697575587; cv=none; d=google.com; s=arc-20160816; b=0hAZdg6ymKXAX3lrfzcdu2iUv8HZJ0Rmubtn9eF45v7xcEdp/Sg/WMBEEhcKwyLqJb WNxC1FuBz557wd3XNSasILWQC88QnmURm4XggzokFO8War2XqVkQCJZcWb8RT2wvhLAz Wr9CpZPUUF7+oMvbvP/fHH1+pg44sPkC3dFXarjTTdrfTg0YT6pfX74lD0EHo1eN5f42 yHgrZo5ZAYvEx0Ji1xuahnk0HZXw5GZ9I+4MEvHeHEAmBJvt9xOWZdKD9YRHtPfM0C2x rREzhPv8KuewJsKtgJz5m1UL7bXVDaiqrz/qP753JH3mBXAL8rO7P8DL0UIOzxXYhRYu urxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=LBDv6AVI4OeoN5+cxp+MMyefh2z1isigCp9CICMiJDs=; fh=Sqf9jGJRjHe81c+9OIbMbiMBNeRRLhs6HVUwlbMktfs=; b=dhkc+ze8wrlRvRdnqQyA8uDYgOtnfKFzqLigdNZ4BKfLI5+T+4kzz1MeeVctuju2pm 8Y2eCJ6H+oBXYmC3NcTmdH4EPxkdyzvcBHzcaoKvI9juxlgu0ra/D8YE1ixN/jvUd8wi j5z0ZWpoEVyRaP8bv+7Lst16xCA9P/pj54/QSMbAXST4gBDEmybt29KeJIt/+3zMc/U/ RU2md5OqAZka+jI0jPGe5P9ui3+Gp+VAATjuvfjmfAABD+p8mvpzr7rw6PnIzYR0BIBd QmKBtDCkM367wV5s7AXrbTdsRV5bYrsuZezfrCouMw4drcgeWg1qMC4KBS5Al+5jGBa/ sdkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id j1-20020a056a00130100b006be1c26af7dsi2448685pfu.236.2023.10.17.13.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 13:46:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 76BE280293DD; Tue, 17 Oct 2023 13:46:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344275AbjJQUp7 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 17 Oct 2023 16:45:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344198AbjJQTTo (ORCPT ); Tue, 17 Oct 2023 15:19:44 -0400 Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 824F5F9; Tue, 17 Oct 2023 12:19:42 -0700 (PDT) Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-581e106fd25so127545eaf.0; Tue, 17 Oct 2023 12:19:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697570381; x=1698175181; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o7ieEvfyHQY7ULuaED1WrfSZ5wAczggZiEh44Iol3Mg=; b=V6RDkGVr1oElsuHIr2MuhX2JvF0c+/qhsqHaMRUDpNlFHVozAd0AiORTjnbmfpRnsk lQ0u5EdS2qnNJRAQ0/BaC28klJl0CfiHNgTnPM3yRgav7VeR17MOKEVjmOIKW6i1gCvm 9Jfxv6ZNMwCzNcJPoRG2Hgq1Ix3b5E5VCjCrYzwYsMG6euFyv/L2BSey17C6mDUlekfx 7FLFJZMYLVirxY+BejXGH3kwMlydiZNOOK3wZhkQjlQOz30RflU1hG6OSHTbM4Jm7ijc nlDzMe5UM/386nzMM0W8iyRl1Jertz42GbRRVwtfo1f3RDp/4QWE0u0+tPCeToaa8Rbi 8BGA== X-Gm-Message-State: AOJu0YwGoZH1+SIMJHJ35CmIdUnKRzfTX1PGHrWF3i4Kq2gwYbaNvF0X RGDxkCWD6HybumfsOa5tYlkpmzhVX1BDubDPCv4= X-Received: by 2002:a4a:e60d:0:b0:57b:7e31:c12 with SMTP id f13-20020a4ae60d000000b0057b7e310c12mr3522279oot.1.1697570381480; Tue, 17 Oct 2023 12:19:41 -0700 (PDT) MIME-Version: 1.0 References: <20230808162800.61651-1-andriy.shevchenko@linux.intel.com> <20230808162800.61651-3-andriy.shevchenko@linux.intel.com> <20230809185944.1ae78e34@jic23-huawei> <20230828190101.50f70921@jic23-huawei> In-Reply-To: <20230828190101.50f70921@jic23-huawei> From: "Rafael J. Wysocki" Date: Tue, 17 Oct 2023 21:19:30 +0200 Message-ID: Subject: Re: [PATCH v1 2/6] device property: Add fwnode_property_match_property_string() To: Jonathan Cameron Cc: Andy Shevchenko , Greg Kroah-Hartman , Antoniu Miclaus , Jonathan Cameron , Gerald Loacker , Gwendal Grignou , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Lars-Peter Clausen , Michael Hennerich Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 17 Oct 2023 13:46:23 -0700 (PDT) On Mon, Aug 28, 2023 at 8:00 PM Jonathan Cameron wrote: > > On Thu, 10 Aug 2023 16:26:54 +0300 > Andy Shevchenko wrote: > > > On Wed, Aug 09, 2023 at 06:59:44PM +0100, Jonathan Cameron wrote: > > > On Tue, 8 Aug 2023 19:27:56 +0300 > > > Andy Shevchenko wrote: > > > > ... > > > > > > +int fwnode_property_match_property_string(const struct fwnode_handle *fwnode, > > > > + const char *propname, const char * const *array, size_t n) > > > > > > Hi Andy, > > > > > > Whilst I'm not 100% sold on adding ever increasing complexity to what we > > > match, this one feels like a common enough thing to be worth providing. > > > > Yep, that's why I considered it's good to add (and because of new comers). > > > > > Looking at the usecases I wonder if it would be better to pass in > > > an unsigned int *ret which is only updated on a match? > > > > So the question is here are we going to match (pun intended) the prototype to > > the device_property_match*() family of functions or to device_property_read_*() > > one. If the latter, this has to be renamed, but then it probably will contradict > > the semantics as we are _matching_ against something and not just _reading_ > > something. > > > > That said, do you agree that current implementation is (slightly) better from > > these aspects? Anyway, look at the below. > > > > > That way the common properties approach of not checking the return value > > > if we have an optional property would apply. > > > > > > e.g. patch 3 > > > > Only? > I didn't look further :) > > > > > > would end up with a block that looks like: > > > > > > st->input_mode = ADMV1014_IQ_MODE; > > > device_property_match_property_string(&spi->dev, "adi,input-mode", > > > input_mode_names, > > > ARRAY_SIZE(input_mode_names), > > > &st->input_mode); > > > > > > Only neat and tidy if the thing being optionally read into is an unsigned int > > > though (otherwise you still need a local variable) > > > > We also can have a hybrid variant, returning in both sides > > > > int device_property_match_property_string(..., size_t *index) > > { > > if (index) > > *index = ret; > > return ret; > > } > > > > (also note the correct return type as it has to match to @n). > > > > Would it be still okay or too over engineered? > > > Probably over engineered.... > > Lets stick to what you have. If various firmware folk are happy with > the new function that's fine by me. Rafael? Sorry for the delay, I've lost track of this. Honestly, I have no strong opinion, but I think that this is going to reduce some code duplication which is a valid purpose, so please feel free to add Acked-by: Rafael J. Wysocki to this patch. Thanks!