2007-06-05 21:21:17

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 1/3] Char: stallion, don't fail with less than max panels

stallion, don't fail with less than max panels

Thanks to Ingo.

Signed-off-by: Jiri Slaby <[email protected]>
Cc: "Ingo Korb" <[email protected]>

---
commit aa7cfc04f92ec2b20a07b29a89527d836a93d00f
tree 064efb1346d6efffcd59cce827e15116c836da5b
parent db6329f0ce9fe4e7773edcabfb97f63e4f4a948f
author Jiri Slaby <[email protected]> Mon, 04 Jun 2007 00:05:16 +0200
committer Jiri Slaby <[email protected]> Tue, 05 Jun 2007 23:14:27 +0200

drivers/char/stallion.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index e45113a..265abad 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -2172,7 +2172,7 @@ static int __devinit stl_initech(struct stlbrd *brdp)
}
status = inb(ioaddr + ECH_PNLSTATUS);
if ((status & ECH_PNLIDMASK) != nxtid)
- goto err_fr;
+ break;
panelp = kzalloc(sizeof(struct stlpanel), GFP_KERNEL);
if (!panelp) {
printk("STALLION: failed to allocate memory "


2007-06-05 21:21:50

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 2/3] Char: stallion, alloc tty before pci devices init

stallion, alloc tty before pci devices init

this causes oops, because pci prboe function calls tty_register_device for
each device found. Thanks to Ingo.

Signed-off-by: Jiri Slaby <[email protected]>
Cc: "Ingo Korb" <[email protected]>

---
commit e7488128b7b4f61c82b6e323067d221c9397c43b
tree 70ea5eb90ca649e3bf6b04db30006afec873fb28
parent aa7cfc04f92ec2b20a07b29a89527d836a93d00f
author Jiri Slaby <[email protected]> Mon, 04 Jun 2007 10:39:41 +0200
committer Jiri Slaby <[email protected]> Tue, 05 Jun 2007 23:14:34 +0200

drivers/char/stallion.c | 73 ++++++++++++++++++++++-------------------------
1 files changed, 34 insertions(+), 39 deletions(-)

diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 265abad..23ea4c8 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -4710,6 +4710,29 @@ static int __init stallion_module_init(void)
spin_lock_init(&stallion_lock);
spin_lock_init(&brd_lock);

+ stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
+ if (!stl_serial) {
+ retval = -ENOMEM;
+ goto err;
+ }
+
+ stl_serial->owner = THIS_MODULE;
+ stl_serial->driver_name = stl_drvname;
+ stl_serial->name = "ttyE";
+ stl_serial->major = STL_SERIALMAJOR;
+ stl_serial->minor_start = 0;
+ stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
+ stl_serial->subtype = SERIAL_TYPE_NORMAL;
+ stl_serial->init_termios = stl_deftermios;
+ stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
+ tty_set_operations(stl_serial, &stl_ops);
+
+ retval = tty_register_driver(stl_serial);
+ if (retval) {
+ printk("STALLION: failed to register serial driver\n");
+ goto err_frtty;
+ }
+
/*
* Find any dynamically supported boards. That is via module load
* line options.
@@ -4739,13 +4762,9 @@ static int __init stallion_module_init(void)

/* this has to be _after_ isa finding because of locking */
retval = pci_register_driver(&stl_pcidriver);
- if (retval && stl_nrbrds == 0)
- goto err;
-
- stl_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
- if (!stl_serial) {
- retval = -ENOMEM;
- goto err_pcidr;
+ if (retval && stl_nrbrds == 0) {
+ printk(KERN_ERR "STALLION: can't register pci driver\n");
+ goto err_unrtty;
}

/*
@@ -4756,43 +4775,18 @@ static int __init stallion_module_init(void)
printk("STALLION: failed to register serial board device\n");

stallion_class = class_create(THIS_MODULE, "staliomem");
- if (IS_ERR(stallion_class)) {
- retval = PTR_ERR(stallion_class);
- goto err_reg;
- }
+ if (IS_ERR(stallion_class))
+ printk("STALLION: failed to create class\n");
for (i = 0; i < 4; i++)
class_device_create(stallion_class, NULL,
MKDEV(STL_SIOMEMMAJOR, i), NULL,
"staliomem%d", i);

- stl_serial->owner = THIS_MODULE;
- stl_serial->driver_name = stl_drvname;
- stl_serial->name = "ttyE";
- stl_serial->major = STL_SERIALMAJOR;
- stl_serial->minor_start = 0;
- stl_serial->type = TTY_DRIVER_TYPE_SERIAL;
- stl_serial->subtype = SERIAL_TYPE_NORMAL;
- stl_serial->init_termios = stl_deftermios;
- stl_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
- tty_set_operations(stl_serial, &stl_ops);
-
- retval = tty_register_driver(stl_serial);
- if (retval) {
- printk("STALLION: failed to register serial driver\n");
- goto err_clsdev;
- }
-
return 0;
-err_clsdev:
- for (i = 0; i < 4; i++)
- class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
- class_destroy(stallion_class);
-err_reg:
- unregister_chrdev(STL_SIOMEMMAJOR, "staliomem");
+err_unrtty:
+ tty_unregister_driver(stl_serial);
+err_frtty:
put_tty_driver(stl_serial);
-err_pcidr:
- pci_unregister_driver(&stl_pcidriver);
- stl_free_isabrds();
err:
return retval;
}
@@ -4821,8 +4815,6 @@ static void __exit stallion_module_exit(void)
tty_unregister_device(stl_serial,
brdp->brdnr * STL_MAXPORTS + j);
}
- tty_unregister_driver(stl_serial);
- put_tty_driver(stl_serial);

for (i = 0; i < 4; i++)
class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
@@ -4834,6 +4826,9 @@ static void __exit stallion_module_exit(void)
pci_unregister_driver(&stl_pcidriver);

stl_free_isabrds();
+
+ tty_unregister_driver(stl_serial);
+ put_tty_driver(stl_serial);
}

module_init(stallion_module_init);

2007-06-05 21:22:40

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 3/3] Char: stallion, proper fail return values

stallion, proper fail return values

do not return 0 in one case and return proper values in other 2.

Signed-off-by: Jiri Slaby <[email protected]>

---
commit d62c04c8fe3271ab2089f442e04ad522a158bf8f
tree 31beaaee84ef718acc5401b3cb07a7f2e340f0fe
parent e7488128b7b4f61c82b6e323067d221c9397c43b
author Jiri Slaby <[email protected]> Mon, 04 Jun 2007 00:07:20 +0200
committer Jiri Slaby <[email protected]> Tue, 05 Jun 2007 23:14:45 +0200

drivers/char/stallion.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 23ea4c8..45bf2a2 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -2177,6 +2177,7 @@ static int __devinit stl_initech(struct stlbrd *brdp)
if (!panelp) {
printk("STALLION: failed to allocate memory "
"(size=%Zd)\n", sizeof(struct stlpanel));
+ retval = -ENOMEM;
goto err_fr;
}
panelp->magic = STL_PANELMAGIC;
@@ -2223,8 +2224,10 @@ static int __devinit stl_initech(struct stlbrd *brdp)
brdp->nrports += panelp->nrports;
brdp->panels[panelnr++] = panelp;
if ((brdp->brdtype != BRD_ECHPCI) &&
- (ioaddr >= (brdp->ioaddr2 + brdp->iosize2)))
+ (ioaddr >= (brdp->ioaddr2 + brdp->iosize2))) {
+ retval = -EINVAL;
goto err_fr;
+ }
}

brdp->nrpanels = panelnr;
@@ -2371,6 +2374,7 @@ static int __devinit stl_pciprobe(struct pci_dev *pdev,
dev_err(&pdev->dev, "too many boards found, "
"maximum supported %d\n", STL_MAXBRDS);
mutex_unlock(&stl_brdslock);
+ retval = -ENODEV;
goto err_fr;
}
brdp->brdnr = (unsigned int)brdnr;

2007-06-05 21:27:49

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 4/3] Char: stallion, remove user class report request

Ok, one more.

--

stallion, remove user class report request

Signed-off-by: Jiri Slaby <[email protected]>

---
commit 400de8dd765298a11daec2a4a936a70798f428aa
tree 81675ba379783ad98f5c0387620a59b2ff2247a7
parent d62c04c8fe3271ab2089f442e04ad522a158bf8f
author Jiri Slaby <[email protected]> Tue, 05 Jun 2007 23:26:16 +0200
committer Jiri Slaby <[email protected]> Tue, 05 Jun 2007 23:26:16 +0200

drivers/char/stallion.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 45bf2a2..eeb6200 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -2357,9 +2357,6 @@ static int __devinit stl_pciprobe(struct pci_dev *pdev,
if ((pdev->class >> 8) == PCI_CLASS_STORAGE_IDE)
goto err;

- dev_info(&pdev->dev, "please, report this to LKML: %x/%x/%x\n",
- pdev->vendor, pdev->device, pdev->class);
-
retval = pci_enable_device(pdev);
if (retval)
goto err;

2007-06-06 00:18:16

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH 1/3] Char: stallion, don't fail with less than max panels

On Tue, 5 Jun 2007 23:20:57 +0200 (CEST)
Jiri Slaby <[email protected]> wrote:

> stallion, don't fail with less than max panels
>

Why not?

What problem is this patch fixing, and how does it fix it?

What are the consequences of not having this patch in the kernel?

etc. More complete changlogs, please.

>
> diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
> index e45113a..265abad 100644
> --- a/drivers/char/stallion.c
> +++ b/drivers/char/stallion.c
> @@ -2172,7 +2172,7 @@ static int __devinit stl_initech(struct stlbrd *brdp)
> }
> status = inb(ioaddr + ECH_PNLSTATUS);
> if ((status & ECH_PNLIDMASK) != nxtid)
> - goto err_fr;
> + break;
> panelp = kzalloc(sizeof(struct stlpanel), GFP_KERNEL);
> if (!panelp) {
> printk("STALLION: failed to allocate memory "

2007-06-06 07:00:18

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH 1/3] Char: stallion, don't fail with less than max panels

Andrew Morton napsal(a):
> On Tue, 5 Jun 2007 23:20:57 +0200 (CEST)
> Jiri Slaby <[email protected]> wrote:
>
>> stallion, don't fail with less than max panels
>>
>
> Why not?
>
> What problem is this patch fixing, and how does it fix it?
>
> What are the consequences of not having this patch in the kernel?
>
> etc. More complete changlogs, please.

Aah, sorry.

--
Since it's not neccesary to have MAX_PANELS on the card, don't fail to let users
use this card even in this case. Stop the testing for loop instead.
--

>
>> diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
>> index e45113a..265abad 100644
>> --- a/drivers/char/stallion.c
>> +++ b/drivers/char/stallion.c
>> @@ -2172,7 +2172,7 @@ static int __devinit stl_initech(struct stlbrd *brdp)
>> }
>> status = inb(ioaddr + ECH_PNLSTATUS);
>> if ((status & ECH_PNLIDMASK) != nxtid)
>> - goto err_fr;
>> + break;
>> panelp = kzalloc(sizeof(struct stlpanel), GFP_KERNEL);
>> if (!panelp) {
>> printk("STALLION: failed to allocate memory "
>

thanks,
--
http://www.fi.muni.cz/~xslaby/ Jiri Slaby
faculty of informatics, masaryk university, brno, cz
e-mail: jirislaby gmail com, gpg pubkey fingerprint:
B674 9967 0407 CE62 ACC8 22A0 32CC 55C3 39D4 7A7E