From patchwork Fri Oct 9 15:51:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel David X-Patchwork-Id: 286037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, FREEMAIL_REPLYTO_END_DIGIT, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A55CFC433E7 for ; Fri, 9 Oct 2020 15:51:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E35232225D for ; Fri, 9 Oct 2020 15:51:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="Fkk+S1Gy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389144AbgJIPvu (ORCPT ); Fri, 9 Oct 2020 11:51:50 -0400 Received: from mail-41104.protonmail.ch ([185.70.41.104]:18833 "EHLO mail-41104.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388745AbgJIPvu (ORCPT ); Fri, 9 Oct 2020 11:51:50 -0400 Received: from mail-02.mail-europe.com (mail-02.mail-europe.com [51.89.119.103]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by mail-41104.protonmail.ch (Postfix) with ESMTPS id 6EFCE2004D9D; Fri, 9 Oct 2020 15:51:45 +0000 (UTC) Authentication-Results: mail-41104.protonmail.ch; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="Fkk+S1Gy" Date: Fri, 09 Oct 2020 15:51:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1602258701; bh=Z8cRmymZDiat5g8lOxpg3X47vm1HbTPdbsT9vFOf+G0=; h=Date:To:From:Cc:Reply-To:Subject:From; b=Fkk+S1Gyl+FlFuZgXgdyJ6/wfuf2PyfjMu7mvy5mKH1ObPVjJImtLtly+TvDClUiV 81EEjP+aFl62CUPM+lEq1h2OmiWksCJQTLBhrCia7JqxA7G0AyQn8U2sBmOdkUZZS/ 683vHs2JsWsXhHQ0vrOJAkvdiSUTlPFbjEm7R+Ug= To: dmurphy@ti.com, pavel@ucw.cz From: Gabriel David Cc: kabel@blackhole.sk, linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Gabriel David Reply-To: Gabriel David Subject: [PATCH v2] leds: lm3697: Rename struct into more appropriate name Message-ID: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org The mentioned struct, lm3697_led, was renamed to lm3697_bank since the structure is representing the control banks. This name, in my opinion, is more semantically correct. The pointers referring to it were also renamed. Signed-off-by: Gabriel David --- Yes, this is the same Gabriel David from ultracoolguy@tutanota.org and ultracoolguy@disroot.org. If you want me to confirm it I'll gladly do it. drivers/leds/leds-lm3697.c | 90 +++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 45 deletions(-) -- 2.28.0 diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c index 31f5ed486839..c62f95fc17e8 100644 --- a/drivers/leds/leds-lm3697.c +++ b/drivers/leds/leds-lm3697.c @@ -39,7 +39,7 @@ #define LM3697_MAX_CONTROL_BANKS 2 /** - * struct lm3697_led - + * struct lm3697_bank - * @hvled_strings: Array of LED strings associated with a control bank * @label: LED label * @led_dev: LED class device @@ -48,7 +48,7 @@ * @control_bank: Control bank the LED is associated to. 0 is control bank A * 1 is control bank B */ -struct lm3697_led { +struct lm3697_bank { u32 hvled_strings[LM3697_MAX_LED_STRINGS]; char label[LED_MAX_NAME_SIZE]; struct led_classdev led_dev; @@ -80,7 +80,7 @@ struct lm3697 { int bank_cfg; int num_banks; - struct lm3697_led leds[]; + struct lm3697_bank banks[]; }; static const struct reg_default lm3697_reg_defs[] = { @@ -113,52 +113,52 @@ static const struct regmap_config lm3697_regmap_config = { static int lm3697_brightness_set(struct led_classdev *led_cdev, enum led_brightness brt_val) { - struct lm3697_led *led = container_of(led_cdev, struct lm3697_led, + struct lm3697_bank *bank = container_of(led_cdev, struct lm3697_bank, led_dev); - int ctrl_en_val = (1 << led->control_bank); + int ctrl_en_val = (1 << bank->control_bank); int ret; - mutex_lock(&led->priv->lock); + mutex_lock(&bank->priv->lock); if (brt_val == LED_OFF) { - ret = regmap_update_bits(led->priv->regmap, LM3697_CTRL_ENABLE, + ret = regmap_update_bits(bank->priv->regmap, LM3697_CTRL_ENABLE, ctrl_en_val, ~ctrl_en_val); if (ret) { - dev_err(&led->priv->client->dev, "Cannot write ctrl register\n"); + dev_err(&bank->priv->client->dev, "Cannot write ctrl register\n"); goto brightness_out; } - led->enabled = LED_OFF; + bank->enabled = LED_OFF; } else { - ret = ti_lmu_common_set_brightness(&led->lmu_data, brt_val); + ret = ti_lmu_common_set_brightness(&bank->lmu_data, brt_val); if (ret) { - dev_err(&led->priv->client->dev, + dev_err(&bank->priv->client->dev, "Cannot write brightness\n"); goto brightness_out; } - if (!led->enabled) { - ret = regmap_update_bits(led->priv->regmap, + if (!bank->enabled) { + ret = regmap_update_bits(bank->priv->regmap, LM3697_CTRL_ENABLE, ctrl_en_val, ctrl_en_val); if (ret) { - dev_err(&led->priv->client->dev, + dev_err(&bank->priv->client->dev, "Cannot enable the device\n"); goto brightness_out; } - led->enabled = brt_val; + bank->enabled = brt_val; } } brightness_out: - mutex_unlock(&led->priv->lock); + mutex_unlock(&bank->priv->lock); return ret; } static int lm3697_init(struct lm3697 *priv) { - struct lm3697_led *led; + struct lm3697_bank *bank; int i, ret; if (priv->enable_gpio) { @@ -182,8 +182,8 @@ static int lm3697_init(struct lm3697 *priv) dev_err(&priv->client->dev, "Cannot write OUTPUT config\n"); for (i = 0; i < priv->num_banks; i++) { - led = &priv->leds[i]; - ret = ti_lmu_common_set_ramp(&led->lmu_data); + bank = &priv->banks[i]; + ret = ti_lmu_common_set_ramp(&bank->lmu_data); if (ret) dev_err(&priv->client->dev, "Setting the ramp rate failed\n"); } @@ -194,7 +194,7 @@ static int lm3697_init(struct lm3697 *priv) static int lm3697_probe_dt(struct lm3697 *priv) { struct fwnode_handle *child = NULL; - struct lm3697_led *led; + struct lm3697_bank *bank; const char *name; int control_bank; size_t i = 0; @@ -229,63 +229,63 @@ static int lm3697_probe_dt(struct lm3697 *priv) goto child_out; } - led = &priv->leds[i]; + bank = &priv->banks[i]; ret = ti_lmu_common_get_brt_res(&priv->client->dev, - child, &led->lmu_data); + child, &bank->lmu_data); if (ret) dev_warn(&priv->client->dev, "brightness resolution property missing\n"); - led->control_bank = control_bank; - led->lmu_data.regmap = priv->regmap; - led->lmu_data.runtime_ramp_reg = LM3697_CTRL_A_RAMP + + bank->control_bank = control_bank; + bank->lmu_data.regmap = priv->regmap; + bank->lmu_data.runtime_ramp_reg = LM3697_CTRL_A_RAMP + control_bank; - led->lmu_data.msb_brightness_reg = LM3697_CTRL_A_BRT_MSB + - led->control_bank * 2; - led->lmu_data.lsb_brightness_reg = LM3697_CTRL_A_BRT_LSB + - led->control_bank * 2; + bank->lmu_data.msb_brightness_reg = LM3697_CTRL_A_BRT_MSB + + bank->control_bank * 2; + bank->lmu_data.lsb_brightness_reg = LM3697_CTRL_A_BRT_LSB + + bank->control_bank * 2; - led->num_leds = fwnode_property_count_u32(child, "led-sources"); - if (led->num_leds > LM3697_MAX_LED_STRINGS) { + bank->num_leds = fwnode_property_count_u32(child, "led-sources"); + if (bank->num_leds > LM3697_MAX_LED_STRINGS) { dev_err(&priv->client->dev, "Too many LED strings defined\n"); continue; } ret = fwnode_property_read_u32_array(child, "led-sources", - led->hvled_strings, - led->num_leds); + bank->hvled_strings, + bank->num_leds); if (ret) { dev_err(&priv->client->dev, "led-sources property missing\n"); fwnode_handle_put(child); goto child_out; } - for (j = 0; j < led->num_leds; j++) + for (j = 0; j < bank->num_leds; j++) priv->bank_cfg |= - (led->control_bank << led->hvled_strings[j]); + (bank->control_bank << bank->hvled_strings[j]); ret = ti_lmu_common_get_ramp_params(&priv->client->dev, - child, &led->lmu_data); + child, &bank->lmu_data); if (ret) dev_warn(&priv->client->dev, "runtime-ramp properties missing\n"); fwnode_property_read_string(child, "linux,default-trigger", - &led->led_dev.default_trigger); + &bank->led_dev.default_trigger); ret = fwnode_property_read_string(child, "label", &name); if (ret) - snprintf(led->label, sizeof(led->label), + snprintf(bank->label, sizeof(bank->label), "%s::", priv->client->name); else - snprintf(led->label, sizeof(led->label), + snprintf(bank->label, sizeof(bank->label), "%s:%s", priv->client->name, name); - led->priv = priv; - led->led_dev.name = led->label; - led->led_dev.max_brightness = led->lmu_data.max_brightness; - led->led_dev.brightness_set_blocking = lm3697_brightness_set; + bank->priv = priv; + bank->led_dev.name = bank->label; + bank->led_dev.max_brightness = bank->lmu_data.max_brightness; + bank->led_dev.brightness_set_blocking = lm3697_brightness_set; - ret = devm_led_classdev_register(priv->dev, &led->led_dev); + ret = devm_led_classdev_register(priv->dev, &bank->led_dev); if (ret) { dev_err(&priv->client->dev, "led register err: %d\n", ret); @@ -313,7 +313,7 @@ static int lm3697_probe(struct i2c_client *client, return -ENODEV; } - led = devm_kzalloc(&client->dev, struct_size(led, leds, count), + led = devm_kzalloc(&client->dev, struct_size(led, banks, count), GFP_KERNEL); if (!led) return -ENOMEM;