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

scsi: bfa: fix type conversion warning

A regression fix introduced a harmless type mismatch warning:

drivers/scsi/bfa/bfad_bsg.c: In function 'bfad_im_bsg_vendor_request':
drivers/scsi/bfa/bfad_bsg.c:3137:35: error: initialization of 'struct bfad_im_port_s *' from 'long unsigned int' makes pointer from integer without a cast [-Werror=int-conversion]
struct bfad_im_port_s *im_port = shost->hostdata[0];
^~~~~
drivers/scsi/bfa/bfad_bsg.c: In function 'bfad_im_bsg_els_ct_request':
drivers/scsi/bfa/bfad_bsg.c:3353:35: error: initialization of 'struct bfad_im_port_s *' from 'long unsigned int' makes pointer from integer without a cast [-Werror=int-conversion]
struct bfad_im_port_s *im_port = shost->hostdata[0];

This changes the code back to shost_priv() once more, but encapsulates
it in an inline function to document the rather unusual way of
using the private data only as a pointer to the previously allocated
structure.

I did not try to get rid of the extra indirection level entirely,
which would have been rather invasive and required reworking the entire
initialization sequence.

Fixes: 45349821ab3a ("scsi: bfa: fix access to bfad_im_port_s")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Arnd Bergmann and committed by
Martin K. Petersen
48d83282 7e70aa78

+16 -4
+2 -2
drivers/scsi/bfa/bfad_bsg.c
··· 3136 3136 struct fc_bsg_reply *bsg_reply = job->reply; 3137 3137 uint32_t vendor_cmd = bsg_request->rqst_data.h_vendor.vendor_cmd[0]; 3138 3138 struct Scsi_Host *shost = fc_bsg_to_shost(job); 3139 - struct bfad_im_port_s *im_port = shost->hostdata[0]; 3139 + struct bfad_im_port_s *im_port = bfad_get_im_port(shost); 3140 3140 struct bfad_s *bfad = im_port->bfad; 3141 3141 void *payload_kbuf; 3142 3142 int rc = -EINVAL; ··· 3352 3352 { 3353 3353 struct bfa_bsg_data *bsg_data; 3354 3354 struct Scsi_Host *shost = fc_bsg_to_shost(job); 3355 - struct bfad_im_port_s *im_port = shost->hostdata[0]; 3355 + struct bfad_im_port_s *im_port = bfad_get_im_port(shost); 3356 3356 struct bfad_s *bfad = im_port->bfad; 3357 3357 bfa_bsg_fcpt_t *bsg_fcpt; 3358 3358 struct bfad_fcxp *drv_fcxp;
+4 -2
drivers/scsi/bfa/bfad_im.c
··· 546 546 bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port, 547 547 struct device *dev) 548 548 { 549 + struct bfad_im_port_pointer *im_portp; 549 550 int error = 1; 550 551 551 552 mutex_lock(&bfad_mutex); ··· 565 564 goto out_free_idr; 566 565 } 567 566 568 - im_port->shost->hostdata[0] = (unsigned long)im_port; 567 + im_portp = shost_priv(im_port->shost); 568 + im_portp->p = im_port; 569 569 im_port->shost->unique_id = im_port->idr_id; 570 570 im_port->shost->this_id = -1; 571 571 im_port->shost->max_id = MAX_FCP_TARGET; ··· 750 748 751 749 sht->sg_tablesize = bfad->cfg_data.io_max_sge; 752 750 753 - return scsi_host_alloc(sht, sizeof(unsigned long)); 751 + return scsi_host_alloc(sht, sizeof(struct bfad_im_port_pointer)); 754 752 } 755 753 756 754 void
+10
drivers/scsi/bfa/bfad_im.h
··· 69 69 struct fc_vport *fc_vport; 70 70 }; 71 71 72 + struct bfad_im_port_pointer { 73 + struct bfad_im_port_s *p; 74 + }; 75 + 76 + static inline struct bfad_im_port_s *bfad_get_im_port(struct Scsi_Host *host) 77 + { 78 + struct bfad_im_port_pointer *im_portp = shost_priv(host); 79 + return im_portp->p; 80 + } 81 + 72 82 enum bfad_itnim_state { 73 83 ITNIM_STATE_NONE, 74 84 ITNIM_STATE_ONLINE,