From: Gleb C. <lna...@ya...> - 2024-05-03 09:51:33
|
Commit: e322287 GitHub URL: https://github.com/SCST-project/scst/commit/e322287f898394f91e2dc986794d0440901316ec Author: Gleb Chesnokov Date: 2024-05-03T12:50:49+03:00 Log Message: ----------- scst/include/backport.h: Backport DEFINE_SHOW_STORE_ATTRIBUTE() Support the previous commit against kernel versions before v6.7. See also commit 9cba82bba500 ("seq_file: add helper macro to define attribute for rw file") # v6.7. Modified Paths: -------------- scst/include/backport.h | 21 +++++++++++++++ 1 file changed, 21 insertions(+) =================================================================== diff --git a/scst/include/backport.h b/scst/include/backport.h index 3ab377c..97e46c9 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -1354,6 +1354,27 @@ static const struct file_operations __name ## _fops = { \ } #endif +/* + * See also commit 9cba82bba500 ("seq_file: add helper macro to define + * attribute for rw file") # v6.7. + */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0) +#define DEFINE_SHOW_STORE_ATTRIBUTE(__name) \ +static int __name ## _open(struct inode *inode, struct file *file) \ +{ \ + return single_open(file, __name ## _show, inode->i_private); \ +} \ + \ +static const struct file_operations __name ## _fops = { \ + .owner = THIS_MODULE, \ + .open = __name ## _open, \ + .read = seq_read, \ + .write = __name ## _write, \ + .llseek = seq_lseek, \ + .release = single_release, \ +} +#endif + /* <linux/slab.h> */ #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) && \ |