From patchwork Fri Nov 8 13:28:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13868200 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D09091EF95A for ; Fri, 8 Nov 2024 13:29:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072573; cv=none; b=mhkJcxnzjB0dGFSEjwM6a3X39oARXK3h3dp3uguC0SGB0m4B5R9fePdEzXxHLaaLV45E8NaHp+45u7UwAftWFZV3IvSgMOJ/AzvNH58SG4RND/LtRoQOVcGU7Zfwvn5y3LE9ICplpIlYjodDbnzwKnsikLvco19YFyBHu8DJr8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072573; c=relaxed/simple; bh=eSch87CyY3MehjJktN1nlntcOVi3d1d1k+yee2U49tQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=av93P+EHsPjm++30gpbELgHQzr7/Q2q4yJBuxE+wIlVOWIEcMmxDu+KtiYqowAfXQVr7BF5OD3Q42Z+7v2FHofFVmOvS/su+XvOA9CiBlWxCI0V7Tluut/DHhr5X6KgAomytfZQdNKJnWux9+28VqtdZRmKjUCCIpizRT3gt9Ms= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q+U+hsBH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q+U+hsBH" Received: by smtp.kernel.org (Postfix) id C0B19C4AF0B; Fri, 8 Nov 2024 13:29:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53CE8C4CEDB; Fri, 8 Nov 2024 13:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072573; bh=eSch87CyY3MehjJktN1nlntcOVi3d1d1k+yee2U49tQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q+U+hsBHObh5um1syeXDkq6AukWQD8lEgf2wpmHFXqjqJTCE9i2OFIdJeDyu4yFcC eJO22tf0npCtJoSQvg5nqy7RsddgiiZA3r7im/HDjNvZeKQhN/wNYQfvcq83+ooh5I 9YDpy9IFCcm2V0LnNOYYob7Ech34N9z7U9ED7O35YTPYE/3HkNBsPt0btj3RGNBlLe HnXlBJgcslnkmNraGdnZZei/UgHMpOBVyORJ+zw+NnSc6UPJ8hCrqNm9mY4RNL14wv 0NN8mgWJ22ROV2KAtQYdyUdlTJnp45UAJ9ClFMZmjBNBmsGooDoMTsBXqh6zYZhJ3c qzDSaF5d6/wqw== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v6 10/12] leds: turris-omnia: Use dev_err_probe() where appropriate Date: Fri, 8 Nov 2024 14:28:43 +0100 Message-ID: <20241108132845.31005-11-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use dev_err_probe() instead of dev_err() + separate return where appropriate. Signed-off-by: Marek BehĂșn --- drivers/leds/leds-turris-omnia.c | 50 ++++++++++---------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index 503e6e476c45..cee53ef94bc9 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -256,33 +256,23 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led, /* put the LED into software mode */ ret = omnia_cmd_write_u8(client, OMNIA_CMD_LED_MODE, OMNIA_CMD_LED_MODE_LED(led->reg) | OMNIA_CMD_LED_MODE_USER); - if (ret) { - dev_err(dev, "Cannot set LED %pOF to software mode: %i\n", np, - ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Cannot set LED %pOF to software mode\n", np); /* disable the LED */ ret = omnia_cmd_write_u8(client, OMNIA_CMD_LED_STATE, OMNIA_CMD_LED_STATE_LED(led->reg)); - if (ret) { - dev_err(dev, "Cannot set LED %pOF brightness: %i\n", np, ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Cannot set LED %pOF brightness\n", np); /* Set initial color and cache it */ ret = omnia_led_send_color_cmd(client, led); - if (ret < 0) { - dev_err(dev, "Cannot set LED %pOF initial color: %i\n", np, - ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "Cannot set LED %pOF initial color\n", np); ret = devm_led_classdev_multicolor_register_ext(dev, &led->mc_cdev, &init_data); - if (ret < 0) { - dev_err(dev, "Cannot register LED %pOF: %i\n", np, ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "Cannot register LED %pOF\n", np); return 1; } @@ -485,13 +475,10 @@ static int omnia_leds_probe(struct i2c_client *client) int ret, count; count = of_get_available_child_count(np); - if (!count) { - dev_err(dev, "LEDs are not defined in device tree!\n"); - return -ENODEV; - } else if (count > OMNIA_BOARD_LEDS) { - dev_err(dev, "Too many LEDs defined in device tree!\n"); - return -EINVAL; - } + if (count == 0) + return dev_err_probe(dev, -ENODEV, "LEDs are not defined in device tree!\n"); + if (count > OMNIA_BOARD_LEDS) + return dev_err_probe(dev, -EINVAL, "Too many LEDs defined in device tree!\n"); leds = devm_kzalloc(dev, struct_size(leds, leds, count), GFP_KERNEL); if (!leds) @@ -501,11 +488,8 @@ static int omnia_leds_probe(struct i2c_client *client) i2c_set_clientdata(client, leds); ret = omnia_find_mcu_and_get_features(dev); - if (ret < 0) { - dev_err(dev, "Cannot determine MCU supported features: %d\n", - ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "Cannot determine MCU supported features\n"); leds->has_gamma_correction = ret & OMNIA_FEAT_LED_GAMMA_CORRECTION; @@ -518,10 +502,8 @@ static int omnia_leds_probe(struct i2c_client *client) mutex_init(&leds->lock); ret = devm_led_trigger_register(dev, &omnia_hw_trigger); - if (ret < 0) { - dev_err(dev, "Cannot register private LED trigger: %d\n", ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "Cannot register private LED trigger\n"); led = &leds->leds[0]; for_each_available_child_of_node_scoped(np, child) {