scsi: core: Do not declare scsi_cmnd pointers const
This change allows removing multiple casts and hence improves type checking by the compiler. Cc: Hannes Reinecke <hare@suse.de> Suggested-by: John Garry <john.g.garry@oracle.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: John Garry <john.g.garry@oracle.com> Link: https://patch.msgid.link/20251014220426.3690007-1-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
committed by
Martin K. Petersen
parent
3d0d1c7a5c
commit
ce085ecdba
@@ -26,9 +26,9 @@ static void scsi_log_release_buffer(char *bufptr)
|
|||||||
kfree(bufptr);
|
kfree(bufptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char *scmd_name(const struct scsi_cmnd *scmd)
|
static inline const char *scmd_name(struct scsi_cmnd *scmd)
|
||||||
{
|
{
|
||||||
struct request *rq = scsi_cmd_to_rq((struct scsi_cmnd *)scmd);
|
const struct request *rq = scsi_cmd_to_rq(scmd);
|
||||||
|
|
||||||
if (!rq->q || !rq->q->disk)
|
if (!rq->q || !rq->q->disk)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -80,8 +80,8 @@ void sdev_prefix_printk(const char *level, const struct scsi_device *sdev,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(sdev_prefix_printk);
|
EXPORT_SYMBOL(sdev_prefix_printk);
|
||||||
|
|
||||||
void scmd_printk(const char *level, const struct scsi_cmnd *scmd,
|
void scmd_printk(const char *level, struct scsi_cmnd *scmd, const char *fmt,
|
||||||
const char *fmt, ...)
|
...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char *logbuf;
|
char *logbuf;
|
||||||
@@ -94,7 +94,7 @@ void scmd_printk(const char *level, const struct scsi_cmnd *scmd,
|
|||||||
if (!logbuf)
|
if (!logbuf)
|
||||||
return;
|
return;
|
||||||
off = sdev_format_header(logbuf, logbuf_len, scmd_name(scmd),
|
off = sdev_format_header(logbuf, logbuf_len, scmd_name(scmd),
|
||||||
scsi_cmd_to_rq((struct scsi_cmnd *)scmd)->tag);
|
scsi_cmd_to_rq(scmd)->tag);
|
||||||
if (off < logbuf_len) {
|
if (off < logbuf_len) {
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
off += vscnprintf(logbuf + off, logbuf_len - off, fmt, args);
|
off += vscnprintf(logbuf + off, logbuf_len - off, fmt, args);
|
||||||
@@ -371,16 +371,15 @@ void __scsi_print_sense(const struct scsi_device *sdev, const char *name,
|
|||||||
EXPORT_SYMBOL(__scsi_print_sense);
|
EXPORT_SYMBOL(__scsi_print_sense);
|
||||||
|
|
||||||
/* Normalize and print sense buffer in SCSI command */
|
/* Normalize and print sense buffer in SCSI command */
|
||||||
void scsi_print_sense(const struct scsi_cmnd *cmd)
|
void scsi_print_sense(struct scsi_cmnd *cmd)
|
||||||
{
|
{
|
||||||
scsi_log_print_sense(cmd->device, scmd_name(cmd),
|
scsi_log_print_sense(cmd->device, scmd_name(cmd),
|
||||||
scsi_cmd_to_rq((struct scsi_cmnd *)cmd)->tag,
|
scsi_cmd_to_rq(cmd)->tag, cmd->sense_buffer,
|
||||||
cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
|
SCSI_SENSE_BUFFERSIZE);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(scsi_print_sense);
|
EXPORT_SYMBOL(scsi_print_sense);
|
||||||
|
|
||||||
void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
|
void scsi_print_result(struct scsi_cmnd *cmd, const char *msg, int disposition)
|
||||||
int disposition)
|
|
||||||
{
|
{
|
||||||
char *logbuf;
|
char *logbuf;
|
||||||
size_t off, logbuf_len;
|
size_t off, logbuf_len;
|
||||||
@@ -393,7 +392,7 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
off = sdev_format_header(logbuf, logbuf_len, scmd_name(cmd),
|
off = sdev_format_header(logbuf, logbuf_len, scmd_name(cmd),
|
||||||
scsi_cmd_to_rq((struct scsi_cmnd *)cmd)->tag);
|
scsi_cmd_to_rq(cmd)->tag);
|
||||||
|
|
||||||
if (off >= logbuf_len)
|
if (off >= logbuf_len)
|
||||||
goto out_printk;
|
goto out_printk;
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ extern size_t __scsi_format_command(char *, size_t,
|
|||||||
const unsigned char *, size_t);
|
const unsigned char *, size_t);
|
||||||
extern void scsi_print_sense_hdr(const struct scsi_device *, const char *,
|
extern void scsi_print_sense_hdr(const struct scsi_device *, const char *,
|
||||||
const struct scsi_sense_hdr *);
|
const struct scsi_sense_hdr *);
|
||||||
extern void scsi_print_sense(const struct scsi_cmnd *);
|
extern void scsi_print_sense(struct scsi_cmnd *);
|
||||||
extern void __scsi_print_sense(const struct scsi_device *, const char *name,
|
extern void __scsi_print_sense(const struct scsi_device *, const char *name,
|
||||||
const unsigned char *sense_buffer,
|
const unsigned char *sense_buffer,
|
||||||
int sense_len);
|
int sense_len);
|
||||||
extern void scsi_print_result(const struct scsi_cmnd *, const char *, int);
|
extern void scsi_print_result(struct scsi_cmnd *, const char *, int);
|
||||||
|
|
||||||
#ifdef CONFIG_SCSI_CONSTANTS
|
#ifdef CONFIG_SCSI_CONSTANTS
|
||||||
extern bool scsi_opcode_sa_name(int, int, const char **, const char **);
|
extern bool scsi_opcode_sa_name(int, int, const char **, const char **);
|
||||||
|
|||||||
@@ -313,8 +313,8 @@ sdev_prefix_printk(const char *, const struct scsi_device *, const char *,
|
|||||||
#define sdev_printk(l, sdev, fmt, a...) \
|
#define sdev_printk(l, sdev, fmt, a...) \
|
||||||
sdev_prefix_printk(l, sdev, NULL, fmt, ##a)
|
sdev_prefix_printk(l, sdev, NULL, fmt, ##a)
|
||||||
|
|
||||||
__printf(3, 4) void
|
__printf(3, 4) void scmd_printk(const char *, struct scsi_cmnd *, const char *,
|
||||||
scmd_printk(const char *, const struct scsi_cmnd *, const char *, ...);
|
...);
|
||||||
|
|
||||||
#define scmd_dbg(scmd, fmt, a...) \
|
#define scmd_dbg(scmd, fmt, a...) \
|
||||||
do { \
|
do { \
|
||||||
|
|||||||
Reference in New Issue
Block a user