Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fsi: Move fsi_slave structure definition to header

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>

authored by

Eddie James and committed by
Joel Stanley
d5d8dfb0 23ad7ec1

+37 -25
+4 -20
drivers/fsi/fsi-core.c
··· 24 24 #include <linux/uaccess.h> 25 25 26 26 #include "fsi-master.h" 27 + #include "fsi-slave.h" 28 + 29 + #define CREATE_TRACE_POINTS 30 + #include <trace/events/fsi.h> 27 31 28 32 #define FSI_SLAVE_CONF_NEXT_MASK GENMASK(31, 31) 29 33 #define FSI_SLAVE_CONF_SLOTS_MASK GENMASK(23, 16) ··· 82 78 #define FSI_SLAVE_SIZE_23b 0x800000 83 79 84 80 static DEFINE_IDA(master_ida); 85 - 86 - struct fsi_slave { 87 - struct device dev; 88 - struct fsi_master *master; 89 - struct cdev cdev; 90 - int cdev_idx; 91 - int id; /* FSI address */ 92 - int link; /* FSI link# */ 93 - u32 cfam_id; 94 - int chip_id; 95 - uint32_t size; /* size of slave address space */ 96 - u8 t_send_delay; 97 - u8 t_echo_delay; 98 - }; 99 - 100 - #define CREATE_TRACE_POINTS 101 - #include <trace/events/fsi.h> 102 - 103 - #define to_fsi_master(d) container_of(d, struct fsi_master, dev) 104 - #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev) 105 81 106 82 static const int slave_retries = 2; 107 83 static int discard_errors;
+1 -1
drivers/fsi/fsi-master-aspeed.c
··· 376 376 static void aspeed_master_release(struct device *dev) 377 377 { 378 378 struct fsi_master_aspeed *aspeed = 379 - to_fsi_master_aspeed(dev_to_fsi_master(dev)); 379 + to_fsi_master_aspeed(to_fsi_master(dev)); 380 380 381 381 kfree(aspeed); 382 382 }
+1 -1
drivers/fsi/fsi-master-ast-cf.c
··· 1190 1190 1191 1191 static void fsi_master_acf_release(struct device *dev) 1192 1192 { 1193 - struct fsi_master_acf *master = to_fsi_master_acf(dev_to_fsi_master(dev)); 1193 + struct fsi_master_acf *master = to_fsi_master_acf(to_fsi_master(dev)); 1194 1194 1195 1195 /* Cleanup, stop coprocessor */ 1196 1196 mutex_lock(&master->lock);
+1 -1
drivers/fsi/fsi-master-gpio.c
··· 761 761 762 762 static void fsi_master_gpio_release(struct device *dev) 763 763 { 764 - struct fsi_master_gpio *master = to_fsi_master_gpio(dev_to_fsi_master(dev)); 764 + struct fsi_master_gpio *master = to_fsi_master_gpio(to_fsi_master(dev)); 765 765 766 766 of_node_put(dev_of_node(master->dev)); 767 767
+1 -1
drivers/fsi/fsi-master-hub.c
··· 105 105 106 106 static void hub_master_release(struct device *dev) 107 107 { 108 - struct fsi_master_hub *hub = to_fsi_master_hub(dev_to_fsi_master(dev)); 108 + struct fsi_master_hub *hub = to_fsi_master_hub(to_fsi_master(dev)); 109 109 110 110 kfree(hub); 111 111 }
+1 -1
drivers/fsi/fsi-master.h
··· 136 136 u8 t_send_delay, u8 t_echo_delay); 137 137 }; 138 138 139 - #define dev_to_fsi_master(d) container_of(d, struct fsi_master, dev) 139 + #define to_fsi_master(d) container_of(d, struct fsi_master, dev) 140 140 141 141 /** 142 142 * fsi_master registration & lifetime: the fsi_master_register() and
+28
drivers/fsi/fsi-slave.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + /* Copyright (C) IBM Corporation 2023 */ 3 + 4 + #ifndef DRIVERS_FSI_SLAVE_H 5 + #define DRIVERS_FSI_SLAVE_H 6 + 7 + #include <linux/cdev.h> 8 + #include <linux/device.h> 9 + 10 + struct fsi_master; 11 + 12 + struct fsi_slave { 13 + struct device dev; 14 + struct fsi_master *master; 15 + struct cdev cdev; 16 + int cdev_idx; 17 + int id; /* FSI address */ 18 + int link; /* FSI link# */ 19 + u32 cfam_id; 20 + int chip_id; 21 + uint32_t size; /* size of slave address space */ 22 + u8 t_send_delay; 23 + u8 t_echo_delay; 24 + }; 25 + 26 + #define to_fsi_slave(d) container_of(d, struct fsi_slave, dev) 27 + 28 + #endif /* DRIVERS_FSI_SLAVE_H */