public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: mptfusion: Remove unnecessarily casts
@ 2020-08-20 18:05 Alex Dewar
  2020-08-20 18:53 ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Dewar @ 2020-08-20 18:05 UTC (permalink / raw)
  To: Sathya Prakash, Sreekanth Reddy, Suganath Prabu Subramani,
	MPT-FusionLinux.pdl, linux-scsi, linux-kernel
  Cc: Alex Dewar

In a number of places, the value returned from pci_alloc_consistent() is
unnecessarily cast from void*. Remove these casts.

Issue identified with Coccinelle.

Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
---
 drivers/message/fusion/mptbase.c | 6 +++---
 drivers/message/fusion/mptctl.c  | 5 ++---
 drivers/message/fusion/mptfc.c   | 8 ++++----
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 9903e9660a38..e61f46fbe7f4 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -4975,7 +4975,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
 
 	if (hdr.PageLength > 0) {
 		data_sz = hdr.PageLength * 4;
-		ppage0_alloc = (LANPage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
+		ppage0_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
 		rc = -ENOMEM;
 		if (ppage0_alloc) {
 			memset((u8 *)ppage0_alloc, 0, data_sz);
@@ -5021,7 +5021,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
 
 	data_sz = hdr.PageLength * 4;
 	rc = -ENOMEM;
-	ppage1_alloc = (LANPage1_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page1_dma);
+	ppage1_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page1_dma);
 	if (ppage1_alloc) {
 		memset((u8 *)ppage1_alloc, 0, data_sz);
 		cfg.physAddr = page1_dma;
@@ -5322,7 +5322,7 @@ GetIoUnitPage2(MPT_ADAPTER *ioc)
 	/* Read the config page */
 	data_sz = hdr.PageLength * 4;
 	rc = -ENOMEM;
-	ppage_alloc = (IOUnitPage2_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page_dma);
+	ppage_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page_dma);
 	if (ppage_alloc) {
 		memset((u8 *)ppage_alloc, 0, data_sz);
 		cfg.physAddr = page_dma;
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 1074b882c57c..24aebad60366 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -2593,7 +2593,7 @@ mptctl_hp_targetinfo(MPT_ADAPTER *ioc, unsigned long arg)
        /* Get the data transfer speeds
         */
 	data_sz = ioc->spi_data.sdp0length * 4;
-	pg0_alloc = (SCSIDevicePage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page_dma);
+	pg0_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page_dma);
 	if (pg0_alloc) {
 		hdr.PageVersion = ioc->spi_data.sdp0version;
 		hdr.PageLength = data_sz;
@@ -2657,8 +2657,7 @@ mptctl_hp_targetinfo(MPT_ADAPTER *ioc, unsigned long arg)
 		/* Issue the second config page request */
 		cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
 		data_sz = (int) cfg.cfghdr.hdr->PageLength * 4;
-		pg3_alloc = (SCSIDevicePage3_t *) pci_alloc_consistent(
-							ioc->pcidev, data_sz, &page_dma);
+		pg3_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page_dma);
 		if (pg3_alloc) {
 			cfg.physAddr = page_dma;
 			cfg.pageAddr = (karg.hdr.channel << 8) | karg.hdr.id;
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 4314a3352b96..5abaadc4fc38 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -763,7 +763,7 @@ mptfc_GetFcPortPage0(MPT_ADAPTER *ioc, int portnum)
 
 	data_sz = hdr.PageLength * 4;
 	rc = -ENOMEM;
-	ppage0_alloc = (FCPortPage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
+	ppage0_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
 	if (ppage0_alloc) {
 
  try_again:
@@ -904,9 +904,9 @@ mptfc_GetFcPortPage1(MPT_ADAPTER *ioc, int portnum)
 		if (data_sz < sizeof(FCPortPage1_t))
 			data_sz = sizeof(FCPortPage1_t);
 
-		page1_alloc = (FCPortPage1_t *) pci_alloc_consistent(ioc->pcidev,
-						data_sz,
-						&page1_dma);
+		page1_alloc = pci_alloc_consistent(ioc->pcidev,
+						   data_sz,
+						   &page1_dma);
 		if (!page1_alloc)
 			return -ENOMEM;
 	}
-- 
2.28.0


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

* Re: [PATCH] scsi: mptfusion: Remove unnecessarily casts
  2020-08-20 18:05 [PATCH] scsi: mptfusion: Remove unnecessarily casts Alex Dewar
@ 2020-08-20 18:53 ` Joe Perches
  2020-08-20 18:56   ` Alex Dewar
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2020-08-20 18:53 UTC (permalink / raw)
  To: Alex Dewar, Sathya Prakash, Sreekanth Reddy,
	Suganath Prabu Subramani, MPT-FusionLinux.pdl, linux-scsi,
	linux-kernel

On Thu, 2020-08-20 at 19:05 +0100, Alex Dewar wrote:
> In a number of places, the value returned from pci_alloc_consistent() is
> unnecessarily cast from void*. Remove these casts.
[]
> diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
[]
> @@ -4975,7 +4975,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
>  
>  	if (hdr.PageLength > 0) {
>  		data_sz = hdr.PageLength * 4;
> -		ppage0_alloc = (LANPage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
> +		ppage0_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
>  		rc = -ENOMEM;
>  		if (ppage0_alloc) {
>  			memset((u8 *)ppage0_alloc, 0, data_sz);

If you are removing unnecessary casts, it'd be better to remove
all of them in the same file or subsystem at once.

Also this memset and cast isn't actually necessary any more
as pci_alloc_consistent already zeros memory.

etc...


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

* Re: [PATCH] scsi: mptfusion: Remove unnecessarily casts
  2020-08-20 18:53 ` Joe Perches
@ 2020-08-20 18:56   ` Alex Dewar
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Dewar @ 2020-08-20 18:56 UTC (permalink / raw)
  To: Joe Perches
  Cc: Alex Dewar, Sathya Prakash, Sreekanth Reddy,
	Suganath Prabu Subramani, MPT-FusionLinux.pdl, linux-scsi,
	linux-kernel

On Thu, Aug 20, 2020 at 11:53:58AM -0700, Joe Perches wrote:
> On Thu, 2020-08-20 at 19:05 +0100, Alex Dewar wrote:
> > In a number of places, the value returned from pci_alloc_consistent() is
> > unnecessarily cast from void*. Remove these casts.
> []
> > diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
> []
> > @@ -4975,7 +4975,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
> >  
> >  	if (hdr.PageLength > 0) {
> >  		data_sz = hdr.PageLength * 4;
> > -		ppage0_alloc = (LANPage0_t *) pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
> > +		ppage0_alloc = pci_alloc_consistent(ioc->pcidev, data_sz, &page0_dma);
> >  		rc = -ENOMEM;
> >  		if (ppage0_alloc) {
> >  			memset((u8 *)ppage0_alloc, 0, data_sz);
> 
> If you are removing unnecessary casts, it'd be better to remove
> all of them in the same file or subsystem at once.
> 
> Also this memset and cast isn't actually necessary any more
> as pci_alloc_consistent already zeros memory.
> 
> etc...
> 

Good suggestion. Thanks for the feedback :-)

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

end of thread, other threads:[~2020-08-20 18:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-20 18:05 [PATCH] scsi: mptfusion: Remove unnecessarily casts Alex Dewar
2020-08-20 18:53 ` Joe Perches
2020-08-20 18:56   ` Alex Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox