mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: darshanrathod475@gmail.com
To: lyude@redhat.com, dakr@kernel.org
Cc: airlied@gmail.com, simona@ffwll.ch,
	dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
	linux-kernel@vger.kernel.org,
	Darshan Rathod <darshanrathod475@gmail.com>
Subject: [PATCH] drm/nouveau/acr: remove assignments from conditional statements
Date: Wed, 13 Aug 2025 18:59:05 +0530	[thread overview]
Message-ID: <20250813132905.653228-1-darshanrathod475@gmail.com> (raw)

From: Darshan Rathod <darshanrathod475@gmail.com>

Replace assignments inside if statements with separate assignment and
conditional check. Assigning variables in conditionals can obscure the
code flow and reduce readability.

This change improves clarity and follows common kernel coding style
practice. There is no change to functionality.

Signed-off-by: Darshan Rathod <darshanrathod475@gmail.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/acr/lsfw.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/acr/lsfw.c b/drivers/gpu/drm/nouveau/nvkm/subdev/acr/lsfw.c
index bd104a030243..f9ac300803e5 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/acr/lsfw.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/acr/lsfw.c
@@ -71,7 +71,8 @@ nvkm_acr_lsfw_add(const struct nvkm_acr_lsf_func *func, struct nvkm_acr *acr,
 	}
 
 	if (!lsfw) {
-		if (!(lsfw = kzalloc(sizeof(*lsfw), GFP_KERNEL)))
+		lsfw = kzalloc(sizeof(*lsfw), GFP_KERNEL);
+		if (!lsfw)
 			return ERR_PTR(-ENOMEM);
 
 		lsfw->id = id;
@@ -95,7 +96,8 @@ nvkm_acr_lsfw_load_sig_image_desc_(struct nvkm_subdev *subdev,
 	struct nvkm_acr_lsfw *lsfw;
 	int ret;
 
-	if (IS_ERR((lsfw = nvkm_acr_lsfw_add(func, acr, falcon, id))))
+	lsfw = nvkm_acr_lsfw_add(func, acr, falcon, id);
+	if (IS_ERR(lsfw))
 		return lsfw;
 
 	ret = nvkm_firmware_load_name(subdev, path, "sig", ver, &lsfw->sig);
@@ -260,7 +262,8 @@ nvkm_acr_lsfw_load_bl_inst_data_sig(struct nvkm_subdev *subdev,
 	u32 *bldata;
 	int ret;
 
-	if (IS_ERR((lsfw = nvkm_acr_lsfw_add(func, acr, falcon, id))))
+	lsfw = nvkm_acr_lsfw_add(func, acr, falcon, id);
+	if (IS_ERR(lsfw))
 		return PTR_ERR(lsfw);
 
 	ret = nvkm_firmware_load_name(subdev, path, "bl", ver, &bl);
@@ -296,7 +299,8 @@ nvkm_acr_lsfw_load_bl_inst_data_sig(struct nvkm_subdev *subdev,
 			 lsfw->app_resident_data_size;
 
 	lsfw->img.size = lsfw->bootloader_size + lsfw->app_size;
-	if (!(lsfw->img.data = kzalloc(lsfw->img.size, GFP_KERNEL))) {
+	lsfw->img.data = kzalloc(lsfw->img.size, GFP_KERNEL);
+	if (!lsfw->img.data) {
 		ret = -ENOMEM;
 		goto done;
 	}
@@ -345,7 +349,8 @@ nvkm_acr_lsfw_load_bl_sig_net(struct nvkm_subdev *subdev,
 	u32 *bldata;
 	int ret;
 
-	if (IS_ERR((lsfw = nvkm_acr_lsfw_add(func, acr, falcon, id))))
+	lsfw = nvkm_acr_lsfw_add(func, acr, falcon, id);
+	if (IS_ERR(lsfw))
 		return PTR_ERR(lsfw);
 
 	ret = nvkm_firmware_load_name(subdev, path, "bl", ver, &bl);
@@ -373,7 +378,8 @@ nvkm_acr_lsfw_load_bl_sig_net(struct nvkm_subdev *subdev,
 	lsfw->app_size = lsfw->app_resident_code_size + lsfw->app_resident_data_size;
 
 	lsfw->img.size = lsfw->bootloader_size + lsfw->app_size;
-	if (!(lsfw->img.data = kzalloc(lsfw->img.size, GFP_KERNEL))) {
+	lsfw->img.data = kzalloc(lsfw->img.size, GFP_KERNEL);
+	if (!lsfw->img.data) {
 		ret = -ENOMEM;
 		goto done;
 	}
-- 
2.25.1


                 reply	other threads:[~2025-08-13 13:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250813132905.653228-1-darshanrathod475@gmail.com \
    --to=darshanrathod475@gmail.com \
    --cc=airlied@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyude@redhat.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=simona@ffwll.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®