public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] accel/habanalabs: simplify function pointer checks in mmu.c
@ 2026-04-16 23:47 Onat Baker
  0 siblings, 0 replies; only message in thread
From: Onat Baker @ 2026-04-16 23:47 UTC (permalink / raw)
  To: ogabbay; +Cc: koby.elbaz, konstantin.sinyuk, dri-devel, linux-kernel

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-16 23:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-16 23:47 [PATCH] accel/habanalabs: simplify function pointer checks in mmu.c Onat Baker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox