From patchwork Tue Jan 3 13:12:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13087655 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8CE13C3DA7D for ; Tue, 3 Jan 2023 16:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+Tp/A4D03rch1SrDUAdccxl9ly1G2v9a1H0MgM+U3ew=; b=0IGPqsUHqWHLU5L/RgtpOssTLX XyYTKwWAJLSW3BzCJ/x12FZJmG6bH445t9uh7UMT85XqARouZtSp67EJ1+g5yWboh5QKKvLEJCLtG eMkn6VU6hnl9ooA36G0ZYexqrUkk9M+FG+M3JJ0Aww+J16mDm7d+iw2p3+U4OFVf4KPLegmEWIczU 6a67ek2ZyYlTbfOJRMp/nM2IowryaxUjJQzv8XMRoWaJx07ZSqBLBpv3mWw1mIwViNCS8Ik86XCvF qsPnkRljwx7Ag6QaWEXTWKfrVbcJAyIXdeJrMpMnh44GMaytQ81ylSCEcKKzjs+1EKUYYX0rVMD6v 5L2ilPcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCk5L-002tYE-AA; Tue, 03 Jan 2023 16:24:19 +0000 Received: from mga09.intel.com ([134.134.136.24]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCh5t-001R07-QG; Tue, 03 Jan 2023 13:12:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672751561; x=1704287561; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9YAyO0NuKkjE8s2MjpGiLsRbRFZd9cli0OG3nOsmD+I=; b=ngls8v4u1WjGKx9CXEp7rHcTTQjhBdyNph3IfECuy6cVRsf3NXQTLNSI fF7TJ0+H987/x8kqQ/1aJz2DzREOUiuCiEDkFNKi5YmLB93dzgt+kOcaq QSfCkZXAyn8FHKXYfPvi+zrs8Eqfq5GhgQNB8rTbLqGA6+AKw2VSPUoj7 9yDCUaMaau5vt4RMA7r2c49fOjFL7/bTeEJpaCVJEKJg0l89jXn8A/SMO XUGn0alEzLVKiNdwiI/6lWGWs6GKQ78ER3NsStkXQxHxEno75QGychJg/ imOExvJla+dM1H9NoQJKNdBQKad8uIxNAKs+UNE1ST/W+Su6Ak84CYBwU A==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322887987" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322887987" 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230103_051242_144364_104D4E31 X-CRM114-Status: GOOD ( 14.75 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.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;