From patchwork Tue Sep 6 13:50:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 603232 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 B6171C6FA8B for ; Tue, 6 Sep 2022 14:20:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241436AbiIFOU1 (ORCPT ); Tue, 6 Sep 2022 10:20:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242011AbiIFOTQ (ORCPT ); Tue, 6 Sep 2022 10:19:16 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41A038A6D4; Tue, 6 Sep 2022 06:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662472226; x=1694008226; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VQzFMWOPVcFhsKxRl9Czr0Mhj2oriMu0x8VLNQGEUCY=; b=Gp03T1KnWdPbBwrUKYnpKJdm6Ws98wT6v//Q6sL7/DwdSwmIqQbbLTbs ojRLqMFf6Xt70Vx47IBK+17f5RlGIvRGFGZJCTlOMpzIOTQ/OsqVmVhFL kkw/pAMkh9FOT10OwA6Qg7kvzCGjadqZ4M1wghdP2jYUGcY2jVeqqYKKd kKvy+wrhflmhCBnxDhlAP6L115Ye/JB9H2mFAkMHJjL/dReN5T0hgq2Ck vyYcQfq30cBi5f6IoWLwFaw/kDPs7EUILUATNLJTZUnGRUP5Dypqg9CfA ViTpdBjczvaAV1OeoQq5qg4or+okX/dL59yE220GT5ATynePsE/sD5W47 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="276334194" X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="276334194" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 06:50:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,294,1654585200"; d="scan'208";a="591269676" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 06 Sep 2022 06:50:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id AAD8A6D1; Tue, 6 Sep 2022 16:50:10 +0300 (EEST) From: Andy Shevchenko To: Gene Chen , Andy Shevchenko , Andrew Jeffery , 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 , Matthias Brugger , Sean Wang , Kurt Kanzenbach , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lee Jones Subject: [PATCH v3 08/11] leds: pca955x: Get rid of custom led_init_default_state_get() Date: Tue, 6 Sep 2022 16:50:01 +0300 Message-Id: <20220906135004.14885-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> References: <20220906135004.14885-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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/leds/leds-pca955x.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index 81aaf21212d7..8dca6f99e699 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c @@ -130,7 +130,7 @@ struct pca955x_led { struct led_classdev led_cdev; int led_num; /* 0 .. 15 potentially */ u32 type; - int default_state; + enum led_default_state default_state; struct fwnode_handle *fwnode; }; @@ -443,7 +443,6 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip) return ERR_PTR(-ENOMEM); device_for_each_child_node(&client->dev, child) { - const char *state; u32 reg; int res; @@ -454,19 +453,9 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip) led = &pdata->leds[reg]; led->type = PCA955X_TYPE_LED; led->fwnode = child; - fwnode_property_read_u32(child, "type", &led->type); + led->default_state = led_init_default_state_get(child); - if (!fwnode_property_read_string(child, "default-state", - &state)) { - if (!strcmp(state, "keep")) - led->default_state = LEDS_GPIO_DEFSTATE_KEEP; - else if (!strcmp(state, "on")) - led->default_state = LEDS_GPIO_DEFSTATE_ON; - else - led->default_state = LEDS_GPIO_DEFSTATE_OFF; - } else { - led->default_state = LEDS_GPIO_DEFSTATE_OFF; - } + fwnode_property_read_u32(child, "type", &led->type); } pdata->num_leds = chip->bits; @@ -578,13 +567,11 @@ static int pca955x_probe(struct i2c_client *client) led->brightness_set_blocking = pca955x_led_set; led->brightness_get = pca955x_led_get; - if (pdata->leds[i].default_state == - LEDS_GPIO_DEFSTATE_OFF) { + if (pdata->leds[i].default_state == LEDS_DEFSTATE_OFF) { err = pca955x_led_set(led, LED_OFF); if (err) return err; - } else if (pdata->leds[i].default_state == - LEDS_GPIO_DEFSTATE_ON) { + } else if (pdata->leds[i].default_state == LEDS_DEFSTATE_ON) { err = pca955x_led_set(led, LED_FULL); if (err) return err; @@ -623,8 +610,7 @@ static int pca955x_probe(struct i2c_client *client) * brightness to see if it's using PWM1. If so, PWM1 * should not be written below. */ - if (pdata->leds[i].default_state == - LEDS_GPIO_DEFSTATE_KEEP) { + if (pdata->leds[i].default_state == LEDS_DEFSTATE_KEEP) { if (led->brightness != LED_FULL && led->brightness != LED_OFF && led->brightness != LED_HALF)