fsi: Move fsi_slave structure definition to header
authorEddie James <eajames@linux.ibm.com>
Mon, 12 Jun 2023 19:56:44 +0000 (14:56 -0500)
committerJoel Stanley <joel@jms.id.au>
Wed, 9 Aug 2023 06:11:59 +0000 (15:41 +0930)
Some FSI drivers may have need of the slave definition, so
move it to a header file. Also use one macro for obtaining a
pointer to the fsi_master structure.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Link: https://lore.kernel.org/r/20230612195657.245125-2-eajames@linux.ibm.com
Signed-off-by: Joel Stanley <joel@jms.id.au>
drivers/fsi/fsi-core.c
drivers/fsi/fsi-master-aspeed.c
drivers/fsi/fsi-master-ast-cf.c
drivers/fsi/fsi-master-gpio.c
drivers/fsi/fsi-master-hub.c
drivers/fsi/fsi-master.h
drivers/fsi/fsi-slave.h [new file with mode: 0644]

index 19c4d5b3bde91494a8d1ee7adc421ebb7a7ed284..66706e7de010fd463d7ebe83175b3354ef143cd0 100644 (file)
 #include <linux/uaccess.h>
 
 #include "fsi-master.h"
+#include "fsi-slave.h"
+
+#define CREATE_TRACE_POINTS
+#include <trace/events/fsi.h>
 
 #define FSI_SLAVE_CONF_NEXT_MASK       GENMASK(31, 31)
 #define FSI_SLAVE_CONF_SLOTS_MASK      GENMASK(23, 16)
@@ -79,26 +83,6 @@ static const int engine_page_size = 0x400;
 
 static DEFINE_IDA(master_ida);
 
-struct fsi_slave {
-       struct device           dev;
-       struct fsi_master       *master;
-       struct cdev             cdev;
-       int                     cdev_idx;
-       int                     id;     /* FSI address */
-       int                     link;   /* FSI link# */
-       u32                     cfam_id;
-       int                     chip_id;
-       uint32_t                size;   /* size of slave address space */
-       u8                      t_send_delay;
-       u8                      t_echo_delay;
-};
-
-#define CREATE_TRACE_POINTS
-#include <trace/events/fsi.h>
-
-#define to_fsi_master(d) container_of(d, struct fsi_master, dev)
-#define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
-
 static const int slave_retries = 2;
 static int discard_errors;
 
index 7cec1772820d344ccc35c0bb24f1235be2a75b01..437f87b4a6a3e80f7ba56054207a99054607b038 100644 (file)
@@ -376,7 +376,7 @@ static int aspeed_master_break(struct fsi_master *master, int link)
 static void aspeed_master_release(struct device *dev)
 {
        struct fsi_master_aspeed *aspeed =
-               to_fsi_master_aspeed(dev_to_fsi_master(dev));
+               to_fsi_master_aspeed(to_fsi_master(dev));
 
        kfree(aspeed);
 }
index 5f608ef8b53cadb76a2a737d0fb5829915600a04..6124978305eb43594465add3b6855a9234d9801c 100644 (file)
@@ -1190,7 +1190,7 @@ static int fsi_master_acf_gpio_release(void *data)
 
 static void fsi_master_acf_release(struct device *dev)
 {
-       struct fsi_master_acf *master = to_fsi_master_acf(dev_to_fsi_master(dev));
+       struct fsi_master_acf *master = to_fsi_master_acf(to_fsi_master(dev));
 
        /* Cleanup, stop coprocessor */
        mutex_lock(&master->lock);
index 7d5f29b4b595d24ae48cd9dd0d0f69bc2209de2d..ed03da4f24478aed395c710c2f6310070efcf38b 100644 (file)
@@ -761,7 +761,7 @@ static DEVICE_ATTR(external_mode, 0664,
 
 static void fsi_master_gpio_release(struct device *dev)
 {
-       struct fsi_master_gpio *master = to_fsi_master_gpio(dev_to_fsi_master(dev));
+       struct fsi_master_gpio *master = to_fsi_master_gpio(to_fsi_master(dev));
 
        of_node_put(dev_of_node(master->dev));
 
index 01f0a796111ed5a137dd5b4b549d15fad31a7870..6d8b6e8854e563e6c560ae6ec0a7a80c1c3d99bc 100644 (file)
@@ -105,7 +105,7 @@ static int hub_master_link_enable(struct fsi_master *master, int link,
 
 static void hub_master_release(struct device *dev)
 {
-       struct fsi_master_hub *hub = to_fsi_master_hub(dev_to_fsi_master(dev));
+       struct fsi_master_hub *hub = to_fsi_master_hub(to_fsi_master(dev));
 
        kfree(hub);
 }
index 4762315a46ba36078ba5f627b632bf7d28f5a373..967622c1cabf7faf52d9afbe405c13d914827715 100644 (file)
@@ -136,7 +136,7 @@ struct fsi_master {
                                       u8 t_send_delay, u8 t_echo_delay);
 };
 
-#define dev_to_fsi_master(d) container_of(d, struct fsi_master, dev)
+#define to_fsi_master(d) container_of(d, struct fsi_master, dev)
 
 /**
  * fsi_master registration & lifetime: the fsi_master_register() and
diff --git a/drivers/fsi/fsi-slave.h b/drivers/fsi/fsi-slave.h
new file mode 100644 (file)
index 0000000..1d63a58
--- /dev/null
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) IBM Corporation 2023 */
+
+#ifndef DRIVERS_FSI_SLAVE_H
+#define DRIVERS_FSI_SLAVE_H
+
+#include <linux/cdev.h>
+#include <linux/device.h>
+
+struct fsi_master;
+
+struct fsi_slave {
+       struct device           dev;
+       struct fsi_master       *master;
+       struct cdev             cdev;
+       int                     cdev_idx;
+       int                     id;     /* FSI address */
+       int                     link;   /* FSI link# */
+       u32                     cfam_id;
+       int                     chip_id;
+       uint32_t                size;   /* size of slave address space */
+       u8                      t_send_delay;
+       u8                      t_echo_delay;
+};
+
+#define to_fsi_slave(d) container_of(d, struct fsi_slave, dev)
+
+#endif /* DRIVERS_FSI_SLAVE_H */