mirror of
https://github.com/tsukumijima/px4_drv.git
synced 2025-07-23 04:03:01 +02:00
モジュールの初期化および終了関数にそれぞれ `__init` と `__exit` を指定 した.これらマクロを使用していなくても大きな問題は発生しないと考えられ るが,一般的な作法として追加した. これらマクロの説明は以下を参照: * https://tldp.org/LDP/lkmpg/2.4/html/x281.htm * https://fastbitlab.com/linux-device-driver-programming-lecture-18-__init-and-__exit-macros/ * https://shnoh171.github.io/linux%20kernel/2019/09/01/linux-kernel-module-basics.html
75 lines
1.3 KiB
C
75 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Module initiator of the driver (driver_module.c)
|
|
*
|
|
* Copyright (c) 2018-2021 nns779
|
|
*/
|
|
|
|
#include "print_format.h"
|
|
#include "driver_module.h"
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/version.h>
|
|
|
|
#include "revision.h"
|
|
#include "px4_usb.h"
|
|
#include "firmware.h"
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,15,4)
|
|
static int __init m_init(void)
|
|
#else
|
|
int init_module(void)
|
|
#endif
|
|
{
|
|
int ret = 0;
|
|
|
|
pr_info(KBUILD_MODNAME
|
|
#ifdef PX4_DRV_VERSION
|
|
" version " PX4_DRV_VERSION
|
|
#endif
|
|
#ifdef REVISION_NUMBER
|
|
#if defined(PX4_DRV_VERSION)
|
|
","
|
|
#endif
|
|
" rev: " REVISION_NUMBER
|
|
#endif
|
|
#ifdef COMMIT_HASH
|
|
#if defined(PX4_DRV_VERSION) || defined(REVISION_NUMBER)
|
|
","
|
|
#endif
|
|
" commit: " COMMIT_HASH
|
|
#endif
|
|
#ifdef REVISION_NAME
|
|
" @ " REVISION_NAME
|
|
#endif
|
|
"\n");
|
|
|
|
ret = px4_usb_register();
|
|
if (ret)
|
|
return ret;
|
|
|
|
return 0;
|
|
}
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,15,4)
|
|
static void __exit m_cleanup(void)
|
|
#else
|
|
void cleanup_module(void)
|
|
#endif
|
|
{
|
|
px4_usb_unregister();
|
|
}
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,15,4)
|
|
module_init(m_init);
|
|
module_exit(m_cleanup);
|
|
#endif
|
|
|
|
MODULE_VERSION(PX4_DRV_VERSION);
|
|
MODULE_AUTHOR("nns779");
|
|
MODULE_DESCRIPTION("Unofficial Linux driver for PLEX PX4/PX5/PX-MLT series ISDB-T/S receivers");
|
|
MODULE_LICENSE("GPL v2");
|
|
|
|
MODULE_FIRMWARE(IT930X_FIRMWARE_FILENAME);
|