18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef __MCONSOLE_KERN_H__
78c2ecf20Sopenharmony_ci#define __MCONSOLE_KERN_H__
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/list.h>
108c2ecf20Sopenharmony_ci#include "mconsole.h"
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cistruct mconsole_entry {
138c2ecf20Sopenharmony_ci	struct list_head list;
148c2ecf20Sopenharmony_ci	struct mc_request request;
158c2ecf20Sopenharmony_ci};
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* All these methods are called in process context. */
188c2ecf20Sopenharmony_cistruct mc_device {
198c2ecf20Sopenharmony_ci	struct list_head list;
208c2ecf20Sopenharmony_ci	char *name;
218c2ecf20Sopenharmony_ci	int (*config)(char *, char **);
228c2ecf20Sopenharmony_ci	int (*get_config)(char *, char *, int, char **);
238c2ecf20Sopenharmony_ci	int (*id)(char **, int *, int *);
248c2ecf20Sopenharmony_ci	int (*remove)(int, char **);
258c2ecf20Sopenharmony_ci};
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define CONFIG_CHUNK(str, size, current, chunk, end) \
288c2ecf20Sopenharmony_cido { \
298c2ecf20Sopenharmony_ci	current += strlen(chunk); \
308c2ecf20Sopenharmony_ci	if(current >= size) \
318c2ecf20Sopenharmony_ci		str = NULL; \
328c2ecf20Sopenharmony_ci	if(str != NULL){ \
338c2ecf20Sopenharmony_ci		strcpy(str, chunk); \
348c2ecf20Sopenharmony_ci		str += strlen(chunk); \
358c2ecf20Sopenharmony_ci	} \
368c2ecf20Sopenharmony_ci	if(end) \
378c2ecf20Sopenharmony_ci		current++; \
388c2ecf20Sopenharmony_ci} while(0)
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#ifdef CONFIG_MCONSOLE
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ciextern void mconsole_register_dev(struct mc_device *new);
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#else
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_cistatic inline void mconsole_register_dev(struct mc_device *new)
478c2ecf20Sopenharmony_ci{
488c2ecf20Sopenharmony_ci}
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#endif
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#endif
53