From fdda6e9262ba019da93832120a9999941e9b8f3b Mon Sep 17 00:00:00 2001 From: "Ing. Jan Kriz" Date: Mon, 18 Apr 2011 10:23:13 +0200 Subject: [PATCH 1/1] Cleaning up chip->chip_data on device unregister --- lincan/include/constants.h | 1 + lincan/include/main.h | 2 +- lincan/src/finish.c | 4 ++++ lincan/src/usbcan.c | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lincan/include/constants.h b/lincan/include/constants.h index 82383c2..1f0a45c 100644 --- a/lincan/include/constants.h +++ b/lincan/include/constants.h @@ -108,6 +108,7 @@ #define CHIP_IRQ_VME (1<<5) /* interrupt is VME bus and requires VME bridge */ #define CHIP_IRQ_CUSTOM (1<<6) /* custom interrupt provided by board or chip code */ #define CHIP_IRQ_FAST (1<<7) /* interrupt handler only schedules postponed processing */ +#define CHIP_KEEP_DATA (1<<8) /* let the hotplug device free its chip_data structure itself */ #define CHIP_MAX_IRQLOOP 1000 diff --git a/lincan/include/main.h b/lincan/include/main.h index c82935b..22fb92f 100644 --- a/lincan/include/main.h +++ b/lincan/include/main.h @@ -185,7 +185,7 @@ struct canchip_t { int chip_idx; /* chip index in candevice_t.chip[] */ int chip_irq; can_ioptr_t chip_base_addr; - unsigned int flags; + uint16_t flags; long clock; /* Chip clock in Hz */ long baudrate; diff --git a/lincan/src/finish.c b/lincan/src/finish.c index 2766c01..6a69222 100644 --- a/lincan/src/finish.c +++ b/lincan/src/finish.c @@ -118,6 +118,10 @@ void canchip_done(struct canchip_t *chip) } can_checked_free(chip->chipspecops); + + if(~chip->flags & CHIP_KEEP_DATA) + can_checked_free(chip->chip_data); + chip->chip_data = NULL; chip->chipspecops=NULL; } diff --git a/lincan/src/usbcan.c b/lincan/src/usbcan.c index 19b1dc6..3e1306a 100644 --- a/lincan/src/usbcan.c +++ b/lincan/src/usbcan.c @@ -1017,7 +1017,7 @@ int usbcan_init_chip_data(struct candevice_t *candev, int chipnr) usbcan_fill_chipspecops(chip); - candev->chip[chipnr]->flags|=CHIP_IRQ_CUSTOM; + candev->chip[chipnr]->flags|=CHIP_IRQ_CUSTOM|CHIP_KEEP_DATA; candev->chip[chipnr]->chip_base_addr=0; candev->chip[chipnr]->clock = 0; -- 2.39.2