Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: megaraid: Stop using the SCSI pointer

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.

Link: https://lore.kernel.org/r/20220218195117.25689-33-bvanassche@acm.org
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
fb597392 cb2b6208

+26 -10
+4 -9
drivers/scsi/megaraid.c
··· 1644 1644 static void 1645 1645 mega_rundoneq (adapter_t *adapter) 1646 1646 { 1647 - struct scsi_cmnd *cmd; 1648 - struct list_head *pos; 1647 + struct megaraid_cmd_priv *cmd_priv; 1649 1648 1650 - list_for_each(pos, &adapter->completed_list) { 1651 - 1652 - struct scsi_pointer* spos = (struct scsi_pointer *)pos; 1653 - 1654 - cmd = list_entry(spos, struct scsi_cmnd, SCp); 1655 - scsi_done(cmd); 1656 - } 1649 + list_for_each_entry(cmd_priv, &adapter->completed_list, entry) 1650 + scsi_done(megaraid_to_scsi_cmd(cmd_priv)); 1657 1651 1658 1652 INIT_LIST_HEAD(&adapter->completed_list); 1659 1653 } ··· 4117 4123 .eh_bus_reset_handler = megaraid_reset, 4118 4124 .eh_host_reset_handler = megaraid_reset, 4119 4125 .no_write_same = 1, 4126 + .cmd_size = sizeof(struct megaraid_cmd_priv), 4120 4127 }; 4121 4128 4122 4129 static int
+22 -1
drivers/scsi/megaraid.h
··· 4 4 5 5 #include <linux/spinlock.h> 6 6 #include <linux/mutex.h> 7 + #include <scsi/scsi_cmnd.h> 7 8 8 9 #define MEGARAID_VERSION \ 9 10 "v2.00.4 (Release Date: Thu Feb 9 08:51:30 EST 2006)\n" ··· 757 756 #define CACHED_IO 0 758 757 #define DIRECT_IO 1 759 758 759 + struct megaraid_cmd_priv { 760 + struct list_head entry; 761 + }; 760 762 761 - #define SCSI_LIST(scp) ((struct list_head *)(&(scp)->SCp)) 763 + #define SCSI_LIST(scp) \ 764 + (&((struct megaraid_cmd_priv *)scsi_cmd_priv(scp))->entry) 765 + 766 + struct scsi_cmd_and_priv { 767 + struct scsi_cmnd cmd; 768 + struct megaraid_cmd_priv priv; 769 + }; 770 + 771 + static inline struct scsi_cmnd * 772 + megaraid_to_scsi_cmd(struct megaraid_cmd_priv *cmd_priv) 773 + { 774 + /* See also scsi_mq_setup_tags() */ 775 + BUILD_BUG_ON(sizeof(struct scsi_cmd_and_priv) != 776 + sizeof(struct scsi_cmnd) + 777 + sizeof(struct megaraid_cmd_priv)); 778 + 779 + return &container_of(cmd_priv, struct scsi_cmd_and_priv, priv)->cmd; 780 + } 762 781 763 782 /* 764 783 * Each controller's soft state