Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Jesse Brandeburg <jesse.brandeburg@intel.com>,
	Xu Wang <vulab@iscas.ac.cn>
Cc: aelior@marvell.com, GR-everest-linux-l2@marvell.com,
	davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] qed_main: Remove unnecessary cast in kfree
Date: Tue, 18 Aug 2020 12:03:02 -0700	[thread overview]
Message-ID: <ac461ce3173457270815aba33b4be36dee760c54.camel@perches.com> (raw)
In-Reply-To: <20200818114403.00001257@intel.com>

On Tue, 2020-08-18 at 11:44 -0700, Jesse Brandeburg wrote:
> On Tue, 18 Aug 2020 09:10:56 +0000
> Xu Wang <vulab@iscas.ac.cn> wrote:
> 
> > Remove unnecassary casts in the argument to kfree.
> > 
> > Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
> 
> You seem to have several of these patches, they should be sent in a
> series with the series patch subject (for example):
> [PATCH net-next 0/n] fix up casts on kfree
> 
> Did you use a coccinelle script to find these? 
> 
> They could all have Fixes tags. I'd resend the whole bunch as a series.
> 
> Since this has no functional change, you could mention that in the
> series commit message text.

Commits with no functional change generally should
not be marked with Fixes:

And some wrapper functions might as well be removed
and just kfree used in-place instead.

Something like:
---
 drivers/net/ethernet/qlogic/qed/qed_main.c | 29 ++++++-----------------------
 1 file changed, 6 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 2558cb680db3..961adb4d8910 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -482,24 +482,6 @@ int qed_fill_dev_info(struct qed_dev *cdev,
 	return 0;
 }
 
-static void qed_free_cdev(struct qed_dev *cdev)
-{
-	kfree((void *)cdev);
-}
-
-static struct qed_dev *qed_alloc_cdev(struct pci_dev *pdev)
-{
-	struct qed_dev *cdev;
-
-	cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
-	if (!cdev)
-		return cdev;
-
-	qed_init_struct(cdev);
-
-	return cdev;
-}
-
 /* Sets the requested power state */
 static int qed_set_power_state(struct qed_dev *cdev, pci_power_t state)
 {
@@ -618,9 +600,11 @@ static struct qed_dev *qed_probe(struct pci_dev *pdev,
 	struct qed_dev *cdev;
 	int rc;
 
-	cdev = qed_alloc_cdev(pdev);
+	cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
 	if (!cdev)
-		goto err0;
+		return NULL;
+
+	qed_init_struct(cdev);
 
 	cdev->drv_type = DRV_ID_DRV_TYPE_LINUX;
 	cdev->protocol = params->protocol;
@@ -658,8 +642,7 @@ static struct qed_dev *qed_probe(struct pci_dev *pdev,
 err2:
 	qed_free_pci(cdev);
 err1:
-	qed_free_cdev(cdev);
-err0:
+	kfree(cdev);
 	return NULL;
 }
 
@@ -676,7 +659,7 @@ static void qed_remove(struct qed_dev *cdev)
 
 	qed_devlink_unregister(cdev);
 
-	qed_free_cdev(cdev);
+	kfree(cdev);
 }
 
 static void qed_disable_msix(struct qed_dev *cdev)



      reply	other threads:[~2020-08-18 19:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18  9:10 Xu Wang
2020-08-18 18:44 ` Jesse Brandeburg
2020-08-18 19:03   ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ac461ce3173457270815aba33b4be36dee760c54.camel@perches.com \
    --to=joe@perches.com \
    --cc=GR-everest-linux-l2@marvell.com \
    --cc=aelior@marvell.com \
    --cc=davem@davemloft.net \
    --cc=jesse.brandeburg@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vulab@iscas.ac.cn \
    --subject='Re: [PATCH] qed_main: Remove unnecessary cast in kfree' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).