anolis: pstore: fix ttyprobe hook
ANBZ: #4411 Do the ttyprobe hook only when ttyprobe is registered Signed-off-by: Yuanhe Shu <xiangzao@linux.alibaba.com> Reviewed-by: Xunlei Pang <xlpang@linux.alibaba.com> Link: https://gitee.com/anolis/cloud-kernel/pulls/1388
This commit is contained in:
parent
6d9da47c00
commit
6c75da2eeb
|
@ -587,7 +587,7 @@ static ssize_t process_output_block(struct tty_struct *tty,
|
|||
}
|
||||
}
|
||||
break_out:
|
||||
pstore_start_ttyprobe(buf, i);
|
||||
tty_pstore_hook(buf, i);
|
||||
i = tty->ops->write(tty, buf, i);
|
||||
|
||||
mutex_unlock(&ldata->output_lock);
|
||||
|
|
|
@ -14,14 +14,11 @@
|
|||
#include "internal.h"
|
||||
|
||||
static DEFINE_MUTEX(ttymsg_lock);
|
||||
DEFINE_STATIC_KEY_FALSE(ttyprobe_key);
|
||||
|
||||
#define TTYPROBE_NAME "ttyprobe"
|
||||
#undef pr_fmt
|
||||
#define pr_fmt(fmt) TTYPROBE_NAME ": " fmt
|
||||
#define PSTORE_TTYPROBE_REGISTERED 1
|
||||
#define PSTORE_TTYPROBE_UNREGISTERED 0
|
||||
|
||||
bool pstore_ttyprobe_status = PSTORE_TTYPROBE_UNREGISTERED;
|
||||
|
||||
static void do_write_ttymsg(const unsigned char *buf, int count,
|
||||
struct pstore_info *psinfo)
|
||||
|
@ -47,16 +44,13 @@ static void do_write_ttymsg(const unsigned char *buf, int count,
|
|||
|
||||
void pstore_register_ttyprobe(void)
|
||||
{
|
||||
pstore_ttyprobe_status = PSTORE_TTYPROBE_REGISTERED;
|
||||
static_branch_enable(&ttyprobe_key);
|
||||
}
|
||||
|
||||
void pstore_start_ttyprobe(const unsigned char *buf, int count)
|
||||
{
|
||||
struct pstore_info_list *entry;
|
||||
|
||||
if (pstore_ttyprobe_status == PSTORE_TTYPROBE_UNREGISTERED)
|
||||
return;
|
||||
|
||||
rcu_read_lock();
|
||||
list_for_each_entry_rcu(entry, &psback->list_entry, list)
|
||||
if (entry->psi->flags & PSTORE_FLAGS_TTYPROBE)
|
||||
|
@ -66,5 +60,5 @@ void pstore_start_ttyprobe(const unsigned char *buf, int count)
|
|||
|
||||
void pstore_unregister_ttyprobe(void)
|
||||
{
|
||||
pstore_ttyprobe_status = PSTORE_TTYPROBE_UNREGISTERED;
|
||||
static_branch_disable(&ttyprobe_key);
|
||||
}
|
||||
|
|
|
@ -532,9 +532,17 @@ extern void tty_termios_encode_baud_rate(struct ktermios *termios,
|
|||
extern void tty_encode_baud_rate(struct tty_struct *tty,
|
||||
speed_t ibaud, speed_t obaud);
|
||||
#ifdef CONFIG_PSTORE_TTYPROBE
|
||||
DECLARE_STATIC_KEY_FALSE(ttyprobe_key);
|
||||
extern void pstore_start_ttyprobe(const unsigned char *buf, int count);
|
||||
|
||||
static inline void tty_pstore_hook(const unsigned char *buf, int count)
|
||||
{
|
||||
if (static_branch_unlikely(&ttyprobe_key))
|
||||
pstore_start_ttyprobe(buf, count);
|
||||
}
|
||||
|
||||
#else
|
||||
static inline void pstore_start_ttyprobe(const unsigned char *buf, int count) {}
|
||||
static inline void tty_pstore_hook(const unsigned char *buf, int count) {}
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue