All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: bfa: fix type conversion warning
@ 2017-12-06 14:14 Arnd Bergmann
  2017-12-07  9:17 ` Johannes Thumshirn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-12-06 14:14 UTC (permalink / raw)
  To: Anil Gurumurthy, Sudarsana Kalluru, James E.J. Bottomley,
	Martin K. Petersen
  Cc: Arnd Bergmann, Johannes Thumshirn, Hannes Reinecke, linux-scsi,
	linux-kernel

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>
---
 drivers/scsi/bfa/bfad_bsg.c |  4 ++--
 drivers/scsi/bfa/bfad_im.c  |  6 ++++--
 drivers/scsi/bfa/bfad_im.h  | 10 ++++++++++
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c
index fa9a966e2c2a..3976e787ba64 100644
--- a/drivers/scsi/bfa/bfad_bsg.c
+++ b/drivers/scsi/bfa/bfad_bsg.c
@@ -3134,7 +3134,7 @@ bfad_im_bsg_vendor_request(struct bsg_job *job)
 	struct fc_bsg_reply *bsg_reply = job->reply;
 	uint32_t vendor_cmd = bsg_request->rqst_data.h_vendor.vendor_cmd[0];
 	struct Scsi_Host *shost = fc_bsg_to_shost(job);
-	struct bfad_im_port_s *im_port = shost->hostdata[0];
+	struct bfad_im_port_s *im_port = bfad_get_im_port(shost);
 	struct bfad_s *bfad = im_port->bfad;
 	void *payload_kbuf;
 	int rc = -EINVAL;
@@ -3350,7 +3350,7 @@ bfad_im_bsg_els_ct_request(struct bsg_job *job)
 {
 	struct bfa_bsg_data *bsg_data;
 	struct Scsi_Host *shost = fc_bsg_to_shost(job);
-	struct bfad_im_port_s *im_port = shost->hostdata[0];
+	struct bfad_im_port_s *im_port = bfad_get_im_port(shost);
 	struct bfad_s *bfad = im_port->bfad;
 	bfa_bsg_fcpt_t *bsg_fcpt;
 	struct bfad_fcxp    *drv_fcxp;
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 24e657a4ec80..c05d6e91e4bd 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -546,6 +546,7 @@ int
 bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port,
 			struct device *dev)
 {
+	struct bfad_im_port_pointer *im_portp;
 	int error = 1;
 
 	mutex_lock(&bfad_mutex);
@@ -564,7 +565,8 @@ bfad_im_scsi_host_alloc(struct bfad_s *bfad, struct bfad_im_port_s *im_port,
 		goto out_free_idr;
 	}
 
-	im_port->shost->hostdata[0] = (unsigned long)im_port;
+	im_portp = shost_priv(im_port->shost);
+	im_portp->p = im_port;
 	im_port->shost->unique_id = im_port->idr_id;
 	im_port->shost->this_id = -1;
 	im_port->shost->max_id = MAX_FCP_TARGET;
@@ -748,7 +750,7 @@ bfad_scsi_host_alloc(struct bfad_im_port_s *im_port, struct bfad_s *bfad)
 
 	sht->sg_tablesize = bfad->cfg_data.io_max_sge;
 
-	return scsi_host_alloc(sht, sizeof(unsigned long));
+	return scsi_host_alloc(sht, sizeof(struct bfad_im_port_pointer));
 }
 
 void
diff --git a/drivers/scsi/bfa/bfad_im.h b/drivers/scsi/bfa/bfad_im.h
index 7f7616c52814..af66275570c3 100644
--- a/drivers/scsi/bfa/bfad_im.h
+++ b/drivers/scsi/bfa/bfad_im.h
@@ -69,6 +69,16 @@ struct bfad_im_port_s {
 	struct fc_vport *fc_vport;
 };
 
+struct bfad_im_port_pointer {
+	struct bfad_im_port_s *p;
+};
+
+static inline struct bfad_im_port_s *bfad_get_im_port(struct Scsi_Host *host)
+{
+	struct bfad_im_port_pointer *im_portp = shost_priv(host);
+	return im_portp->p;
+}
+
 enum bfad_itnim_state {
 	ITNIM_STATE_NONE,
 	ITNIM_STATE_ONLINE,
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: bfa: fix type conversion warning
  2017-12-06 14:14 [PATCH] scsi: bfa: fix type conversion warning Arnd Bergmann
@ 2017-12-07  9:17 ` Johannes Thumshirn
  2017-12-07  9:19 ` Hannes Reinecke
  2017-12-08  0:58 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2017-12-07  9:17 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Anil Gurumurthy, Sudarsana Kalluru, James E.J. Bottomley,
	Martin K. Petersen, Hannes Reinecke, linux-scsi, linux-kernel

Thanks Arnd,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: bfa: fix type conversion warning
  2017-12-06 14:14 [PATCH] scsi: bfa: fix type conversion warning Arnd Bergmann
  2017-12-07  9:17 ` Johannes Thumshirn
@ 2017-12-07  9:19 ` Hannes Reinecke
  2017-12-08  0:58 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2017-12-07  9:19 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Anil Gurumurthy, Sudarsana Kalluru, James E.J. Bottomley,
	Martin K. Petersen, Johannes Thumshirn, linux-scsi, linux-kernel

On Wed,  6 Dec 2017 15:14:18 +0100
Arnd Bergmann <arnd@arndb.de> wrote:

> 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>
> ---
>  drivers/scsi/bfa/bfad_bsg.c |  4 ++--
>  drivers/scsi/bfa/bfad_im.c  |  6 ++++--
>  drivers/scsi/bfa/bfad_im.h  | 10 ++++++++++
>  3 files changed, 16 insertions(+), 4 deletions(-)
> 

Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: bfa: fix type conversion warning
  2017-12-06 14:14 [PATCH] scsi: bfa: fix type conversion warning Arnd Bergmann
  2017-12-07  9:17 ` Johannes Thumshirn
  2017-12-07  9:19 ` Hannes Reinecke
@ 2017-12-08  0:58 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2017-12-08  0:58 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Anil Gurumurthy, Sudarsana Kalluru, James E.J. Bottomley,
	Martin K. Petersen, Johannes Thumshirn, Hannes Reinecke,
	linux-scsi, linux-kernel


Arnd,

> 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.

Applied to 4.15/scsi-fixes, thank you!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-08  0:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-06 14:14 [PATCH] scsi: bfa: fix type conversion warning Arnd Bergmann
2017-12-07  9:17 ` Johannes Thumshirn
2017-12-07  9:19 ` Hannes Reinecke
2017-12-08  0:58 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.