public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Onat Baker <onat@onatbaker.dev>
To: ogabbay@kernel.org
Cc: koby.elbaz@intel.com, konstantin.sinyuk@intel.com,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH] accel/habanalabs: simplify function pointer checks in mmu.c
Date: Fri, 17 Apr 2026 02:47:14 +0300	[thread overview]
Message-ID: <20260416234714.8143-1-onat@onatbaker.dev> (raw)

Function pointers can be tested directly without an explicit
comparison to NULL. Simplify the repeated checks in mmu.c by using
direct pointer truth tests.

No functional change intended.

Signed-off-by: Onat Baker <onat@onatbaker.dev>
---
 drivers/accel/habanalabs/common/mmu/mmu.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/accel/habanalabs/common/mmu/mmu.c b/drivers/accel/habanalabs/common/mmu/mmu.c
index 6c7c4ff8a8a9..222cd6b77891 100644
--- a/drivers/accel/habanalabs/common/mmu/mmu.c
+++ b/drivers/accel/habanalabs/common/mmu/mmu.c
@@ -50,13 +50,13 @@ int hl_mmu_init(struct hl_device *hdev)
 
 	mutex_init(&hdev->mmu_lock);
 
-	if (hdev->mmu_func[MMU_DR_PGT].init != NULL) {
+	if (hdev->mmu_func[MMU_DR_PGT].init) {
 		rc = hdev->mmu_func[MMU_DR_PGT].init(hdev);
 		if (rc)
 			return rc;
 	}
 
-	if (hdev->mmu_func[MMU_HR_PGT].init != NULL) {
+	if (hdev->mmu_func[MMU_HR_PGT].init) {
 		rc = hdev->mmu_func[MMU_HR_PGT].init(hdev);
 		if (rc)
 			goto fini_dr_mmu;
@@ -65,7 +65,7 @@ int hl_mmu_init(struct hl_device *hdev)
 	return 0;
 
 fini_dr_mmu:
-	if (hdev->mmu_func[MMU_DR_PGT].fini != NULL)
+	if (hdev->mmu_func[MMU_DR_PGT].fini)
 		hdev->mmu_func[MMU_DR_PGT].fini(hdev);
 
 	return rc;
@@ -86,10 +86,10 @@ void hl_mmu_fini(struct hl_device *hdev)
 	if (hdev->mmu_disable)
 		return;
 
-	if (hdev->mmu_func[MMU_DR_PGT].fini != NULL)
+	if (hdev->mmu_func[MMU_DR_PGT].fini)
 		hdev->mmu_func[MMU_DR_PGT].fini(hdev);
 
-	if (hdev->mmu_func[MMU_HR_PGT].fini != NULL)
+	if (hdev->mmu_func[MMU_HR_PGT].fini)
 		hdev->mmu_func[MMU_HR_PGT].fini(hdev);
 
 	mutex_destroy(&hdev->mmu_lock);
@@ -111,13 +111,13 @@ int hl_mmu_ctx_init(struct hl_ctx *ctx)
 	if (hdev->mmu_disable)
 		return 0;
 
-	if (hdev->mmu_func[MMU_DR_PGT].ctx_init != NULL) {
+	if (hdev->mmu_func[MMU_DR_PGT].ctx_init) {
 		rc = hdev->mmu_func[MMU_DR_PGT].ctx_init(ctx);
 		if (rc)
 			return rc;
 	}
 
-	if (hdev->mmu_func[MMU_HR_PGT].ctx_init != NULL) {
+	if (hdev->mmu_func[MMU_HR_PGT].ctx_init) {
 		rc = hdev->mmu_func[MMU_HR_PGT].ctx_init(ctx);
 		if (rc)
 			goto fini_dr_ctx;
@@ -126,7 +126,7 @@ int hl_mmu_ctx_init(struct hl_ctx *ctx)
 	return 0;
 
 fini_dr_ctx:
-	if (hdev->mmu_func[MMU_DR_PGT].fini != NULL)
+	if (hdev->mmu_func[MMU_DR_PGT].fini)
 		hdev->mmu_func[MMU_DR_PGT].fini(hdev);
 
 	return rc;
@@ -149,10 +149,10 @@ void hl_mmu_ctx_fini(struct hl_ctx *ctx)
 	if (hdev->mmu_disable)
 		return;
 
-	if (hdev->mmu_func[MMU_DR_PGT].ctx_fini != NULL)
+	if (hdev->mmu_func[MMU_DR_PGT].ctx_fini)
 		hdev->mmu_func[MMU_DR_PGT].ctx_fini(ctx);
 
-	if (hdev->mmu_func[MMU_HR_PGT].ctx_fini != NULL)
+	if (hdev->mmu_func[MMU_HR_PGT].ctx_fini)
 		hdev->mmu_func[MMU_HR_PGT].ctx_fini(ctx);
 }
 
-- 
2.47.3


                 reply	other threads:[~2026-04-16 23:48 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=20260416234714.8143-1-onat@onatbaker.dev \
    --to=onat@onatbaker.dev \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=koby.elbaz@intel.com \
    --cc=konstantin.sinyuk@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ogabbay@kernel.org \
    /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