Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2754871imn; Tue, 2 Aug 2022 14:48:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tcOIbMd85Va7YpmOemyX2ueXcL3SQ5FDKXGq0+siigMWLF9kHY4RGbo291iiwIqxKh9dl+ X-Received: by 2002:a05:6a00:2401:b0:52b:cd67:d997 with SMTP id z1-20020a056a00240100b0052bcd67d997mr22710168pfh.70.1659476884091; Tue, 02 Aug 2022 14:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659476884; cv=none; d=google.com; s=arc-20160816; b=OymM8iGncHK9CWhSNEkXn1iOdO/hUNXVwZJox0FeK3EuWhLydQOnKtqgjJLfbum5Rq IQvT+dQOTrLtQwwV9TrCvui26tZYWnDj6ECjSoKUoS0TReUxbKWFad1sD3dJTiUgBxPz yk5vp4EbHgTweDx1f662YURHlSrQ3kxcega9dDkLFWcRhtfwrvRPDv8ucyg01OwSFfDY TQeD6XApziuw/s8hIcooTByKJNBULY9KVdcDOWqAlH6kcq3k+1k8XKl6bjDe6L0T1d9O ggyfn/yHPdOzKI70n+WGcG6b4HaUUgIkIJlhK6CehU/5ksleywwkXX3yjx6UE+aM8nck +mZA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ZVkSqxAb1FtD00/Rhi1hyXE+Hn63bye5S1l7NxYvOHg=; b=CnegIPgTXS3PVloEOqw9QFm8OOPpMjecZnyzbKF3bDbuN/DFdA3/YWxsNeWytp5epC f6ghSlCJpBH9YSjQt0kpD3GiR/X1kZ6EFM3TUKlzjUtvMI0JTXKV4wKqD81nq9GUnbBw yd60DYc3rXdFuH9LCxPVHhMCF5ccDyj5vjf8fonXhRpSfWagOucS4+BZvTjSVx/vGNY8 NkrqOx8EZdtYM+bwENKxTJWuAT5pnnQquYb/AZwu2Y/yIacbxeyM9ATckVXzi3Pf2Uv6 1lMho6cNhd937nhd3usYow42pk+riKfX7REe7V+fMgQeh4AA9nrbrmsNBngiVpGqRPj9 kNLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l+9Ut9bw; 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 me13-20020a17090b17cd00b001f4f259febesi9828166pjb.163.2022.08.02.14.47.49; Tue, 02 Aug 2022 14:48:04 -0700 (PDT) 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=l+9Ut9bw; 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 S231674AbiHBVVx (ORCPT + 99 others); Tue, 2 Aug 2022 17:21:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiHBVVu (ORCPT ); Tue, 2 Aug 2022 17:21:50 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07A2C2F663; Tue, 2 Aug 2022 14:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659475300; x=1691011300; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=kK0hPRdSyvWlZo38p4QMgn/ySqgObmyyzYJGxFidk7g=; b=l+9Ut9bwPznKk2SEo1deNvWRc4tQaEoiD0ak0+m5r/OO6uCaXa2nN+Yu mrNTTahAkrl3f/B5yIMYbLgV/qBawOrjyYDtH79mkFfx0us4Zosbb7rJr HcPnI7mgw5QpdBBc7k+YdKhNIPAfG2wTJlO5szhhfcKXT9TDrBx6xDYTo gaSkxH6EVOatub0rb/YBDIch9XuUA4Dic0DZZjGXV1focUJgIR5IDuqnv eUa8J8Q4VRoRZfiWEE/w18lIP0UPLGgG6tbaiQLU3PrXsNJPqLXuh1fEu N9Yawbld8vwIxOUc/5YhQwcktyBVfYH+zSTJp09OTFVoiiWxRbwUv1FUL g==; X-IronPort-AV: E=McAfee;i="6400,9594,10427"; a="289533759" X-IronPort-AV: E=Sophos;i="5.93,212,1654585200"; d="scan'208";a="289533759" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2022 14:21:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,212,1654585200"; d="scan'208";a="692001798" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 02 Aug 2022 14:21:36 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C211EF7; Wed, 3 Aug 2022 00:21:47 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net-next v1 1/1] net: dsa: hellcreek: Get rid of custom led_init_default_state_get() Date: Wed, 3 Aug 2022 00:21:44 +0300 Message-Id: <20220802212144.6743-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,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/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