From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Sat, 25 Jan 2003 20:02:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Sat, 25 Jan 2003 20:02:23 -0500 Received: from dhcp024-209-039-102.neo.rr.com ([24.209.39.102]:50048 "EHLO neo.rr.com") by vger.kernel.org with ESMTP id ; Sat, 25 Jan 2003 20:02:18 -0500 Date: Sat, 25 Jan 2003 20:15:24 +0000 From: Adam Belay To: greg@kroah.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH] Cadet PnP Update (3/6) Message-ID: <20030125201524.GA12806@neo.rr.com> Mail-Followup-To: Adam Belay , greg@kroah.com, linux-kernel@vger.kernel.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Converts the radio-cadet driver. Once again I don't have the hardware for this. -Adam --- a/drivers/media/radio/radio-cadet.c Tue Jan 14 05:58:38 2003 +++ b/drivers/media/radio/radio-cadet.c Fri Jan 17 15:30:12 2003 @@ -1,4 +1,4 @@ -/* radio-cadet.c - A video4linux driver for the ADS Cadet AM/FM Radio Card +/* radio-cadet.c - A video4linux driver for the ADS Cadet AM/FM Radio Card * * by Fred Gleason * Version 0.3.3 @@ -20,6 +20,9 @@ * Removed dead CONFIG_RADIO_CADET_PORT code * PnP detection on load is now default (no args necessary) * + * 2002-01-17 Adam Belay + * Updated to latest pnp code + * */ #include /* Modules */ @@ -30,7 +33,7 @@ #include /* copy to/from user */ #include /* kernel radio structs */ #include -#include +#include #define RDS_BUFFER 256 @@ -47,8 +50,6 @@ static int cadet_lock=0; static int cadet_probe(void); -static struct pnp_dev *dev = NULL; -static int isapnp_cadet_probe(void); /* * Signal Strength Threshold Values @@ -152,7 +153,7 @@ */ outb(curvol,io+1); cadet_lock--; - + return fifo; } @@ -541,22 +542,23 @@ .fops = &cadet_fops, }; -static int isapnp_cadet_probe(void) -{ - dev = pnp_find_dev (NULL, ISAPNP_VENDOR('M','S','M'), - ISAPNP_FUNCTION(0x0c24), NULL); +static struct pnp_device_id cadet_pnp_devices[] = { + /* ADS Cadet AM/FM Radio Card */ + {.id = "MSM0c24", .driver_data = 0}, + {.id = ""} +}; +MODULE_DEVICE_TABLE(pnp, id_table); + +static int cadet_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id) +{ if (!dev) return -ENODEV; - if (pnp_device_attach(dev) < 0) - return -EAGAIN; - if (pnp_activate_dev(dev, NULL) < 0) { - printk ("radio-cadet: pnp configure failed (out of resources?)\n"); - pnp_device_detach(dev); - return -EIO; - } + /* only support one device */ + if (io > 0) + return -EBUSY; + if (!pnp_port_valid(dev, 0)) { - pnp_device_detach(dev); return -ENODEV; } @@ -567,6 +569,13 @@ return io; } +static struct pnp_driver cadet_pnp_driver = { + .name = "radio-cadet", + .id_table = cadet_pnp_devices, + .probe = cadet_pnp_probe, + .remove = NULL, +}; + static int cadet_probe(void) { static int iovals[8]={0x330,0x332,0x334,0x336,0x338,0x33a,0x33c,0x33e}; @@ -597,7 +606,7 @@ * If a probe was requested then probe ISAPnP first (safest) */ if (io < 0) - io = isapnp_cadet_probe(); + pnp_register_driver(&cadet_pnp_driver); /* * If that fails then probe unsafely if probe is requested */ @@ -612,16 +621,19 @@ #ifdef MODULE printk(KERN_ERR "You must set an I/O address with io=0x???\n"); #endif - return -EINVAL; + goto fail; } if (!request_region(io,2,"cadet")) - return -EBUSY; + goto fail; if(video_register_device(&cadet_radio,VFL_TYPE_RADIO,radio_nr)==-1) { release_region(io,2); - return -EINVAL; + goto fail; } printk(KERN_INFO "ADS Cadet Radio Card at 0x%x\n",io); return 0; +fail: + pnp_unregister_driver(&cadet_pnp_driver); + return -1; } @@ -634,21 +646,11 @@ MODULE_PARM_DESC(io, "I/O address of Cadet card (0x330,0x332,0x334,0x336,0x338,0x33a,0x33c,0x33e)"); MODULE_PARM(radio_nr, "i"); -static struct isapnp_device_id id_table[] __devinitdata = { - { ISAPNP_ANY_ID, ISAPNP_ANY_ID, - ISAPNP_VENDOR('M','S','M'), ISAPNP_FUNCTION(0x0c24), 0 }, - {0} -}; - -MODULE_DEVICE_TABLE(isapnp, id_table); - static void __exit cadet_cleanup_module(void) { video_unregister_device(&cadet_radio); release_region(io,2); - - if (dev) - pnp_device_detach(dev); + pnp_unregister_driver(&cadet_pnp_driver); } module_init(cadet_init);