Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11827173rwl; Tue, 3 Jan 2023 05:25:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXtxARYH2p8jPT6pk1bzK/raJVlQE9qrT0KD9JVPcZqDMhXQFoAkP9IiICteYUeVrmsbVL15 X-Received: by 2002:a17:90a:3f82:b0:218:12e7:3f8f with SMTP id m2-20020a17090a3f8200b0021812e73f8fmr61727178pjc.9.1672752359425; Tue, 03 Jan 2023 05:25:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672752359; cv=none; d=google.com; s=arc-20160816; b=uIrbdR5rksHreOdg7AOj5Ed83eZcTGeIrRVzkEqQJz+K22EnqXov4nZUaB9ZfS/n4b uSwbdvIa98LW8BspW4nX8OYajuJZKepqfYaPU9REXVd0Rsmht2oHh2lpoqqK6Bvlward jUzu229/iM/crurhhDT09XTe3poCZLP877dksYzrz3PVbMw3ochan6zbU17+xnpnx+2s EtW/v4WqGjuXMF1eh+2KKh//b2BA1erQqU4iPORcwQuIWV1SpTY/l46rzs74n6Zb10Bg 4q/eZIuCj8JBDQJu6h98m2B+3uGkNOJd19JArCRneySgYPxXxAUq5+ECON6oV4dB8vqa XfUQ== 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=+Tp/A4D03rch1SrDUAdccxl9ly1G2v9a1H0MgM+U3ew=; b=TysXapqXJwZMtmaJa3m3H1kFf42CjUq7C7qP4QF0/npRIVQyYepBNdLh/TGZkmWA+c RjKoVgX1oKCwaH/HKqus4JojqvwIX+t8Z/bZHdohKwXp8HtnkC5GqahjkshuZSLO3Twx 1Y6sjAX183s1PoLugKXIbKcqtG6B1htg8igqo7gAGWwZkZ42dhkdf7WpuFa9AE0auyur DANtY9d1QwkF2Q14z1g/8o5h2HIvwOAK2Xxnezl4Cxe5PE6bB6WehygsPqbom0wRPb5J UcwOUm3tZvOgBvqazsRlUJQ3y+IlbmO3rZalYhCP+yas9IVSHkHs5s4h5PIPwCw2bPxh pQug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MuDNEBml; 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 nv14-20020a17090b1b4e00b0020af2b9dd80si33544926pjb.69.2023.01.03.05.25.51; Tue, 03 Jan 2023 05:25:59 -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=MuDNEBml; 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 S237779AbjACNNj (ORCPT + 60 others); Tue, 3 Jan 2023 08:13:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237730AbjACNNM (ORCPT ); Tue, 3 Jan 2023 08:13:12 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2994F10FCA; Tue, 3 Jan 2023 05:12:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751564; x=1704287564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9YAyO0NuKkjE8s2MjpGiLsRbRFZd9cli0OG3nOsmD+I=; b=MuDNEBmli6TnNdQW14WCV4+aEE0WA9x1pYBpWmgz0R5onaKmxBMsocwg OBU1ChFtkiedbTFmseOiVEFfQqDAdJlf3T4hUYLxhTbr0wnmwk5inLsXz nzn6KVgxSUihqkrl+cgAYzMqShvJL2whKOAZLiy4bHqypjUbeui8e/jX7 1Vhgz5p/nyAL+3WUurV5er3JBFeKf+6/QepwI09K/ng9bq0dGo8CmYsxE cTqMdkvfOKNHkC8tMyndnpPeJrymrkHJ/Lazx1YSuzfoRYj3zJ4NrCbwJ RTTFl7TinoHYOsBD8ZI0HQbTCgDTF4ttawY9RFeiPV9TlL8jJDqSY0Upa A==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322887989" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322887989" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 05:12:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="685397942" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="685397942" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 03 Jan 2023 05:12:33 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id B095E2AD; 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 , AngeloGioacchino Del Regno Subject: [PATCH v4 06/11] leds: mt6323: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:51 +0200 Message-Id: <20230103131256.33894-7-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 Reviewed-by: AngeloGioacchino Del Regno --- drivers/leds/leds-mt6323.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c index f59e0e8bda8b..17ee88043f52 100644 --- a/drivers/leds/leds-mt6323.c +++ b/drivers/leds/leds-mt6323.c @@ -339,23 +339,23 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev, struct device_node *np) { struct mt6323_led *led = container_of(cdev, struct mt6323_led, cdev); - const char *state; + enum led_default_state state; int ret = 0; - state = of_get_property(np, "default-state", NULL); - if (state) { - if (!strcmp(state, "keep")) { - ret = mt6323_get_led_hw_brightness(cdev); - if (ret < 0) - return ret; - led->current_brightness = ret; - ret = 0; - } else if (!strcmp(state, "on")) { - ret = - mt6323_led_set_brightness(cdev, cdev->max_brightness); - } else { - ret = mt6323_led_set_brightness(cdev, LED_OFF); - } + state = led_init_default_state_get(of_fwnode_handle(np)); + switch (state) { + case LEDS_DEFSTATE_ON: + ret = mt6323_led_set_brightness(cdev, cdev->max_brightness); + break; + case LEDS_DEFSTATE_KEEP: + ret = mt6323_get_led_hw_brightness(cdev); + if (ret < 0) + return ret; + led->current_brightness = ret; + ret = 0; + break; + default: + ret = mt6323_led_set_brightness(cdev, LED_OFF); } return ret; -- 2.35.1