[parisc-linux-cvs] linux-2.4.18-pa43: (new) HIL drivers working as modules and built-into kernel
Helge Deller
deller@gmx.de
Thu, 27 Jun 2002 23:48:12 +0200
--Boundary-00=_cg4G9xstY1soQdr
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
On Thursday 27 June 2002 23:46, Helge Deller wrote:
> CVSROOT: /var/cvs
> Module name: linux
> Changes by: deller 02/06/27 15:46:55
>
> Modified files:
> . : Makefile
> include/linux : hil_mlc.h
> drivers/hil : hil_mlc.c hp_sdc.c hp_sdc_mlc.c
>
> Log message:
> linux-2.4.18-pa43:
> - hil_mlc now uses linux standard list.h for linked lists
> - this change also makes my HIL keyboard and HIL mouse detected and
> working in both (HIL-drivers built-into kernel or as modules) modes.
--Boundary-00=_cg4G9xstY1soQdr
Content-Type: text/plain;
charset="iso-8859-1";
name="diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="diff"
Index: Makefile
===================================================================
RCS file: /var/cvs/linux/Makefile,v
retrieving revision 1.313
diff -u -p -r1.313 Makefile
--- Makefile 2002/06/26 22:20:32 1.313
+++ Makefile 2002/06/27 21:42:55
@@ -1,7 +1,7 @@
VERSION = 2
PATCHLEVEL = 4
SUBLEVEL = 18
-EXTRAVERSION = -pa42
+EXTRAVERSION = -pa43
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
Index: include/linux/hil_mlc.h
===================================================================
RCS file: /var/cvs/linux/include/linux/hil_mlc.h,v
retrieving revision 1.1
diff -u -p -r1.1 hil_mlc.h
--- include/linux/hil_mlc.h 2002/05/03 18:56:47 1.1
+++ include/linux/hil_mlc.h 2002/06/27 21:42:56
@@ -36,6 +36,7 @@
#include <linux/interrupt.h>
#include <asm/semaphore.h>
#include <linux/serio.h>
+#include <linux/list.h>
typedef struct hil_mlc hil_mlc;
@@ -122,6 +123,7 @@ struct hil_mlc_serio_map {
#define HIL_MLC_DEVMEM 16
struct hil_mlc {
+ struct list_head list; /* hil_mlc is organized as linked list */
rwlock_t lock;
@@ -163,9 +165,6 @@ struct hil_mlc {
int opercnt;
struct tasklet_struct *tasklet;
-
- hil_mlc *next;
-
};
int hil_mlc_register(hil_mlc *mlc);
Index: drivers/hil/hil_mlc.c
===================================================================
RCS file: /var/cvs/linux/drivers/hil/hil_mlc.c,v
retrieving revision 1.2
diff -u -p -r1.2 hil_mlc.c
--- drivers/hil/hil_mlc.c 2002/06/27 18:46:00 1.2
+++ drivers/hil/hil_mlc.c 2002/06/27 21:42:57
@@ -60,6 +60,7 @@
#include <linux/interrupt.h>
#include <linux/timer.h>
#include <linux/sched.h>
+#include <linux/list.h>
MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>");
MODULE_DESCRIPTION("HIL MLC serio");
@@ -68,8 +69,8 @@ MODULE_LICENSE("Dual BSD/GPL");
EXPORT_SYMBOL(hil_mlc_register);
EXPORT_SYMBOL(hil_mlc_unregister);
-static hil_mlc *hil_mlcs;
-static rwlock_t hil_mlcs_lock;
+static LIST_HEAD(hil_mlcs);
+static rwlock_t hil_mlcs_lock = RW_LOCK_UNLOCKED;
static struct timer_list hil_mlcs_kicker;
static int hil_mlcs_probe;
@@ -260,10 +261,12 @@ static int hilse_inc_lcv(hil_mlc *mlc, i
return 0;
}
+#if 0
static int hilse_set_lcv(hil_mlc *mlc, int val) {
mlc->lcv = val;
return 0;
}
+#endif
/* Management of the discovered device index (zero based, -1 means no devs) */
static int hilse_set_ddi(hil_mlc *mlc, int val) {
@@ -694,11 +697,12 @@ static int hilse_donode (hil_mlc *mlc) {
/******************** tasklet context functions **************************/
static void hil_mlcs_process(unsigned long unused) {
- hil_mlc *mlc;
+ struct list_head *tmp;
read_lock(&hil_mlcs_lock);
- mlc = hil_mlcs;
- while (mlc != NULL) {
+ if (!list_empty(&hil_mlcs))
+ list_for_each(tmp, &hil_mlcs) {
+ struct hil_mlc *mlc = list_entry(tmp, hil_mlc, list);
while (hilse_donode(mlc) == 0) {
#ifdef HIL_MLC_DEBUG
if (mlc->seidx != 41 &&
@@ -707,7 +711,6 @@ static void hil_mlcs_process(unsigned lo
printk(" + ");
#endif
};
- mlc = mlc->next;
}
read_unlock(&hil_mlcs_lock);
}
@@ -841,7 +844,6 @@ static void hil_mlc_serio_close(struct s
}
int hil_mlc_register(hil_mlc *mlc) {
- hil_mlc *ptr;
int i;
unsigned long flags;
@@ -886,38 +888,37 @@ int hil_mlc_register(hil_mlc *mlc) {
mlc->tasklet = &hil_mlcs_tasklet;
write_lock_irqsave(&hil_mlcs_lock, flags);
- ptr = hil_mlcs;
- hil_mlcs = mlc;
- mlc->next = ptr;
+ INIT_LIST_HEAD(&mlc->list);
+ list_add_tail(&mlc->list, &hil_mlcs);
mlc->seidx = HILSEN_START;
write_unlock_irqrestore(&hil_mlcs_lock, flags);
+
printk("Registered MLC %p\n", mlc);
hil_tasklet_schedule(&hil_mlcs_tasklet);
return 0;
}
int hil_mlc_unregister(hil_mlc *mlc) {
- hil_mlc *ptr;
+ struct list_head *tmp;
unsigned long flags;
int i;
- if (mlc == NULL) return -EINVAL;
+ if (mlc == NULL)
+ return -EINVAL;
write_lock_irqsave(&hil_mlcs_lock, flags);
- if (hil_mlcs == NULL) goto fail;
+ list_for_each(tmp, &hil_mlcs) {
+ if (list_entry(tmp, hil_mlc, list) == mlc)
+ goto found;
+ }
- if (hil_mlcs == mlc) {
- hil_mlcs = mlc->next;
- goto done;
- }
- ptr = hil_mlcs;
- while (ptr->next != mlc) {
- if (ptr->next == NULL) goto fail;
- ptr = ptr->next;
- }
- ptr->next = mlc->next;
- done:
- mlc->next = NULL;
+ /* not found in list */
+ write_unlock_irqrestore(&hil_mlcs_lock, flags);
+ hil_tasklet_schedule(&hil_mlcs_tasklet);
+ return -ENODEV;
+
+ found:
+ list_del(tmp);
write_unlock_irqrestore(&hil_mlcs_lock, flags);
MOD_DEC_USE_COUNT;
@@ -927,10 +928,6 @@ int hil_mlc_unregister(hil_mlc *mlc) {
printk("Unregistered MLC %p\n", mlc);
hil_tasklet_schedule(&hil_mlcs_tasklet);
return 0;
- fail:
- write_unlock_irqrestore(&hil_mlcs_lock, flags);
- hil_tasklet_schedule(&hil_mlcs_tasklet);
- return -ENODEV;
}
/**************************** Module interface *************************/
@@ -938,8 +935,6 @@ int hil_mlc_unregister(hil_mlc *mlc) {
static int __init hil_mlc_init(void)
{
printk("HIL MLC support infrastructure loaded.\n");
- hil_mlcs = NULL;
- hil_mlcs_lock = RW_LOCK_UNLOCKED;
init_timer(&hil_mlcs_kicker);
hil_mlcs_kicker.expires = jiffies + HZ;
Index: drivers/hil/hp_sdc.c
===================================================================
RCS file: /var/cvs/linux/drivers/hil/hp_sdc.c,v
retrieving revision 1.1
diff -u -p -r1.1 hp_sdc.c
--- drivers/hil/hp_sdc.c 2002/06/25 19:53:07 1.1
+++ drivers/hil/hp_sdc.c 2002/06/27 21:42:59
@@ -764,7 +764,6 @@ static struct parisc_driver hp_sdc_drive
name: "HP SDC",
id_table: hp_sdc_tbl,
probe: hp_sdc_init,
- next: NULL,
};
static int __init hp_sdc_init(struct parisc_device *d)
Index: drivers/hil/hp_sdc_mlc.c
===================================================================
RCS file: /var/cvs/linux/drivers/hil/hp_sdc_mlc.c,v
retrieving revision 1.1
diff -u -p -r1.1 hp_sdc_mlc.c
--- drivers/hil/hp_sdc_mlc.c 2002/06/25 19:53:07 1.1
+++ drivers/hil/hp_sdc_mlc.c 2002/06/27 21:42:59
@@ -331,7 +331,6 @@ static int __init hp_sdc_mlc_init(void)
mlc->inc_use_count = &hp_sdc_mlc_inc_use_count;
mlc->dec_use_count = &hp_sdc_mlc_dec_use_count;
- mlc->next = NULL;
if (hil_mlc_register(mlc)) {
printk("Failed to register MLC structure with hil_mlc\n");
goto err0;
--Boundary-00=_cg4G9xstY1soQdr--