Re: [PATCH v6 2/3] bsg: add io_uring command support to generic layer
From: Bart Van Assche
Date: Thu Mar 05 2026 - 10:24:38 EST
On 3/4/26 7:28 PM, Yang Xiuwei wrote:
+static int bsg_uring_cmd(struct io_uring_cmd *ioucmd, unsigned int issue_flags)
+{
+ struct bsg_device *bd = to_bsg_device(file_inode(ioucmd->file));
+ struct request_queue *q = bd->queue;
+ bool open_for_write = ioucmd->file->f_mode & FMODE_WRITE;
+ int ret;
Please order declarations from longest to shortest.
+ if (bd->uring_cmd_fn)
+ return bd->uring_cmd_fn(q, ioucmd, issue_flags, open_for_write);
+ return -EOPNOTSUPP;
The traditional Linux kernel coding style is to return early in case of
an error. For the above code that means writing it as follows:
if (!bd->uring_cmd_fn)
return -EOPNOTSUPP;
return bd->uring_cmd_fn(q, ioucmd, issue_flags, open_for_write);
Thanks,
Bart.