From: Casey Leedom <leedom@chelsio•com>
To: Jingoo Han <jg1.han@samsung•com>
Cc: "'David S. Miller'" <davem@davemloft•net>, netdev@vger•kernel.org
Subject: Re: [PATCH 14/52] net: cxgb4vf: remove unnecessary pci_set_drvdata()
Date: Thu, 12 Sep 2013 08:59:07 -0700 [thread overview]
Message-ID: <5231E4CB.2060901@chelsio.com> (raw)
In-Reply-To: <000001ceaf56$1cdf7d60$569e7820$%han@samsung.com>
Ah, okay. And I presume the same is true of the PCI Remove path. I
wasn't aware of this but if it's the Linux pattern to let the
surrounding support code do this work, then go for it.
As I said, I'm something of a Mad Housewife when it comes to cleaning
things up which were allocated/assigned in a particular routine.
Basically I program like I drive, practising defensive programming ... :-)
Casey
On 09/11/13 18:19, Jingoo Han wrote:
> On Thursday, September 12, 2013 2:24 AM, Casey Leedom wrote:
>> I agree that the redundant pci_set_drvdata(pdev, NULL) in
>> cxgb4vf_pci_probe() under the err_release_regions: label is unneeded,
>> but don't we need to NULL out the PCI Driver Data under the
>> err_free_adapter: label and also in cxgb4vf_pci_remove()? Or is that
>> handled automatically in the PCI infrastructure code which calls the
>> Device Probe and Remove routines? Mostly I was just being an
>> obsessively clean housewife assuming that we'd want to clean up these
>> references ...
>
> No, 'pci_set_drvdata(pdev, NULL) under err_free_adapter label' is not
> necessary.
>
> As you know, pci_set_drvdata(pdev, NULL) calls dev_set_drvdata() as below:
> pci_set_drvdata(pdev, NULL) is dev_set_drvdata(&pdev->dev, NULL).
>
> ./include/linux/pci.h
> 1504:static inline void pci_set_drvdata(struct pci_dev *pdev, void *data)
> 1505{
> 1506 dev_set_drvdata(&pdev->dev, data);
> 1507}
>
>
> However, when the driver goes to err_free_adapter label,
> The following sequence will be done.
> kfree(adapter) -> .... -> return -ENOMEM;
>
> In this case,
> when probe() returns error value such as '-ENOMEM',
> really_probe() of driver core automatically calls 'dev_set_drvdata(dev, NULL)'
> as below:
>
> ./drivers/base/dd.c
> 303-probe_failed:
> 304 devres_release_all(dev);
> 305 driver_sysfs_remove(dev);
> 306 dev->driver = NULL;
> 307 dev_set_drvdata(dev, NULL);
>
> Thus, without 'pci_set_drvdata(pdev, NULL) under err_free_adapter label',
> dev_set_drvdata(dev, NULL) can be called.
>
> I already tested this with other drivers such as e1000e LAN card driver.
>
> Best regards,
> Jingoo Han
>
>
next prev parent reply other threads:[~2013-09-12 15:59 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-11 7:19 [PATCH 00/52] net: ethernet: remove unnecessary pci_set_drvdata() Jingoo Han
2013-09-11 7:21 ` [PATCH 01/52] net: typhoon: " Jingoo Han
2013-09-11 22:18 ` David Dillow
2013-09-11 7:23 ` [PATCH 02/52] net: 8390: " Jingoo Han
2013-09-11 7:24 ` [PATCH 03/52] net: starfire: " Jingoo Han
2013-09-11 7:25 ` [PATCH 04/52] net: pcnet32: " Jingoo Han
2013-09-17 3:14 ` Don Fry
2013-09-11 7:26 ` [PATCH 05/52] net: amd8111e: " Jingoo Han
2013-09-11 7:27 ` [PATCH 06/52] net: alx: " Jingoo Han
2013-09-11 7:28 ` [PATCH 07/52] net: bnx2: " Jingoo Han
2013-09-11 7:29 ` [PATCH 08/52] net: bnx2x: " Jingoo Han
2013-09-11 7:30 ` [PATCH 09/52] net: tg3: " Jingoo Han
2013-09-11 7:31 ` [PATCH 10/52] net: bna: " Jingoo Han
2013-09-11 7:32 ` [PATCH 11/52] net: cxgb4: " Jingoo Han
2013-09-11 7:33 ` [PATCH 12/52] net: cxgb3: " Jingoo Han
2013-09-11 7:34 ` [PATCH 13/52] net: cxgb2: " Jingoo Han
2013-09-11 7:34 ` [PATCH 14/52] net: cxgb4vf: " Jingoo Han
2013-09-11 17:24 ` Casey Leedom
2013-09-12 1:19 ` Jingoo Han
2013-09-12 15:59 ` Casey Leedom [this message]
2013-09-11 7:36 ` [PATCH 15/52] net: enic: " Jingoo Han
2013-09-11 7:37 ` [PATCH 16/52] net: tulip: " Jingoo Han
2013-09-11 7:37 ` [PATCH 17/52] net: sundance: " Jingoo Han
2013-09-11 7:38 ` [PATCH 18/52] net: dl2k: " Jingoo Han
2013-09-11 7:39 ` [PATCH 19/52] net: be2net: " Jingoo Han
2013-09-11 7:40 ` [PATCH 20/52] net: fealnx: " Jingoo Han
2013-09-11 18:19 ` Sergei Shtylyov
2013-09-12 0:11 ` Jingoo Han
2013-09-12 5:24 ` David Miller
2013-09-12 5:49 ` Jingoo Han
2013-09-12 7:36 ` David Miller
2013-09-12 7:54 ` Jingoo Han
2013-09-12 8:19 ` David Miller
2013-09-12 8:40 ` Jingoo Han
2013-09-12 13:16 ` Ben Hutchings
2013-09-12 17:11 ` Sergei Shtylyov
2013-09-12 5:57 ` [PATCH V2 " Jingoo Han
2013-09-11 7:41 ` [PATCH 21/52] net: icplus: " Jingoo Han
2013-09-11 7:45 ` [PATCH 22/52] net: e100: " Jingoo Han
2013-09-11 8:39 ` Jeff Kirsher
2013-09-11 8:52 ` Jingoo Han
2013-09-11 7:46 ` [PATCH 23/52] net: jme: " Jingoo Han
2013-09-11 7:48 ` [PATCH 24/52] net: skge: " Jingoo Han
2013-09-11 7:49 ` [PATCH 25/52] net: sky2: " Jingoo Han
2013-09-11 7:49 ` [PATCH 26/52] net: ksz884x: " Jingoo Han
2013-09-11 7:50 ` [PATCH 27/52] net: myri10ge: " Jingoo Han
2013-09-11 7:51 ` [PATCH 28/52] net: natsemi: " Jingoo Han
2013-09-11 7:52 ` [PATCH 29/52] net: neterion: " Jingoo Han
2013-09-11 18:05 ` Jon Mason
2013-09-11 7:53 ` [PATCH 30/52] net: packetengines: " Jingoo Han
2013-09-11 7:53 ` [PATCH 31/52] net: pasemi: " Jingoo Han
2013-09-11 7:55 ` [PATCH 32/52] net: netxen: " Jingoo Han
2013-09-11 7:56 ` [PATCH 33/52] net: qlge: " Jingoo Han
2013-09-11 7:57 ` [PATCH 34/52] net: qlcnic: " Jingoo Han
2013-09-11 7:58 ` [PATCH 35/52] net: qla3xxx: " Jingoo Han
2013-09-11 7:59 ` [PATCH 36/52] net: r6040: " Jingoo Han
2013-09-11 7:59 ` [PATCH 37/52] net: 8139cp: " Jingoo Han
2013-09-11 8:00 ` [PATCH 38/52] net: 8139too: " Jingoo Han
2013-09-11 8:01 ` [PATCH 39/52] net: r8169: " Jingoo Han
2013-09-11 8:02 ` [PATCH 40/52] net: sis190: " Jingoo Han
2013-09-11 8:02 ` [PATCH 41/52] net: epic100: " Jingoo Han
2013-09-11 8:03 ` [PATCH 42/52] net: smsc9420: " Jingoo Han
2013-09-11 8:05 ` [PATCH 43/52] net: stmmac: " Jingoo Han
2013-09-11 8:06 ` [PATCH 44/52] net: sunhme: " Jingoo Han
2013-09-11 8:07 ` [PATCH 45/52] net: cassini: " Jingoo Han
2013-09-11 8:07 ` [PATCH 46/52] net: sungem: " Jingoo Han
2013-09-11 8:08 ` [PATCH 47/52] net: niu: " Jingoo Han
2013-09-11 8:08 ` [PATCH 48/52] net: tehuti: " Jingoo Han
2013-09-11 8:09 ` [PATCH 49/52] net: tlan: " Jingoo Han
2013-09-11 8:10 ` [PATCH 50/52] net: spider_net: " Jingoo Han
2013-09-11 8:10 ` [PATCH 51/52] net: tc35815: " Jingoo Han
2013-09-11 8:11 ` [PATCH 52/52] net: via-rhine: " Jingoo Han
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=5231E4CB.2060901@chelsio.com \
--to=leedom@chelsio$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=jg1.han@samsung$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox