Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp6727883ioo; Thu, 2 Jun 2022 12:22:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYGY8L20y8MT/w3h1IHFAAK7VHK+Rk1aZE1ZrBgHrDvfZQufOL+WJAXgEgH8TF43Oc9LE9 X-Received: by 2002:a05:6402:354f:b0:42e:1f02:1379 with SMTP id f15-20020a056402354f00b0042e1f021379mr3301830edd.401.1654197741721; Thu, 02 Jun 2022 12:22:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654197741; cv=none; d=google.com; s=arc-20160816; b=EKNbICp8qLOpLSDmIaa5XtHWuX0vLo3jw136QsYpLxPabkXFlC0HQkAm/F49YsoUXX oq4d9JIGMY8i4ffLMzC7r08WLaX8bQrtSiBouERyzySu4AHHPUZqaSg0a6U+1j9AQ/tV TFyblzyb/E+6kyot+Fw9DMh38ZTLMikb+9lgj1Zp5taJjpm1nlQbd22MuBoLn5Y4Vnlq 59FTsU9jSKynm8glrKuyckcu2Qm0mnR5bmIMBVrsjdeCTeMxzRloGqNs98yJHNdZdqFb oyzD1wY43MM9Xxs2m8c+NP/rHIo/I6TrCZ+Hote6SBthfR4G2OskmcJcaCXOV3YJSocM IhYQ== 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 :dkim-signature; bh=lCjXd1DtLAOiKDUVepuP3tVKlqmoM9phz1lypZW4eiM=; b=FJ98IX+ZlwaNX2ua7dMyQb9EIv7+KOy5c0Dsl5UtUPK4SZ3xlZF2jrFJml5Gv1p9sU HClDoDJ4bbgNFpd5D6pBEJIReOgm61WvGDYJ1mAZyXGRFkLdqV1toF7KmwG/WKvIKqm7 blg91dT8oKoQCy1RNP1+l9EQDczwew8IvL7DK6xQBoQXvTy+wUME3QsX/3deIyg9NYdo qVME4DqzlftegtaUoBF6uFvpkS19E/40dIR5Dn249Z48E93pNowOCaI1nV2frh7EnN55 B8N9Rq3v7pN2iq3DCnUJJTltu/IoZLNREppEnPQwV8wtmdQyIaMpYmAP6u8EyaDX26S4 0DOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eKXUR7ki; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a056402278600b0042b756321f5si6466839ede.104.2022.06.02.12.21.56; Thu, 02 Jun 2022 12:22:21 -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=@gmail.com header.s=20210112 header.b=eKXUR7ki; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235207AbiFBN6E (ORCPT + 99 others); Thu, 2 Jun 2022 09:58:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231286AbiFBN6A (ORCPT ); Thu, 2 Jun 2022 09:58:00 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DAD0793B2; Thu, 2 Jun 2022 06:57:58 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id n10so10158719ejk.5; Thu, 02 Jun 2022 06:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=lCjXd1DtLAOiKDUVepuP3tVKlqmoM9phz1lypZW4eiM=; b=eKXUR7kiBU80Kt1ivUsBYC1Vp5ABsZgOFlwcUTfYnL3EYaoBLLC4llE6qNCbLYkoPK yV/E9DUt2ifgfA2Nbk6ykWpgQhfm9txSuz+Z9LmYA2e0QtK14BpQdaIg86EMFNfuUWkx hMXNoGeRpp7Hw5ALo7uCiIN/Vg+bFN+64MnxIrSs4784P1udBgejLUQnnHasBXCy/VJv Hraq92Husrz3Xf7aLdubPKJuxySVXpGPA0CZZLKoHOr29+EvAoDaQOSqIfuA/pA2wdFl oxnZHqbsTfLFBaxgW2BGhnhwkC0uMC12x04YUFSe3zvFWWisWKPD/j9A/tTeJZTOCSWO kQFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=lCjXd1DtLAOiKDUVepuP3tVKlqmoM9phz1lypZW4eiM=; b=NWuso4ZzJ2XIOREiQvXrUw/xeTo07Z3fHySVFA9TDeKu07xHWPceLUwXEDFYALRl0S uaeG7QzPp1TeVgLicOtPL8nwiXYTN3cgFBJrLk69g/Mx7HPVHkUb7rNoEPXj1qvDL4nv oJaMJPPL/vAxZkKZv3B4ffi8V0TmuCV2SdURfhKLPZ/qGDXIes5HimrFntNNtz13e5zM rkFSzx1v5Og1dZIrjRBTGpLPyUiVgR4nbuJehcnrg/yNqwr2SL18Vmvxwhr4yPzsD0u8 Y6QD6XDuj+bMSIQSRzwDVROxrZl4VAPwwt/izuS1JBcd5cAxpsi+DVO7mGdbD+ccmghI yLwg== X-Gm-Message-State: AOAM5316Gy/jrnPFisdF0TmIb9D8QZ3WQg76+w3E9C+Cel0YmpXYq7K+ tOdhpMRUbSgymgoHxR4FF/WmYF9ZwQ9AeQW+Rb0= X-Received: by 2002:a17:907:6e04:b0:6f4:d6f3:c72a with SMTP id sd4-20020a1709076e0400b006f4d6f3c72amr4545345ejc.636.1654178277156; Thu, 02 Jun 2022 06:57:57 -0700 (PDT) MIME-Version: 1.0 References: <20220531102809.11976-1-peterwu.pub@gmail.com> <20220531102809.11976-8-peterwu.pub@gmail.com> In-Reply-To: From: Andy Shevchenko Date: Thu, 2 Jun 2022 15:57:19 +0200 Message-ID: Subject: Re: [PATCH 07/14] leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support To: szuni chen Cc: ChiaEn Wu , Lee Jones , Daniel Thompson , Jingoo Han , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Matthias Brugger , Sebastian Reichel , Chunfeng Yun , Greg Kroah-Hartman , Jonathan Cameron , Lars-Peter Clausen , Liam Girdwood , Mark Brown , Guenter Roeck , "Krogerus, Heikki" , Helge Deller , cy_huang@richtek.com, alice_chen@richtek.com, chiaen_wu@richtek.com, dri-devel , Linux LED Subsystem , devicetree , linux-arm Mailing List , "moderated list:ARM/Mediatek SoC support" , Linux Kernel Mailing List , Linux PM , USB , linux-iio , "open list:FRAMEBUFFER LAYER" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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, Jun 2, 2022 at 2:07 PM szuni chen wrote: > Andy Shevchenko =E6=96=BC 2022=E5=B9=B46=E6= =9C=881=E6=97=A5 =E9=80=B1=E4=B8=89 =E4=B8=8B=E5=8D=885:57=E5=AF=AB=E9=81= =93=EF=BC=9A > > On Tue, May 31, 2022 at 1:32 PM ChiaEn Wu wrote= : ... > > > + const char * const states[] =3D { "off", "keep", "on" }; > > > + const char *str; > > > + int ret; > > > + > > > + if (!fwnode_property_read_string(init_data->fwnode, > > > + "default-state", &str)) { > > > + ret =3D match_string(states, ARRAY_SIZE(states), str)= ; > > > + if (ret < 0) > > > + ret =3D STATE_OFF; > > > + > > > + led->default_state =3D ret; > > > + } > > > > fwnode_property_match_string()? > Sorry, but I think the use of this function is different from my target. > I want to read the string of the "default-state" property and figure > out if the string is in the states array. > But the fwnode_property_match_string aimed to figure out if the state > in the property array. > One is a property array and another one is a state array. Ah, indeed. Nevertheless you may reduce the code base by doing like the following (I wonder what your code do if there is no default-state property): led->default_state =3D STATE_OFF; // it's by default off since kzalloc(), so I don't see why we need this line at all. fwnode_property_read_string(init_data->fwnode, "default-state", &str); ret =3D match_string(states, ARRAY_SIZE(states), str); if (ret >=3D 0) led->default_state =3D ret; --=20 With Best Regards, Andy Shevchenko