summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bentele2021-12-07 13:31:59 +0100
committerManuel Bentele2021-12-07 13:31:59 +0100
commit08285e2910237c7e6bfe43b12a8fbe03bc718fbb (patch)
tree022b7a48048654b895d684da1531feb441bacbbb
parentAdd support for Linux LTS kernel 5.15.x (diff)
downloadxloop-08285e2910237c7e6bfe43b12a8fbe03bc718fbb.tar.gz
xloop-08285e2910237c7e6bfe43b12a8fbe03bc718fbb.tar.xz
xloop-08285e2910237c7e6bfe43b12a8fbe03bc718fbb.zip
Fix linter errors and warnings from checkpatch.pl
-rw-r--r--src/kernel/CMakeLists.txt4
-rw-r--r--src/kernel/xloop_main.c36
-rw-r--r--src/kernel/xloop_main.h15
3 files changed, 29 insertions, 26 deletions
diff --git a/src/kernel/CMakeLists.txt b/src/kernel/CMakeLists.txt
index babcaf0..3920562 100644
--- a/src/kernel/CMakeLists.txt
+++ b/src/kernel/CMakeLists.txt
@@ -33,7 +33,9 @@ set(CHECKPATCH_IGNORE_WARNINGS "LINUX_VERSION_CODE"
"CONSIDER_KSTRTO"
"UNNECESSARY_ELSE"
"SPLIT_STRING"
- "STATIC_CONST_CHAR_ARRAY")
+ "STATIC_CONST_CHAR_ARRAY"
+ "UNSPECIFIED_INT"
+ "ENOSYS")
# xloop main Linux kernel module
set(KERNEL_MODULE_XLOOP_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/xloop_file_fmt.c
diff --git a/src/kernel/xloop_main.c b/src/kernel/xloop_main.c
index 9585e24..d133709 100644
--- a/src/kernel/xloop_main.c
+++ b/src/kernel/xloop_main.c
@@ -190,13 +190,13 @@ static int xor_init(struct xloop_device *xlo, const struct xloop_info64 *info)
static struct xloop_func_table none_funcs = {
.number = XLO_CRYPT_NONE,
-};
+};
static struct xloop_func_table xor_funcs = {
.number = XLO_CRYPT_XOR,
.transfer = transfer_xor,
.init = xor_init
-};
+};
/* xfer_funcs[0] is special - its release function is never called */
static struct xloop_func_table *xfer_funcs[MAX_XLO_CRYPT] = {
@@ -341,7 +341,7 @@ static int do_req_filebacked(struct xloop_device *xlo, struct request *rq)
/*
* xlo_write_simple and xlo_read_simple should have been covered
- * by io submit style function like xloop_file_fmt_read_aio(), one
+ * by io submit style function like xloop_file_fmt_read_aio(), one
* blocker is that xloop_file_fmt_read() need to call flush_dcache_page
* after the page is written from kernel, and it isn't easy to handle
* this in io submit style function which submits all segments
@@ -609,7 +609,7 @@ static struct attribute *xloop_attrs[] = {
static struct attribute_group xloop_attribute_group = {
.name = "xloop",
- .attrs= xloop_attrs,
+ .attrs = xloop_attrs,
};
static void xloop_sysfs_init(struct xloop_device *xlo)
@@ -1401,7 +1401,7 @@ xloop_set_status_old(struct xloop_device *xlo, const struct xloop_info __user *a
struct xloop_info info;
struct xloop_info64 info64;
- if (copy_from_user(&info, arg, sizeof (struct xloop_info)))
+ if (copy_from_user(&info, arg, sizeof(struct xloop_info)))
return -EFAULT;
xloop_info64_from_old(&info, &info64);
return xloop_set_status(xlo, &info64);
@@ -1412,13 +1412,14 @@ xloop_set_status64(struct xloop_device *xlo, const struct xloop_info64 __user *a
{
struct xloop_info64 info64;
- if (copy_from_user(&info64, arg, sizeof (struct xloop_info64)))
+ if (copy_from_user(&info64, arg, sizeof(struct xloop_info64)))
return -EFAULT;
return xloop_set_status(xlo, &info64);
}
static int
-xloop_get_status_old(struct xloop_device *xlo, struct xloop_info __user *arg) {
+xloop_get_status_old(struct xloop_device *xlo, struct xloop_info __user *arg)
+{
struct xloop_info info;
struct xloop_info64 info64;
int err;
@@ -1435,7 +1436,8 @@ xloop_get_status_old(struct xloop_device *xlo, struct xloop_info __user *arg) {
}
static int
-xloop_get_status64(struct xloop_device *xlo, struct xloop_info64 __user *arg) {
+xloop_get_status64(struct xloop_device *xlo, struct xloop_info64 __user *arg)
+{
struct xloop_info64 info64;
int err;
@@ -1464,6 +1466,7 @@ static int xloop_set_capacity(struct xloop_device *xlo)
static int xloop_set_dio(struct xloop_device *xlo, unsigned long arg)
{
int error = -ENXIO;
+
if (xlo->xlo_state != Xlo_bound)
goto out;
@@ -1574,17 +1577,15 @@ static int xlo_ioctl(struct block_device *bdev, fmode_t mode,
return xloop_clr_fd(xlo);
case XLOOP_SET_STATUS:
err = -EPERM;
- if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) {
+ if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))
err = xloop_set_status_old(xlo, argp);
- }
break;
case XLOOP_GET_STATUS:
return xloop_get_status_old(xlo, argp);
case XLOOP_SET_STATUS64:
err = -EPERM;
- if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) {
+ if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))
err = xloop_set_status64(xlo, argp);
- }
break;
case XLOOP_GET_STATUS64:
return xloop_get_status64(xlo, argp);
@@ -1726,7 +1727,7 @@ static int xlo_compat_ioctl(struct block_device *bdev, fmode_t mode,
struct xloop_device *xlo = bdev->bd_disk->private_data;
int err;
- switch(cmd) {
+ switch (cmd) {
case XLOOP_SET_STATUS:
err = xloop_set_status_compat(xlo,
(const struct compat_xloop_info __user *)arg);
@@ -1836,13 +1837,14 @@ int xloop_register_transfer(struct xloop_func_table *funcs)
xfer_funcs[n] = funcs;
return 0;
}
+EXPORT_SYMBOL(xloop_register_transfer);
int xloop_unregister_transfer(int number)
{
unsigned int n = number;
- struct xloop_func_table *xfer;
+ struct xloop_func_table *xfer = xfer_funcs[n];
- if (n == 0 || n >= MAX_XLO_CRYPT || (xfer = xfer_funcs[n]) == NULL)
+ if (n == 0 || n >= MAX_XLO_CRYPT || xfer == NULL)
return -EINVAL;
/*
* This function is called from only cleanup_cryptoxloop().
@@ -1860,8 +1862,6 @@ int xloop_unregister_transfer(int number)
xfer_funcs[n] = NULL;
return 0;
}
-
-EXPORT_SYMBOL(xloop_register_transfer);
EXPORT_SYMBOL(xloop_unregister_transfer);
static blk_status_t xloop_queue_rq(struct blk_mq_hw_ctx *hctx,
@@ -2204,7 +2204,7 @@ static int xloop_control_remove(int idx)
pr_warn("deleting an unspecified xloop device is not supported.\n");
return -EINVAL;
}
-
+
/* Hide this xloop device for serialization. */
ret = mutex_lock_killable(&xloop_ctl_mutex);
if (ret)
diff --git a/src/kernel/xloop_main.h b/src/kernel/xloop_main.h
index 360f3e5..4126460 100644
--- a/src/kernel/xloop_main.h
+++ b/src/kernel/xloop_main.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* loop_main.h
*
@@ -45,13 +46,13 @@ struct xloop_device {
struct xloop_func_table *xlo_encryption;
__u32 xlo_init[2];
kuid_t xlo_key_owner; /* Who set the key */
- int (*ioctl)(struct xloop_device *xlo, int cmd, unsigned long arg);
+ int (*ioctl)(struct xloop_device *xlo, int cmd, unsigned long arg);
struct xloop_file_fmt *xlo_fmt;
struct file *xlo_backing_file;
struct block_device *xlo_device;
- void *key_data;
+ void *key_data;
gfp_t old_gfp_mask;
@@ -91,18 +92,18 @@ struct xloop_cmd {
/* Support for loadable transfer modules */
struct xloop_func_table {
- int number; /* filter type */
+ int number; /* filter type */
int (*transfer)(struct xloop_device *xlo, int cmd, struct page *raw_page, unsigned raw_off, struct page *xloop_page, unsigned xloop_off, int size, sector_t real_block);
- int (*init)(struct xloop_device *xlo, const struct xloop_info64 *);
+ int (*init)(struct xloop_device *xlo, const struct xloop_info64 *info);
/* release is called from xloop_unregister_transfer or clr_fd */
- int (*release)(struct xloop_device *xlo);
+ int (*release)(struct xloop_device *xlo);
int (*ioctl)(struct xloop_device *xlo, int cmd, unsigned long arg);
struct module *owner;
-};
+};
extern inline struct device *xloop_device_to_dev(struct xloop_device *xlo);
int xloop_register_transfer(struct xloop_func_table *funcs);
-int xloop_unregister_transfer(int number);
+int xloop_unregister_transfer(int number);
#endif