From: Paul B Schroeder The following patch simply moves the 'nr_registered_attrs' and 'device_registered' variables in mwavedd.c into the MWAVE_DEVICE_DATA struct which is defined in mwavedd.h.. drivers/char/mwave/mwavedd.c | 14 ++++++-------- drivers/char/mwave/mwavedd.h | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff -puN drivers/char/mwave/mwavedd.c~mwave-cleanup drivers/char/mwave/mwavedd.c --- 25/drivers/char/mwave/mwavedd.c~mwave-cleanup 2003-04-28 20:34:29.000000000 -0700 +++ 25-akpm/drivers/char/mwave/mwavedd.c 2003-04-28 20:34:29.000000000 -0700 @@ -502,8 +502,6 @@ static struct device_attribute * const m &dev_attr_uart_irq, &dev_attr_uart_io, }; -static int nr_registered_attrs; -static int device_registered; /* * mwave_init is called on module load @@ -518,13 +516,13 @@ static void mwave_exit(void) PRINTK_1(TRACE_MWAVE, "mwavedd::mwave_exit entry\n"); - for (i = 0; i < nr_registered_attrs; i++) + for (i = 0; i < pDrvData->nr_registered_attrs; i++) device_remove_file(&mwave_device, mwave_dev_attrs[i]); - nr_registered_attrs = 0; + pDrvData->nr_registered_attrs = 0; - if (device_registered) { + if (pDrvData->device_registered) { device_unregister(&mwave_device); - device_registered = 0; + pDrvData->device_registered = FALSE; } if ( pDrvData->sLine >= 0 ) { @@ -650,7 +648,7 @@ static int __init mwave_init(void) if (device_register(&mwave_device)) goto cleanup_error; - device_registered = 1; + pDrvData->device_registered = TRUE; for (i = 0; i < ARRAY_SIZE(mwave_dev_attrs); i++) { if(device_create_file(&mwave_device, mwave_dev_attrs[i])) { PRINTK_ERROR(KERN_ERR_MWAVE @@ -659,7 +657,7 @@ static int __init mwave_init(void) mwave_dev_attrs[i]->attr.name); goto cleanup_error; } - nr_registered_attrs++; + pDrvData->nr_registered_attrs++; } /* SUCCESS! */ diff -puN drivers/char/mwave/mwavedd.h~mwave-cleanup drivers/char/mwave/mwavedd.h --- 25/drivers/char/mwave/mwavedd.h~mwave-cleanup 2003-04-28 20:34:29.000000000 -0700 +++ 25-akpm/drivers/char/mwave/mwavedd.h 2003-04-28 20:34:29.000000000 -0700 @@ -140,6 +140,8 @@ typedef struct _MWAVE_DEVICE_DATA { MWAVE_IPC IPCs[16]; BOOLEAN bMwaveDevRegistered; short sLine; + int nr_registered_attrs; + int device_registered; } MWAVE_DEVICE_DATA, *pMWAVE_DEVICE_DATA; _