^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef __MCONSOLE_KERN_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define __MCONSOLE_KERN_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "mconsole.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct mconsole_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct mc_request request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /* All these methods are called in process context. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct mc_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) int (*config)(char *, char **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) int (*get_config)(char *, char *, int, char **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) int (*id)(char **, int *, int *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) int (*remove)(int, char **);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define CONFIG_CHUNK(str, size, current, chunk, end) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) current += strlen(chunk); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) if(current >= size) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) str = NULL; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) if(str != NULL){ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) strcpy(str, chunk); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) str += strlen(chunk); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if(end) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) current++; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) } while(0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #ifdef CONFIG_MCONSOLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) extern void mconsole_register_dev(struct mc_device *new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static inline void mconsole_register_dev(struct mc_device *new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #endif