linux: Make the macro LINUX_IOCTL_SET public

There're some other drivers want to register and unregister linux
ioctl handler. Move the macro LINUX_IOCTL_SET from tdfx_linux.h to
linux_ioctl.h so that they can also benefit it.

While here, rename the declaration of linux ioctl function to be
consistent with the name of the handler.

Meanwhile, drop a comment about the macro, since its function is
obvious.

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D53158

(cherry picked from commit 790c27317ec1a997a4e5c2bdee9e4acc610c8e3c)
This commit is contained in:
Zhenlei Huang 2025-10-20 12:28:41 +08:00
parent b8fb76b78e
commit 087e77b523
3 changed files with 13 additions and 13 deletions

View file

@ -823,4 +823,16 @@ int linux32_ioctl_register_handler(struct linux_ioctl_handler *h);
int linux32_ioctl_unregister_handler(struct linux_ioctl_handler *h);
#endif
#define LINUX_IOCTL_SET(n, low, high) \
static linux_ioctl_function_t n##_linux_ioctl; \
static struct linux_ioctl_handler n##_linux_handler = { \
n##_linux_ioctl, \
low, \
high \
}; \
SYSINIT(n##_ioctl_register, SI_SUB_KLD, SI_ORDER_MIDDLE, \
linux_ioctl_register_handler, &n##_linux_handler); \
SYSUNINIT(n##_ioctl_unregister, SI_SUB_KLD, SI_ORDER_MIDDLE, \
linux_ioctl_unregister_handler, &n##_linux_handler)
#endif /* !_LINUX_IOCTL_H_ */

View file

@ -42,7 +42,7 @@ LINUX_IOCTL_SET(tdfx, LINUX_IOCTL_TDFX_MIN, LINUX_IOCTL_TDFX_MAX);
* Linux emulation IOCTL for /dev/tdfx
*/
static int
linux_ioctl_tdfx(struct thread *td, struct linux_ioctl_args* args)
tdfx_linux_ioctl(struct thread *td, struct linux_ioctl_args* args)
{
cap_rights_t rights;
int error = 0;

View file

@ -35,18 +35,6 @@
#include <machine/../linux/linux_proto.h>
#include <compat/linux/linux_ioctl.h>
/*
* This code was donated by Vladimir N. Silynaev to allow for defining
* ioctls within modules
*/
#define LINUX_IOCTL_SET(n,low,high) \
static linux_ioctl_function_t linux_ioctl_##n; \
static struct linux_ioctl_handler n##_handler = {linux_ioctl_##n, low, high}; \
SYSINIT(n##register, SI_SUB_KLD, SI_ORDER_MIDDLE,\
linux_ioctl_register_handler, &n##_handler); \
SYSUNINIT(n##unregister, SI_SUB_KLD, SI_ORDER_MIDDLE,\
linux_ioctl_unregister_handler, &n##_handler);
/* Values for /dev/3dfx */
/* Query IOCTLs */
#define LINUX_IOCTL_TDFX_QUERY_BOARDS 0x3302