mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: "Pedram M" <pmessri@gmail.com>
Cc: kernel-janitors@lists.osdl.org, linux-kernel@vger.kernel.org
Subject: Re: my first janitorial
Date: Sun, 1 Apr 2007 17:00:43 +0100	[thread overview]
Message-ID: <20070401170043.27a581cb@the-village.bc.nu> (raw)
In-Reply-To: <9c9aa5d00703312224t1948b24bhe34199f19cbda4fb@mail.gmail.com>

On Sat, 31 Mar 2007 22:24:12 -0700
"Pedram M" <pmessri@gmail.com> wrote:

> How about this one? Am I doing it right now?
> If not, please try to explain more to me what I am
> doing wrong.

You need to hold a reference to the PCI device for the entire duration it
is used. I think you actually also need something like this to get the whole
thing using pci references and pci_get_* properly

Alan

--- drivers/char/cyclades.c~	2007-04-01 15:52:16.000000000 +0100
+++ drivers/char/cyclades.c	2007-04-01 15:52:16.000000000 +0100
@@ -4803,7 +4782,7 @@
                 cy_card[j].bus_index = 1;
                 cy_card[j].first_line = cy_next_channel;
                 cy_card[j].num_chips = cy_pci_nchan/4;
-		cy_card[j].pdev = pdev;
+		cy_card[j].pdev = pci_dev_get(pdev);
 	
                 /* enable interrupts in the PCI interface */
 		plx_ver = cy_readb(cy_pci_addr2 + CyPLX_VER) & 0x0f;
@@ -4901,7 +4880,7 @@
 			Ze_addr0[ZeIndex] = cy_pci_addr0;
 			Ze_addr2[ZeIndex] = cy_pci_addr2;
 			Ze_irq[ZeIndex] = cy_pci_irq;
-			Ze_pdev[ZeIndex] = pdev;
+			Ze_pdev[ZeIndex] = pci_dev_get(pdev);
 			ZeIndex++;
 		    }
 		    i--;
@@ -4986,7 +4965,7 @@
                 cy_card[j].bus_index = 1;
                 cy_card[j].first_line = cy_next_channel;
                 cy_card[j].num_chips = -1;
-		cy_card[j].pdev = pdev;
+		cy_card[j].pdev = pci_dev_get(pdev);
 
                 /* print message */
 #ifdef CONFIG_CYZ_INTR
@@ -5007,6 +4986,10 @@
                 cy_next_channel += cy_pci_nchan;
 	    }
         }
+        
+        if (pdev)
+		pci_dev_put(pdev);
+        
 
         for (; ZeIndex != 0 && i < NR_CARDS; i++) {
 	    cy_pci_phys0 = Ze_phys0[0];
@@ -5485,11 +5468,12 @@
 	    )
 		free_irq(cy_card[i].irq, &cy_card[i]);
 #ifdef CONFIG_PCI
-		if (cy_card[i].pdev)
+		if (cy_card[i].pdev) {
 			pci_release_regions(cy_card[i].pdev);
+			pci_dev_put(pdev);
+		}
 #endif
         }
     }
 } /* cy_cleanup_module */
 
 module_init(cy_init);

  parent reply	other threads:[~2007-04-01 14:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <9c9aa5d00703310639q68fa5d19k4d8e3bfb56b1fa6@mail.gmail.com>
2007-04-01  5:24 ` Pedram M
2007-04-01  6:16   ` [KJ] " Jaco Kroon
2007-04-01  6:17   ` Willy Tarreau
2007-04-01 19:04     ` Jan Engelhardt
2007-04-01 16:00   ` Alan Cox [this message]
2007-04-01 18:28     ` Jiri Slaby

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=20070401170043.27a581cb@the-village.bc.nu \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=kernel-janitors@lists.osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmessri@gmail.com \
    /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
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

all inboxes | Powered by JetHome®