Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp6574800ioo; Thu, 2 Jun 2022 09:09:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe24yOCVJBl2KesCIZwaecn7hyNKzp04ht2Nd2cWeY0WkykwZtP72PamyL25DWKuqQ4U0t X-Received: by 2002:aa7:c744:0:b0:42d:f68f:13de with SMTP id c4-20020aa7c744000000b0042df68f13demr6231802eds.294.1654186143194; Thu, 02 Jun 2022 09:09:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654186143; cv=none; d=google.com; s=arc-20160816; b=PYwL0qDj4YUh95Kt8cL8tSVgduLX10eVwV0p7eNQlzxLyU5Lb+e5aEBVw2mfasVe7d 7zTnRX3olGuLC9TZ9VumsWKoJ0ZvldylKcwGsZk8FkBjSvibSFPN39D5xJruJBs9Uzzx VPJXJoeFE2W95+9yU/WC6onfOtEpYevF909k7oOcGpteY/Hy84EKgYiJNN9rP7sVK8E/ Ir2uzoHF1CGrzWCe00AUMpYBqKcV21LcuodRR0EW65HlQaY2CYLH1rY7YZ+u7zJB90xz 5WRWg8s3OaBULOTfieK+cF/usCBWeySADmUM52Ve+vxTZ6WGeyZW8yoToob6d5IQBRQi aN8Q== 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=AYxq+mMduPBX5NXqRBF2+5IJjnwegK5vDcEeTyInUPU=; b=otqHqsKkJGfuxO7pJjWU/0lf8eg23zBqNXdCpiW5tbiM23Bensxr9s/z83nAT3HAxK 3UN+DEeXE7pnXknJC5L+gjXX09mYCvdV/qxkP3wCPR1clU6iI5WnDaeF+6rRWCsO6SlP O2kAuHBVokTUvtii6jbNNT++w8UkM3MVBGggRi1B+yZ6W+MQ0LFlI/mfCrH5b+kvEKx7 w4QvCmFdOyGnVVb0wjIU7lGx1pCi23GADm1A15kYI8YjTrsrTr4io895Q/gkFjUt73C5 0EFtHhnelPOADNcz7R/yonxo+QpbqJ0eBytXMzxH1Wvbj5ol4swipvC62IOymjSsmegC du+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=auP1KW3K; 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 w16-20020a170906131000b006f4326c816bsi4463778ejb.357.2022.06.02.09.08.35; Thu, 02 Jun 2022 09:09:03 -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=auP1KW3K; 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 S235687AbiFBOA3 (ORCPT + 99 others); Thu, 2 Jun 2022 10:00:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235643AbiFBOA1 (ORCPT ); Thu, 2 Jun 2022 10:00:27 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18AD5271781; Thu, 2 Jun 2022 07:00:26 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id f9so10254962ejc.0; Thu, 02 Jun 2022 07:00:26 -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=AYxq+mMduPBX5NXqRBF2+5IJjnwegK5vDcEeTyInUPU=; b=auP1KW3KeSmMw7VIZ62/gbLMAnB923JIROgeNcNM60iNfs70SRXGH9Oh+PqNAIdl95 sF3KgLrJAdhJvNL5E/yTCatacqFZTuJwNSgnwpd8r3nWCcjRXQOJQGh/LEv8L8WGwDHn GRMckxbpngc/1zSMfnGGQOEbWW1vqQbIAf/Fr7XQHihGGmhAIL+CXKz/Sx20mLoDFvK2 Mrq/lvN37tLRQTJChv3fW11X7HfKADxJn3lW1n7mcgkdAUHAPKZhMEZRqOIIvJS+CQJo E9+wli3/tU0/Qxnp7IRGppAp11D6KG1QpREaRpW+RGISetT3kVGuRq7qeRk42Hciw7Be LYwg== 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=AYxq+mMduPBX5NXqRBF2+5IJjnwegK5vDcEeTyInUPU=; b=ND6vo9TSDcon/FmEUjE+075JxG/6ovzx/dplStXFQ+KTdj+yLHnr9f2bum1FkOT6QG oTnhJbLJ654aRR8//t3d6Nuj9JOSjq+bQRbHyEkbgc3rcRkJcBvFbOJryiRxeWlqP6eC 9MV/dDkEe0ziWC+CMLSgisNfLOa4r45JVnOJi9NEwoZwVb+g2PFtwwj3OBG6jayL1TiL I9QzTvn+RiGuc91kDYdwic2yoRFit0rkF/Apwp7X+eILLFxqvLTOOXekzIlbIqaZB3Wb cnHYUnCa/OtF7wGfhSvt6N43PinmmuswWRcF404NnjEimncKk8OVkVm8nSUp9qu/hLjM f6Kw== X-Gm-Message-State: AOAM532TKGBJY+Ss51GOm90GYOOs8uwe5JUvEN5lnjmuMC0lKo/F1SlR Z4UofG7MOSLrh/iTM0EEoTIop/aumYUXFE6Gi/I= X-Received: by 2002:a17:907:8a27:b0:707:cc50:e790 with SMTP id sc39-20020a1709078a2700b00707cc50e790mr4462180ejc.77.1654178424506; Thu, 02 Jun 2022 07:00:24 -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:59:48 +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 3:57 PM Andy Shevchenko wrote: > 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 wro= te: ... > > > > + 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), st= r); > > > > + 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; Missed change const char *str =3D states[STATE_OFF]; --=20 With Best Regards, Andy Shevchenko