From a51eb8de31492d2139e66a7e66b8fb3f03ddca50 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 11 Aug 2022 19:34:45 -0600 Subject: blk: Use a function for whether block devices are available At present we use HAVE_BLOCK_DEVICE to indicate when block devices are available. This is a very strange option, since it partially duplicates the BLK option used by driver model. It also covers both U-Boot proper and SPL, even though one might have block devices and another not. As a first step towards correcting this, create a new inline function called blk_enabled() which indicates if block devices are available. This cannot be used in Makefiles, or #if clauses, but can be used in C code. A function is useful because we cannot use CONFIG_IS_ENABLED(BLK) to decide if block devices are needed, since we must consider the legacy block interface, enabled by HAVE_BLOCK_DEVICE Update a few places where it can be used and drop some unnecessary #if checks around some functions in disk/part.c - rely on the compiler's dead-code elimination instead. Signed-off-by: Simon Glass --- include/blk.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/blk.h') diff --git a/include/blk.h b/include/blk.h index 9503369db83..332481a90b8 100644 --- a/include/blk.h +++ b/include/blk.h @@ -21,6 +21,11 @@ typedef ulong lbaint_t; struct udevice; +static inline bool blk_enabled(void) +{ + return CONFIG_IS_ENABLED(BLK) || IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE); +} + /* Interface types: */ enum if_type { IF_TYPE_UNKNOWN = 0, -- cgit v1.2.3