Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11832392rwl; Tue, 3 Jan 2023 05:30:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXtFAB1a3dDAqn73lX6U+6gi53oJTbF4wqTlpKu5WleT4FA6BY4gB/POcwErOOhWzGr7Lsrh X-Received: by 2002:a17:902:6805:b0:191:1545:a652 with SMTP id h5-20020a170902680500b001911545a652mr55667815plk.31.1672752628744; Tue, 03 Jan 2023 05:30:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672752628; cv=none; d=google.com; s=arc-20160816; b=I73iDay5zb7N3vTWTpu98+En92pl3U7C0vwnZDfh1s+Kc2jrFy98Y3iIkNWoToR2u8 da2XoMjeNKVdNUaBVvoylbio8XcqXL+/d4/96bnO6uEYJQnBY6m0BFmTsCa19tv4rKTj V4h6WtMETVp8perap4hx659WCsCPL6ji8nx34kWLmnSbMyw5ObTCy/JoaRmQheZ4Xedb u5sxTwr6WmcEuptRkXqMPbgTeZIhQ9NBE3ppT3XBwzaWQo4qwFYuHy7L7PwxOCG5PuFP xiqDgKFiFrHPAcgQftu197wGt3CPmry+uMPY8rPDJlSk7Jl50apQgUcYRBFJ0qgwJxyU 2R3Q== 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=zB9RCZahTy8yJATnLOpF1pfodSkHXOFYZBuM0cS+Q/E=; b=naCeMWD88XbiO0tAjnKOzaBNtC2UVKPe/ZLFd9guoHyivKXFVltr0rpSMXGLYkV7WA QBqjz5xtGoeJ+SQUpjC+UUBtpNASGfghikaTR5Zm4GTApumz9nxcd93R+Zu50/IIwv4T rqO8Earp+V4ZwXJizYWpb++XXVeU93fHUEO9Iz/kPLQaUlwHg4s93z6WX/x2KD7GrOOg 0seMNkiXbiCvsHXOuTcoFlCCAK6nvB59AStLQLEOBt+fLrem3tT28PneLXlQtJXM+I+A 78cEXY9Mre4eSsDLT7WR9VX4ekYzeySZsQF1Z+ysOlpRoarrGdW9kMZHavHSnUOTGLGA XREA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VEnh19Vi; 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 m5-20020a170902bb8500b0018c35376fdcsi30003472pls.78.2023.01.03.05.30.21; Tue, 03 Jan 2023 05:30:28 -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=VEnh19Vi; 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 S237436AbjACNNx (ORCPT + 60 others); Tue, 3 Jan 2023 08:13:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237739AbjACNNN (ORCPT ); Tue, 3 Jan 2023 08:13:13 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 645191114B; 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=WhGrjx6LzV2jk/LAfomo4zdb3Tdn1LBofxlORU1JDv0=; b=VEnh19VivwIMpe6hZMkoOBw+iPBVlOXfiQ8M2op6En9nltN6BPgVw4DI euIIJ/CmmnoVs1VUTkGT23dCqyadrpucX4OVJo91Bq0U1ze1AuxWYtt/u YykK1JW4P56mF2200zI2XHNZjnZq/axm7A1ehZUOVEMfEymHqeu8w5b1G orEgufqr5hm6ZKBsruoPzz4QS1CNrA3KiE52/zyI0sHoo2qIzR4n2G7cG Jh0LYNkVZfcyZzPZmdmMzYzc+gPX1kC8QTGHv/D3eT6GA8cgWn0Ns4lHk ucw/nJyo6mFCXcxjLVC6wzj2Lp00hMMpZ8kZH4dWwQyCMn50H5DvA0ta/ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="322888002" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="322888002" 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="685397947" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="685397947" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 03 Jan 2023 05:12:34 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id EDD04458; 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 11/11] net: dsa: hellcreek: Get rid of custom led_init_default_state_get() Date: Tue, 3 Jan 2023 15:12:56 +0200 Message-Id: <20230103131256.33894-12-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: Kurt Kanzenbach --- drivers/net/dsa/hirschmann/hellcreek_ptp.c | 45 ++++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/dsa/hirschmann/hellcreek_ptp.c b/drivers/net/dsa/hirschmann/hellcreek_ptp.c index b28baab6d56a..793b2c296314 100644 --- a/drivers/net/dsa/hirschmann/hellcreek_ptp.c +++ b/drivers/net/dsa/hirschmann/hellcreek_ptp.c @@ -297,7 +297,8 @@ static enum led_brightness hellcreek_led_is_gm_get(struct led_classdev *ldev) static int hellcreek_led_setup(struct hellcreek *hellcreek) { struct device_node *leds, *led = NULL; - const char *label, *state; + enum led_default_state state; + const char *label; int ret = -EINVAL; of_node_get(hellcreek->dev->of_node); @@ -318,16 +319,17 @@ static int hellcreek_led_setup(struct hellcreek *hellcreek) ret = of_property_read_string(led, "label", &label); hellcreek->led_sync_good.name = ret ? "sync_good" : label; - ret = of_property_read_string(led, "default-state", &state); - if (!ret) { - if (!strcmp(state, "on")) - hellcreek->led_sync_good.brightness = 1; - else if (!strcmp(state, "off")) - hellcreek->led_sync_good.brightness = 0; - else if (!strcmp(state, "keep")) - hellcreek->led_sync_good.brightness = - hellcreek_get_brightness(hellcreek, - STATUS_OUT_SYNC_GOOD); + state = led_init_default_state_get(of_fwnode_handle(led)); + switch (state) { + case LEDS_DEFSTATE_ON: + hellcreek->led_sync_good.brightness = 1; + break; + case LEDS_DEFSTATE_KEEP: + hellcreek->led_sync_good.brightness = + hellcreek_get_brightness(hellcreek, STATUS_OUT_SYNC_GOOD); + break; + default: + hellcreek->led_sync_good.brightness = 0; } hellcreek->led_sync_good.max_brightness = 1; @@ -344,16 +346,17 @@ static int hellcreek_led_setup(struct hellcreek *hellcreek) ret = of_property_read_string(led, "label", &label); hellcreek->led_is_gm.name = ret ? "is_gm" : label; - ret = of_property_read_string(led, "default-state", &state); - if (!ret) { - if (!strcmp(state, "on")) - hellcreek->led_is_gm.brightness = 1; - else if (!strcmp(state, "off")) - hellcreek->led_is_gm.brightness = 0; - else if (!strcmp(state, "keep")) - hellcreek->led_is_gm.brightness = - hellcreek_get_brightness(hellcreek, - STATUS_OUT_IS_GM); + state = led_init_default_state_get(of_fwnode_handle(led)); + switch (state) { + case LEDS_DEFSTATE_ON: + hellcreek->led_is_gm.brightness = 1; + break; + case LEDS_DEFSTATE_KEEP: + hellcreek->led_is_gm.brightness = + hellcreek_get_brightness(hellcreek, STATUS_OUT_IS_GM); + break; + default: + hellcreek->led_is_gm.brightness = 0; } hellcreek->led_is_gm.max_brightness = 1; -- 2.35.1