]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
cxl: Export file ops for use by API
authorMichael Neuling <mikey@neuling.org>
Wed, 27 May 2015 06:07:17 +0000 (16:07 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 3 Jun 2015 03:27:20 +0000 (13:27 +1000)
The cxl kernel API will allow drivers other than cxl to export a file
descriptor which has the same userspace API.  These file descriptors will be
able to be used against libcxl.

This exports those file ops for use by other drivers.

Signed-off-by: Michael Neuling <mikey@neuling.org>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
drivers/misc/cxl/cxl.h
drivers/misc/cxl/file.c

index 46d806e3b943499f702e12f200966a1e87d635a4..2ec8e96e2de3a989d91c8c203f7cdb0212625e5b 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/pid.h>
 #include <linux/io.h>
 #include <linux/pci.h>
+#include <linux/fs.h>
 #include <asm/cputable.h>
 #include <asm/mmu.h>
 #include <asm/reg.h>
@@ -674,4 +675,12 @@ void cxl_stop_trace(struct cxl *cxl);
 extern struct pci_driver cxl_pci_driver;
 int afu_allocate_irqs(struct cxl_context *ctx, u32 count);
 
+int afu_open(struct inode *inode, struct file *file);
+int afu_release(struct inode *inode, struct file *file);
+long afu_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+int afu_mmap(struct file *file, struct vm_area_struct *vm);
+unsigned int afu_poll(struct file *file, struct poll_table_struct *poll);
+ssize_t afu_read(struct file *file, char __user *buf, size_t count, loff_t *off);
+extern const struct file_operations afu_fops;
+
 #endif
index c16bd6fa06ed20638eb359cd586541b8610ba730..e3f4b69527a9bd2df592c36227c536c8a3321f50 100644 (file)
@@ -96,7 +96,8 @@ err_put_adapter:
        put_device(&adapter->dev);
        return rc;
 }
-static int afu_open(struct inode *inode, struct file *file)
+
+int afu_open(struct inode *inode, struct file *file)
 {
        return __afu_open(inode, file, false);
 }
@@ -106,7 +107,7 @@ static int afu_master_open(struct inode *inode, struct file *file)
        return __afu_open(inode, file, true);
 }
 
-static int afu_release(struct inode *inode, struct file *file)
+int afu_release(struct inode *inode, struct file *file)
 {
        struct cxl_context *ctx = file->private_data;
 
@@ -230,7 +231,7 @@ static long afu_ioctl_get_afu_id(struct cxl_context *ctx,
        return 0;
 }
 
-static long afu_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+long afu_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        struct cxl_context *ctx = file->private_data;
 
@@ -250,13 +251,13 @@ static long afu_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        return -EINVAL;
 }
 
-static long afu_compat_ioctl(struct file *file, unsigned int cmd,
+long afu_compat_ioctl(struct file *file, unsigned int cmd,
                             unsigned long arg)
 {
        return afu_ioctl(file, cmd, arg);
 }
 
-static int afu_mmap(struct file *file, struct vm_area_struct *vm)
+int afu_mmap(struct file *file, struct vm_area_struct *vm)
 {
        struct cxl_context *ctx = file->private_data;
 
@@ -267,7 +268,7 @@ static int afu_mmap(struct file *file, struct vm_area_struct *vm)
        return cxl_context_iomap(ctx, vm);
 }
 
-static unsigned int afu_poll(struct file *file, struct poll_table_struct *poll)
+unsigned int afu_poll(struct file *file, struct poll_table_struct *poll)
 {
        struct cxl_context *ctx = file->private_data;
        int mask = 0;
@@ -299,7 +300,7 @@ static inline int ctx_event_pending(struct cxl_context *ctx)
            ctx->pending_afu_err || (ctx->status == CLOSED));
 }
 
-static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
+ssize_t afu_read(struct file *file, char __user *buf, size_t count,
                        loff_t *off)
 {
        struct cxl_context *ctx = file->private_data;
@@ -380,7 +381,11 @@ out:
        return rc;
 }
 
-static const struct file_operations afu_fops = {
+/* 
+ * Note: if this is updated, we need to update api.c to patch the new ones in
+ * too
+ */
+const struct file_operations afu_fops = {
        .owner          = THIS_MODULE,
        .open           = afu_open,
        .poll           = afu_poll,
@@ -391,7 +396,7 @@ static const struct file_operations afu_fops = {
        .mmap           = afu_mmap,
 };
 
-static const struct file_operations afu_master_fops = {
+const struct file_operations afu_master_fops = {
        .owner          = THIS_MODULE,
        .open           = afu_master_open,
        .poll           = afu_poll,