From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 882D7C433EF for ; Thu, 2 Jun 2022 14:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235667AbiFBOA2 (ORCPT ); Thu, 2 Jun 2022 10:00:28 -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-Google-Smtp-Source: ABdhPJxtpuBCKEOrj7yi3ocCsJZ0ETA3Lw0fV9RaebX5CwbyumoNpdxxmykaJXm5oH5aPRnpODJs/24H5iu7FWYfbjE= 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 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@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