mbox series

[00/81] Constify most SCSI host templates

Message ID 20230304003103.2572793-1-bvanassche@acm.org
Headers show
Series Constify most SCSI host templates | expand

Message

Bart Van Assche March 4, 2023, 12:29 a.m. UTC
Hi Martin,

It helps humans and the compiler if it is made explicit that SCSI host
templates are not modified. Hence this patch series that constifies most
SCSI host templates. Please consider this patch series for the next merge
window.

Thanks,

Bart.

Bart Van Assche (81):
  scsi: qla2xxx: Refer directly to the qla2xxx_driver_template
  scsi: core: Declare most SCSI host template pointers const
  scsi: core: Declare SCSI host template pointer members const
  ata: Declare SCSI host templates const
  firewire: sbp2: Declare the SCSI host template const
  RDMA/srp: Declare the SCSI host template const
  scsi: message: fusion: Declare SCSI host template members const
  scsi: zfcp: Declare SCSI host template const
  scsi: 3w-9xxx: Declare SCSI host template const
  scsi: 3w-sas: Declare SCSI host template const
  scsi: 3w-xxxx: Declare SCSI host template const
  scsi: BusLogic: Declare SCSI host template const
  scsi: a100u2w: Declare SCSI host template const
  scsi: a2091: Declare SCSI host template const
  scsi: a3000: Declare SCSI host template const
  scsi: aacraid: Declare SCSI host template const
  scsi: advansys: Declare SCSI host template const
  scsi: aha152x: Declare SCSI host template const
  scsi: aha1542: Declare SCSI host template const
  scsi: aic94xx: Declare SCSI host template const
  scsi: arcmsr: Declare SCSI host template const
  scsi: acornscsi: Declare SCSI host template const
  scsi: arxescsi: Declare SCSI host template const
  scsi: aha1740: Declare SCSI host template const
  scsi: cumana: Declare SCSI host template const
  scsi: eesox: Declare SCSI host template const
  scsi: oak: Declare SCSI host template const
  scsi: powertec: Declare SCSI host template const
  scsi: atp870u: Declare SCSI host template const
  scsi: dc395x: Declare SCSI host template const
  scsi: dmx3191d: Declare SCSI host template const
  scsi: elx: efct: Declare SCSI host template const
  scsi: esas2r: Declare SCSI host template const
  scsi: esp_scsi: Declare SCSI host template const
  scsi: fcoe: Declare SCSI host template const
  scsi: fnic: Declare host template const
  scsi: qedf: Declare host template const
  scsi: fdomain: Declare SCSI host template const
  scsi: NCR5380: Declare SCSI host template const
  scsi: gvp11: Declare SCSI host template const
  scsi: hisi_sas: Declare SCSI host template const
  scsi: hpsa: Declare SCSI host template const
  scsi: hptiop: Declare SCSI host template const
  scsi: ibmvfc: Declare SCSI host template const
  scsi: imm: Declare SCSI host template const
  scsi: initio: Declare SCSI host template const
  scsi: ipr: Declare SCSI host template const
  scsi: iscsi: Declare SCSI host template const
  scsi: mac53c94: Declare SCSI host template const
  scsi: mac_scsi: Declare SCSI host template const
  scsi: megaraid: Declare SCSI host template const
  scsi: mesh: Declare SCSI host template const
  scsi: mpi3mr: Declare SCSI host template const
  scsi: mpt3sas: Declare SCSI host template const
  scsi: mvme147: Declare SCSI host template const
  scsi: mvsas: Declare SCSI host template const
  scsi: mvumi: Declare SCSI host template const
  scsi: myrb: Declare SCSI host template const
  scsi: myrs: Declare SCSI host template const
  scsi: nsp32: Declare SCSI host template const
  scsi: pcmcia-sym53c500: Declare SCSI host template const
  scsi: pcmcia-pm8001: Declare SCSI host template const
  scsi: pmcraid: Declare SCSI host template const
  scsi: ppa: Declare SCSI host template const
  scsi: ps3rom: Declare SCSI host template const
  scsi: qla1280: Declare SCSI host template const
  scsi: qla2xxx: Declare SCSI host template const
  scsi: qlogicpti: Declare SCSI host template const
  scsi: sgiwd93: Declare SCSI host template const
  scsi: smartpqi: Declare SCSI host template const
  scsi: snic: Declare SCSI host template const
  scsi: stex: Declare SCSI host template const
  scsi: sym53c8xx: Declare SCSI host template const
  scsi: virtio-scsi: Declare SCSI host template const
  scsi: wd719x: Declare SCSI host template const
  scsi: xen-scsifront: Declare SCSI host template const
  scsi: rts5208: Declare SCSI host template const
  scsi: target: tcm-loop: Declare SCSI host template const
  scsi: ufs: Declare SCSI host template const
  usb: uas: Declare two host templates and host template pointers const
  scsi: core: Update a source code comment

 drivers/ata/acard-ahci.c                  |   2 +-
 drivers/ata/ahci.c                        |   2 +-
 drivers/ata/ahci.h                        |   2 +-
 drivers/ata/ahci_brcm.c                   |   2 +-
 drivers/ata/ahci_ceva.c                   |   2 +-
 drivers/ata/ahci_da850.c                  |   2 +-
 drivers/ata/ahci_dm816.c                  |   2 +-
 drivers/ata/ahci_imx.c                    |   2 +-
 drivers/ata/ahci_mtk.c                    |   2 +-
 drivers/ata/ahci_mvebu.c                  |   2 +-
 drivers/ata/ahci_platform.c               |   2 +-
 drivers/ata/ahci_qoriq.c                  |   2 +-
 drivers/ata/ahci_seattle.c                |   2 +-
 drivers/ata/ahci_st.c                     |   2 +-
 drivers/ata/ahci_sunxi.c                  |   2 +-
 drivers/ata/ahci_tegra.c                  |   2 +-
 drivers/ata/ahci_xgene.c                  |   2 +-
 drivers/ata/ata_generic.c                 |   2 +-
 drivers/ata/ata_piix.c                    |   6 +-
 drivers/ata/libahci.c                     |   4 +-
 drivers/ata/libahci_platform.c            |   2 +-
 drivers/ata/libata-core.c                 |   4 +-
 drivers/ata/libata-scsi.c                 |   2 +-
 drivers/ata/libata-sff.c                  |   8 +-
 drivers/ata/libata.h                      |   2 +-
 drivers/ata/pata_acpi.c                   |   2 +-
 drivers/ata/pata_ali.c                    |   2 +-
 drivers/ata/pata_amd.c                    |   2 +-
 drivers/ata/pata_arasan_cf.c              |   2 +-
 drivers/ata/pata_artop.c                  |   2 +-
 drivers/ata/pata_atiixp.c                 |   2 +-
 drivers/ata/pata_atp867x.c                |   2 +-
 drivers/ata/pata_bk3710.c                 | 380 ++++++++++++++++++++++
 drivers/ata/pata_buddha.c                 |   2 +-
 drivers/ata/pata_cmd640.c                 |   2 +-
 drivers/ata/pata_cmd64x.c                 |   2 +-
 drivers/ata/pata_cs5520.c                 |   2 +-
 drivers/ata/pata_cs5530.c                 |   2 +-
 drivers/ata/pata_cs5535.c                 |   2 +-
 drivers/ata/pata_cs5536.c                 |   2 +-
 drivers/ata/pata_cypress.c                |   2 +-
 drivers/ata/pata_efar.c                   |   2 +-
 drivers/ata/pata_ep93xx.c                 |   2 +-
 drivers/ata/pata_falcon.c                 |   2 +-
 drivers/ata/pata_ftide010.c               |   2 +-
 drivers/ata/pata_gayle.c                  |   2 +-
 drivers/ata/pata_hpt366.c                 |   2 +-
 drivers/ata/pata_hpt37x.c                 |   2 +-
 drivers/ata/pata_hpt3x2n.c                |   2 +-
 drivers/ata/pata_hpt3x3.c                 |   2 +-
 drivers/ata/pata_icside.c                 |   2 +-
 drivers/ata/pata_imx.c                    |   2 +-
 drivers/ata/pata_isapnp.c                 |   2 +-
 drivers/ata/pata_it8213.c                 |   2 +-
 drivers/ata/pata_it821x.c                 |   2 +-
 drivers/ata/pata_ixp4xx_cf.c              |   2 +-
 drivers/ata/pata_jmicron.c                |   2 +-
 drivers/ata/pata_legacy.c                 |   2 +-
 drivers/ata/pata_macio.c                  |   2 +-
 drivers/ata/pata_marvell.c                |   2 +-
 drivers/ata/pata_mpc52xx.c                |   2 +-
 drivers/ata/pata_mpiix.c                  |   2 +-
 drivers/ata/pata_netcell.c                |   2 +-
 drivers/ata/pata_ninja32.c                |   2 +-
 drivers/ata/pata_ns87410.c                |   2 +-
 drivers/ata/pata_ns87415.c                |   2 +-
 drivers/ata/pata_octeon_cf.c              |   2 +-
 drivers/ata/pata_of_platform.c            |   2 +-
 drivers/ata/pata_oldpiix.c                |   2 +-
 drivers/ata/pata_opti.c                   |   2 +-
 drivers/ata/pata_optidma.c                |   2 +-
 drivers/ata/pata_pcmcia.c                 |   2 +-
 drivers/ata/pata_pdc2027x.c               |   2 +-
 drivers/ata/pata_pdc202xx_old.c           |   2 +-
 drivers/ata/pata_piccolo.c                |   2 +-
 drivers/ata/pata_platform.c               |   4 +-
 drivers/ata/pata_pxa.c                    |   2 +-
 drivers/ata/pata_radisys.c                |   2 +-
 drivers/ata/pata_rb532_cf.c               |   2 +-
 drivers/ata/pata_rdc.c                    |   2 +-
 drivers/ata/pata_rz1000.c                 |   2 +-
 drivers/ata/pata_sc1200.c                 |   2 +-
 drivers/ata/pata_sch.c                    |   2 +-
 drivers/ata/pata_serverworks.c            |   6 +-
 drivers/ata/pata_sil680.c                 |   2 +-
 drivers/ata/pata_sis.c                    |   2 +-
 drivers/ata/pata_sl82c105.c               |   2 +-
 drivers/ata/pata_triflex.c                |   2 +-
 drivers/ata/pata_via.c                    |   2 +-
 drivers/ata/pdc_adma.c                    |   2 +-
 drivers/ata/sata_dwc_460ex.c              |   2 +-
 drivers/ata/sata_fsl.c                    |   2 +-
 drivers/ata/sata_highbank.c               |   2 +-
 drivers/ata/sata_inic162x.c               |   2 +-
 drivers/ata/sata_mv.c                     |   4 +-
 drivers/ata/sata_nv.c                     |   8 +-
 drivers/ata/sata_promise.c                |   2 +-
 drivers/ata/sata_qstor.c                  |   2 +-
 drivers/ata/sata_rcar.c                   |   2 +-
 drivers/ata/sata_sil.c                    |   2 +-
 drivers/ata/sata_sil24.c                  |   2 +-
 drivers/ata/sata_sis.c                    |   2 +-
 drivers/ata/sata_svw.c                    |   2 +-
 drivers/ata/sata_sx4.c                    |   2 +-
 drivers/ata/sata_uli.c                    |   2 +-
 drivers/ata/sata_via.c                    |   2 +-
 drivers/ata/sata_vsc.c                    |   2 +-
 drivers/firewire/sbp2.c                   |   4 +-
 drivers/infiniband/ulp/iser/iscsi_iser.c  |   4 +-
 drivers/infiniband/ulp/srp/ib_srp.c       |   2 +-
 drivers/message/fusion/mptfc.c            |   2 +-
 drivers/message/fusion/mptsas.c           |   2 +-
 drivers/message/fusion/mptspi.c           |   2 +-
 drivers/s390/scsi/zfcp_scsi.c             |   2 +-
 drivers/scsi/3w-9xxx.c                    |   3 +-
 drivers/scsi/3w-sas.c                     |   3 +-
 drivers/scsi/3w-xxxx.c                    |   2 +-
 drivers/scsi/BusLogic.c                   |   4 +-
 drivers/scsi/a100u2w.c                    |   2 +-
 drivers/scsi/a2091.c                      |   2 +-
 drivers/scsi/a3000.c                      |   2 +-
 drivers/scsi/aacraid/linit.c              |   2 +-
 drivers/scsi/advansys.c                   |   2 +-
 drivers/scsi/aha152x.c                    |   4 +-
 drivers/scsi/aha1542.c                    |   5 +-
 drivers/scsi/aha1740.c                    |   2 +-
 drivers/scsi/aic94xx/aic94xx_init.c       |   2 +-
 drivers/scsi/am53c974.c                   |   2 +-
 drivers/scsi/arcmsr/arcmsr_hba.c          |   2 +-
 drivers/scsi/arm/acornscsi.c              |   2 +-
 drivers/scsi/arm/arxescsi.c               |   2 +-
 drivers/scsi/arm/cumana_1.c               |   2 +-
 drivers/scsi/arm/cumana_2.c               |   2 +-
 drivers/scsi/arm/eesox.c                  |   2 +-
 drivers/scsi/arm/oak.c                    |   2 +-
 drivers/scsi/arm/powertec.c               |   2 +-
 drivers/scsi/atp870u.c                    |   4 +-
 drivers/scsi/be2iscsi/be_main.c           |   2 +-
 drivers/scsi/bnx2i/bnx2i_iscsi.c          |   4 +-
 drivers/scsi/cxgbi/cxgb3i/cxgb3i.c        |   2 +-
 drivers/scsi/cxgbi/libcxgbi.c             |   2 +-
 drivers/scsi/cxgbi/libcxgbi.h             |   2 +-
 drivers/scsi/dc395x.c                     |   2 +-
 drivers/scsi/dmx3191d.c                   |   2 +-
 drivers/scsi/elx/efct/efct_xport.c        |   2 +-
 drivers/scsi/esas2r/esas2r_main.c         |   2 +-
 drivers/scsi/esp_scsi.c                   |   2 +-
 drivers/scsi/esp_scsi.h                   |   2 +-
 drivers/scsi/fcoe/fcoe.c                  |   2 +-
 drivers/scsi/fdomain.c                    |   2 +-
 drivers/scsi/fnic/fnic_main.c             |   2 +-
 drivers/scsi/g_NCR5380.c                  |   4 +-
 drivers/scsi/gvp11.c                      |   2 +-
 drivers/scsi/hisi_sas/hisi_sas.h          |   2 +-
 drivers/scsi/hisi_sas/hisi_sas_v1_hw.c    |   2 +-
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c    |   2 +-
 drivers/scsi/hisi_sas/hisi_sas_v3_hw.c    |   2 +-
 drivers/scsi/hosts.c                      |   4 +-
 drivers/scsi/hpsa.c                       |   2 +-
 drivers/scsi/hptiop.c                     |   2 +-
 drivers/scsi/ibmvscsi/ibmvfc.c            |   2 +-
 drivers/scsi/imm.c                        |   2 +-
 drivers/scsi/initio.c                     |   2 +-
 drivers/scsi/ipr.c                        |   2 +-
 drivers/scsi/isci/init.c                  |   2 +-
 drivers/scsi/iscsi_tcp.c                  |   4 +-
 drivers/scsi/jazz_esp.c                   |   2 +-
 drivers/scsi/libiscsi.c                   |   2 +-
 drivers/scsi/mac53c94.c                   |   2 +-
 drivers/scsi/mac_esp.c                    |   2 +-
 drivers/scsi/mac_scsi.c                   |   2 +-
 drivers/scsi/megaraid.c                   |   2 +-
 drivers/scsi/megaraid/megaraid_mbox.c     |   2 +-
 drivers/scsi/megaraid/megaraid_sas_base.c |   2 +-
 drivers/scsi/mesh.c                       |   2 +-
 drivers/scsi/mpi3mr/mpi3mr_os.c           |   2 +-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c      |   4 +-
 drivers/scsi/mvme147.c                    |   2 +-
 drivers/scsi/mvsas/mv_init.c              |   2 +-
 drivers/scsi/mvumi.c                      |   2 +-
 drivers/scsi/myrb.c                       |   2 +-
 drivers/scsi/myrs.c                       |   2 +-
 drivers/scsi/nsp32.c                      |   2 +-
 drivers/scsi/pcmcia/sym53c500_cs.c        |   4 +-
 drivers/scsi/pm8001/pm8001_init.c         |   2 +-
 drivers/scsi/pmcraid.c                    |   2 +-
 drivers/scsi/ppa.c                        |   2 +-
 drivers/scsi/ps3rom.c                     |   2 +-
 drivers/scsi/qedf/qedf_main.c             |   2 +-
 drivers/scsi/qedi/qedi_gbl.h              |   2 +-
 drivers/scsi/qedi/qedi_iscsi.c            |   2 +-
 drivers/scsi/qla1280.c                    |   2 +-
 drivers/scsi/qla2xxx/qla_gbl.h            |   2 +-
 drivers/scsi/qla2xxx/qla_mid.c            |   2 +-
 drivers/scsi/qla2xxx/qla_os.c             |   4 +-
 drivers/scsi/qla2xxx/qla_target.c         |   4 +-
 drivers/scsi/qlogicpti.c                  |   2 +-
 drivers/scsi/scsi_error.c                 |  16 +-
 drivers/scsi/scsi_sysfs.c                 |   6 +-
 drivers/scsi/sgiwd93.c                    |   2 +-
 drivers/scsi/smartpqi/smartpqi_init.c     |   2 +-
 drivers/scsi/snic/snic_main.c             |   2 +-
 drivers/scsi/stex.c                       |   2 +-
 drivers/scsi/sun3x_esp.c                  |   2 +-
 drivers/scsi/sun_esp.c                    |   2 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c       |   4 +-
 drivers/scsi/virtio_scsi.c                |   2 +-
 drivers/scsi/wd719x.c                     |   2 +-
 drivers/scsi/xen-scsifront.c              |   2 +-
 drivers/scsi/zorro_esp.c                  |   2 +-
 drivers/staging/rts5208/rtsx.c            |   2 +-
 drivers/target/loopback/tcm_loop.c        |   2 +-
 drivers/ufs/core/ufshcd.c                 |   2 +-
 drivers/usb/image/microtek.c              |   2 +-
 drivers/usb/storage/uas.c                 |   2 +-
 drivers/usb/storage/usb.c                 |   2 +-
 drivers/usb/storage/usb.h                 |   2 +-
 include/linux/ahci_platform.h             |   2 +-
 include/linux/ata_platform.h              |   2 +-
 include/linux/libata.h                    |  10 +-
 include/linux/raid_class.h                |   2 +-
 include/scsi/libfc.h                      |   2 +-
 include/scsi/libiscsi.h                   |   2 +-
 include/scsi/scsi_host.h                  |   6 +-
 224 files changed, 648 insertions(+), 269 deletions(-)
 create mode 100644 drivers/ata/pata_bk3710.c

Comments

Alan Stern March 4, 2023, 3:51 p.m. UTC | #1
On Fri, Mar 03, 2023 at 04:31:02PM -0800, Bart Van Assche wrote:
> Improve source code documentation by constifying host templates that are
> not modified.
> 
> Cc: Oliver Neukum <oneukum@suse.com>
> Cc: linux-usb@vger.kernel.org
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---

For the usb-storage parts:

Acked-by: Alan Stern <stern@rowland.harvard.edu>

>  drivers/usb/image/microtek.c | 2 +-
>  drivers/usb/storage/uas.c    | 2 +-
>  drivers/usb/storage/usb.c    | 2 +-
>  drivers/usb/storage/usb.h    | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
> index 874ea4b54ced..8c8fa71c69c4 100644
> --- a/drivers/usb/image/microtek.c
> +++ b/drivers/usb/image/microtek.c
> @@ -620,7 +620,7 @@ static int mts_scsi_queuecommand_lck(struct scsi_cmnd *srb)
>  
>  static DEF_SCSI_QCMD(mts_scsi_queuecommand)
>  
> -static struct scsi_host_template mts_scsi_host_template = {
> +static const struct scsi_host_template mts_scsi_host_template = {
>  	.module			= THIS_MODULE,
>  	.name			= "microtekX6",
>  	.proc_name		= "microtekX6",
> diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
> index de3836412bf3..2583ee9815c5 100644
> --- a/drivers/usb/storage/uas.c
> +++ b/drivers/usb/storage/uas.c
> @@ -894,7 +894,7 @@ static int uas_slave_configure(struct scsi_device *sdev)
>  	return 0;
>  }
>  
> -static struct scsi_host_template uas_host_template = {
> +static const struct scsi_host_template uas_host_template = {
>  	.module = THIS_MODULE,
>  	.name = "uas",
>  	.queuecommand = uas_queuecommand,
> diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
> index ed7c6ad96a74..7b36a3334fb3 100644
> --- a/drivers/usb/storage/usb.c
> +++ b/drivers/usb/storage/usb.c
> @@ -937,7 +937,7 @@ int usb_stor_probe1(struct us_data **pus,
>  		struct usb_interface *intf,
>  		const struct usb_device_id *id,
>  		const struct us_unusual_dev *unusual_dev,
> -		struct scsi_host_template *sht)
> +		const struct scsi_host_template *sht)
>  {
>  	struct Scsi_Host *host;
>  	struct us_data *us;
> diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
> index 0451fac1adce..fd3f32670873 100644
> --- a/drivers/usb/storage/usb.h
> +++ b/drivers/usb/storage/usb.h
> @@ -187,7 +187,7 @@ extern int usb_stor_probe1(struct us_data **pus,
>  		struct usb_interface *intf,
>  		const struct usb_device_id *id,
>  		const struct us_unusual_dev *unusual_dev,
> -		struct scsi_host_template *sht);
> +		const struct scsi_host_template *sht);
>  extern int usb_stor_probe2(struct us_data *us);
>  extern void usb_stor_disconnect(struct usb_interface *intf);
>
Linus Walleij March 4, 2023, 10:44 p.m. UTC | #2
On Sat, Mar 4, 2023 at 1:31 AM Bart Van Assche <bvanassche@acm.org> wrote:

> Make it explicit that ATA host templates are not modified.
>
> Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: John Garry <john.garry@huawei.com>
> Cc: Mike Christie <michael.christie@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Looks reasonable.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Oliver Neukum March 6, 2023, 12:27 p.m. UTC | #3
On 04.03.23 01:31, Bart Van Assche wrote:
> Improve source code documentation by constifying host templates that are
> not modified.
> 
> Cc: Oliver Neukum <oneukum@suse.com>
> Cc: linux-usb@vger.kernel.org
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Oliver Neukum <oneukum@suse.com>
John Garry March 6, 2023, 1:10 p.m. UTC | #4
On 04/03/2023 00:29, Bart Van Assche wrote:
> Access the qla2xxx_driver_template data structure directly instead of via
> the host pointer. This patch prepares for declaring the 'hostt' pointer
> const.
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/qla2xxx/qla_target.c | 4 ++--

Hi Bart,

>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
> index aa0cf5ca6c1c..8d9a6aa3ea61 100644
> --- a/drivers/scsi/qla2xxx/qla_target.c
> +++ b/drivers/scsi/qla2xxx/qla_target.c
> @@ -6395,8 +6395,8 @@ int qlt_add_target(struct qla_hw_data *ha, struct scsi_qla_host *base_vha)
>   		return -ENOMEM;
>   	}
>   
> -	if (!(base_vha->host->hostt->supported_mode & MODE_TARGET))
> -		base_vha->host->hostt->supported_mode |= MODE_TARGET;
> +	if (!(qla2xxx_driver_template.supported_mode & MODE_TARGET))
> +		qla2xxx_driver_template.supported_mode |= MODE_TARGET;

So we're saying if that MODE_TARGET bit is not set, then set it. It 
would be neater to just always set it, right?

Apart from that, I will say that I haven't studied the driver in detail, 
but my impression is that we should just set this flag per-shost in 
base_vha->host.active_mode, and not the host template supported_mode 
member. Indeed, we don't even seem to be making this driver 
scsi_host_template as const in this series, which I thought was the aim 
(and I assume because of this).

Thanks,
John

>   
>   	rc = btree_init64(&tgt->lun_qpair_map);
>   	if (rc) {
Bart Van Assche March 6, 2023, 1:51 p.m. UTC | #5
On 3/6/23 05:10, John Garry wrote:
> On 04/03/2023 00:29, Bart Van Assche wrote:
>> --- a/drivers/scsi/qla2xxx/qla_target.c
>> +++ b/drivers/scsi/qla2xxx/qla_target.c
>> @@ -6395,8 +6395,8 @@ int qlt_add_target(struct qla_hw_data *ha, 
>> struct scsi_qla_host *base_vha)
>>           return -ENOMEM;
>>       }
>> -    if (!(base_vha->host->hostt->supported_mode & MODE_TARGET))
>> -        base_vha->host->hostt->supported_mode |= MODE_TARGET;
>> +    if (!(qla2xxx_driver_template.supported_mode & MODE_TARGET))
>> +        qla2xxx_driver_template.supported_mode |= MODE_TARGET;
> 
> So we're saying if that MODE_TARGET bit is not set, then set it. It 
> would be neater to just always set it, right?
> 
> Apart from that, I will say that I haven't studied the driver in detail, 
> but my impression is that we should just set this flag per-shost in 
> base_vha->host.active_mode, and not the host template supported_mode 
> member. Indeed, we don't even seem to be making this driver 
> scsi_host_template as const in this series, which I thought was the aim 
> (and I assume because of this).

Hi John,

If I have to repost this patch series I will implement this suggestion.

Thanks,

Bart.
John Garry March 6, 2023, 2:29 p.m. UTC | #6
On 04/03/2023 00:29, Bart Van Assche wrote:
> Prepare for constifying most SCSI host template pointers by constifying
> the SCSI host template pointer arguments and variables in the SCSI core.
> 
> Cc: Christoph Hellwig<hch@lst.de>
> Cc: Ming Lei<ming.lei@redhat.com>
> Cc: Hannes Reinecke<hare@suse.de>
> Cc: John Garry<john.garry@huawei.com>
> Cc: Mike Christie<michael.christie@oracle.com>
> Signed-off-by: Bart Van Assche<bvanassche@acm.org>

Hi Bart,

You wrote that most pointers were now cast as const - which ones where 
not? From a quick scan they all seem to be const

Apart from that:
Reviewed-by: John Garry <john.g.garry@oracle.com>

Thanks,
John
Bart Van Assche March 6, 2023, 4:07 p.m. UTC | #7
On 3/6/23 06:29, John Garry wrote:
> You wrote that most pointers were now cast as const - which ones where 
> not? From a quick scan they all seem to be const

Hi Garry,

Some SCSI drivers modify one of more members of the SCSI host template. 
An example can be found in drivers/scsi/pcmcia/nsp_cs.c:

	sht->name	  = data->nspinfo;

Another example from drivers/scsi/bnx2fc/bnx2fc_fcoe.c:

	bnx2fc_shost_template.can_queue = hba->max_outstanding_cmds;

Thanks,

Bart.
John Garry March 6, 2023, 6:55 p.m. UTC | #8
On 06/03/2023 16:07, Bart Van Assche wrote:
> On 3/6/23 06:29, John Garry wrote:
>> You wrote that most pointers were now cast as const - which ones were 
>> not? From a quick scan they all seem to be const
> 
> Hi Garry,
> 
> Some SCSI drivers modify one of more members of the SCSI host template. 
> An example can be found in drivers/scsi/pcmcia/nsp_cs.c:

I seemed to get the wrong idea of what you meant in the commit message. 
When you wrote "Prepare for constifying most SCSI host template 
pointers", I got the impression that most of the pointers to SCSI host 
template in the core code were going to be pointers to const. However 
you really meant that most of the per-driver SCSI host template 
instances would be const.

Anyway,

Reviewed-by: John Garry <john.g.garry@oracle.com>

> 
>      sht->name      = data->nspinfo;
> 
> Another example from drivers/scsi/bnx2fc/bnx2fc_fcoe.c:
> 
>      bnx2fc_shost_template.can_queue = hba->max_outstanding_cmds;

BTW, surely we should be setting shost->can_queue = 
hba->max_outstanding_cmds after scsi_host_alloc() and not modifying 
bnx2fc_shost_template, right? The series is already huge, so this stuff 
would be done separately, I suppose.

Thanks,
John
Bart Van Assche March 6, 2023, 7:41 p.m. UTC | #9
On 3/6/23 10:55, John Garry wrote:
> On 06/03/2023 16:07, Bart Van Assche wrote:
>> Another example from drivers/scsi/bnx2fc/bnx2fc_fcoe.c:
>>
>>      bnx2fc_shost_template.can_queue = hba->max_outstanding_cmds;
> 
> BTW, surely we should be setting shost->can_queue = 
> hba->max_outstanding_cmds after scsi_host_alloc() and not modifying 
> bnx2fc_shost_template, right? The series is already huge, so this stuff 
> would be done separately, I suppose.

Hi John,

If anyone else wants to work on this that's fine with me. My view is 
that the SCSI core should support declaring host templates const but I'm 
not sure it's worth it to make changes in old drivers such that their 
SCSI host template can be declared const. One class of SCSI LLDs that 
does not have a const SCSI host template are the NCR drivers. The NCR 
SCSI host controller was popular 40 years ago. There are probably not 
many working SCSI devices left that are based on this SCSI controller.

Bart.
Finn Thain March 6, 2023, 11:34 p.m. UTC | #10
On Mon, 6 Mar 2023, Bart Van Assche wrote:

> On 3/6/23 10:55, John Garry wrote:
> > On 06/03/2023 16:07, Bart Van Assche wrote:
> >> Another example from drivers/scsi/bnx2fc/bnx2fc_fcoe.c:
> >>
> >>      bnx2fc_shost_template.can_queue = hba->max_outstanding_cmds;
> > 
> > BTW, surely we should be setting shost->can_queue =
> > hba->max_outstanding_cmds after scsi_host_alloc() and not modifying
> > bnx2fc_shost_template, right? The series is already huge, so this stuff
> > would be done separately, I suppose.
> 
> Hi John,
> 
> If anyone else wants to work on this that's fine with me. My view is 
> that the SCSI core should support declaring host templates const but I'm 
> not sure it's worth it to make changes in old drivers such that their 
> SCSI host template can be declared const.

Would it alter the driver .o files? If not, the changes won't require 
actual testing.

> One class of SCSI LLDs that does not have a const SCSI host template are 
> the NCR drivers. The NCR SCSI host controller was popular 40 years ago. 
> There are probably not many working SCSI devices left that are based on 
> this SCSI controller.
> 

True, the NCR 5380 controller was popular 40 years ago among early 
adopters like Sun and Apple. Is this relevant?
Bart Van Assche March 6, 2023, 11:41 p.m. UTC | #11
On 3/6/23 15:34, Finn Thain wrote:
> Would it alter the driver .o files? If not, the changes won't require
> actual testing.

Hi Finn,

My understanding is that declaring a static data structure const may 
move it to another section in the .o file but otherwise that the .o file 
should not be affected. I agree that retesting shouldn't be necessary 
for patches that only involve making data structures const.

Thanks,

Bart.
Khalid Aziz March 6, 2023, 11:42 p.m. UTC | #12
On 3/3/23 5:29 PM, Bart Van Assche wrote:
> Make it explicit that the SCSI host template is not modified.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/BusLogic.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
> index f7b7ffda1161..72ceaf650b0d 100644
> --- a/drivers/scsi/BusLogic.c
> +++ b/drivers/scsi/BusLogic.c
> @@ -54,7 +54,7 @@
>   #define FAILURE (-1)
>   #endif
>   
> -static struct scsi_host_template blogic_template;
> +static const struct scsi_host_template blogic_template;
>   
>   /*
>     blogic_drvr_options_count is a count of the number of BusLogic Driver
> @@ -3663,7 +3663,7 @@ static int __init blogic_parseopts(char *options)
>     Get it all started
>   */
>   
> -static struct scsi_host_template blogic_template = {
> +static const struct scsi_host_template blogic_template = {
>   	.module = THIS_MODULE,
>   	.proc_name = "BusLogic",
>   	.write_info = blogic_wr

Looks good to me.

Acked-by: Khalid Aziz <khalid@gonehiking.org>
Ming Lei March 7, 2023, 12:04 a.m. UTC | #13
On Sat, Mar 4, 2023 at 8:31 AM Bart Van Assche <bvanassche@acm.org> wrote:
>
> Prepare for constifying most SCSI host template pointers by constifying
> the SCSI host template pointer arguments and variables in the SCSI core.
>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Hannes Reinecke <hare@suse.de>
> Cc: John Garry <john.garry@huawei.com>
> Cc: Mike Christie <michael.christie@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: Ming Lei <ming.lei@redhat.com>
Martin K. Petersen March 7, 2023, 2 a.m. UTC | #14
Hi Bart!

> Make it explicit that ATA host templates are not modified.

>  drivers/ata/pata_atiixp.c       |   2 +-
>  drivers/ata/pata_atp867x.c      |   2 +-
>  drivers/ata/pata_bk3710.c       | 380 ++++++++++++++++++++++++++++++++
   ^^^^^^^^^^^^^^^^^^^^^^^^^
Don't believe you meant to add this...
>  drivers/ata/pata_buddha.c       |   2 +-
>  drivers/ata/pata_cmd640.c       |   2 +-
Bart Van Assche March 7, 2023, 2:53 a.m. UTC | #15
On 3/6/23 18:00, Martin K. Petersen wrote:
>> Make it explicit that ATA host templates are not modified.
> 
>>   drivers/ata/pata_atiixp.c       |   2 +-
>>   drivers/ata/pata_atp867x.c      |   2 +-
>>   drivers/ata/pata_bk3710.c       | 380 ++++++++++++++++++++++++++++++++
>     ^^^^^^^^^^^^^^^^^^^^^^^^^
> Don't believe you meant to add this...

Hi Martin,

Thanks for having reported this. The above is the result of having 
resolved a rebase conflict incorrectly. I will remove file 
drivers/ata/pata_bk3710.c from this patch.

Thanks,

Bart.
Damien Le Moal March 7, 2023, 3:29 a.m. UTC | #16
On 3/7/23 11:00, Martin K. Petersen wrote:
> 
> Hi Bart!
> 
>> Make it explicit that ATA host templates are not modified.
> 
>>  drivers/ata/pata_atiixp.c       |   2 +-
>>  drivers/ata/pata_atp867x.c      |   2 +-
>>  drivers/ata/pata_bk3710.c       | 380 ++++++++++++++++++++++++++++++++
>    ^^^^^^^^^^^^^^^^^^^^^^^^^
> Don't believe you meant to add this...

Oops. Yes, indeed, good catch !

>>  drivers/ata/pata_buddha.c       |   2 +-
>>  drivers/ata/pata_cmd640.c       |   2 +-
>
John Garry March 9, 2023, 6:59 p.m. UTC | #17
On 09/03/2023 18:42, Bart Van Assche wrote:
> On 3/6/23 05:10, John Garry wrote:
>> Apart from that, I will say that I haven't studied the driver in 
>> detail, but my impression is that we should just set this flag 
>> per-shost in base_vha->host.active_mode, and not the host template 
>> supported_mode member. Indeed, we don't even seem to be making this 
>> driver scsi_host_template as const in this series, which I thought was 
>> the aim (and I assume because of this).
> 
> This patch is necessary because this patch prevents to declare the 
> 'hostt' member of struct Scsi_Host const.

ok, sure, but I am just saying that that the pre-existing code looks 
suspicious. However, as I mentioned before, things like this (modifying 
the host template) could be improved later by someone.

Thanks,
John