netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 2.6.10-rc1 0/5] dscc4: short summary for the serie of patches
@ 2005-01-14  0:07 Francois Romieu
  2005-01-14  0:09 ` [patch 2.6.10-rc1 1/5] dscc4: use of uncompletely initialized struct Francois Romieu
  0 siblings, 1 reply; 7+ messages in thread
From: Francois Romieu @ 2005-01-14  0:07 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev

The dscc4 driver has inherited a missing initialization bug since the
internals of the struct hdlc_dev was reworked (!). Now it kills the
driver at startup. The first patch of the incoming serie fixes it.

I would appreciate if it could be included in mainline for the next
release. The remaining patches are not critical.

Patches are archived as:
o patch-script
  http://www.fr.zoreil.com/linux/kernel/2.6.x/2.6.11-rc1/dscc4
o tar-ball
  http://www.fr.zoreil.com/linux/kernel/2.6.x/2.6.11-rc1/dscc4-blob.tar.bz2

--
Ueimor

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

* [patch 2.6.10-rc1 1/5] dscc4: use of uncompletely initialized struct
  2005-01-14  0:07 [patch 2.6.10-rc1 0/5] dscc4: short summary for the serie of patches Francois Romieu
@ 2005-01-14  0:09 ` Francois Romieu
  2005-01-14  0:10   ` [patch 2.6.10-rc1 2/5] dscc4: code factorisation Francois Romieu
  2005-01-27 20:59   ` [patch 2.6.10-rc1 1/5] dscc4: use of uncompletely initialized struct Jeff Garzik
  0 siblings, 2 replies; 7+ messages in thread
From: Francois Romieu @ 2005-01-14  0:09 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev

dscc4_set_quartz() is issued with an argument in an unitialized state and
the kernel does not like it.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>

diff -puN drivers/net/wan/dscc4.c~dscc4-000 drivers/net/wan/dscc4.c
--- linux-2.6.11-rc1/drivers/net/wan/dscc4.c~dscc4-000	2005-01-13 23:57:53.017533390 +0100
+++ linux-2.6.11-rc1-fr/drivers/net/wan/dscc4.c	2005-01-14 00:06:01.600966142 +0100
@@ -905,9 +905,7 @@ static int dscc4_found1(struct pci_dev *
 		goto err_free_dev2;
 	}
 	memset(ppriv, 0, sizeof(struct dscc4_pci_priv));
-	ret = dscc4_set_quartz(root, quartz);
-	if (ret < 0)
-		goto err_free_priv;
+
 	ppriv->root = root;
 	spin_lock_init(&ppriv->lock);
 
@@ -951,6 +949,11 @@ static int dscc4_found1(struct pci_dev *
 			goto err_unregister;
 	        }
 	}
+
+	ret = dscc4_set_quartz(root, quartz);
+	if (ret < 0)
+		goto err_unregister;
+
 	pci_set_drvdata(pdev, ppriv);
 	return ret;
 
@@ -959,7 +962,6 @@ err_unregister:
 		dscc4_release_ring(root + i);
 		unregister_hdlc_device(dscc4_to_dev(&root[i]));
 	}
-err_free_priv:
 	kfree(ppriv);
 err_free_dev2:
 	for (i = 0; i < dev_per_card; i++)

_

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

* [patch 2.6.10-rc1 2/5] dscc4: code factorisation
  2005-01-14  0:09 ` [patch 2.6.10-rc1 1/5] dscc4: use of uncompletely initialized struct Francois Romieu
@ 2005-01-14  0:10   ` Francois Romieu
  2005-01-14  0:12     ` [patch 2.6.10-rc1 3/5] dscc4: error status checking and pci janitoring Francois Romieu
  2005-01-27 20:59   ` [patch 2.6.10-rc1 1/5] dscc4: use of uncompletely initialized struct Jeff Garzik
  1 sibling, 1 reply; 7+ messages in thread
From: Francois Romieu @ 2005-01-14  0:10 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev

Small code factorization.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>

diff -puN drivers/net/wan/dscc4.c~dscc4-010 drivers/net/wan/dscc4.c
--- linux-2.6.11-rc1/drivers/net/wan/dscc4.c~dscc4-010	2005-01-14 00:54:44.287823008 +0100
+++ linux-2.6.11-rc1-fr/drivers/net/wan/dscc4.c	2005-01-14 00:54:44.291822356 +0100
@@ -892,17 +892,14 @@ static int dscc4_found1(struct pci_dev *
 
 	for (i = 0; i < dev_per_card; i++) {
 		root[i].dev = alloc_hdlcdev(root + i);
-		if (!root[i].dev) {
-			while (i--)
-				free_netdev(root[i].dev);
+		if (!root[i].dev)
 			goto err_free_dev;
-		}
 	}
 
 	ppriv = (struct dscc4_pci_priv *) kmalloc(sizeof(*ppriv), GFP_KERNEL);
 	if (!ppriv) {
 		printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME);
-		goto err_free_dev2;
+		goto err_free_dev;
 	}
 	memset(ppriv, 0, sizeof(struct dscc4_pci_priv));
 
@@ -958,15 +955,15 @@ static int dscc4_found1(struct pci_dev *
 	return ret;
 
 err_unregister:
-	while (--i >= 0) {
+	while (i-- > 0) {
 		dscc4_release_ring(root + i);
 		unregister_hdlc_device(dscc4_to_dev(&root[i]));
 	}
 	kfree(ppriv);
-err_free_dev2:
-	for (i = 0; i < dev_per_card; i++)
-		free_netdev(root[i].dev);
+	i = dev_per_card;
 err_free_dev:
+	while (i-- > 0)
+		free_netdev(root[i].dev);
 	kfree(root);
 err_out:
 	return ret;

_

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

* [patch 2.6.10-rc1 3/5] dscc4: error status checking and pci janitoring
  2005-01-14  0:10   ` [patch 2.6.10-rc1 2/5] dscc4: code factorisation Francois Romieu
@ 2005-01-14  0:12     ` Francois Romieu
  2005-01-14  0:13       ` [patch 2.6.10-rc1 4/5] dscc4: removal of unneeded casts Francois Romieu
  0 siblings, 1 reply; 7+ messages in thread
From: Francois Romieu @ 2005-01-14  0:12 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev

Error status checking and PCI janitoring
- propagation of the error code;
- pci_request_region use in dscc4_init_one;
- missing pci_disable_device() added to the error path;

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>

diff -puN drivers/net/wan/dscc4.c~dscc4-020 drivers/net/wan/dscc4.c
--- linux-2.6.11-rc1/drivers/net/wan/dscc4.c~dscc4-020	2005-01-14 00:54:49.243016015 +0100
+++ linux-2.6.11-rc1-fr/drivers/net/wan/dscc4.c	2005-01-14 00:54:49.248015200 +0100
@@ -708,31 +708,35 @@ static int __devinit dscc4_init_one(stru
 	struct dscc4_dev_priv *dpriv;
 	static int cards_found = 0;
 	void __iomem *ioaddr;
-	int i;
+	int i, rc;
 
 	printk(KERN_DEBUG "%s", version);
 
-	if (pci_enable_device(pdev))
-		goto err_out;
-	if (!request_mem_region(pci_resource_start(pdev, 0),
-	                	pci_resource_len(pdev, 0), "registers")) {
+	rc = pci_enable_device(pdev);
+	if (rc < 0)
+		goto out;
+
+	rc = pci_request_region(pdev, 0, "registers");
+	if (rc < 0) {
 	        printk(KERN_ERR "%s: can't reserve MMIO region (regs)\n",
 			DRV_NAME);
-	        goto err_out;
+	        goto err_disable_0;
 	}
-	if (!request_mem_region(pci_resource_start(pdev, 1),
-	                        pci_resource_len(pdev, 1), "LBI interface")) {
+	rc = pci_request_region(pdev, 1, "LBI interface");
+	if (rc < 0) {
 	        printk(KERN_ERR "%s: can't reserve MMIO region (lbi)\n",
 			DRV_NAME);
-	        goto err_out_free_mmio_region0;
+	        goto err_free_mmio_region_1;
 	}
+
 	ioaddr = ioremap(pci_resource_start(pdev, 0),
 					pci_resource_len(pdev, 0));
 	if (!ioaddr) {
 		printk(KERN_ERR "%s: cannot remap MMIO region %lx @ %lx\n",
 			DRV_NAME, pci_resource_len(pdev, 0),
 			pci_resource_start(pdev, 0));
-		goto err_out_free_mmio_region;
+		rc = -EIO;
+		goto err_free_mmio_regions_2;
 	}
 	printk(KERN_DEBUG "Siemens DSCC4, MMIO at %#lx (regs), %#lx (lbi), IRQ %d\n",
 	        pci_resource_start(pdev, 0),
@@ -742,14 +746,16 @@ static int __devinit dscc4_init_one(stru
 	pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xf8);
 	pci_set_master(pdev);
 
-	if (dscc4_found1(pdev, ioaddr))
-	        goto err_out_iounmap;
+	rc = dscc4_found1(pdev, ioaddr);
+	if (rc < 0)
+	        goto err_iounmap_3;
 
 	priv = (struct dscc4_pci_priv *)pci_get_drvdata(pdev);
 
-	if (request_irq(pdev->irq, &dscc4_irq, SA_SHIRQ, DRV_NAME, priv->root)){
+	rc = request_irq(pdev->irq, dscc4_irq, SA_SHIRQ, DRV_NAME, priv->root);
+	if (rc < 0) {
 		printk(KERN_WARNING "%s: IRQ %d busy\n", DRV_NAME, pdev->irq);
-		goto err_out_free1;
+		goto err_release_4;
 	}
 
 	/* power up/little endian/dma core controlled via lrda/ltda */
@@ -769,9 +775,11 @@ static int __devinit dscc4_init_one(stru
 	priv->iqcfg = (u32 *) pci_alloc_consistent(pdev,
 		IRQ_RING_SIZE*sizeof(u32), &priv->iqcfg_dma);
 	if (!priv->iqcfg)
-		goto err_out_free_irq;
+		goto err_free_irq_5;
 	writel(priv->iqcfg_dma, ioaddr + IQCFG);
 
+	rc = -ENOMEM;
+
 	/*
 	 * SCC 0-3 private rx/tx irq structures
 	 * IQRX/TXi needs to be set soon. Learned it the hard way...
@@ -781,7 +789,7 @@ static int __devinit dscc4_init_one(stru
 		dpriv->iqtx = (u32 *) pci_alloc_consistent(pdev,
 			IRQ_RING_SIZE*sizeof(u32), &dpriv->iqtx_dma);
 		if (!dpriv->iqtx)
-			goto err_out_free_iqtx;
+			goto err_free_iqtx_6;
 		writel(dpriv->iqtx_dma, ioaddr + IQTX0 + i*4);
 	}
 	for (i = 0; i < dev_per_card; i++) {
@@ -789,7 +797,7 @@ static int __devinit dscc4_init_one(stru
 		dpriv->iqrx = (u32 *) pci_alloc_consistent(pdev,
 			IRQ_RING_SIZE*sizeof(u32), &dpriv->iqrx_dma);
 		if (!dpriv->iqrx)
-			goto err_out_free_iqrx;
+			goto err_free_iqrx_7;
 		writel(dpriv->iqrx_dma, ioaddr + IQRX0 + i*4);
 	}
 
@@ -805,16 +813,19 @@ static int __devinit dscc4_init_one(stru
 	writel(0xff200001, ioaddr + GCMDR);
 
 	cards_found++;
-	return 0;
 
-err_out_free_iqrx:
+	rc = 0;
+out:
+	return rc;
+
+err_free_iqrx_7:
 	while (--i >= 0) {
 		dpriv = priv->root + i;
 		pci_free_consistent(pdev, IRQ_RING_SIZE*sizeof(u32),
 				    dpriv->iqrx, dpriv->iqrx_dma);
 	}
 	i = dev_per_card;
-err_out_free_iqtx:
+err_free_iqtx_6:
 	while (--i >= 0) {
 		dpriv = priv->root + i;
 		pci_free_consistent(pdev, IRQ_RING_SIZE*sizeof(u32),
@@ -822,20 +833,19 @@ err_out_free_iqtx:
 	}
 	pci_free_consistent(pdev, IRQ_RING_SIZE*sizeof(u32), priv->iqcfg,
 			    priv->iqcfg_dma);
-err_out_free_irq:
+err_free_irq_5:
 	free_irq(pdev->irq, priv->root);
-err_out_free1:
+err_release_4:
 	dscc4_free1(pdev);
-err_out_iounmap:
+err_iounmap_3:
 	iounmap (ioaddr);
-err_out_free_mmio_region:
-	release_mem_region(pci_resource_start(pdev, 1),
-			   pci_resource_len(pdev, 1));
-err_out_free_mmio_region0:
-	release_mem_region(pci_resource_start(pdev, 0),
-			   pci_resource_len(pdev, 0));
-err_out:
-	return -ENODEV;
+err_free_mmio_regions_2:
+	pci_release_region(pdev, 1);
+err_free_mmio_region_1:
+	pci_release_region(pdev, 0);
+err_disable_0:
+	pci_disable_device(pdev);
+	goto out;
 };
 
 /*
@@ -1997,10 +2007,10 @@ static void __devexit dscc4_remove_one(s
 
 	iounmap(ioaddr);
 
-	release_mem_region(pci_resource_start(pdev, 1),
-			   pci_resource_len(pdev, 1));
-	release_mem_region(pci_resource_start(pdev, 0),
-			   pci_resource_len(pdev, 0));
+	pci_release_region(pdev, 1);
+	pci_release_region(pdev, 0);
+
+	pci_disable_device(pdev);
 }
 
 static int dscc4_hdlc_attach(struct net_device *dev, unsigned short encoding,

_

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

* [patch 2.6.10-rc1 4/5] dscc4: removal of unneeded casts
  2005-01-14  0:12     ` [patch 2.6.10-rc1 3/5] dscc4: error status checking and pci janitoring Francois Romieu
@ 2005-01-14  0:13       ` Francois Romieu
  2005-01-14  0:15         ` [patch 2.6.10-rc1 5/5] dscc4: removal of unneeded variable Francois Romieu
  0 siblings, 1 reply; 7+ messages in thread
From: Francois Romieu @ 2005-01-14  0:13 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev

Removal of unneeded casts.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>

diff -puN drivers/net/wan/dscc4.c~dscc4-030 drivers/net/wan/dscc4.c
--- linux-2.6.11-rc1/drivers/net/wan/dscc4.c~dscc4-030	2005-01-14 00:54:54.446168638 +0100
+++ linux-2.6.11-rc1-fr/drivers/net/wan/dscc4.c	2005-01-14 00:54:54.449168149 +0100
@@ -750,7 +750,7 @@ static int __devinit dscc4_init_one(stru
 	if (rc < 0)
 	        goto err_iounmap_3;
 
-	priv = (struct dscc4_pci_priv *)pci_get_drvdata(pdev);
+	priv = pci_get_drvdata(pdev);
 
 	rc = request_irq(pdev->irq, dscc4_irq, SA_SHIRQ, DRV_NAME, priv->root);
 	if (rc < 0) {
@@ -892,8 +892,7 @@ static int dscc4_found1(struct pci_dev *
 	struct dscc4_dev_priv *root;
 	int i, ret = -ENOMEM;
 
-	root = (struct dscc4_dev_priv *)
-		kmalloc(dev_per_card*sizeof(*root), GFP_KERNEL);
+	root = kmalloc(dev_per_card*sizeof(*root), GFP_KERNEL);
 	if (!root) {
 		printk(KERN_ERR "%s: can't allocate data\n", DRV_NAME);
 		goto err_out;
@@ -906,7 +905,7 @@ static int dscc4_found1(struct pci_dev *
 			goto err_free_dev;
 	}
 
-	ppriv = (struct dscc4_pci_priv *) kmalloc(sizeof(*ppriv), GFP_KERNEL);
+	ppriv = kmalloc(sizeof(*ppriv), GFP_KERNEL);
 	if (!ppriv) {
 		printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME);
 		goto err_free_dev;

_

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

* [patch 2.6.10-rc1 5/5] dscc4: removal of unneeded variable
  2005-01-14  0:13       ` [patch 2.6.10-rc1 4/5] dscc4: removal of unneeded casts Francois Romieu
@ 2005-01-14  0:15         ` Francois Romieu
  0 siblings, 0 replies; 7+ messages in thread
From: Francois Romieu @ 2005-01-14  0:15 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev

Removal of unneeded variable and more spaces for my eyes.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>

diff -puN drivers/net/wan/dscc4.c~dscc4-040 drivers/net/wan/dscc4.c
--- linux-2.6.11-rc1/drivers/net/wan/dscc4.c~dscc4-040	2005-01-14 00:54:59.425357736 +0100
+++ linux-2.6.11-rc1-fr/drivers/net/wan/dscc4.c	2005-01-14 00:55:22.581586543 +0100
@@ -691,7 +691,7 @@ static void dscc4_free1(struct pci_dev *
 	root = ppriv->root;
 
 	for (i = 0; i < dev_per_card; i++)
-		unregister_hdlc_device(dscc4_to_dev(&root[i]));
+		unregister_hdlc_device(dscc4_to_dev(root + i));
 
 	pci_set_drvdata(pdev, NULL);
 
@@ -706,7 +706,6 @@ static int __devinit dscc4_init_one(stru
 {
 	struct dscc4_pci_priv *priv;
 	struct dscc4_dev_priv *dpriv;
-	static int cards_found = 0;
 	void __iomem *ioaddr;
 	int i, rc;
 
@@ -812,8 +811,6 @@ static int __devinit dscc4_init_one(stru
 
 	writel(0xff200001, ioaddr + GCMDR);
 
-	cards_found++;
-
 	rc = 0;
 out:
 	return rc;
@@ -966,7 +963,7 @@ static int dscc4_found1(struct pci_dev *
 err_unregister:
 	while (i-- > 0) {
 		dscc4_release_ring(root + i);
-		unregister_hdlc_device(dscc4_to_dev(&root[i]));
+		unregister_hdlc_device(dscc4_to_dev(root + i));
 	}
 	kfree(ppriv);
 	i = dev_per_card;

_

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

* Re: [patch 2.6.10-rc1 1/5] dscc4: use of uncompletely initialized struct
  2005-01-14  0:09 ` [patch 2.6.10-rc1 1/5] dscc4: use of uncompletely initialized struct Francois Romieu
  2005-01-14  0:10   ` [patch 2.6.10-rc1 2/5] dscc4: code factorisation Francois Romieu
@ 2005-01-27 20:59   ` Jeff Garzik
  1 sibling, 0 replies; 7+ messages in thread
From: Jeff Garzik @ 2005-01-27 20:59 UTC (permalink / raw)
  To: Francois Romieu; +Cc: netdev

applied all 5

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

end of thread, other threads:[~2005-01-27 20:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-14  0:07 [patch 2.6.10-rc1 0/5] dscc4: short summary for the serie of patches Francois Romieu
2005-01-14  0:09 ` [patch 2.6.10-rc1 1/5] dscc4: use of uncompletely initialized struct Francois Romieu
2005-01-14  0:10   ` [patch 2.6.10-rc1 2/5] dscc4: code factorisation Francois Romieu
2005-01-14  0:12     ` [patch 2.6.10-rc1 3/5] dscc4: error status checking and pci janitoring Francois Romieu
2005-01-14  0:13       ` [patch 2.6.10-rc1 4/5] dscc4: removal of unneeded casts Francois Romieu
2005-01-14  0:15         ` [patch 2.6.10-rc1 5/5] dscc4: removal of unneeded variable Francois Romieu
2005-01-27 20:59   ` [patch 2.6.10-rc1 1/5] dscc4: use of uncompletely initialized struct Jeff Garzik

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).