summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2018-10-25 15:43:37 -0500
committerJohn Klug <john.klug@multitech.com>2018-10-25 15:43:37 -0500
commit3b9a137cd0a9b2b11924fdbdfec01121fe65fafd (patch)
treecf44dd047d266dd4df497bbf4a458bda8b41624d
parentd3ff82c06fe0fd40fcf0c72be4eae279a2580d9c (diff)
downloadmtac-lora-3b9a137cd0a9b2b11924fdbdfec01121fe65fafd.tar.gz
mtac-lora-3b9a137cd0a9b2b11924fdbdfec01121fe65fafd.tar.bz2
mtac-lora-3b9a137cd0a9b2b11924fdbdfec01121fe65fafd.zip
Use mtac_free function in lora_exit1.1.0
-rw-r--r--mtac_lora.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/mtac_lora.c b/mtac_lora.c
index 7283d7e..d14b192 100644
--- a/mtac_lora.c
+++ b/mtac_lora.c
@@ -1,7 +1,8 @@
-#define DRIVER_VERSION "v1.0.0"
+#define DRIVER_VERSION "v1.1.0"
#define DRIVER_AUTHOR "John Klug <john.klug@multitech.com>"
#define DRIVER_DESC "MTS Multi-Fuction Serial Accessory Card"
#define DRIVER_NAME "mtac-lora"
+#define DEBUG 0
#include <linux/types.h>
#include <linux/gpio.h>
@@ -307,7 +308,6 @@ static bool lora_setup(enum ap port) {
attr->show = lora_show_eui;
attrs[index++] = &attr->attr;
-
// add attributes for eeprom contents
ret = mtac_add_product_info_attributes(port, attrs, &index);
log_debug("Terminate addrs at index %d",index);
@@ -335,23 +335,26 @@ static bool lora_teardown(enum ap port) {
int i;
log_info("unloading LORA accessory card in port %d", port);
-
+
if(attrs) {
- // clean up allocated memory for attributes
- for(i=0;attrs[i];i++) {
- p = attrs[i];
- if (p->name)
- kfree(p->name);
- kfree(p);
- }
-
- log_info("kfree %p",attrs);
- kfree(attrs);
+ // clean up allocated memory for attributes
+ for(i=0;attrs[i];i++) {
+ p = attrs[i];
+ if (p->name) {
+ log_debug("Free name %s",p->name);
+ kfree(p->name);
+ }
+ log_debug("Free attribute %p",p);
+ kfree(p);
+ }
+ log_info("kfree %p",attrs);
+ kfree(attrs);
}
// clean up our "apX/" kobject if it exists
log_info("free up directories");
if (mtac_port_info[port_index]->subdirs) {
- kobject_put(mtac_port_info[port_index]->subdirs);
+ log_debug("Free subdirs %p",mtac_port_info[port_index]->subdirs);
+ kobject_put(mtac_port_info[port_index]->subdirs);
}
mtac_clear_port_pins(port_index);
@@ -391,18 +394,7 @@ static int __init mtac_lora_init(void)
/* We can only tear down our own device */
static void __exit mtac_lora_exit(void)
{
- int port_index;
- struct mts_ap_eeprom_layout *app;
-
- for (port_index = 0; port_index < NUM_AP; port_index++) {
- app = (struct mts_ap_eeprom_layout *)mts_ap_eeprom[port_index];
- if (app && strstr(app->product_id, PRODUCT_ID_MTAC_LORA)) {
- if (mtac_port_info[port_index]->setup == &lora_setup) {
- mtac_port_info[port_index]->teardown(port_index+1);
- kfree(mtac_port_info[port_index]);
- }
- }
- }
+ mtac_free(PRODUCT_ID_MTAC_LORA,lora_setup,"lora");
log_info("exiting");
}