/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
/*
 * Copyright (c) 2020 MediaTek Inc.
 */

#ifndef MDRV_DEMUX_DEBUG_H
#define MDRV_DEMUX_DEBUG_H

#undef pr_fmt
#define pr_fmt(fmt) "[MDRV_DEMUX]: " fmt

#include <linux/platform_device.h>

#define DEMUX_DEBUG_ERR(fmt, ...)	pr_err(fmt, ##__VA_ARGS__)
#define DEMUX_DEBUG_WARN(fmt, ...)	pr_warn(fmt, ##__VA_ARGS__)
#define DEMUX_DEBUG_INFO(fmt, ...)	pr_info(fmt, ##__VA_ARGS__)
#define DEMUX_DEBUG_DEBUG(fmt, ...)	pr_debug(fmt, ##__VA_ARGS__)

#define DEMUX_KOBJ_INIT_ADD(kobj, attr_group, parent, fmt, ...) \
({ \
	int ret; \
	ret = kobject_init_and_add(kobj, mdrv_demux_debug_get_ktype(), \
		parent, fmt, ##__VA_ARGS__); \
	if (ret) { \
		DEMUX_DEBUG_DEBUG("[%s][%d] kobj init & add fail\n", \
			__FUNCTION__, __LINE__); \
		ret = -EFAULT; \
	} else \
		if (attr_group) \
			sysfs_create_group(kobj, attr_group); \
	ret; \
})

int mdrv_demux_debug_init(struct platform_device *pdev);
int mdrv_demux_debug_exit(struct platform_device *pdev);

struct kobject *mdrv_demux_debug_get_root_kobj(void);
struct kobj_type *mdrv_demux_debug_get_ktype(void);
int mdrv_demux_debug_remove_attr_group(struct kobject *kobj, struct attribute_group *attr_group);

#endif				/* MDRV_DEMUX_DEBUG_H */
