On Wed, 01 Feb 2006 00:54:37 -0800
[EMAIL PROTECTED] wrote:
>
> From: "Jiri Slaby" <[EMAIL PROTECTED]>
>
> Pci probing functions added, some functions were rewritten. Use PCI_DEVICE
> macro.
>
> Signed-off-by: Jiri Slaby <[EMAIL PROTECTED]>
> Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
> ---
This code should also be fixed...
#if defined(CONFIG_PCI) && defined(MODULE)
/* This happy_pci_ids is declared __initdata because it is only used
as an advisory to depmod. If this is ported to the new PCI interface
where it could be referenced at any time due to hot plugging,
the __initdata reference should be removed. */
static struct pci_device_id happymeal_pci_ids[] = {
{
.vendor = PCI_VENDOR_ID_SUN,
.device = PCI_DEVICE_ID_SUN_HAPPYMEAL,
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
},
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(pci, happymeal_pci_ids);
#endif
Get rid of #if and use PCI_DEVICE() macro.
>
> drivers/net/sunhme.c | 79 ++++++++++++++++++++++++++++-------------
> 1 files changed, 55 insertions(+), 24 deletions(-)
>
> diff -puN drivers/net/sunhme.c~happtmeal-add-pci-probing drivers/net/sunhme.c
> --- devel/drivers/net/sunhme.c~happtmeal-add-pci-probing 2006-01-31
> 21:07:12.000000000 -0800
> +++ devel-akpm/drivers/net/sunhme.c 2006-01-31 21:07:12.000000000 -0800
> @@ -3013,7 +3013,7 @@ static void get_hme_mac_nonsparc(struct
> }
> #endif /* !(__sparc__) */
>
> -static int __init happy_meal_pci_init(struct pci_dev *pdev)
> +static int __devinit happy_meal_pci_init(struct pci_dev *pdev)
> {
> struct quattro *qp = NULL;
> #ifdef __sparc__
> @@ -3073,6 +3073,7 @@ static int __init happy_meal_pci_init(st
> memset(hp, 0, sizeof(*hp));
>
> hp->happy_dev = pdev;
> + pci_dev_get(pdev);
You shouldn't have to call pci_dev_get/put on network devices.
> spin_lock_init(&hp->happy_lock);
>
> @@ -3260,6 +3261,7 @@ err_out_free_res:
> pci_release_regions(pdev);
>
> err_out_clear_quattro:
> + pci_dev_put(pdev);
> if (qp != NULL)
> qp->happy_meals[qfe_slot] = NULL;
>
> @@ -3304,21 +3306,58 @@ static int __init happy_meal_sbus_probe(
> #endif
>
> #ifdef CONFIG_PCI
> -static int __init happy_meal_pci_probe(void)
> +static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
> + const struct pci_device_id *id)
> {
> - struct pci_dev *pdev = NULL;
> - int cards = 0;
> + int retval;
> +
> + retval = pci_enable_device(pdev);
> + if (retval < 0)
> + goto err;
> +
> + pci_set_master(pdev);
> + happy_meal_pci_init(pdev);
> +
> + return 0;
> +err:
> + return retval;
> +}
>
> - while ((pdev = pci_find_device(PCI_VENDOR_ID_SUN,
> - PCI_DEVICE_ID_SUN_HAPPYMEAL, pdev)) !=
> NULL) {
> - if (pci_enable_device(pdev))
> - continue;
> - pci_set_master(pdev);
> - cards++;
> - happy_meal_pci_init(pdev);
> +static void __devexit happy_meal_pci_remove(struct pci_dev *pdev)
> +{
> + struct quattro *tmp, *qp = qfe_pci_list;
> + struct pci_dev *bdev = pdev->bus->self;
> +
> + if (qp->quattro_dev == bdev) { /* is it the 1st one? */
> + qfe_pci_list = qp->next;
> + kfree(qp);
> + goto end;
> }
> - return cards;
> +
> + for (; qp->next != NULL; qp = qp->next) /* some further? */
> + if (qp->next->quattro_dev == bdev)
> + break;
> +
> + tmp = qp->next; /* kill it, but preserve list */
> + qp->next = qp->next->next;
> + kfree(tmp);
> +end:
> + pci_dev_put(pdev);
> }
Rather than a list, wouldn't ref counting the quattro structure be
safer.
Also this driver needs should use netdev_priv().
--
Stephen Hemminger <[EMAIL PROTECTED]>
OSDL http://developer.osdl.org/~shemminger
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html