| Message ID | 20260903034201.112211-41-dlemoal@kernel.org |
|---|---|
| State | New |
| Headers | show |
| Series | Use defined 16-bits ASC/ASCQ combinations | expand |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The kernel-doc block for scsi_set_sense() is outdated, documenting removed parameters instead of the new parameter. -- commit 346248be55e45fce39f6b6a510b7c29fbb538f5c Author: Damien Le Moal <dlemoal@kernel.org> scsi: remove scsi_build_sense() and scsi_build_sense_buffer() This commit converts the SCSI sense building functions to use a single 16-bit sense code parameter and renames them to scsi_set_sense() and scsi_set_sense_buffer(). > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c > index b58e028a362e2..3fcc4062ad813 100644 > --- a/drivers/scsi/scsi_lib.c > +++ b/drivers/scsi/scsi_lib.c [ ... ] > @@ -3585,7 +3585,7 @@ int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id) > EXPORT_SYMBOL(scsi_vpd_tpg_id); > > /** > - * scsi_build_sense - build sense data for a command > + * scsi_set_sense - build sense data for a command > * @scmd: scsi command for which the sense should be formatted > * @desc: Sense format (non-zero == descriptor format, > * 0 == fixed format) > @@ -3594,12 +3594,12 @@ EXPORT_SYMBOL(scsi_vpd_tpg_id); > * @ascq: Additional sense code qualifier > * > **/ > -void scsi_build_sense(struct scsi_cmnd *scmd, int desc, u8 key, u8 asc, u8 ascq) > +void scsi_set_sense(struct scsi_cmnd *scmd, int desc, u8 key, u16 code) [Severity: Low] Does this kernel-doc block need updating for the new parameter? It looks like the documentation for scsi_set_sense() still lists the removed @asc and @ascq parameters, but is missing the new @code parameter. This will likely cause warnings during documentation builds. > { > - scsi_build_sense_buffer(desc, scmd->sense_buffer, key, asc, ascq); > + scsi_set_sense_buffer(desc, scmd->sense_buffer, key, code); > scmd->result = SAM_STAT_CHECK_CONDITION; > }
On Thu, Sep 03, 2026 at 12:42:01PM +0900, Damien Le Moal wrote: > Now that all code has been converted to use 16-bits sense codes and to > initialize sense with scsi_set_sense() and scsi_set_sense_buffer(), remove > the inline definitions of these new functions, change scsi_build_sense() > and scsi_build_sense_buffer() to use a single 16-bits sense code as > argument (instead of separate arguments for the ASC and ASCQ), and > rename them to scsi_set_sense() and scsi_set_sense_buffer(). > > Signed-off-by: Damien Le Moal <dlemoal@kernel.org> With the trivial kdoc nit for scsi_set_sense() pointed out by Sashiko fixed: Reviewed-by: Niklas Cassel <cassel@kernel.org>
On 9/3/26 5:42 AM, Damien Le Moal wrote: > Now that all code has been converted to use 16-bits sense codes and to > initialize sense with scsi_set_sense() and scsi_set_sense_buffer(), remove > the inline definitions of these new functions, change scsi_build_sense() > and scsi_build_sense_buffer() to use a single 16-bits sense code as > argument (instead of separate arguments for the ASC and ASCQ), and > rename them to scsi_set_sense() and scsi_set_sense_buffer(). > > Signed-off-by: Damien Le Moal <dlemoal@kernel.org> > --- > drivers/scsi/scsi_common.c | 12 +++++++----- > drivers/scsi/scsi_lib.c | 8 ++++---- > include/scsi/scsi_cmnd.h | 10 +--------- > include/scsi/scsi_common.h | 8 +------- > 4 files changed, 13 insertions(+), 25 deletions(-) > Reviewed-by: Hannes Reinecke <hare@kernel.org> Cheers, Hannes
diff --git a/drivers/scsi/scsi_common.c b/drivers/scsi/scsi_common.c index 2cabc932acd4..4376a4945338 100644 --- a/drivers/scsi/scsi_common.c +++ b/drivers/scsi/scsi_common.c @@ -276,17 +276,19 @@ const u8 * scsi_sense_desc_find(const u8 * sense_buffer, int sb_len, EXPORT_SYMBOL(scsi_sense_desc_find); /** - * scsi_build_sense_buffer - build sense data in a buffer + * scsi_set_sense_buffer - build sense data in a buffer * @desc: Sense format (non-zero == descriptor format, * 0 == fixed format) * @buf: Where to build sense data * @key: Sense key - * @asc: Additional sense code - * @ascq: Additional sense code qualifier + * @code: Additional sense code and its code qualifier * **/ -void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq) +void scsi_set_sense_buffer(int desc, u8 *buf, u8 key, u16 code) { + u8 asc = scsi_sense_code_asc(code); + u8 ascq = scsi_sense_code_ascq(code); + if (desc) { buf[0] = 0x72; /* descriptor, current */ buf[1] = key; @@ -301,7 +303,7 @@ void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq) buf[13] = ascq; } } -EXPORT_SYMBOL(scsi_build_sense_buffer); +EXPORT_SYMBOL(scsi_set_sense_buffer); /** * scsi_set_sense_information - set the information field in a diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index b58e028a362e..3fcc4062ad81 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -3585,7 +3585,7 @@ int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id) EXPORT_SYMBOL(scsi_vpd_tpg_id); /** - * scsi_build_sense - build sense data for a command + * scsi_set_sense - build sense data for a command * @scmd: scsi command for which the sense should be formatted * @desc: Sense format (non-zero == descriptor format, * 0 == fixed format) @@ -3594,12 +3594,12 @@ EXPORT_SYMBOL(scsi_vpd_tpg_id); * @ascq: Additional sense code qualifier * **/ -void scsi_build_sense(struct scsi_cmnd *scmd, int desc, u8 key, u8 asc, u8 ascq) +void scsi_set_sense(struct scsi_cmnd *scmd, int desc, u8 key, u16 code) { - scsi_build_sense_buffer(desc, scmd->sense_buffer, key, asc, ascq); + scsi_set_sense_buffer(desc, scmd->sense_buffer, key, code); scmd->result = SAM_STAT_CHECK_CONDITION; } -EXPORT_SYMBOL_GPL(scsi_build_sense); +EXPORT_SYMBOL_GPL(scsi_set_sense); #ifdef CONFIG_SCSI_LIB_KUNIT_TEST #include "scsi_lib_test.c" diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index bf6d69f0249f..2f2364c96457 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -391,15 +391,7 @@ static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd) return xfer_len; } -extern void scsi_build_sense(struct scsi_cmnd *scmd, int desc, - u8 key, u8 asc, u8 ascq); - -static inline void scsi_set_sense(struct scsi_cmnd *scmd, int desc, - u8 key, u16 code) -{ - scsi_build_sense(scmd, desc, key, scsi_sense_code_asc(code), - scsi_sense_code_ascq(code)); -} +void scsi_set_sense(struct scsi_cmnd *scmd, int desc, u8 key, u16 code); struct request *scsi_alloc_request(struct request_queue *q, blk_opf_t opf, blk_mq_req_flags_t flags); diff --git a/include/scsi/scsi_common.h b/include/scsi/scsi_common.h index 405512554ee8..88a076c1a137 100644 --- a/include/scsi/scsi_common.h +++ b/include/scsi/scsi_common.h @@ -99,13 +99,7 @@ static inline u8 scsi_sense_ascq(const struct scsi_sense_hdr *sshdr) extern bool scsi_normalize_sense(const u8 *sense_buffer, int sb_len, struct scsi_sense_hdr *sshdr); -extern void scsi_build_sense_buffer(int desc, u8 *buf, u8 key, u8 asc, u8 ascq); - -static inline void scsi_set_sense_buffer(int desc, u8 *buf, u8 key, u16 code) -{ - scsi_build_sense_buffer(desc, buf, key, scsi_sense_code_asc(code), - scsi_sense_code_ascq(code)); -} +void scsi_set_sense_buffer(int desc, u8 *buf, u8 key, u16 code); int scsi_set_sense_information(u8 *buf, int buf_len, u64 info); int scsi_set_sense_field_pointer(u8 *buf, int buf_len, u16 fp, u8 bp, bool cd);
Now that all code has been converted to use 16-bits sense codes and to initialize sense with scsi_set_sense() and scsi_set_sense_buffer(), remove the inline definitions of these new functions, change scsi_build_sense() and scsi_build_sense_buffer() to use a single 16-bits sense code as argument (instead of separate arguments for the ASC and ASCQ), and rename them to scsi_set_sense() and scsi_set_sense_buffer(). Signed-off-by: Damien Le Moal <dlemoal@kernel.org> --- drivers/scsi/scsi_common.c | 12 +++++++----- drivers/scsi/scsi_lib.c | 8 ++++---- include/scsi/scsi_cmnd.h | 10 +--------- include/scsi/scsi_common.h | 8 +------- 4 files changed, 13 insertions(+), 25 deletions(-)