Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11828075rwl; Tue, 3 Jan 2023 05:26:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXv97twYM5S6GNJT9R3qT5S8trT1D7O0qghwnyfELFz1CkIP7Er2eXgiTxG/vJjUhfarzZiP X-Received: by 2002:a62:ea01:0:b0:582:bbc7:c61e with SMTP id t1-20020a62ea01000000b00582bbc7c61emr1802240pfh.11.1672752406968; Tue, 03 Jan 2023 05:26:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672752406; cv=none; d=google.com; s=arc-20160816; b=mHwVzjfLVepJXeotbK15AV4WQPJ40VvZHyMxC6MDzS1TI2lz0mM4hVtKwPR9Dt5Xyz qsTen/SQ/nSF/4c2eBowNUvKGswYSthz23k01EjpvBd2+Ady+YM3M2RXAexvnAyW4QO9 iFL2FJSsovAVQlCjnyT/tzqM4PUOmh4dRjja8RnZdfwV1MPvIibqO9PkUga3ufou35Fn 4OMbsSitL0ckrJaW8huMYWVIKzcYbRQOA+f7wE0cFSNzitk+/SQSlsFxgRpn5b2pBuSt IB7vyWcuKm3t/GLTqImfoXH0eOYaqLLCvEPg8gJkDLoqO6Ub1BUIg5PAM+/Q+NNj9Czq FYig== 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:date:subject:cc:to:from :dkim-signature; bh=whtg+X8APOE7axzskbilEU6qOgpVAHq4XkJqOAxAWVA=; b=V1TXiKe8giF+/7qKUq4wQbug4x1QfUpC5nEx+lnTl6VwuJNXmAp5cBShtXvypvGz1B WYRMhmJmpNJ+pcnFEYdUMkYPK056pc9pU04DuexaJy2JMv3wZnD2AferYUzsrDM3WzgF PrN9IsDWZqWsnj97d2+Sbh5FoLMPvvY86a/x5gvu34hztXSOfGGOQh+owNQz1hUZri/2 S2nnoqHxoF/q1JaljLXuZOblAr22b98VdozaJR5lRm4OyGAAZkq2r+XYagYkr0dhHG51 ku3TKpnQhO9ya/AuqWHgDnMnV39/WHi1OdSBTzNjaUbb6xPoqjuLi3GDFrfCodix5Fgf DXZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Swr37CLj; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t40-20020a056a0013a800b0056cd91516b6si11159824pfg.325.2023.01.03.05.26.39; Tue, 03 Jan 2023 05:26:46 -0800 (PST) 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=@intel.com header.s=Intel header.b=Swr37CLj; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237699AbjACNMk (ORCPT + 60 others); Tue, 3 Jan 2023 08:12:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233197AbjACNMf (ORCPT ); Tue, 3 Jan 2023 08:12:35 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9438FFAF4; Tue, 3 Jan 2023 05:12:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751554; x=1704287554; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2vu7l/6K0nvkzNmUjyptRlngyguT+RoN4sYZnyNxAgU=; b=Swr37CLj2gh1BsOP9p5cf1C484uGxngOH57/mgOpKpilAQKS1YFXs1Bs 0ObO9JcQVrQRJ7JKS+4171kNy05X0JDL6792qxriiEZGg/9yvhmoZ7//J bFu2jKsyTO3/3CDdERqxQIN7SKRC4usiB9o7ODkvKMp/Ia2C9mT1+8mmp Ja6b64A8xZRAX/MeVIWhnp72MgmcFGXu3mERgV1YGRFDaYE8fPWCMV3Ct kbIqFhHm6WnmQhjyzBb6PZ8sjYS9yUMJIFPfOlqjihlTxN6b2os6O9s4L /RgfcYO363IPmYwW1Y1erlNI6MFWWytRD5vdL5FzqkJ67hudyLCkmeLsy A==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="320367246" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="320367246" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="654781131" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="654781131" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 03 Jan 2023 05:12:28 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 91CA1220; Tue, 3 Jan 2023 15:13:00 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Gene Chen , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Pavel Machek , Lee Jones , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v4 03/11] leds: an30259a: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:48 +0200 Message-Id: <20230103131256.33894-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> References: <20230103131256.33894-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 LED core provides a helper to parse default state from firmware node. Use it instead of custom implementation. Signed-off-by: Andy Shevchenko --- drivers/leds/leds-an30259a.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/leds/leds-an30259a.c b/drivers/leds/leds-an30259a.c index e072ee5409f7..89df267853a9 100644 --- a/drivers/leds/leds-an30259a.c +++ b/drivers/leds/leds-an30259a.c @@ -55,10 +55,6 @@ #define AN30259A_NAME "an30259a" -#define STATE_OFF 0 -#define STATE_KEEP 1 -#define STATE_ON 2 - struct an30259a; struct an30259a_led { @@ -66,7 +62,7 @@ struct an30259a_led { struct fwnode_handle *fwnode; struct led_classdev cdev; u32 num; - u32 default_state; + enum led_default_state default_state; bool sloping; }; @@ -205,7 +201,6 @@ static int an30259a_dt_init(struct i2c_client *client, struct device_node *np = dev_of_node(&client->dev), *child; int count, ret; int i = 0; - const char *str; struct an30259a_led *led; count = of_get_available_child_count(np); @@ -228,15 +223,7 @@ static int an30259a_dt_init(struct i2c_client *client, led->num = source; led->chip = chip; led->fwnode = of_fwnode_handle(child); - - if (!of_property_read_string(child, "default-state", &str)) { - if (!strcmp(str, "on")) - led->default_state = STATE_ON; - else if (!strcmp(str, "keep")) - led->default_state = STATE_KEEP; - else - led->default_state = STATE_OFF; - } + led->default_state = led_init_default_state_get(led->fwnode); i++; } @@ -261,10 +248,10 @@ static void an30259a_init_default_state(struct an30259a_led *led) int led_on, err; switch (led->default_state) { - case STATE_ON: + case LEDS_DEFSTATE_ON: led->cdev.brightness = LED_FULL; break; - case STATE_KEEP: + case LEDS_DEFSTATE_KEEP: err = regmap_read(chip->regmap, AN30259A_REG_LED_ON, &led_on); if (err) break; -- 2.35.1