Skip to content

Commit e3bc040

Browse files
jognesspmladek
authored andcommitted
printk: ringbuffer: add BLK_DATALESS() macro
Rather than continually needing to explicitly check @begin and @next to identify a dataless block, introduce and use a BLK_DATALESS() macro. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20200914123354.832-3-john.ogness@linutronix.de
1 parent 2a7f87e commit e3bc040

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎kernel/printk/printk_ringbuffer.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@
266266

267267
/* Determine if a logical position refers to a data-less block. */
268268
#define LPOS_DATALESS(lpos) ((lpos) & 1UL)
269+
#define BLK_DATALESS(blk) (LPOS_DATALESS((blk)->begin) && \
270+
LPOS_DATALESS((blk)->next))
269271

270272
/* Get the logical position at index 0 of the current wrap. */
271273
#define DATA_THIS_WRAP_START_LPOS(data_ring, lpos) \
@@ -1038,7 +1040,7 @@ static unsigned int space_used(struct prb_data_ring *data_ring,
10381040
struct prb_data_blk_lpos *blk_lpos)
10391041
{
10401042
/* Data-less blocks take no space. */
1041-
if (LPOS_DATALESS(blk_lpos->begin))
1043+
if (BLK_DATALESS(blk_lpos))
10421044
return 0;
10431045

10441046
if (DATA_WRAPS(data_ring, blk_lpos->begin) == DATA_WRAPS(data_ring, blk_lpos->next)) {
@@ -1071,7 +1073,7 @@ static const char *get_data(struct prb_data_ring *data_ring,
10711073
struct prb_data_block *db;
10721074

10731075
/* Data-less data block description. */
1074-
if (LPOS_DATALESS(blk_lpos->begin) && LPOS_DATALESS(blk_lpos->next)) {
1076+
if (BLK_DATALESS(blk_lpos)) {
10751077
if (blk_lpos->begin == NO_LPOS && blk_lpos->next == NO_LPOS) {
10761078
*data_size = 0;
10771079
return "";

0 commit comments

Comments
 (0)