diff mbox series

[4/5] drivers: fsi: separate char device code for occ and sbefifo

Message ID 20221014220540.55570-5-eajames@linux.ibm.com
State New
Headers show
Series fsi: Add regmap and refactor sbefifo | expand

Commit Message

Eddie James Oct. 14, 2022, 10:05 p.m. UTC
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 drivers/fsi/Makefile       |   4 +-
 drivers/fsi/occ-cdev.c     | 139 ++++++++++++++++++++++++
 drivers/fsi/occ.c          | 137 -----------------------
 drivers/fsi/sbefifo-cdev.c | 217 +++++++++++++++++++++++++++++++++++++
 drivers/fsi/sbefifo.c      | 215 ------------------------------------
 5 files changed, 358 insertions(+), 354 deletions(-)
 create mode 100644 drivers/fsi/occ-cdev.c
 create mode 100644 drivers/fsi/sbefifo-cdev.c

Comments

kernel test robot Oct. 17, 2022, 8:53 p.m. UTC | #1
Hi Eddie,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.1-rc1 next-20221017]
[cannot apply to broonie-regmap/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Eddie-James/fsi-Add-regmap-and-refactor-sbefifo/20221017-114633
patch link:    https://lore.kernel.org/r/20221014220540.55570-5-eajames%40linux.ibm.com
patch subject: [PATCH 4/5] drivers: fsi: separate char device code for occ and sbefifo
config: arm-defconfig
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/498e22ba941d12f714dd5f55dedf709edfe4966f
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Eddie-James/fsi-Add-regmap-and-refactor-sbefifo/20221017-114633
        git checkout 498e22ba941d12f714dd5f55dedf709edfe4966f
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/fsi/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/fsi/occ-cdev.c:4:49: warning: 'struct file' declared inside parameter list will not be visible outside of this definition or declaration
       4 | static int occ_open(struct inode *inode, struct file *file)
         |                                                 ^~~~
   drivers/fsi/occ-cdev.c:4:28: warning: 'struct inode' declared inside parameter list will not be visible outside of this definition or declaration
       4 | static int occ_open(struct inode *inode, struct file *file)
         |                            ^~~~~
   drivers/fsi/occ-cdev.c: In function 'occ_open':
   drivers/fsi/occ-cdev.c:6:37: error: implicit declaration of function 'kzalloc' [-Werror=implicit-function-declaration]
       6 |         struct occ_client *client = kzalloc(sizeof(*client), GFP_KERNEL);
         |                                     ^~~~~~~
   drivers/fsi/occ-cdev.c:6:51: error: invalid application of 'sizeof' to incomplete type 'struct occ_client'
       6 |         struct occ_client *client = kzalloc(sizeof(*client), GFP_KERNEL);
         |                                                   ^
   drivers/fsi/occ-cdev.c:6:62: error: 'GFP_KERNEL' undeclared (first use in this function)
       6 |         struct occ_client *client = kzalloc(sizeof(*client), GFP_KERNEL);
         |                                                              ^~~~~~~~~~
   drivers/fsi/occ-cdev.c:6:62: note: each undeclared identifier is reported only once for each function it appears in
   drivers/fsi/occ-cdev.c:7:39: error: invalid use of undefined type 'struct file'
       7 |         struct miscdevice *mdev = file->private_data;
         |                                       ^~
   drivers/fsi/occ-cdev.c:8:27: error: implicit declaration of function 'to_occ' [-Werror=implicit-function-declaration]
       8 |         struct occ *occ = to_occ(mdev);
         |                           ^~~~~~
   drivers/fsi/occ-cdev.c:8:27: warning: initialization of 'struct occ *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   drivers/fsi/occ-cdev.c:11:25: error: 'ENOMEM' undeclared (first use in this function)
      11 |                 return -ENOMEM;
         |                         ^~~~~~
   drivers/fsi/occ-cdev.c:13:15: error: invalid use of undefined type 'struct occ_client'
      13 |         client->buffer = (u8 *)__get_free_page(GFP_KERNEL);
         |               ^~
   drivers/fsi/occ-cdev.c:13:27: error: 'u8' undeclared (first use in this function)
      13 |         client->buffer = (u8 *)__get_free_page(GFP_KERNEL);
         |                           ^~
   drivers/fsi/occ-cdev.c:13:31: error: expected expression before ')' token
      13 |         client->buffer = (u8 *)__get_free_page(GFP_KERNEL);
         |                               ^
   drivers/fsi/occ-cdev.c:14:20: error: invalid use of undefined type 'struct occ_client'
      14 |         if (!client->buffer) {
         |                    ^~
   drivers/fsi/occ-cdev.c:15:17: error: implicit declaration of function 'kfree' [-Werror=implicit-function-declaration]
      15 |                 kfree(client);
         |                 ^~~~~
   drivers/fsi/occ-cdev.c:19:15: error: invalid use of undefined type 'struct occ_client'
      19 |         client->occ = occ;
         |               ^~
   drivers/fsi/occ-cdev.c:20:9: error: implicit declaration of function 'mutex_init' [-Werror=implicit-function-declaration]
      20 |         mutex_init(&client->lock);
         |         ^~~~~~~~~~
   drivers/fsi/occ-cdev.c:20:27: error: invalid use of undefined type 'struct occ_client'
      20 |         mutex_init(&client->lock);
         |                           ^~
   drivers/fsi/occ-cdev.c:21:13: error: invalid use of undefined type 'struct file'
      21 |         file->private_data = client;
         |             ^~
   drivers/fsi/occ-cdev.c:22:9: error: implicit declaration of function 'get_device' [-Werror=implicit-function-declaration]
      22 |         get_device(occ->dev);
         |         ^~~~~~~~~~
>> drivers/fsi/occ-cdev.c:22:23: error: invalid use of undefined type 'struct occ'
      22 |         get_device(occ->dev);
         |                       ^~
   drivers/fsi/occ-cdev.c:25:9: error: implicit declaration of function 'BUILD_BUG_ON' [-Werror=implicit-function-declaration]
      25 |         BUILD_BUG_ON((OCC_CMD_DATA_BYTES + 3) > PAGE_SIZE);
         |         ^~~~~~~~~~~~
>> drivers/fsi/occ-cdev.c:25:23: error: 'OCC_CMD_DATA_BYTES' undeclared (first use in this function)
      25 |         BUILD_BUG_ON((OCC_CMD_DATA_BYTES + 3) > PAGE_SIZE);
         |                       ^~~~~~~~~~~~~~~~~~
   drivers/fsi/occ-cdev.c:25:49: error: 'PAGE_SIZE' undeclared (first use in this function)
      25 |         BUILD_BUG_ON((OCC_CMD_DATA_BYTES + 3) > PAGE_SIZE);
         |                                                 ^~~~~~~~~
   drivers/fsi/occ-cdev.c:26:23: error: 'OCC_RESP_DATA_BYTES' undeclared (first use in this function)
      26 |         BUILD_BUG_ON((OCC_RESP_DATA_BYTES + 7) > PAGE_SIZE);
         |                       ^~~~~~~~~~~~~~~~~~~
   drivers/fsi/occ-cdev.c: At top level:
   drivers/fsi/occ-cdev.c:31:8: error: unknown type name 'ssize_t'
      31 | static ssize_t occ_read(struct file *file, char __user *buf, size_t len,
         |        ^~~~~~~
   drivers/fsi/occ-cdev.c:31:62: error: unknown type name 'size_t'
      31 | static ssize_t occ_read(struct file *file, char __user *buf, size_t len,
         |                                                              ^~~~~~
   drivers/fsi/occ-cdev.c:1:1: note: 'size_t' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
     +++ |+#include <stddef.h>
       1 | // SPDX-License-Identifier: GPL-2.0
   drivers/fsi/occ-cdev.c:32:25: error: unknown type name 'loff_t'
      32 |                         loff_t *offset)
         |                         ^~~~~~
   drivers/fsi/occ-cdev.c:64:8: error: unknown type name 'ssize_t'
      64 | static ssize_t occ_write(struct file *file, const char __user *buf,
         |        ^~~~~~~
   drivers/fsi/occ-cdev.c:65:26: error: unknown type name 'size_t'
      65 |                          size_t len, loff_t *offset)
         |                          ^~~~~~
   drivers/fsi/occ-cdev.c:65:26: note: 'size_t' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
   drivers/fsi/occ-cdev.c:65:38: error: unknown type name 'loff_t'
      65 |                          size_t len, loff_t *offset)
         |                                      ^~~~~~
   drivers/fsi/occ-cdev.c:122:52: warning: 'struct file' declared inside parameter list will not be visible outside of this definition or declaration
     122 | static int occ_release(struct inode *inode, struct file *file)
         |                                                    ^~~~
   drivers/fsi/occ-cdev.c:122:31: warning: 'struct inode' declared inside parameter list will not be visible outside of this definition or declaration
     122 | static int occ_release(struct inode *inode, struct file *file)
         |                               ^~~~~
   drivers/fsi/occ-cdev.c: In function 'occ_release':
   drivers/fsi/occ-cdev.c:124:41: error: invalid use of undefined type 'struct file'
     124 |         struct occ_client *client = file->private_data;
         |                                         ^~
   drivers/fsi/occ-cdev.c:126:9: error: implicit declaration of function 'put_device' [-Werror=implicit-function-declaration]
     126 |         put_device(client->occ->dev);
         |         ^~~~~~~~~~
   drivers/fsi/occ-cdev.c:126:26: error: invalid use of undefined type 'struct occ_client'
     126 |         put_device(client->occ->dev);
         |                          ^~
   drivers/fsi/occ-cdev.c:127:9: error: implicit declaration of function 'free_page' [-Werror=implicit-function-declaration]
     127 |         free_page((unsigned long)client->buffer);
         |         ^~~~~~~~~
   drivers/fsi/occ-cdev.c:127:40: error: invalid use of undefined type 'struct occ_client'
     127 |         free_page((unsigned long)client->buffer);
         |                                        ^~
   drivers/fsi/occ-cdev.c: At top level:
   drivers/fsi/occ-cdev.c:133:21: error: variable 'occ_fops' has initializer but incomplete type
     133 | static const struct file_operations occ_fops = {
         |                     ^~~~~~~~~~~~~~~
   drivers/fsi/occ-cdev.c:134:10: error: 'const struct file_operations' has no member named 'owner'
     134 |         .owner = THIS_MODULE,
         |          ^~~~~
   drivers/fsi/occ-cdev.c:134:18: error: 'THIS_MODULE' undeclared here (not in a function); did you mean 'IS_MODULE'?
     134 |         .owner = THIS_MODULE,
         |                  ^~~~~~~~~~~
         |                  IS_MODULE
   drivers/fsi/occ-cdev.c:134:18: warning: excess elements in struct initializer
   drivers/fsi/occ-cdev.c:134:18: note: (near initialization for 'occ_fops')
   drivers/fsi/occ-cdev.c:135:10: error: 'const struct file_operations' has no member named 'open'
     135 |         .open = occ_open,
         |          ^~~~
   drivers/fsi/occ-cdev.c:135:17: warning: excess elements in struct initializer
     135 |         .open = occ_open,
         |                 ^~~~~~~~
   drivers/fsi/occ-cdev.c:135:17: note: (near initialization for 'occ_fops')
   drivers/fsi/occ-cdev.c:136:10: error: 'const struct file_operations' has no member named 'read'
     136 |         .read = occ_read,
         |          ^~~~
   drivers/fsi/occ-cdev.c:136:17: error: 'occ_read' undeclared here (not in a function)
     136 |         .read = occ_read,
         |                 ^~~~~~~~
   drivers/fsi/occ-cdev.c:136:17: warning: excess elements in struct initializer
   drivers/fsi/occ-cdev.c:136:17: note: (near initialization for 'occ_fops')
   drivers/fsi/occ-cdev.c:137:10: error: 'const struct file_operations' has no member named 'write'
     137 |         .write = occ_write,
         |          ^~~~~
   drivers/fsi/occ-cdev.c:137:18: error: 'occ_write' undeclared here (not in a function)
     137 |         .write = occ_write,
         |                  ^~~~~~~~~
   drivers/fsi/occ-cdev.c:137:18: warning: excess elements in struct initializer
   drivers/fsi/occ-cdev.c:137:18: note: (near initialization for 'occ_fops')
   drivers/fsi/occ-cdev.c:138:10: error: 'const struct file_operations' has no member named 'release'
     138 |         .release = occ_release,
         |          ^~~~~~~
   drivers/fsi/occ-cdev.c:138:20: warning: excess elements in struct initializer
     138 |         .release = occ_release,
         |                    ^~~~~~~~~~~
   drivers/fsi/occ-cdev.c:138:20: note: (near initialization for 'occ_fops')
   drivers/fsi/occ-cdev.c:133:37: error: storage size of 'occ_fops' isn't known
     133 | static const struct file_operations occ_fops = {
         |                                     ^~~~~~~~
   drivers/fsi/occ-cdev.c:133:37: warning: 'occ_fops' defined but not used [-Wunused-const-variable=]


vim +22 drivers/fsi/occ-cdev.c

     3	
     4	static int occ_open(struct inode *inode, struct file *file)
     5	{
     6		struct occ_client *client = kzalloc(sizeof(*client), GFP_KERNEL);
     7		struct miscdevice *mdev = file->private_data;
     8		struct occ *occ = to_occ(mdev);
     9	
    10		if (!client)
    11			return -ENOMEM;
    12	
    13		client->buffer = (u8 *)__get_free_page(GFP_KERNEL);
    14		if (!client->buffer) {
    15			kfree(client);
    16			return -ENOMEM;
    17		}
    18	
    19		client->occ = occ;
    20		mutex_init(&client->lock);
    21		file->private_data = client;
  > 22		get_device(occ->dev);
    23	
    24		/* We allocate a 1-page buffer, make sure it all fits */
  > 25		BUILD_BUG_ON((OCC_CMD_DATA_BYTES + 3) > PAGE_SIZE);
    26		BUILD_BUG_ON((OCC_RESP_DATA_BYTES + 7) > PAGE_SIZE);
    27	
    28		return 0;
    29	}
    30
diff mbox series

Patch

diff --git a/drivers/fsi/Makefile b/drivers/fsi/Makefile
index 7fcd70ee0b10..e4182a2b2600 100644
--- a/drivers/fsi/Makefile
+++ b/drivers/fsi/Makefile
@@ -6,5 +6,5 @@  obj-$(CONFIG_FSI_MASTER_ASPEED) += fsi-master-aspeed.o
 obj-$(CONFIG_FSI_MASTER_GPIO) += fsi-master-gpio.o
 obj-$(CONFIG_FSI_MASTER_AST_CF) += fsi-master-ast-cf.o
 obj-$(CONFIG_FSI_SCOM) += fsi-scom.o
-obj-$(CONFIG_FSI_SBEFIFO) += sbefifo.o
-obj-$(CONFIG_FSI_OCC) += occ.o
+obj-$(CONFIG_FSI_SBEFIFO) += sbefifo.o sbefifo-cdev.o
+obj-$(CONFIG_FSI_OCC) += occ.o occ-cdev.o
diff --git a/drivers/fsi/occ-cdev.c b/drivers/fsi/occ-cdev.c
new file mode 100644
index 000000000000..b3be880b5fe8
--- /dev/null
+++ b/drivers/fsi/occ-cdev.c
@@ -0,0 +1,139 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) IBM Corporation 2022 */
+
+static int occ_open(struct inode *inode, struct file *file)
+{
+	struct occ_client *client = kzalloc(sizeof(*client), GFP_KERNEL);
+	struct miscdevice *mdev = file->private_data;
+	struct occ *occ = to_occ(mdev);
+
+	if (!client)
+		return -ENOMEM;
+
+	client->buffer = (u8 *)__get_free_page(GFP_KERNEL);
+	if (!client->buffer) {
+		kfree(client);
+		return -ENOMEM;
+	}
+
+	client->occ = occ;
+	mutex_init(&client->lock);
+	file->private_data = client;
+	get_device(occ->dev);
+
+	/* We allocate a 1-page buffer, make sure it all fits */
+	BUILD_BUG_ON((OCC_CMD_DATA_BYTES + 3) > PAGE_SIZE);
+	BUILD_BUG_ON((OCC_RESP_DATA_BYTES + 7) > PAGE_SIZE);
+
+	return 0;
+}
+
+static ssize_t occ_read(struct file *file, char __user *buf, size_t len,
+			loff_t *offset)
+{
+	struct occ_client *client = file->private_data;
+	ssize_t rc = 0;
+
+	if (!client)
+		return -ENODEV;
+
+	if (len > OCC_SRAM_BYTES)
+		return -EINVAL;
+
+	mutex_lock(&client->lock);
+
+	/* This should not be possible ... */
+	if (WARN_ON_ONCE(client->read_offset > client->data_size)) {
+		rc = -EIO;
+		goto done;
+	}
+
+	/* Grab how much data we have to read */
+	rc = min(len, client->data_size - client->read_offset);
+	if (copy_to_user(buf, client->buffer + client->read_offset, rc))
+		rc = -EFAULT;
+	else
+		client->read_offset += rc;
+
+ done:
+	mutex_unlock(&client->lock);
+
+	return rc;
+}
+
+static ssize_t occ_write(struct file *file, const char __user *buf,
+			 size_t len, loff_t *offset)
+{
+	struct occ_client *client = file->private_data;
+	size_t rlen, data_length;
+	ssize_t rc;
+	u8 *cmd;
+
+	if (!client)
+		return -ENODEV;
+
+	if (len > (OCC_CMD_DATA_BYTES + 3) || len < 3)
+		return -EINVAL;
+
+	mutex_lock(&client->lock);
+
+	/* Construct the command */
+	cmd = client->buffer;
+
+	/*
+	 * Copy the user command (assume user data follows the occ command
+	 * format)
+	 * byte 0: command type
+	 * bytes 1-2: data length (msb first)
+	 * bytes 3-n: data
+	 */
+	if (copy_from_user(&cmd[1], buf, len)) {
+		rc = -EFAULT;
+		goto done;
+	}
+
+	/* Extract data length */
+	data_length = (cmd[2] << 8) + cmd[3];
+	if (data_length > OCC_CMD_DATA_BYTES) {
+		rc = -EINVAL;
+		goto done;
+	}
+
+	/* Submit command; 4 bytes before the data and 2 bytes after */
+	rlen = PAGE_SIZE;
+	rc = fsi_occ_submit(client->occ->dev, cmd, data_length + 6, cmd,
+			    &rlen);
+	if (rc)
+		goto done;
+
+	/* Set read tracking data */
+	client->data_size = rlen;
+	client->read_offset = 0;
+
+	/* Done */
+	rc = len;
+
+ done:
+	mutex_unlock(&client->lock);
+
+	return rc;
+}
+
+static int occ_release(struct inode *inode, struct file *file)
+{
+	struct occ_client *client = file->private_data;
+
+	put_device(client->occ->dev);
+	free_page((unsigned long)client->buffer);
+	kfree(client);
+
+	return 0;
+}
+
+static const struct file_operations occ_fops = {
+	.owner = THIS_MODULE,
+	.open = occ_open,
+	.read = occ_read,
+	.write = occ_write,
+	.release = occ_release,
+};
\ No newline at end of file
diff --git a/drivers/fsi/occ.c b/drivers/fsi/occ.c
index abdd37d5507f..83429b0289e9 100644
--- a/drivers/fsi/occ.c
+++ b/drivers/fsi/occ.c
@@ -77,143 +77,6 @@  struct occ_client {
 
 static DEFINE_IDA(occ_ida);
 
-static int occ_open(struct inode *inode, struct file *file)
-{
-	struct occ_client *client = kzalloc(sizeof(*client), GFP_KERNEL);
-	struct miscdevice *mdev = file->private_data;
-	struct occ *occ = to_occ(mdev);
-
-	if (!client)
-		return -ENOMEM;
-
-	client->buffer = (u8 *)__get_free_page(GFP_KERNEL);
-	if (!client->buffer) {
-		kfree(client);
-		return -ENOMEM;
-	}
-
-	client->occ = occ;
-	mutex_init(&client->lock);
-	file->private_data = client;
-	get_device(occ->dev);
-
-	/* We allocate a 1-page buffer, make sure it all fits */
-	BUILD_BUG_ON((OCC_CMD_DATA_BYTES + 3) > PAGE_SIZE);
-	BUILD_BUG_ON((OCC_RESP_DATA_BYTES + 7) > PAGE_SIZE);
-
-	return 0;
-}
-
-static ssize_t occ_read(struct file *file, char __user *buf, size_t len,
-			loff_t *offset)
-{
-	struct occ_client *client = file->private_data;
-	ssize_t rc = 0;
-
-	if (!client)
-		return -ENODEV;
-
-	if (len > OCC_SRAM_BYTES)
-		return -EINVAL;
-
-	mutex_lock(&client->lock);
-
-	/* This should not be possible ... */
-	if (WARN_ON_ONCE(client->read_offset > client->data_size)) {
-		rc = -EIO;
-		goto done;
-	}
-
-	/* Grab how much data we have to read */
-	rc = min(len, client->data_size - client->read_offset);
-	if (copy_to_user(buf, client->buffer + client->read_offset, rc))
-		rc = -EFAULT;
-	else
-		client->read_offset += rc;
-
- done:
-	mutex_unlock(&client->lock);
-
-	return rc;
-}
-
-static ssize_t occ_write(struct file *file, const char __user *buf,
-			 size_t len, loff_t *offset)
-{
-	struct occ_client *client = file->private_data;
-	size_t rlen, data_length;
-	ssize_t rc;
-	u8 *cmd;
-
-	if (!client)
-		return -ENODEV;
-
-	if (len > (OCC_CMD_DATA_BYTES + 3) || len < 3)
-		return -EINVAL;
-
-	mutex_lock(&client->lock);
-
-	/* Construct the command */
-	cmd = client->buffer;
-
-	/*
-	 * Copy the user command (assume user data follows the occ command
-	 * format)
-	 * byte 0: command type
-	 * bytes 1-2: data length (msb first)
-	 * bytes 3-n: data
-	 */
-	if (copy_from_user(&cmd[1], buf, len)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	/* Extract data length */
-	data_length = (cmd[2] << 8) + cmd[3];
-	if (data_length > OCC_CMD_DATA_BYTES) {
-		rc = -EINVAL;
-		goto done;
-	}
-
-	/* Submit command; 4 bytes before the data and 2 bytes after */
-	rlen = PAGE_SIZE;
-	rc = fsi_occ_submit(client->occ->dev, cmd, data_length + 6, cmd,
-			    &rlen);
-	if (rc)
-		goto done;
-
-	/* Set read tracking data */
-	client->data_size = rlen;
-	client->read_offset = 0;
-
-	/* Done */
-	rc = len;
-
- done:
-	mutex_unlock(&client->lock);
-
-	return rc;
-}
-
-static int occ_release(struct inode *inode, struct file *file)
-{
-	struct occ_client *client = file->private_data;
-
-	put_device(client->occ->dev);
-	free_page((unsigned long)client->buffer);
-	kfree(client);
-
-	return 0;
-}
-
-static const struct file_operations occ_fops = {
-	.owner = THIS_MODULE,
-	.open = occ_open,
-	.read = occ_read,
-	.write = occ_write,
-	.release = occ_release,
-};
-
 static void occ_save_ffdc(struct occ *occ, __be32 *resp, size_t parsed_len,
 			  size_t resp_len)
 {
diff --git a/drivers/fsi/sbefifo-cdev.c b/drivers/fsi/sbefifo-cdev.c
new file mode 100644
index 000000000000..75765e8c307a
--- /dev/null
+++ b/drivers/fsi/sbefifo-cdev.c
@@ -0,0 +1,217 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) IBM Corporation 2022 */
+
+/*
+ * Char device interface
+ */
+
+static void sbefifo_release_command(struct sbefifo_user *user)
+{
+	if (is_vmalloc_addr(user->pending_cmd))
+		vfree(user->pending_cmd);
+	user->pending_cmd = NULL;
+	user->pending_len = 0;
+}
+
+static int sbefifo_user_open(struct inode *inode, struct file *file)
+{
+	struct sbefifo *sbefifo = container_of(inode->i_cdev, struct sbefifo, cdev);
+	struct sbefifo_user *user;
+
+	user = kzalloc(sizeof(struct sbefifo_user), GFP_KERNEL);
+	if (!user)
+		return -ENOMEM;
+
+	file->private_data = user;
+	user->sbefifo = sbefifo;
+	user->cmd_page = (void *)__get_free_page(GFP_KERNEL);
+	if (!user->cmd_page) {
+		kfree(user);
+		return -ENOMEM;
+	}
+	mutex_init(&user->file_lock);
+	user->read_timeout_ms = SBEFIFO_TIMEOUT_START_RSP;
+
+	return 0;
+}
+
+static ssize_t sbefifo_user_read(struct file *file, char __user *buf,
+				 size_t len, loff_t *offset)
+{
+	struct sbefifo_user *user = file->private_data;
+	struct sbefifo *sbefifo;
+	struct iov_iter resp_iter;
+        struct iovec resp_iov;
+	size_t cmd_len;
+	int rc;
+
+	if (!user)
+		return -EINVAL;
+	sbefifo = user->sbefifo;
+	if (len & 3)
+		return -EINVAL;
+
+	mutex_lock(&user->file_lock);
+
+	/* Cronus relies on -EAGAIN after a short read */
+	if (user->pending_len == 0) {
+		rc = -EAGAIN;
+		goto bail;
+	}
+	if (user->pending_len < 8) {
+		rc = -EINVAL;
+		goto bail;
+	}
+	cmd_len = user->pending_len >> 2;
+
+	/* Prepare iov iterator */
+	resp_iov.iov_base = buf;
+	resp_iov.iov_len = len;
+	iov_iter_init(&resp_iter, WRITE, &resp_iov, 1, len);
+
+	/* Perform the command */
+	rc = mutex_lock_interruptible(&sbefifo->lock);
+	if (rc)
+		goto bail;
+	sbefifo->timeout_start_rsp_ms = user->read_timeout_ms;
+	rc = __sbefifo_submit(sbefifo, user->pending_cmd, cmd_len, &resp_iter);
+	sbefifo->timeout_start_rsp_ms = SBEFIFO_TIMEOUT_START_RSP;
+	mutex_unlock(&sbefifo->lock);
+	if (rc < 0)
+		goto bail;
+
+	/* Extract the response length */
+	rc = len - iov_iter_count(&resp_iter);
+ bail:
+	sbefifo_release_command(user);
+	mutex_unlock(&user->file_lock);
+	return rc;
+}
+
+static ssize_t sbefifo_user_write(struct file *file, const char __user *buf,
+				  size_t len, loff_t *offset)
+{
+	struct sbefifo_user *user = file->private_data;
+	struct sbefifo *sbefifo;
+	int rc = len;
+
+	if (!user)
+		return -EINVAL;
+	sbefifo = user->sbefifo;
+	if (len > SBEFIFO_MAX_USER_CMD_LEN)
+		return -EINVAL;
+	if (len & 3)
+		return -EINVAL;
+
+	mutex_lock(&user->file_lock);
+
+	/* Can we use the pre-allocate buffer ? If not, allocate */
+	if (len <= PAGE_SIZE)
+		user->pending_cmd = user->cmd_page;
+	else
+		user->pending_cmd = vmalloc(len);
+	if (!user->pending_cmd) {
+		rc = -ENOMEM;
+		goto bail;
+	}
+
+	/* Copy the command into the staging buffer */
+	if (copy_from_user(user->pending_cmd, buf, len)) {
+		rc = -EFAULT;
+		goto bail;
+	}
+
+	/* Check for the magic reset command */
+	if (len == 4 && be32_to_cpu(*(__be32 *)user->pending_cmd) ==
+	    SBEFIFO_RESET_MAGIC)  {
+
+		/* Clear out any pending command */
+		user->pending_len = 0;
+
+		/* Trigger reset request */
+		rc = mutex_lock_interruptible(&sbefifo->lock);
+		if (rc)
+			goto bail;
+		rc = sbefifo_request_reset(user->sbefifo);
+		mutex_unlock(&sbefifo->lock);
+		if (rc == 0)
+			rc = 4;
+		goto bail;
+	}
+
+	/* Update the staging buffer size */
+	user->pending_len = len;
+ bail:
+	if (!user->pending_len)
+		sbefifo_release_command(user);
+
+	mutex_unlock(&user->file_lock);
+
+	/* And that's it, we'll issue the command on a read */
+	return rc;
+}
+
+static int sbefifo_user_release(struct inode *inode, struct file *file)
+{
+	struct sbefifo_user *user = file->private_data;
+
+	if (!user)
+		return -EINVAL;
+
+	sbefifo_release_command(user);
+	free_page((unsigned long)user->cmd_page);
+	kfree(user);
+
+	return 0;
+}
+
+static int sbefifo_read_timeout(struct sbefifo_user *user, void __user *argp)
+{
+	struct device *dev = &user->sbefifo->dev;
+	u32 timeout;
+
+	if (get_user(timeout, (__u32 __user *)argp))
+		return -EFAULT;
+
+	if (timeout == 0) {
+		user->read_timeout_ms = SBEFIFO_TIMEOUT_START_RSP;
+		dev_dbg(dev, "Timeout reset to %d\n", user->read_timeout_ms);
+		return 0;
+	}
+
+	if (timeout < 10 || timeout > 120)
+		return -EINVAL;
+
+	user->read_timeout_ms = timeout * 1000; /* user timeout is in sec */
+
+	dev_dbg(dev, "Timeout set to %d\n", user->read_timeout_ms);
+
+	return 0;
+}
+
+static long sbefifo_user_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	struct sbefifo_user *user = file->private_data;
+	int rc = -ENOTTY;
+
+	if (!user)
+		return -EINVAL;
+
+	mutex_lock(&user->file_lock);
+	switch (cmd) {
+	case FSI_SBEFIFO_READ_TIMEOUT_SECONDS:
+		rc = sbefifo_read_timeout(user, (void __user *)arg);
+		break;
+	}
+	mutex_unlock(&user->file_lock);
+	return rc;
+}
+
+static const struct file_operations sbefifo_fops = {
+	.owner		= THIS_MODULE,
+	.open		= sbefifo_user_open,
+	.read		= sbefifo_user_read,
+	.write		= sbefifo_user_write,
+	.release	= sbefifo_user_release,
+	.unlocked_ioctl = sbefifo_user_ioctl,
+};
diff --git a/drivers/fsi/sbefifo.c b/drivers/fsi/sbefifo.c
index 5f93a53846aa..634405b7aaf4 100644
--- a/drivers/fsi/sbefifo.c
+++ b/drivers/fsi/sbefifo.c
@@ -773,221 +773,6 @@  int sbefifo_submit(struct device *dev, const __be32 *command, size_t cmd_len,
 }
 EXPORT_SYMBOL_GPL(sbefifo_submit);
 
-/*
- * Char device interface
- */
-
-static void sbefifo_release_command(struct sbefifo_user *user)
-{
-	if (is_vmalloc_addr(user->pending_cmd))
-		vfree(user->pending_cmd);
-	user->pending_cmd = NULL;
-	user->pending_len = 0;
-}
-
-static int sbefifo_user_open(struct inode *inode, struct file *file)
-{
-	struct sbefifo *sbefifo = container_of(inode->i_cdev, struct sbefifo, cdev);
-	struct sbefifo_user *user;
-
-	user = kzalloc(sizeof(struct sbefifo_user), GFP_KERNEL);
-	if (!user)
-		return -ENOMEM;
-
-	file->private_data = user;
-	user->sbefifo = sbefifo;
-	user->cmd_page = (void *)__get_free_page(GFP_KERNEL);
-	if (!user->cmd_page) {
-		kfree(user);
-		return -ENOMEM;
-	}
-	mutex_init(&user->file_lock);
-	user->read_timeout_ms = SBEFIFO_TIMEOUT_START_RSP;
-
-	return 0;
-}
-
-static ssize_t sbefifo_user_read(struct file *file, char __user *buf,
-				 size_t len, loff_t *offset)
-{
-	struct sbefifo_user *user = file->private_data;
-	struct sbefifo *sbefifo;
-	struct iov_iter resp_iter;
-        struct iovec resp_iov;
-	size_t cmd_len;
-	int rc;
-
-	if (!user)
-		return -EINVAL;
-	sbefifo = user->sbefifo;
-	if (len & 3)
-		return -EINVAL;
-
-	mutex_lock(&user->file_lock);
-
-	/* Cronus relies on -EAGAIN after a short read */
-	if (user->pending_len == 0) {
-		rc = -EAGAIN;
-		goto bail;
-	}
-	if (user->pending_len < 8) {
-		rc = -EINVAL;
-		goto bail;
-	}
-	cmd_len = user->pending_len >> 2;
-
-	/* Prepare iov iterator */
-	resp_iov.iov_base = buf;
-	resp_iov.iov_len = len;
-	iov_iter_init(&resp_iter, WRITE, &resp_iov, 1, len);
-
-	/* Perform the command */
-	rc = mutex_lock_interruptible(&sbefifo->lock);
-	if (rc)
-		goto bail;
-	sbefifo->timeout_start_rsp_ms = user->read_timeout_ms;
-	rc = __sbefifo_submit(sbefifo, user->pending_cmd, cmd_len, &resp_iter);
-	sbefifo->timeout_start_rsp_ms = SBEFIFO_TIMEOUT_START_RSP;
-	mutex_unlock(&sbefifo->lock);
-	if (rc < 0)
-		goto bail;
-
-	/* Extract the response length */
-	rc = len - iov_iter_count(&resp_iter);
- bail:
-	sbefifo_release_command(user);
-	mutex_unlock(&user->file_lock);
-	return rc;
-}
-
-static ssize_t sbefifo_user_write(struct file *file, const char __user *buf,
-				  size_t len, loff_t *offset)
-{
-	struct sbefifo_user *user = file->private_data;
-	struct sbefifo *sbefifo;
-	int rc = len;
-
-	if (!user)
-		return -EINVAL;
-	sbefifo = user->sbefifo;
-	if (len > SBEFIFO_MAX_USER_CMD_LEN)
-		return -EINVAL;
-	if (len & 3)
-		return -EINVAL;
-
-	mutex_lock(&user->file_lock);
-
-	/* Can we use the pre-allocate buffer ? If not, allocate */
-	if (len <= PAGE_SIZE)
-		user->pending_cmd = user->cmd_page;
-	else
-		user->pending_cmd = vmalloc(len);
-	if (!user->pending_cmd) {
-		rc = -ENOMEM;
-		goto bail;
-	}
-
-	/* Copy the command into the staging buffer */
-	if (copy_from_user(user->pending_cmd, buf, len)) {
-		rc = -EFAULT;
-		goto bail;
-	}
-
-	/* Check for the magic reset command */
-	if (len == 4 && be32_to_cpu(*(__be32 *)user->pending_cmd) ==
-	    SBEFIFO_RESET_MAGIC)  {
-
-		/* Clear out any pending command */
-		user->pending_len = 0;
-
-		/* Trigger reset request */
-		rc = mutex_lock_interruptible(&sbefifo->lock);
-		if (rc)
-			goto bail;
-		rc = sbefifo_request_reset(user->sbefifo);
-		mutex_unlock(&sbefifo->lock);
-		if (rc == 0)
-			rc = 4;
-		goto bail;
-	}
-
-	/* Update the staging buffer size */
-	user->pending_len = len;
- bail:
-	if (!user->pending_len)
-		sbefifo_release_command(user);
-
-	mutex_unlock(&user->file_lock);
-
-	/* And that's it, we'll issue the command on a read */
-	return rc;
-}
-
-static int sbefifo_user_release(struct inode *inode, struct file *file)
-{
-	struct sbefifo_user *user = file->private_data;
-
-	if (!user)
-		return -EINVAL;
-
-	sbefifo_release_command(user);
-	free_page((unsigned long)user->cmd_page);
-	kfree(user);
-
-	return 0;
-}
-
-static int sbefifo_read_timeout(struct sbefifo_user *user, void __user *argp)
-{
-	struct device *dev = &user->sbefifo->dev;
-	u32 timeout;
-
-	if (get_user(timeout, (__u32 __user *)argp))
-		return -EFAULT;
-
-	if (timeout == 0) {
-		user->read_timeout_ms = SBEFIFO_TIMEOUT_START_RSP;
-		dev_dbg(dev, "Timeout reset to %d\n", user->read_timeout_ms);
-		return 0;
-	}
-
-	if (timeout < 10 || timeout > 120)
-		return -EINVAL;
-
-	user->read_timeout_ms = timeout * 1000; /* user timeout is in sec */
-
-	dev_dbg(dev, "Timeout set to %d\n", user->read_timeout_ms);
-
-	return 0;
-}
-
-static long sbefifo_user_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct sbefifo_user *user = file->private_data;
-	int rc = -ENOTTY;
-
-	if (!user)
-		return -EINVAL;
-
-	mutex_lock(&user->file_lock);
-	switch (cmd) {
-	case FSI_SBEFIFO_READ_TIMEOUT_SECONDS:
-		rc = sbefifo_read_timeout(user, (void __user *)arg);
-		break;
-	}
-	mutex_unlock(&user->file_lock);
-	return rc;
-}
-
-static const struct file_operations sbefifo_fops = {
-	.owner		= THIS_MODULE,
-	.open		= sbefifo_user_open,
-	.read		= sbefifo_user_read,
-	.write		= sbefifo_user_write,
-	.release	= sbefifo_user_release,
-	.unlocked_ioctl = sbefifo_user_ioctl,
-};
-
 static void sbefifo_free(struct device *dev)
 {
 	struct sbefifo *sbefifo = container_of(dev, struct sbefifo, dev);