From nobody Thu Nov 14 09:11:15 2024 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 EACA6C00140 for ; Fri, 5 Aug 2022 15:51:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241436AbiHEPvj (ORCPT ); Fri, 5 Aug 2022 11:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241323AbiHEPvR (ORCPT ); Fri, 5 Aug 2022 11:51:17 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E84F06611B; Fri, 5 Aug 2022 08:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659714555; x=1691250555; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nHnWOVfew8TcWbs/bmlCO+Rb3gJGgB68Y5o1rear14Y=; b=TJGX8VukUXjJqVd4FLwyNe64hjhqTa7jc2D/5efAqbVh1/hHM36sINtU FAh42xaL+VUCxNss19Md3NLUtgdZYVRWqavqq8awrGlblhlfi6KhR+rAG /UcnLrnGMXOGPyxz+szpGo/hsO3X89sPRjy1oLTnJEtTnsH/QFqa4SEwA qFl1L2nacrlpNeiGEwJf67thplrISQkYmzvmREaN0HOQRjYyJubFrfq4G FSt+u5e7UlA0srja4QCCt2nEOEZaPsuL7ClzlHU6ubOC+lLkkKh9kfZ03 zYFlOSL8s2eQp3g4/c6BjsgOp5Lgblr4/6P7t8Iod2GNu8UUUzn8UHz8c A==; X-IronPort-AV: E=McAfee;i="6400,9594,10430"; a="351943661" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="351943661" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2022 08:49:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="603631124" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 05 Aug 2022 08:49:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A69711D0; Fri, 5 Aug 2022 18:49:16 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Pavel Machek , Eddie James , Denis Osterland-Heim , 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: Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v2 03/11] leds: an30259a: Get rid of custom led_init_default_state_get() Date: Fri, 5 Aug 2022 18:48:59 +0300 Message-Id: <20220805154907.32263-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220805154907.32263-1-andriy.shevchenko@linux.intel.com> References: <20220805154907.32263-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 a0df1fb28774..d7db47cf859b 100644 --- a/drivers/leds/leds-an30259a.c +++ b/drivers/leds/leds-an30259a.c @@ -55,10 +55,6 @@ =20 #define AN30259A_NAME "an30259a" =20 -#define STATE_OFF 0 -#define STATE_KEEP 1 -#define STATE_ON 2 - struct an30259a; =20 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; }; =20 @@ -205,7 +201,6 @@ static int an30259a_dt_init(struct i2c_client *client, struct device_node *np =3D dev_of_node(&client->dev), *child; int count, ret; int i =3D 0; - const char *str; struct an30259a_led *led; =20 count =3D of_get_available_child_count(np); @@ -228,15 +223,7 @@ static int an30259a_dt_init(struct i2c_client *client, led->num =3D source; led->chip =3D chip; led->fwnode =3D of_fwnode_handle(child); - - if (!of_property_read_string(child, "default-state", &str)) { - if (!strcmp(str, "on")) - led->default_state =3D STATE_ON; - else if (!strcmp(str, "keep")) - led->default_state =3D STATE_KEEP; - else - led->default_state =3D STATE_OFF; - } + led->default_state =3D led_init_default_state_get(led->fwnode); =20 i++; } @@ -261,10 +248,10 @@ static void an30259a_init_default_state(struct an3025= 9a_led *led) int led_on, err; =20 switch (led->default_state) { - case STATE_ON: + case LEDS_DEFSTATE_ON: led->cdev.brightness =3D LED_FULL; break; - case STATE_KEEP: + case LEDS_DEFSTATE_KEEP: err =3D regmap_read(chip->regmap, AN30259A_REG_LED_ON, &led_on); if (err) break; --=20 2.35.1