Re: [PATCH v2 27/44] megaraid: Stop using the SCSI pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Feb 8, 2022, at 9:24 AM, Bart Van Assche <bvanassche@xxxxxxx> wrote:
> 
> Set .cmd_size in the SCSI host template instead of using the SCSI pointer
> from struct scsi_cmnd. This patch prepares for removal of the SCSI pointer
> from struct scsi_cmnd.
> 
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
> ---
> drivers/scsi/megaraid.c | 13 ++++---------
> drivers/scsi/megaraid.h | 15 ++++++++++++++-
> 2 files changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
> index 2061e3fe9824..a5d8cee2d510 100644
> --- a/drivers/scsi/megaraid.c
> +++ b/drivers/scsi/megaraid.c
> @@ -1644,16 +1644,10 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
> static void
> mega_rundoneq (adapter_t *adapter)
> {
> -	struct scsi_cmnd *cmd;
> -	struct list_head *pos;
> +	struct megaraid_cmd_priv *cmd_priv;
> 
> -	list_for_each(pos, &adapter->completed_list) {
> -
> -		struct scsi_pointer* spos = (struct scsi_pointer *)pos;
> -
> -		cmd = list_entry(spos, struct scsi_cmnd, SCp);
> -		scsi_done(cmd);
> -	}
> +	list_for_each_entry(cmd_priv, &adapter->completed_list, entry)
> +		scsi_done(megaraid_to_scsi_cmd(cmd_priv));
> 
> 	INIT_LIST_HEAD(&adapter->completed_list);
> }
> @@ -4123,6 +4117,7 @@ static struct scsi_host_template megaraid_template = {
> 	.eh_bus_reset_handler		= megaraid_reset,
> 	.eh_host_reset_handler		= megaraid_reset,
> 	.no_write_same			= 1,
> +	.cmd_size			= sizeof(struct megaraid_cmd_priv),
> };
> 
> static int
> diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
> index cce23a086fbe..be809ccb757e 100644
> --- a/drivers/scsi/megaraid.h
> +++ b/drivers/scsi/megaraid.h
> @@ -4,6 +4,7 @@
> 
> #include <linux/spinlock.h>
> #include <linux/mutex.h>
> +#include <scsi/scsi_cmnd.h>
> 
> #define MEGARAID_VERSION	\
> 	"v2.00.4 (Release Date: Thu Feb 9 08:51:30 EST 2006)\n"
> @@ -756,8 +757,20 @@ struct private_bios_data {
> #define CACHED_IO		0
> #define DIRECT_IO		1
> 
> +struct megaraid_cmd_priv {
> +	struct list_head entry;
> +};
> +
> +#define SCSI_LIST(scp)							\
> +	(&((struct megaraid_cmd_priv *)scsi_cmd_priv(scp))->entry)
> +
> +static inline struct scsi_cmnd *
> +megaraid_to_scsi_cmd(struct megaraid_cmd_priv *cmd_priv)
> +{
> +	struct scsi_cmnd *cmd = (void *)cmd_priv;
> 
> -#define SCSI_LIST(scp) ((struct list_head *)(&(scp)->SCp))
> +	return cmd - 1;
> +}
> 
> /*
>  * Each controller's soft state

Reviewed-by: Himanshu Madhani <himanshu.madhani@xxxxxxxxxx>

--
Himanshu Madhani	 Oracle Linux Engineering





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux