Skip to content

Commit

Permalink
printk: ringbuffer: add BLK_DATALESS() macro
Browse files Browse the repository at this point in the history
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
  • Loading branch information
John Ogness authored and Petr Mladek committed Sep 15, 2020
1 parent 2a7f87e commit e3bc040
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kernel/printk/printk_ringbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@

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

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

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

/* Data-less data block description. */
if (LPOS_DATALESS(blk_lpos->begin) && LPOS_DATALESS(blk_lpos->next)) {
if (BLK_DATALESS(blk_lpos)) {
if (blk_lpos->begin == NO_LPOS && blk_lpos->next == NO_LPOS) {
*data_size = 0;
return "";
Expand Down

0 comments on commit e3bc040

Please sign in to comment.