* [BK PATCH] PNP driver changes for 2.5.44
@ 2002-10-29 18:40 Greg KH
2002-10-29 18:43 ` [PATCH] " Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2002-10-29 18:40 UTC (permalink / raw)
To: torvalds; +Cc: linux-kernel, ambx1
Here's a set of updated PNP driver patches from Adam Belay.
Please pull from: bk://linuxusb.bkbits.net/pnp-2.5
thanks,
greg k-h
drivers/pnp/compat.c | 94 ----------------------------------------
drivers/pnp/Config.in | 16 +++---
drivers/pnp/Makefile | 4 -
drivers/pnp/base.h | 3 -
drivers/pnp/core.c | 5 --
drivers/pnp/driver.c | 19 ++++++--
drivers/pnp/isapnp/Makefile | 4 -
drivers/pnp/isapnp/compat.c | 94 ++++++++++++++++++++++++++++++++++++++++
drivers/pnp/names.c | 1
drivers/pnp/pnpbios/core.c | 101 ++++++++++++++++++++++++++++++--------------
drivers/pnp/quirks.c | 1
drivers/pnp/resource.c | 72 +++++++++++++++++++++++--------
include/linux/pnp.h | 62 ++++++++++++++++-----------
sound/oss/ad1848.c | 5 --
sound/oss/cs4232.c | 88 ++++++++++++++------------------------
15 files changed, 317 insertions(+), 252 deletions(-)
-----
ChangeSet@1.808.31.1, 2002-10-28 21:30:10-08:00, greg@kroah.com
merge
include/linux/pnp.h | 30 ++++++++++++++++++------------
1 files changed, 18 insertions(+), 12 deletions(-)
------
ChangeSet@1.808.4.5, 2002-10-24 00:27:01-07:00, ambx1@neo.rr.com
[PATCH] update PnP layer to driver model changes - 2.5.44 (4/4)
Updates to the driver model changes. This should fix a potential panic.
drivers/pnp/driver.c | 2 +-
1 files changed, 1 insertion(+), 1 deletion(-)
------
ChangeSet@1.808.4.4, 2002-10-24 00:26:22-07:00, ambx1@neo.rr.com
[PATCH] Convert CS4236B driver - 2.5.44 (3/4)
This patch converts the CS4236B sound card driver to the new PnP APIs. Also it
makes pnp_driver_register return the number of matches during the driver add.
This should serve as a sample driver, along with the serial and parport_pc.
drivers/pnp/driver.c | 12 ++++++
include/linux/pnp.h | 1
sound/oss/ad1848.c | 5 --
sound/oss/cs4232.c | 88 +++++++++++++++++++--------------------------------
4 files changed, 45 insertions(+), 61 deletions(-)
------
ChangeSet@1.808.4.3, 2002-10-24 00:25:49-07:00, ambx1@neo.rr.com
[PATCH] PnPBIOS changes - 2.5.44 (2/4)
This patch adds compatible PnP ID support to the PnPBIOS protocol. None of my
test systems take advantage of this feature but it is included in the
specifications so it makes sense to support it. If anyone does get a compatible
ID listed for the PnPBIOS I'd be interested to hear about it (if more than 1 id
is listed when viewing the driverfs file 'id' within the PnPBIOS protocol). Also
it fixes the dma and mem resource problem.
drivers/pnp/pnpbios/core.c | 101 +++++++++++++++++++++++++++++++--------------
1 files changed, 70 insertions(+), 31 deletions(-)
------
ChangeSet@1.808.4.2, 2002-10-24 00:25:27-07:00, ambx1@neo.rr.com
[PATCH] PnP cleanups and resource changes - 2.5.44 (1/4)
This patch fixes a number of things pointed out by Arne Thomassen. Also it
makes a few changes to the resource checking functions in that they now check to
make sure that resources do not conflict within the same device instead of only
other devices. Although it is rare for this to be a factor it's nice to be able
to deal with such situations properly.
drivers/pnp/core.c | 5 ---
drivers/pnp/driver.c | 3 -
drivers/pnp/isapnp/compat.c | 1
drivers/pnp/names.c | 1
drivers/pnp/quirks.c | 1
drivers/pnp/resource.c | 72 +++++++++++++++++++++++++++++++++-----------
6 files changed, 57 insertions(+), 26 deletions(-)
------
ChangeSet@1.808.4.1, 2002-10-21 11:39:24-07:00, ambx1@neo.rr.com
[PATCH] PnP Rewrite Fixes - 2.5.44
This patch addresses a few minor issues for the Linux Plug and Play Rewrite. It
is against 2.5.44.
They are as follows.
1.) fix Config.in file - from Adrian Bunk and Roman Zippel
2.) if unable to activate a device the match should fail. This can be done now
that the driver model matching bug has been corrected.
3.) move compat.c to isapnp directory and fix everything accordingly - suggested
by Stelian Pop. This fixes a compile error if ISAPNP is disabled.
4.) fix a typo in pnp.h - patch from Skip Ford
Please Apply,
Adam
drivers/pnp/compat.c | 94 --------------------------------------------
drivers/pnp/Config.in | 16 ++++---
drivers/pnp/Makefile | 4 -
drivers/pnp/base.h | 3 -
drivers/pnp/driver.c | 2
drivers/pnp/isapnp/Makefile | 4 -
drivers/pnp/isapnp/compat.c | 93 +++++++++++++++++++++++++++++++++++++++++++
include/linux/pnp.h | 31 ++++++++------
8 files changed, 126 insertions(+), 121 deletions(-)
------
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] PNP driver changes for 2.5.44
2002-10-29 18:40 [BK PATCH] PNP driver changes for 2.5.44 Greg KH
@ 2002-10-29 18:43 ` Greg KH
2002-10-29 18:44 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2002-10-29 18:43 UTC (permalink / raw)
To: linux-kernel
ChangeSet 1.808.4.1, 2002/10/21 11:39:24-07:00, ambx1@neo.rr.com
[PATCH] PnP Rewrite Fixes - 2.5.44
This patch addresses a few minor issues for the Linux Plug and Play Rewrite. It
is against 2.5.44.
They are as follows.
1.) fix Config.in file - from Adrian Bunk and Roman Zippel
2.) if unable to activate a device the match should fail. This can be done now
that the driver model matching bug has been corrected.
3.) move compat.c to isapnp directory and fix everything accordingly - suggested
by Stelian Pop. This fixes a compile error if ISAPNP is disabled.
4.) fix a typo in pnp.h - patch from Skip Ford
Please Apply,
Adam
diff -Nru a/drivers/pnp/Config.in b/drivers/pnp/Config.in
--- a/drivers/pnp/Config.in Tue Oct 29 10:39:05 2002
+++ b/drivers/pnp/Config.in Tue Oct 29 10:39:05 2002
@@ -4,15 +4,17 @@
mainmenu_option next_comment
comment 'Plug and Play configuration'
-dep_bool 'Plug and Play support' CONFIG_PNP
+bool 'Plug and Play support' CONFIG_PNP
- dep_bool ' Plug and Play device name database' CONFIG_PNP_NAMES $CONFIG_PNP
- dep_bool ' PnP Debug Messages' CONFIG_PNP_DEBUG $CONFIG_PNP
+if [ "$CONFIG_PNP" = "y" ]; then
+ bool ' Plug and Play device name database' CONFIG_PNP_NAMES
+ bool ' PnP Debug Messages' CONFIG_PNP_DEBUG
-comment 'Protocols' $CONFIG_PNP
+ comment 'Protocols'
-if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
- dep_bool ' ISA Plug and Play support (EXPERIMENTAL)' CONFIG_ISAPNP $CONFIG_PNP
- dep_bool ' Plug and Play BIOS support (EXPERIMENTAL)' CONFIG_PNPBIOS $CONFIG_PNP
+ if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
+ bool ' ISA Plug and Play support (EXPERIMENTAL)' CONFIG_ISAPNP
+ bool ' Plug and Play BIOS support (EXPERIMENTAL)' CONFIG_PNPBIOS
+ fi
fi
endmenu
diff -Nru a/drivers/pnp/Makefile b/drivers/pnp/Makefile
--- a/drivers/pnp/Makefile Tue Oct 29 10:39:05 2002
+++ b/drivers/pnp/Makefile Tue Oct 29 10:39:05 2002
@@ -2,11 +2,11 @@
# Makefile for the Linux Plug-and-Play Support.
#
-obj-y := core.o driver.o resource.o interface.o quirks.o names.o compat.o system.o
+obj-y := core.o driver.o resource.o interface.o quirks.o names.o system.o
obj-$(CONFIG_PNPBIOS) += pnpbios/
obj-$(CONFIG_ISAPNP) += isapnp/
-export-objs := core.o driver.o resource.o compat.o
+export-objs := core.o driver.o resource.o
include $(TOPDIR)/Rules.make
diff -Nru a/drivers/pnp/base.h b/drivers/pnp/base.h
--- a/drivers/pnp/base.h Tue Oct 29 10:39:05 2002
+++ b/drivers/pnp/base.h Tue Oct 29 10:39:05 2002
@@ -4,8 +4,5 @@
extern int pnp_interface_attach_device(struct pnp_dev *dev);
extern void pnp_name_device(struct pnp_dev *dev);
extern void pnp_fixup_device(struct pnp_dev *dev);
-extern int compare_pnp_id(struct list_head * id_list, char * id);
extern void pnp_free_ids(struct pnp_dev *dev);
extern void pnp_free_resources(struct pnp_resources *resources);
-
-
diff -Nru a/drivers/pnp/compat.c b/drivers/pnp/compat.c
--- a/drivers/pnp/compat.c Tue Oct 29 10:39:05 2002
+++ /dev/null Wed Dec 31 16:00:00 1969
@@ -1,94 +0,0 @@
-/*
- * compat.c - A series of functions to make it easier to convert drivers that use
- * the old isapnp APIs. If possible use the new APIs instead.
- *
- * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
- *
- */
-
-/* TODO: see if more isapnp functions are needed here */
-
-#include <linux/pnp.h>
-#include <linux/isapnp.h>
-#include <linux/string.h>
-#include <linux/module.h>
-#include "base.h"
-
-static void pnp_convert_id(char *buf, unsigned short vendor, unsigned short device)
-{
- sprintf(buf, "%c%c%c%x%x%x%x",
- 'A' + ((vendor >> 2) & 0x3f) - 1,
- 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
- 'A' + ((vendor >> 8) & 0x1f) - 1,
- (device >> 4) & 0x0f,
- device & 0x0f,
- (device >> 12) & 0x0f,
- (device >> 8) & 0x0f);
- return;
-}
-
-struct pnp_card *pnp_find_card(unsigned short vendor,
- unsigned short device,
- struct pnp_card *from)
-{
- char id[7];
- char any[7];
- struct list_head *list;
- pnp_convert_id(id, vendor, device);
- pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID);
- list = isapnp_cards.next;
- if (from)
- list = from->node.next;
-
- while (list != &isapnp_cards) {
- struct pnp_card *card = to_pnp_card(list);
- if (compare_pnp_id(&card->ids,id) || (memcmp(id,any,7)==0))
- return card;
- list = list->next;
- }
- return NULL;
-}
-
-struct pnp_dev *pnp_find_dev(struct pnp_card *card,
- unsigned short vendor,
- unsigned short function,
- struct pnp_dev *from)
-{
- char id[7];
- char any[7];
- pnp_convert_id(id, vendor, function);
- pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID);
- if (card == NULL) { /* look for a logical device from all cards */
- struct list_head *list;
-
- list = pnp_global.next;
- if (from)
- list = from->global_list.next;
-
- while (list != &pnp_global) {
- struct pnp_dev *dev = global_to_pnp_dev(list);
- if (compare_pnp_id(&dev->ids,id) || (memcmp(id,any,7)==0))
- return dev;
- list = list->next;
- }
- } else {
- struct list_head *list;
-
- list = card->devices.next;
- if (from) {
- list = from->card_list.next;
- if (from->card != card) /* something is wrong */
- return NULL;
- }
- while (list != &card->devices) {
- struct pnp_dev *dev = card_to_pnp_dev(list);
- if (compare_pnp_id(&dev->ids,id))
- return dev;
- list = list->next;
- }
- }
- return NULL;
-}
-
-EXPORT_SYMBOL(pnp_find_card);
-EXPORT_SYMBOL(pnp_find_dev);
diff -Nru a/drivers/pnp/driver.c b/drivers/pnp/driver.c
--- a/drivers/pnp/driver.c Tue Oct 29 10:39:05 2002
+++ b/drivers/pnp/driver.c Tue Oct 29 10:39:05 2002
@@ -93,7 +93,7 @@
if (pnp_dev->active == 0)
if(pnp_activate_dev(pnp_dev)<0)
- return 0;
+ return -1;
if (pnp_drv->probe && pnp_dev->active) {
if (pnp_dev->card && pnp_drv->card_id_table){
card_id = match_card(pnp_drv, pnp_dev->card);
diff -Nru a/drivers/pnp/isapnp/Makefile b/drivers/pnp/isapnp/Makefile
--- a/drivers/pnp/isapnp/Makefile Tue Oct 29 10:39:05 2002
+++ b/drivers/pnp/isapnp/Makefile Tue Oct 29 10:39:05 2002
@@ -2,10 +2,10 @@
# Makefile for the kernel ISAPNP driver.
#
-export-objs := core.o
+export-objs := core.o compat.o
isapnp-proc-$(CONFIG_PROC_FS) = proc.o
-obj-y := core.o $(isapnp-proc-y)
+obj-y := core.o compat.o $(isapnp-proc-y)
include $(TOPDIR)/Rules.make
diff -Nru a/drivers/pnp/isapnp/compat.c b/drivers/pnp/isapnp/compat.c
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/drivers/pnp/isapnp/compat.c Tue Oct 29 10:39:05 2002
@@ -0,0 +1,93 @@
+/*
+ * compat.c - A series of functions to make it easier to convert drivers that use
+ * the old isapnp APIs. If possible use the new APIs instead.
+ *
+ * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
+ *
+ */
+
+/* TODO: see if more isapnp functions are needed here */
+
+#include <linux/pnp.h>
+#include <linux/isapnp.h>
+#include <linux/string.h>
+#include <linux/module.h>
+
+static void pnp_convert_id(char *buf, unsigned short vendor, unsigned short device)
+{
+ sprintf(buf, "%c%c%c%x%x%x%x",
+ 'A' + ((vendor >> 2) & 0x3f) - 1,
+ 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
+ 'A' + ((vendor >> 8) & 0x1f) - 1,
+ (device >> 4) & 0x0f,
+ device & 0x0f,
+ (device >> 12) & 0x0f,
+ (device >> 8) & 0x0f);
+ return;
+}
+
+struct pnp_card *pnp_find_card(unsigned short vendor,
+ unsigned short device,
+ struct pnp_card *from)
+{
+ char id[7];
+ char any[7];
+ struct list_head *list;
+ pnp_convert_id(id, vendor, device);
+ pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID);
+ list = isapnp_cards.next;
+ if (from)
+ list = from->node.next;
+
+ while (list != &isapnp_cards) {
+ struct pnp_card *card = to_pnp_card(list);
+ if (compare_pnp_id(&card->ids,id) || (memcmp(id,any,7)==0))
+ return card;
+ list = list->next;
+ }
+ return NULL;
+}
+
+struct pnp_dev *pnp_find_dev(struct pnp_card *card,
+ unsigned short vendor,
+ unsigned short function,
+ struct pnp_dev *from)
+{
+ char id[7];
+ char any[7];
+ pnp_convert_id(id, vendor, function);
+ pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID);
+ if (card == NULL) { /* look for a logical device from all cards */
+ struct list_head *list;
+
+ list = pnp_global.next;
+ if (from)
+ list = from->global_list.next;
+
+ while (list != &pnp_global) {
+ struct pnp_dev *dev = global_to_pnp_dev(list);
+ if (compare_pnp_id(&dev->ids,id) || (memcmp(id,any,7)==0))
+ return dev;
+ list = list->next;
+ }
+ } else {
+ struct list_head *list;
+
+ list = card->devices.next;
+ if (from) {
+ list = from->card_list.next;
+ if (from->card != card) /* something is wrong */
+ return NULL;
+ }
+ while (list != &card->devices) {
+ struct pnp_dev *dev = card_to_pnp_dev(list);
+ if (compare_pnp_id(&dev->ids,id))
+ return dev;
+ list = list->next;
+ }
+ }
+ return NULL;
+}
+
+EXPORT_SYMBOL(pnp_find_card);
+EXPORT_SYMBOL(pnp_find_dev);
diff -Nru a/include/linux/pnp.h b/include/linux/pnp.h
--- a/include/linux/pnp.h Tue Oct 29 10:39:05 2002
+++ b/include/linux/pnp.h Tue Oct 29 10:39:05 2002
@@ -227,25 +227,16 @@
int pnp_raw_set_dev(struct pnp_dev *dev, int depnum, int mode);
/* driver */
+int compare_pnp_id(struct list_head * id_list, const char * id);
int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
int pnp_register_driver(struct pnp_driver *drv);
void pnp_unregister_driver(struct pnp_driver *drv);
-/* compat */
-struct pnp_card *pnp_find_card(unsigned short vendor,
- unsigned short device,
- struct pnp_card *from);
-struct pnp_dev *pnp_find_dev(struct pnp_card *card,
- unsigned short vendor,
- unsigned short function,
- struct pnp_dev *from);
-
-
#else
/* just in case anyone decides to call these without PnP Support Enabled */
static inline int pnp_protocol_register(struct pnp_protocol *protocol) { return -ENODEV; }
-static inline void pnp_protocol_unregister(struct pnp_protocol *protocol) { ; )
+static inline void pnp_protocol_unregister(struct pnp_protocol *protocol) { ; }
static inline int pnp_init_device(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; }
static inline void pnp_remove_device(struct pnp_dev *dev) { ; }
@@ -260,9 +251,25 @@
static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_raw_set_dev(struct pnp_dev *dev, int depnum, int mode) { return -ENODEV; }
+static inline int compare_pnp_id(struct list_head * id_list, char * id) { return -ENODEV; }
static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; }
static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
static inline void pnp_unregister_driver(struct pnp_driver *drv) { ; }
+
+#endif /* CONFIG_PNP */
+
+#if defined(CONFIG_ISAPNP)
+/* compat */
+struct pnp_card *pnp_find_card(unsigned short vendor,
+ unsigned short device,
+ struct pnp_card *from);
+struct pnp_dev *pnp_find_dev(struct pnp_card *card,
+ unsigned short vendor,
+ unsigned short function,
+ struct pnp_dev *from);
+
+#else
+
static inline struct pnp_card *pnp_find_card(unsigned short vendor,
unsigned short device,
struct pnp_card *from) { return NULL; }
@@ -271,7 +278,7 @@
unsigned short function,
struct pnp_dev *from) { return NULL; }
-#endif /* CONFIG_PNP */
+#endif /* CONFIG_ISAPNP */
#ifdef DEBUG
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PNP driver changes for 2.5.44
2002-10-29 18:43 ` [PATCH] " Greg KH
@ 2002-10-29 18:44 ` Greg KH
2002-10-29 18:44 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2002-10-29 18:44 UTC (permalink / raw)
To: linux-kernel
ChangeSet 1.808.4.2, 2002/10/24 00:25:27-07:00, ambx1@neo.rr.com
[PATCH] PnP cleanups and resource changes - 2.5.44 (1/4)
This patch fixes a number of things pointed out by Arne Thomassen. Also it
makes a few changes to the resource checking functions in that they now check to
make sure that resources do not conflict within the same device instead of only
other devices. Although it is rare for this to be a factor it's nice to be able
to deal with such situations properly.
diff -Nru a/drivers/pnp/core.c b/drivers/pnp/core.c
--- a/drivers/pnp/core.c Tue Oct 29 10:38:56 2002
+++ b/drivers/pnp/core.c Tue Oct 29 10:38:56 2002
@@ -82,7 +82,6 @@
list_del_init(&protocol->protocol_list);
spin_unlock(&pnp_lock);
device_unregister(&protocol->dev);
- return;
}
/**
@@ -105,7 +104,6 @@
pnp_free_resources(dev->res);
pnp_free_ids(dev);
kfree(dev);
- return;
}
/**
@@ -118,7 +116,7 @@
int pnp_add_device(struct pnp_dev *dev)
{
int error = 0;
- if (!dev && !dev->protocol)
+ if (!dev || !dev->protocol)
return -EINVAL;
if (dev->card)
sprintf(dev->dev.bus_id, "%02x:%02x.%02x", dev->protocol->number,
@@ -158,7 +156,6 @@
list_del_init(&dev->global_list);
list_del_init(&dev->dev_list);
spin_unlock(&pnp_lock);
- return;
}
static int __init pnp_init(void)
diff -Nru a/drivers/pnp/driver.c b/drivers/pnp/driver.c
--- a/drivers/pnp/driver.c Tue Oct 29 10:38:56 2002
+++ b/drivers/pnp/driver.c Tue Oct 29 10:38:56 2002
@@ -150,7 +150,7 @@
int pnp_register_driver(struct pnp_driver *drv)
{
- int count = 0;
+ int count;
pnp_dbg("the driver '%s' has been registered", drv->name);
drv->driver.name = drv->name;
@@ -194,7 +194,6 @@
struct pnp_id *pnp_id = to_pnp_id(pos);
kfree(pnp_id);
}
- return;
}
EXPORT_SYMBOL(pnp_register_driver);
diff -Nru a/drivers/pnp/isapnp/compat.c b/drivers/pnp/isapnp/compat.c
--- a/drivers/pnp/isapnp/compat.c Tue Oct 29 10:38:56 2002
+++ b/drivers/pnp/isapnp/compat.c Tue Oct 29 10:38:56 2002
@@ -23,7 +23,6 @@
device & 0x0f,
(device >> 12) & 0x0f,
(device >> 8) & 0x0f);
- return;
}
struct pnp_card *pnp_find_card(unsigned short vendor,
diff -Nru a/drivers/pnp/names.c b/drivers/pnp/names.c
--- a/drivers/pnp/names.c Tue Oct 29 10:38:56 2002
+++ b/drivers/pnp/names.c Tue Oct 29 10:38:56 2002
@@ -37,7 +37,6 @@
return;
}
}
- return;
}
#else
diff -Nru a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
--- a/drivers/pnp/quirks.c Tue Oct 29 10:38:56 2002
+++ b/drivers/pnp/quirks.c Tue Oct 29 10:38:56 2002
@@ -164,6 +164,5 @@
}
i++;
}
- return;
}
diff -Nru a/drivers/pnp/resource.c b/drivers/pnp/resource.c
--- a/drivers/pnp/resource.c Tue Oct 29 10:38:56 2002
+++ b/drivers/pnp/resource.c Tue Oct 29 10:38:56 2002
@@ -308,7 +308,7 @@
/* resource validity checking functions */
-static int pnp_check_port(int port, int size)
+static int pnp_check_port(int port, int size, int idx, struct pnp_cfg *config)
{
int i, tmp, rport, rsize;
struct pnp_dev *dev;
@@ -338,10 +338,20 @@
}
}
}
+ for (tmp = 0; tmp < 8 && tmp != idx; tmp++) {
+ if (dev->resource[tmp].flags) {
+ rport = config->request.resource[tmp].start;
+ rsize = (config->request.resource[tmp].end - rport) + 1;
+ if (port >= rport && port < rport + rsize)
+ return 1;
+ if (port + size > rport && port + size < (rport + rsize) - 1)
+ return 1;
+ }
+ }
return 0;
}
-static int pnp_check_mem(unsigned int addr, unsigned int size)
+static int pnp_check_mem(unsigned int addr, unsigned int size, int idx, struct pnp_cfg *config)
{
int i, tmp;
unsigned int raddr, rsize;
@@ -360,7 +370,7 @@
pnp_for_each_dev(dev) {
if (dev->active) {
for (tmp = 0; tmp < 4; tmp++) {
- if (dev->resource[tmp].flags) {
+ if (dev->resource[tmp + 8].flags) {
raddr = dev->resource[tmp + 8].start;
rsize = (dev->resource[tmp + 8].end - raddr) + 1;
if (addr >= raddr && addr < raddr + rsize)
@@ -371,6 +381,16 @@
}
}
}
+ for (tmp = 0; tmp < 4 && tmp != idx; tmp++) {
+ if (dev->resource[tmp + 8].flags) {
+ raddr = config->request.resource[tmp + 8].start;
+ rsize = (config->request.resource[tmp + 8].end - raddr) + 1;
+ if (addr >= raddr && addr < raddr + rsize)
+ return 1;
+ if (addr + size > raddr && addr + size < (raddr + rsize) - 1)
+ return 1;
+ }
+ }
return 0;
}
@@ -453,10 +473,11 @@
/* config generation functions */
static int pnp_generate_port(struct pnp_cfg *config, int num)
{
- struct pnp_port *port = config->port[num];
+ struct pnp_port *port;
unsigned long *value1, *value2, *value3;
if (!config || num < 0 || num > 7)
return -EINVAL;
+ port = config->port[num];
if (!port)
return 0;
value1 = &config->request.resource[num].start;
@@ -465,7 +486,7 @@
*value1 = port->min;
*value2 = *value1 + port->size -1;
*value3 = port->flags | IORESOURCE_IO;
- while (pnp_check_port(*value1, port->size)) {
+ while (pnp_check_port(*value1, port->size, num, config)) {
*value1 += port->align;
*value2 = *value1 + port->size - 1;
if (*value1 > port->max || !port->align)
@@ -476,10 +497,11 @@
static int pnp_generate_mem(struct pnp_cfg *config, int num)
{
- struct pnp_mem *mem = config->mem[num];
+ struct pnp_mem *mem;
unsigned long *value1, *value2, *value3;
if (!config || num < 0 || num > 3)
return -EINVAL;
+ mem = config->mem[num];
if (!mem)
return 0;
value1 = &config->request.resource[num + 8].start;
@@ -496,7 +518,7 @@
*value3 |= IORESOURCE_RANGELENGTH;
if (mem->flags & IORESOURCE_MEM_SHADOWABLE)
*value3 |= IORESOURCE_SHADOWABLE;
- while (pnp_check_mem(*value1, mem->size)) {
+ while (pnp_check_mem(*value1, mem->size, num, config)) {
*value1 += mem->align;
*value2 = *value1 + mem->size - 1;
if (*value1 > mem->max || !mem->align)
@@ -507,7 +529,7 @@
static int pnp_generate_irq(struct pnp_cfg *config, int num)
{
- struct pnp_irq *irq = config->irq[num];
+ struct pnp_irq *irq;
unsigned long *value1, *value2, *value3;
/* IRQ priority: this table is good for i386 */
static unsigned short xtab[16] = {
@@ -516,6 +538,7 @@
int i;
if (!config || num < 0 || num > 1)
return -EINVAL;
+ irq = config->irq[num];
if (!irq)
return 0;
value1 = &config->request.irq_resource[num].start;
@@ -536,16 +559,16 @@
static int pnp_generate_dma(struct pnp_cfg *config, int num)
{
- struct pnp_dma *dma = config->dma[num];
+ struct pnp_dma *dma;
unsigned long *value1, *value2, *value3;
/* DMA priority: this table is good for i386 */
static unsigned short xtab[16] = {
1, 3, 5, 6, 7, 0, 2, 4
};
int i;
-
if (!config || num < 0 || num > 1)
return -EINVAL;
+ dma = config->dma[num];
if (!dma)
return 0;
value1 = &config->request.dma_resource[num].start;
@@ -566,10 +589,11 @@
static int pnp_prepare_request(struct pnp_cfg *config)
{
- struct pnp_dev *dev = &config->request;
+ struct pnp_dev *dev;
int idx;
if (!config)
return -EINVAL;
+ dev = &config->request;
if (dev == NULL)
return -EINVAL;
if (dev->active || dev->ro)
@@ -629,21 +653,29 @@
static struct pnp_cfg * pnp_generate_config(struct pnp_dev *dev, int depnum)
{
- struct pnp_cfg * config = pnp_alloc(sizeof(struct pnp_cfg));
+ struct pnp_cfg * config;
int nport = 0, nirq = 0, ndma = 0, nmem = 0;
- struct pnp_resources * res = dev->res;
- struct pnp_port * port = res->port;
- struct pnp_mem * mem = res->mem;
- struct pnp_irq * irq = res->irq;
- struct pnp_dma * dma = res->dma;
+ struct pnp_resources * res;
+ struct pnp_port * port;
+ struct pnp_mem * mem;
+ struct pnp_irq * irq;
+ struct pnp_dma * dma;
if (!dev)
return NULL;
if (depnum < 0)
return NULL;
+ config = pnp_alloc(sizeof(struct pnp_cfg));
if (!config)
return NULL;
/* independent */
+ res = pnp_find_resources(dev, 0);
+ if (!res)
+ goto fail;
+ port = res->port;
+ mem = res->mem;
+ irq = res->irq;
+ dma = res->dma;
while (port){
config->port[nport] = port;
nport++;
@@ -669,6 +701,8 @@
if (depnum == 0)
return config;
res = pnp_find_resources(dev, depnum);
+ if (!res)
+ goto fail;
port = res->port;
mem = res->mem;
irq = res->irq;
@@ -695,6 +729,10 @@
dma = dma->next;
}
return config;
+
+ fail:
+ kfree(config);
+ return NULL;
}
/* PnP Device Resource Management */
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PNP driver changes for 2.5.44
2002-10-29 18:44 ` Greg KH
@ 2002-10-29 18:44 ` Greg KH
2002-10-29 18:45 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2002-10-29 18:44 UTC (permalink / raw)
To: linux-kernel
ChangeSet 1.808.4.3, 2002/10/24 00:25:49-07:00, ambx1@neo.rr.com
[PATCH] PnPBIOS changes - 2.5.44 (2/4)
This patch adds compatible PnP ID support to the PnPBIOS protocol. None of my
test systems take advantage of this feature but it is included in the
specifications so it makes sense to support it. If anyone does get a compatible
ID listed for the PnPBIOS I'd be interested to hear about it (if more than 1 id
is listed when viewing the driverfs file 'id' within the PnPBIOS protocol). Also
it fixes the dma and mem resource problem.
diff -Nru a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
--- a/drivers/pnp/pnpbios/core.c Tue Oct 29 10:38:46 2002
+++ b/drivers/pnp/pnpbios/core.c Tue Oct 29 10:38:46 2002
@@ -680,7 +680,7 @@
static void add_dmaresource(struct pnp_dev *dev, int dma)
{
- int i = 8;
+ int i = 0;
while (!(dev->dma_resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_DMA) i++;
if (i < DEVICE_COUNT_DMA) {
dev->dma_resource[i].start = (unsigned long) dma;
@@ -701,7 +701,7 @@
static void add_memresource(struct pnp_dev *dev, int mem, int len)
{
- int i = 0;
+ int i = 8;
while (!(dev->resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_RESOURCE) i++;
if (i < DEVICE_COUNT_RESOURCE) {
dev->resource[i].start = (unsigned long) mem;
@@ -816,6 +816,7 @@
} /* while */
end:
if ((dev->resource[0].start == 0) &&
+ (dev->resource[8].start == 0) &&
(dev->irq_resource[0].start == -1) &&
(dev->dma_resource[0].start == -1))
dev->active = 0;
@@ -927,7 +928,6 @@
static unsigned char *node_possible_resource_data_to_dev(unsigned char *p, struct pnp_bios_node *node, struct pnp_dev *dev)
{
- unsigned char *lastp = NULL;
int len, depnum, dependent;
if ((char *)p == NULL)
@@ -963,8 +963,7 @@
break;
}
} /* switch */
- lastp = p+3;
- p = p + p[1] + p[2]*256 + 3;
+ p += len + 3;
continue;
}
len = p[0] & 0x07;
@@ -1030,6 +1029,70 @@
return NULL;
}
+/* pnp EISA ids */
+
+#define HEX(id,a) hex[((id)>>a) & 15]
+#define CHAR(id,a) (0x40 + (((id)>>a) & 31))
+//
+
+static void inline pnpid32_to_pnpid(u32 id, char *str)
+{
+ const char *hex = "0123456789abcdef";
+
+ id = be32_to_cpu(id);
+ str[0] = CHAR(id, 26);
+ str[1] = CHAR(id, 21);
+ str[2] = CHAR(id,16);
+ str[3] = HEX(id, 12);
+ str[4] = HEX(id, 8);
+ str[5] = HEX(id, 4);
+ str[6] = HEX(id, 0);
+ str[7] = '\0';
+
+ return;
+}
+//
+#undef CHAR
+#undef HEX
+
+static void node_id_data_to_dev(unsigned char *p, struct pnp_bios_node *node, struct pnp_dev *dev)
+{
+ int len;
+ struct pnp_id *dev_id;
+
+ if ((char *)p == NULL)
+ return;
+ while ( (char *)p < ((char *)node->data + node->size )) {
+
+ if( p[0] & 0x80 ) {// large item
+ len = (p[2] << 8) | p[1];
+ p += len + 3;
+ continue;
+ }
+ len = p[0] & 0x07;
+ switch ((p[0]>>3) & 0x0f) {
+ case 0x0f:
+ {
+ return;
+ break;
+ }
+ case 0x03: // compatible ID
+ {
+ if (len != 4)
+ goto __skip;
+ dev_id = pnpbios_kmalloc(sizeof (struct pnp_id), GFP_KERNEL);
+ if (!dev_id)
+ return;
+ pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24,dev_id->id);
+ pnp_add_id(dev_id, dev);
+ break;
+ }
+ } /* switch */
+ __skip:
+ p += len + 1;
+
+ } /* while */
+}
/* pnp resource writing functions */
@@ -1314,31 +1377,6 @@
return 0;
}
-#define HEX(id,a) hex[((id)>>a) & 15]
-#define CHAR(id,a) (0x40 + (((id)>>a) & 31))
-//
-
-static void inline pnpid32_to_pnpid(u32 id, char *str)
-{
- const char *hex = "0123456789abcdef";
-
- id = be32_to_cpu(id);
- str[0] = CHAR(id, 26);
- str[1] = CHAR(id, 21);
- str[2] = CHAR(id,16);
- str[3] = HEX(id, 12);
- str[4] = HEX(id, 8);
- str[5] = HEX(id, 4);
- str[6] = HEX(id, 0);
- str[7] = '\0';
-
- return;
-}
-//
-#undef CHAR
-#undef HEX
-
-
static void __init build_devlist(void)
{
u8 nodenum;
@@ -1386,7 +1424,8 @@
memcpy(dev_id->id,id,8);
pnp_add_id(dev_id, dev);
pos = node_current_resource_data_to_dev(node,dev);
- node_possible_resource_data_to_dev(pos,node,dev);
+ pos = node_possible_resource_data_to_dev(pos,node,dev);
+ node_id_data_to_dev(pos,node,dev);
dev->protocol = &pnpbios_protocol;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PNP driver changes for 2.5.44
2002-10-29 18:44 ` Greg KH
@ 2002-10-29 18:45 ` Greg KH
2002-10-29 18:47 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2002-10-29 18:45 UTC (permalink / raw)
To: linux-kernel
ChangeSet 1.808.4.4, 2002/10/24 00:26:22-07:00, ambx1@neo.rr.com
[PATCH] Convert CS4236B driver - 2.5.44 (3/4)
This patch converts the CS4236B sound card driver to the new PnP APIs. Also it
makes pnp_driver_register return the number of matches during the driver add.
This should serve as a sample driver, along with the serial and parport_pc.
diff -Nru a/drivers/pnp/driver.c b/drivers/pnp/driver.c
--- a/drivers/pnp/driver.c Tue Oct 29 10:38:37 2002
+++ b/drivers/pnp/driver.c Tue Oct 29 10:38:37 2002
@@ -151,6 +151,8 @@
int pnp_register_driver(struct pnp_driver *drv)
{
int count;
+ struct list_head *pos;
+
pnp_dbg("the driver '%s' has been registered", drv->name);
drv->driver.name = drv->name;
@@ -159,7 +161,15 @@
drv->driver.remove = pnp_device_remove;
count = driver_register(&drv->driver);
- return count ? count : 1;
+
+ /* get the number of initial matches */
+ if (count >= 0){
+ count = 0;
+ list_for_each(pos,&drv->driver.devices){
+ count++;
+ }
+ }
+ return count;
}
void pnp_unregister_driver(struct pnp_driver *drv)
diff -Nru a/include/linux/pnp.h b/include/linux/pnp.h
--- a/include/linux/pnp.h Tue Oct 29 10:38:37 2002
+++ b/include/linux/pnp.h Tue Oct 29 10:38:37 2002
@@ -94,7 +94,6 @@
int (*probe) (struct pnp_dev *dev, const struct pnp_id *card_id,
const struct pnp_id *dev_id);
void (*remove) (struct pnp_dev *dev);
- struct device * (*legacy) (void);
struct device_driver driver;
};
diff -Nru a/sound/oss/ad1848.c b/sound/oss/ad1848.c
--- a/sound/oss/ad1848.c Tue Oct 29 10:38:37 2002
+++ b/sound/oss/ad1848.c Tue Oct 29 10:38:37 2002
@@ -3026,8 +3026,6 @@
{
char *busname = bus->name[0] ? bus->name : ad1848_isapnp_list[slot].name;
- printk(KERN_INFO "ad1848: %s detected\n", busname);
-
/* Initialize this baby. */
if(ad1848_init_generic(bus, hw_config, slot)) {
@@ -3039,9 +3037,6 @@
hw_config->dma2);
return 1;
}
- else
- printk(KERN_INFO "ad1848: Failed to initialize %s\n", busname);
-
return 0;
}
diff -Nru a/sound/oss/cs4232.c b/sound/oss/cs4232.c
--- a/sound/oss/cs4232.c Tue Oct 29 10:38:37 2002
+++ b/sound/oss/cs4232.c Tue Oct 29 10:38:37 2002
@@ -46,7 +46,7 @@
*/
#include <linux/config.h>
-#include <linux/isapnp.h>
+#include <linux/pnp.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -71,7 +71,7 @@
static int synth_base = 0, synth_irq = 0;
static int mpu_detected = 0;
-int __init probe_cs4232_mpu(struct address_info *hw_config)
+int probe_cs4232_mpu(struct address_info *hw_config)
{
/*
* Just write down the config values.
@@ -83,7 +83,7 @@
return 1;
}
-static unsigned char crystal_key[] __initdata = /* A 32 byte magic key sequence */
+static unsigned char crystal_key[] = /* A 32 byte magic key sequence */
{
0x96, 0x35, 0x9a, 0xcd, 0xe6, 0xf3, 0x79, 0xbc,
0x5e, 0xaf, 0x57, 0x2b, 0x15, 0x8a, 0xc5, 0xe2,
@@ -97,7 +97,7 @@
schedule_timeout(howlong);
}
-int __init probe_cs4232(struct address_info *hw_config, int isapnp_configured)
+int probe_cs4232(struct address_info *hw_config, int isapnp_configured)
{
int i, n;
int base = hw_config->io_base, irq = hw_config->irq;
@@ -218,7 +218,7 @@
return 0;
}
-void __init attach_cs4232(struct address_info *hw_config)
+void attach_cs4232(struct address_info *hw_config)
{
int base = hw_config->io_base,
irq = hw_config->irq,
@@ -277,7 +277,7 @@
}
}
-static void __exit unload_cs4232(struct address_info *hw_config)
+static void unload_cs4232(struct address_info *hw_config)
{
int base = hw_config->io_base, irq = hw_config->irq;
int dma1 = hw_config->dma, dma2 = hw_config->dma2;
@@ -357,48 +357,24 @@
/* All cs4232 based cards have the main ad1848 card either as CSC0000 or
* CSC0100. */
-struct isapnp_device_id isapnp_cs4232_list[] __initdata = {
- { ISAPNP_ANY_ID, ISAPNP_ANY_ID,
- ISAPNP_VENDOR('C','S','C'), ISAPNP_FUNCTION(0x0100),
- 0 },
- { ISAPNP_ANY_ID, ISAPNP_ANY_ID,
- ISAPNP_VENDOR('C','S','C'), ISAPNP_FUNCTION(0x0000),
- 0 },
+static const struct pnp_id cs4232_pnp_table[] = {
+ { .id = "CSC0100", .driver_data = 0 },
+ { .id = "CSC0000", .driver_data = 0 },
/* Guillemot Turtlebeach something appears to be cs4232 compatible
* (untested) */
- { ISAPNP_VENDOR('C','S','C'), ISAPNP_ANY_ID,
- ISAPNP_VENDOR('G','I','M'), ISAPNP_FUNCTION(0x0100),
- 0 },
- {0}
+ { .id = "GIM0100", .driver_data = 0 },
+ { .id = ""}
};
-MODULE_DEVICE_TABLE(isapnp, isapnp_cs4232_list);
+/*MODULE_DEVICE_TABLE(isapnp, isapnp_cs4232_list);*/
-int cs4232_isapnp_probe(struct pci_dev *dev, const struct isapnp_device_id *id)
+static int cs4232_pnp_probe(struct pnp_dev *dev, const struct pnp_id *card_id, const struct pnp_id *dev_id)
{
- int ret;
struct address_info *isapnpcfg;
isapnpcfg=(struct address_info*)kmalloc(sizeof(*isapnpcfg),GFP_KERNEL);
- if (!isapnpcfg)
+ if (!isapnpcfg)
return -ENOMEM;
- /*
- * If device is active, assume configured with /proc/isapnp
- * and use anyway. Any other way to check this?
- */
- ret = dev->prepare(dev);
- if(ret && ret != -EBUSY) {
- printk(KERN_ERR "cs4232: ISA PnP found device that could not be autoconfigured.\n");
- kfree(isapnpcfg);
- return -ENODEV;
- }
- if(ret != -EBUSY) {
- if(dev->activate(dev) < 0) {
- printk(KERN_WARNING "cs4232: ISA PnP activate failed\n");
- kfree(isapnpcfg);
- return -ENODEV;
- }
- } /* else subfunction is already activated */
isapnpcfg->irq = dev->irq_resource[0].start;
isapnpcfg->dma = dev->dma_resource[0].start;
@@ -409,10 +385,25 @@
return -ENODEV;
}
attach_cs4232(isapnpcfg);
- pci_set_drvdata(dev,isapnpcfg);
+ dev->driver_data = isapnpcfg;
return 0;
}
+static void cs4232_pnp_remove(struct pnp_dev *dev)
+{
+ struct address_info *cfg = (struct address_info*) dev->driver_data;
+ if (cfg)
+ unload_cs4232(cfg);
+}
+
+static struct pnp_driver cs4232_driver = {
+ .name = "cs4232",
+ .card_id_table = NULL,
+ .id_table = cs4232_pnp_table,
+ .probe = cs4232_pnp_probe,
+ .remove = cs4232_pnp_remove,
+};
+
static int __init init_cs4232(void)
{
#ifdef CONFIG_SOUND_WAVEFRONT_MODULE
@@ -420,7 +411,7 @@
printk(KERN_INFO "cs4232: set synthio and synthirq to use the wavefront facilities.\n");
else {
synth_base = synthio;
- synth_irq = synthirq;
+ synth_irq = synthirq;
}
#else
if(synthio != -1)
@@ -429,7 +420,7 @@
cfg.irq = -1;
if (isapnp &&
- (isapnp_probe_devs(isapnp_cs4232_list, cs4232_isapnp_probe) > 0)
+ (pnp_register_driver(&cs4232_driver) > 0)
)
return 0;
@@ -456,24 +447,13 @@
if (probe_cs4232(&cfg,FALSE) == 0)
return -ENODEV;
attach_cs4232(&cfg);
-
- return 0;
-}
-static int __exit cs4232_isapnp_remove(struct pci_dev *dev,
- const struct isapnp_device_id *id)
-{
- struct address_info *cfg = (struct address_info*)pci_get_drvdata(dev);
- if (cfg)
- unload_cs4232(cfg);
- pci_set_drvdata(dev,NULL);
- dev->deactivate(dev);
return 0;
}
static void __exit cleanup_cs4232(void)
{
- isapnp_probe_devs(isapnp_cs4232_list, cs4232_isapnp_remove);
+ pnp_unregister_driver(&cs4232_driver);
if (cfg.irq != -1)
unload_cs4232(&cfg); /* Unloads global MPU as well, if needed */
}
@@ -488,7 +468,7 @@
int ints[7];
/* If we have isapnp cards, no need for options */
- if (isapnp_probe_devs(isapnp_cs4232_list, cs4232_isapnp_probe) > 0)
+ if (pnp_register_driver(&cs4232_driver) > 0)
return 1;
str = get_options(str, ARRAY_SIZE(ints), ints);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PNP driver changes for 2.5.44
2002-10-29 18:45 ` Greg KH
@ 2002-10-29 18:47 ` Greg KH
0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2002-10-29 18:47 UTC (permalink / raw)
To: linux-kernel
ChangeSet 1.808.4.5, 2002/10/24 00:27:01-07:00, ambx1@neo.rr.com
[PATCH] update PnP layer to driver model changes - 2.5.44 (4/4)
Updates to the driver model changes. This should fix a potential panic.
diff -Nru a/drivers/pnp/driver.c b/drivers/pnp/driver.c
--- a/drivers/pnp/driver.c Tue Oct 29 10:38:28 2002
+++ b/drivers/pnp/driver.c Tue Oct 29 10:38:28 2002
@@ -175,7 +175,7 @@
void pnp_unregister_driver(struct pnp_driver *drv)
{
pnp_dbg("the driver '%s' has been unregistered", drv->name);
- remove_driver(&drv->driver);
+ driver_unregister(&drv->driver);
}
/**
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-10-29 18:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-29 18:40 [BK PATCH] PNP driver changes for 2.5.44 Greg KH
2002-10-29 18:43 ` [PATCH] " Greg KH
2002-10-29 18:44 ` Greg KH
2002-10-29 18:44 ` Greg KH
2002-10-29 18:45 ` Greg KH
2002-10-29 18:47 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox