1 #define S_SIZE (1024 - (sizeof(unsigned int) + 1))
7 static struct sbuff emergency
, *emergency_ptr
= &emergency
;
9 static int sb_add(struct sbuff
*m
, const char *f
, ...)
14 if (likely(m
->count
< S_SIZE
)) {
16 len
= vsnprintf(m
->buf
+ m
->count
, S_SIZE
- m
->count
, f
, args
);
18 if (likely(m
->count
+ len
< S_SIZE
)) {
24 printk_once(KERN_ERR KBUILD_MODNAME
" please increase S_SIZE\n");
28 static struct sbuff
*sb_open(void)
30 struct sbuff
*m
= kmalloc(sizeof(*m
), GFP_ATOMIC
);
35 m
= xchg(&emergency_ptr
, NULL
);
42 static void sb_close(struct sbuff
*m
)
45 printk("%s\n", m
->buf
);
47 if (likely(m
!= &emergency
))
50 xchg(&emergency_ptr
, m
);