From 03f1cf9f32ad6c8aacc2dcdb6b015923f5a346f8 Mon Sep 17 00:00:00 2001 From: Johannes Lundberg Date: Sun, 19 May 2019 15:44:21 +0000 Subject: [PATCH] LinuxKPI: Finalize move of lindebugfs from ports to base. The source file was moved to base earlier and also improved upon, but never compiled in. This patch will: - Make a module in sys/modules - Make lindebugfs depend on linuxkpi (for seq_file) - Check if read/write functions are set before calling, DRM drivers don't always set both of them. Reviewed by: hps Approved by: imp (mentor), hps MFC after: 1 week --- sys/compat/lindebugfs/lindebugfs.c | 16 ++++++++++++---- sys/modules/Makefile | 1 + sys/modules/lindebugfs/Makefile | 12 ++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 sys/modules/lindebugfs/Makefile diff --git a/sys/compat/lindebugfs/lindebugfs.c b/sys/compat/lindebugfs/lindebugfs.c index fc07dec1d01..c86e93d99ff 100644 --- a/sys/compat/lindebugfs/lindebugfs.c +++ b/sys/compat/lindebugfs/lindebugfs.c @@ -143,10 +143,17 @@ debugfs_fill(PFS_FILL_ARGS) } sf = lf.private_data; sf->buf = sb; - if (uio->uio_rw == UIO_READ) - rc = d->dm_fops->read(&lf, NULL, len, &off); - else - rc = d->dm_fops->write(&lf, buf, len, &off); + if (uio->uio_rw == UIO_READ) { + if (d->dm_fops->read) + rc = d->dm_fops->read(&lf, NULL, len, &off); + else + rc = ENODEV; + } else { + if (d->dm_fops->write) + rc = d->dm_fops->write(&lf, buf, len, &off); + else + rc = ENODEV; + } if (d->dm_fops->release) d->dm_fops->release(&vn, &lf); else @@ -307,3 +314,4 @@ PSEUDOFS(debugfs, 1, PR_ALLOW_MOUNT_LINSYSFS); #else PSEUDOFS(debugfs, 1, VFCF_JAIL); #endif +MODULE_DEPEND(lindebugfs, linuxkpi, 1, 1, 1); diff --git a/sys/modules/Makefile b/sys/modules/Makefile index ecaf858ac57..396d3e3f722 100644 --- a/sys/modules/Makefile +++ b/sys/modules/Makefile @@ -205,6 +205,7 @@ SUBDIR= \ libalias \ libiconv \ libmchain \ + lindebugfs \ ${_linux} \ ${_linux_common} \ ${_linux64} \ diff --git a/sys/modules/lindebugfs/Makefile b/sys/modules/lindebugfs/Makefile new file mode 100644 index 00000000000..0cb732e77b9 --- /dev/null +++ b/sys/modules/lindebugfs/Makefile @@ -0,0 +1,12 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/sys/compat/lindebugfs + +KMOD= lindebugfs +SRCS= vnode_if.h \ + device_if.h bus_if.h pci_if.h \ + lindebugfs.c + +CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include + +.include