From: Nikolay Kulikov <nikolayof23@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Hans de Goede <hansg@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Andy Shevchenko <andy@kernel.org>
Cc: linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org,
Nikolay Kulikov <nikolayof23@gmail.com>
Subject: [PATCH v2 3/4] staging: media: atomisp: inline the check_bo_status_*() macros
Date: Thu, 23 Jul 2026 21:51:20 +0300 [thread overview]
Message-ID: <20260723185217.317981-4-nikolayof23@gmail.com> (raw)
In-Reply-To: <20260723185217.317981-1-nikolayof23@gmail.com>
These macros check a bit in the bo->status field. Replace them with
conditional expressions to make the code clearer.
Signed-off-by: Nikolay Kulikov <nikolayof23@gmail.com>
---
.../media/atomisp/include/hmm/hmm_bo.h | 12 --------
.../media/atomisp/include/hmm/hmm_common.h | 18 -----------
.../staging/media/atomisp/pci/hmm/hmm_bo.c | 30 ++++++++++++-------
3 files changed, 20 insertions(+), 40 deletions(-)
diff --git a/drivers/staging/media/atomisp/include/hmm/hmm_bo.h b/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
index e974ab5ca2fc..69cf490bd88c 100644
--- a/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
+++ b/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
@@ -19,18 +19,6 @@
#include "hmm/hmm_common.h"
#include "ia_css_types.h"
-#define check_bo_status_yes_goto(bo, _status, label) \
- var_not_equal_goto((bo->status & (_status)), (_status), \
- label, \
- "HMM buffer status not contain %s.\n", \
- #_status)
-
-#define check_bo_status_no_goto(bo, _status, label) \
- var_equal_goto((bo->status & (_status)), (_status), \
- label, \
- "HMM buffer status contains %s.\n", \
- #_status)
-
#define rbtree_node_to_hmm_bo(root_node) \
container_of((root_node), struct hmm_buffer_object, node)
diff --git a/drivers/staging/media/atomisp/include/hmm/hmm_common.h b/drivers/staging/media/atomisp/include/hmm/hmm_common.h
index f215130e5e17..c406fe8b1345 100644
--- a/drivers/staging/media/atomisp/include/hmm/hmm_common.h
+++ b/drivers/staging/media/atomisp/include/hmm/hmm_common.h
@@ -33,22 +33,4 @@
} \
} while (0)
-#define var_equal_goto(var1, var2, label, fmt, arg ...) \
- do { \
- if ((var1) == (var2)) { \
- dev_err(atomisp_dev, \
- fmt, ## arg); \
- goto label;\
- } \
- } while (0)
-
-#define var_not_equal_goto(var1, var2, label, fmt, arg ...) \
- do { \
- if ((var1) != (var2)) { \
- dev_err(atomisp_dev, \
- fmt, ## arg); \
- goto label;\
- } \
- } while (0)
-
#endif
diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
index b9949cc080e5..e92538ab025e 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
@@ -687,7 +687,10 @@ int hmm_bo_alloc_pages(struct hmm_buffer_object *bo,
}
mutex_lock(&bo->mutex);
- check_bo_status_no_goto(bo, HMM_BO_PAGE_ALLOCED, status_err);
+ if (bo->status & HMM_BO_PAGE_ALLOCED) {
+ dev_err(atomisp_dev, "HMM buffer status contains HMM_BO_PAGE_ALLOCED.\n");
+ goto status_err;
+ }
bo->pages = kzalloc_objs(struct page *, bo->pgnr);
if (unlikely(!bo->pages)) {
@@ -738,7 +741,10 @@ void hmm_bo_free_pages(struct hmm_buffer_object *bo)
mutex_lock(&bo->mutex);
- check_bo_status_yes_goto(bo, HMM_BO_PAGE_ALLOCED, status_err2);
+ if (!(bo->status & HMM_BO_PAGE_ALLOCED)) {
+ dev_err(atomisp_dev, "HMM buffer status not contain HMM_BO_PAGE_ALLOCED.\n");
+ goto status_err2;
+ }
/* clear the flag anyway. */
bo->status &= (~HMM_BO_PAGE_ALLOCED);
@@ -788,11 +794,15 @@ int hmm_bo_bind(struct hmm_buffer_object *bo)
mutex_lock(&bo->mutex);
- check_bo_status_yes_goto(bo,
- HMM_BO_PAGE_ALLOCED | HMM_BO_ALLOCED,
- status_err1);
+ if (!(bo->status & (HMM_BO_PAGE_ALLOCED | HMM_BO_ALLOCED))) {
+ dev_err(atomisp_dev, "HMM buffer status not contain HMM_BO_PAGE_ALLOCED | HMM_BO_ALLOCED.\n");
+ goto status_err1;
+ }
- check_bo_status_no_goto(bo, HMM_BO_BINDED, status_err2);
+ if (bo->status & HMM_BO_BINDED) {
+ dev_err(atomisp_dev, "HMM buffer status contains HMM_BO_BINDED.\n");
+ goto status_err2;
+ }
bdev = bo->bdev;
@@ -868,10 +878,10 @@ void hmm_bo_unbind(struct hmm_buffer_object *bo)
mutex_lock(&bo->mutex);
- check_bo_status_yes_goto(bo,
- HMM_BO_PAGE_ALLOCED |
- HMM_BO_ALLOCED |
- HMM_BO_BINDED, status_err);
+ if (!(bo->status & (HMM_BO_PAGE_ALLOCED | HMM_BO_ALLOCED | HMM_BO_BINDED))) {
+ dev_err(atomisp_dev, "HMM buffer status not contain HMM_BO_PAGE_ALLOCED | HMM_BO_ALLOCED | HMM_BO_BINDED.\n");
+ goto status_err;
+ }
bdev = bo->bdev;
--
2.55.0
next prev parent reply other threads:[~2026-07-23 18:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 18:51 [PATCH v2 0/4] staging: media: atomisp: cleanup pci/hmm/ code Nikolay Kulikov
2026-07-23 18:51 ` [PATCH v2 1/4] staging: media: atomisp: remove unused functions from pci/hmm/ Nikolay Kulikov
2026-08-12 7:49 ` Andy Shevchenko
2026-07-23 18:51 ` [PATCH v2 2/4] staging: media: atomisp: inline macros for checking the bo/bodev pointer Nikolay Kulikov
2026-08-12 7:49 ` Andy Shevchenko
2026-08-12 7:52 ` Andy Shevchenko
2026-07-23 18:51 ` Nikolay Kulikov [this message]
2026-08-12 7:51 ` [PATCH v2 3/4] staging: media: atomisp: inline the check_bo_status_*() macros Andy Shevchenko
2026-07-23 18:51 ` [PATCH v2 4/4] staging: media: atomisp: remove include/hmm/hmm_common.h file Nikolay Kulikov
2026-08-12 7:56 ` Andy Shevchenko
2026-08-12 17:22 ` Nikolay Kulikov
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=20260723185217.317981-4-nikolayof23@gmail.com \
--to=nikolayof23@gmail.com \
--cc=andy@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.