public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ip2: Remove #ifdef MODULE from ip2main.c
@ 2009-12-01  9:02 Rakib Mullick
  2009-12-01 15:00 ` Michael H. Warfield
  2009-12-04  4:14 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Rakib Mullick @ 2009-12-01  9:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: LKML, Michael H. Warfield

 ip2: Remove #ifdef MODULE completely.

>From kernel command line we can pass "module parameters".
So #ifdef MODULE is obsolute now. Remove it completely.
When CONFIG_PCI=n and building ip2main.c then we are hit
by the following warning. So move *pdev into #ifdef CONFIG_PCI.

drivers/char/ip2/ip2main.c: In function `ip2_loadmain':
drivers/char/ip2/ip2main.c:542: warning: unused variable `pdev'

Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
---

--- linus/drivers/char/ip2/ip2main.c	2009-12-01 12:41:53.000000000 +0600
+++ rakib/drivers/char/ip2/ip2main.c	2009-12-01 12:56:56.000000000 +0600
@@ -263,7 +263,7 @@ static int tracewrap;
 /* Macros */
 /**********/

-#if defined(MODULE) && defined(IP2DEBUG_OPEN)
+#ifdef IP2DEBUG_OPEN
 #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] ttyc=%d, modc=%x -> %s\n", \
 		    tty->name,(pCh->flags), \
 		    tty->count,/*GET_USE_COUNT(module)*/0,s)
@@ -487,7 +487,6 @@ static const struct firmware *ip2_reques
 	return fw;
 }

-#ifndef MODULE
 /******************************************************************************
  *	ip2_setup:
  *		str: kernel command line string
@@ -531,7 +530,6 @@ static int __init ip2_setup(char *str)
 	return 1;
 }
 __setup("ip2=", ip2_setup);
-#endif /* !MODULE */

 static int __init ip2_loadmain(void)
 {
@@ -539,7 +537,6 @@ static int __init ip2_loadmain(void)
 	int err = 0;
 	i2eBordStrPtr pB = NULL;
 	int rc = -1;
-	struct pci_dev *pdev = NULL;
 	const struct firmware *fw = NULL;

 	if (poll_only) {
@@ -612,6 +609,7 @@ static int __init ip2_loadmain(void)
 		case PCI:
 #ifdef CONFIG_PCI
 		{
+			struct pci_dev *pdev = NULL;
 			u32 addr;
 			int status;

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

* Re: [PATCH] ip2: Remove #ifdef MODULE from ip2main.c
  2009-12-01  9:02 [PATCH] ip2: Remove #ifdef MODULE from ip2main.c Rakib Mullick
@ 2009-12-01 15:00 ` Michael H. Warfield
  2009-12-04  4:14 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: Michael H. Warfield @ 2009-12-01 15:00 UTC (permalink / raw)
  To: Rakib Mullick; +Cc: mhw, Andrew Morton, LKML

[-- Attachment #1: Type: text/plain, Size: 2385 bytes --]

[Crud...  NOW I find out that I've been dumped from all the Vger mailing
lists...  Again...  Sigh...]

Looks good to me.

Regards,
Mike

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>

On Tue, 2009-12-01 at 15:02 +0600, Rakib Mullick wrote: 
> ip2: Remove #ifdef MODULE completely.
> 
> From kernel command line we can pass "module parameters".
> So #ifdef MODULE is obsolute now. Remove it completely.
> When CONFIG_PCI=n and building ip2main.c then we are hit
> by the following warning. So move *pdev into #ifdef CONFIG_PCI.
> 
> drivers/char/ip2/ip2main.c: In function `ip2_loadmain':
> drivers/char/ip2/ip2main.c:542: warning: unused variable `pdev'
> 
> Signed-off-by: Rakib Mullick <rakib.mullick@gmail.com>
> ---
> 
> --- linus/drivers/char/ip2/ip2main.c	2009-12-01 12:41:53.000000000 +0600
> +++ rakib/drivers/char/ip2/ip2main.c	2009-12-01 12:56:56.000000000 +0600
> @@ -263,7 +263,7 @@ static int tracewrap;
>  /* Macros */
>  /**********/
> 
> -#if defined(MODULE) && defined(IP2DEBUG_OPEN)
> +#ifdef IP2DEBUG_OPEN
>  #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] ttyc=%d, modc=%x -> %s\n", \
>  		    tty->name,(pCh->flags), \
>  		    tty->count,/*GET_USE_COUNT(module)*/0,s)
> @@ -487,7 +487,6 @@ static const struct firmware *ip2_reques
>  	return fw;
>  }
> 
> -#ifndef MODULE
>  /******************************************************************************
>   *	ip2_setup:
>   *		str: kernel command line string
> @@ -531,7 +530,6 @@ static int __init ip2_setup(char *str)
>  	return 1;
>  }
>  __setup("ip2=", ip2_setup);
> -#endif /* !MODULE */
> 
>  static int __init ip2_loadmain(void)
>  {
> @@ -539,7 +537,6 @@ static int __init ip2_loadmain(void)
>  	int err = 0;
>  	i2eBordStrPtr pB = NULL;
>  	int rc = -1;
> -	struct pci_dev *pdev = NULL;
>  	const struct firmware *fw = NULL;
> 
>  	if (poll_only) {
> @@ -612,6 +609,7 @@ static int __init ip2_loadmain(void)
>  		case PCI:
>  #ifdef CONFIG_PCI
>  		{
> +			struct pci_dev *pdev = NULL;
>  			u32 addr;
>  			int status;

-- 
Michael H. Warfield (AI4NB) | (770) 985-6132 |  mhw@WittsEnd.com
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 482 bytes --]

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

* Re: [PATCH] ip2: Remove #ifdef MODULE from ip2main.c
  2009-12-01  9:02 [PATCH] ip2: Remove #ifdef MODULE from ip2main.c Rakib Mullick
  2009-12-01 15:00 ` Michael H. Warfield
@ 2009-12-04  4:14 ` Andrew Morton
  2009-12-04  9:37   ` Rakib Mullick
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2009-12-04  4:14 UTC (permalink / raw)
  To: Rakib Mullick; +Cc: LKML, Michael H. Warfield

On Tue, 1 Dec 2009 15:02:56 +0600 Rakib Mullick <rakib.mullick@gmail.com> wrote:

> >From kernel command line we can pass "module parameters".
> So #ifdef MODULE is obsolute now. Remove it completely.
> When CONFIG_PCI=n and building ip2main.c then we are hit
> by the following warning. So move *pdev into #ifdef CONFIG_PCI.
> 
> drivers/char/ip2/ip2main.c: In function `ip2_loadmain':
> drivers/char/ip2/ip2main.c:542: warning: unused variable `pdev'

x86_64 allmodconfig:

drivers/char/ip2/ip2main.c: In function 'ip2_loadmain':
drivers/char/ip2/ip2main.c:657: error: 'pdev' undeclared (first use in this function)
drivers/char/ip2/ip2main.c:657: error: (Each undeclared identifier is reported only once
drivers/char/ip2/ip2main.c:657: error: for each function it appears in.)


I suppose this:

--- a/drivers/char/ip2/ip2main.c~ip2-remove-ifdef-module-from-ip2mainc-fix
+++ a/drivers/char/ip2/ip2main.c
@@ -636,6 +636,7 @@ static int __init ip2_loadmain(void)
 				dev_err(&pdev->dev, "I/O address error\n");
 
 			ip2config.irq[i] = pdev->irq;
+			pci_dev_put(pdev);
 		}
 #else
 			printk(KERN_ERR "IP2: PCI card specified but PCI "
@@ -654,7 +655,6 @@ static int __init ip2_loadmain(void)
 			break;
 		}	/* switch */
 	}	/* for */
-	pci_dev_put(pdev);
 
 	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
 		if (ip2config.addr[i]) {
_

but it needs checking - does pci_get_device() need a balancing pci_dev_put()?

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

* Re: [PATCH] ip2: Remove #ifdef MODULE from ip2main.c
  2009-12-04  4:14 ` Andrew Morton
@ 2009-12-04  9:37   ` Rakib Mullick
  0 siblings, 0 replies; 4+ messages in thread
From: Rakib Mullick @ 2009-12-04  9:37 UTC (permalink / raw)
  To: Andrew Morton; +Cc: LKML, Michael H. Warfield

On 12/4/09, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Tue, 1 Dec 2009 15:02:56 +0600 Rakib Mullick <rakib.mullick@gmail.com> wrote:
>
> x86_64 allmodconfig:
>
>  drivers/char/ip2/ip2main.c: In function 'ip2_loadmain':
>
> drivers/char/ip2/ip2main.c:657: error: 'pdev' undeclared (first use in this function)
>  drivers/char/ip2/ip2main.c:657: error: (Each undeclared identifier is reported only once
>  drivers/char/ip2/ip2main.c:657: error: for each function it appears in.)
>
Yes, I've also notice that pci_dev_put was outside of the #ifdef CONFIG_PCI
 context.  I was about to make patch for this.
>
>  I suppose this:
>
>  but it needs checking - does pci_get_device() need a balancing pci_dev_put()?

I thinks - yes. Otherwise we've to face ref counting problem.
And when pci_enable_device fails we need to make sure that we're
calling pci_dev_put.

So.. please checkout the following patch. Following patch has
been made without applying 'ip2-remove-ifdef-module-from-ip2mainc-fix' patch.
Please just check is it okay or not.

---
--- linus/drivers/char/ip2/ip2main.c	2009-12-01 12:41:53.000000000 +0600
+++ rakib/drivers/char/ip2/ip2main.c	2009-12-04 16:32:22.000000000 +0600
@@ -626,7 +626,7 @@ static int __init ip2_loadmain(void)

 			if (pci_enable_device(pdev)) {
 				dev_err(&pdev->dev, "can't enable device\n");
-				break;
+				goto out;
 			}
 			ip2config.type[i] = PCI;
 			ip2config.pci_dev[i] = pci_dev_get(pdev);
@@ -638,6 +638,8 @@ static int __init ip2_loadmain(void)
 				dev_err(&pdev->dev, "I/O address error\n");

 			ip2config.irq[i] = pdev->irq;
+out:
+			pci_dev_put(pdev);
 		}
 #else
 			printk(KERN_ERR "IP2: PCI card specified but PCI "
@@ -656,7 +658,6 @@ static int __init ip2_loadmain(void)
 			break;
 		}	/* switch */
 	}	/* for */
-	pci_dev_put(pdev);

 	for (i = 0; i < IP2_MAX_BOARDS; ++i) {
 		if (ip2config.addr[i]) {

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

end of thread, other threads:[~2009-12-04  9:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-01  9:02 [PATCH] ip2: Remove #ifdef MODULE from ip2main.c Rakib Mullick
2009-12-01 15:00 ` Michael H. Warfield
2009-12-04  4:14 ` Andrew Morton
2009-12-04  9:37   ` Rakib Mullick

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