From 69645a71d82453a59b9fbfe4ccbf2ceaa2f0696f Mon Sep 17 00:00:00 2001 From: John Klug Date: Wed, 18 Jan 2023 13:20:21 -0600 Subject: Fix log noise comming from MTS-IO module --- io-module/mts-io.c | 87 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 31 deletions(-) (limited to 'io-module') diff --git a/io-module/mts-io.c b/io-module/mts-io.c index df52a12..0072d2e 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -122,18 +122,18 @@ static int mts_io_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mts_io_dd); if (!dev->parent) { - log_warning("Parent device is not found"); + dev_info(dev, "Parent device is not found"); } else if (dev->parent == &platform_bus) { - log_info("Parent device is platform_bus. No need to create symlink"); + dev_info(dev "Parent device is platform_bus. No need to create symlink"); goto exit; } - log_info("Creating symlink on platform_bus to %s", symlink_name); + dev_info(dev "Creating symlink on platform_bus to %s", symlink_name); res = sysfs_create_link(&platform_bus.kobj, &dev->kobj, symlink_name); if (!res) { mts_io_dd->f_platform_bus_symlink = true; } else { - log_warning("Failed to create symlink"); + dev_warn(dev "Failed to create symlink"); } exit: @@ -148,7 +148,7 @@ static int mts_io_remove(struct platform_device *pdev) struct mts_io_drvdata *mts_io_dd = platform_get_drvdata(pdev); const char *symlink_name = kobject_name(&pdev->dev.kobj); if (mts_io_dd && mts_io_dd->f_platform_bus_symlink) { - log_info("Removing %s symlink from platform_bus", symlink_name); + dev_info(&mts_io_platform_device->dev,"Removing %s symlink from platform_bus", symlink_name); //JAK sysfs_remove_link(&platform_bus.kobj, symlink_name); } #endif // PLATFORM_BUS_SYMLINK @@ -246,14 +246,14 @@ mts_has_radio(const char *product_id, size_t len) return 1; /* No Product ID? */ p = memchr(product_id,'-',len); if (p) { /* Found a hyphen */ - log_debug("Found hyphen"); + dev_dbg(&mts_io_platform_device->dev,"Found hyphen"); p++; if (p >= product_id+len) { - log_debug("End of string -- hyphen"); + dev_dbg(&mts_io_platform_device->dev,"End of string -- hyphen"); return 1; /* Last character was hyphen */ } if (isdigit(*p)) { - log_debug("Found digit after hypen"); + dev_dbg(&mts_io_platform_device->dev,"Found digit after hypen"); return 0; /* Modem name never starts with a digit */ } @@ -264,30 +264,30 @@ mts_has_radio(const char *product_id, size_t len) if (*p == 'I') found_i = 1; if ((*p != 'B') && (! found_i)) { - log_debug("Did not find B, I, or digit after hyphen in product-id"); + dev_dbg(&mts_io_platform_device->dev,"Did not find B, I, or digit after hyphen in product-id"); return 1; /* Modem starting with a letter, but not B or I */ } /* Found a B or an I */ p++; if (p >= product_id+len) { - log_debug("B or I at end of product-id string"); + dev_dbg(&mts_io_platform_device->dev,"B or I at end of product-id string"); return 1; /* Last character was B or I */ } /* No modem starts with IN */ if (found_i && (*p == 'N')) { - log_debug("IN found in 2nd product-id field -- India LoRa Channel plan"); + dev_dbg(&mts_io_platform_device->dev,"IN found in 2nd product-id field -- India LoRa Channel plan"); return 0; } if (isdigit(*p)) { - log_debug("B followed by digit after hyphen - no modem"); + dev_dbg(&mts_io_platform_device->dev,"B followed by digit after hyphen - no modem"); return 0; /* B[numeric] is MTR Build number */ } - log_debug("B followed by non-digit after hyphen - has modem"); + dev_dbg(&mts_io_platform_device->dev,"B followed by non-digit after hyphen - has modem"); return 1; /* B[non-numeric] so assume a modem that starts with B */ } /* End of found hyphen case */ - log_debug("Undefined product-id - has modem"); + dev_dbg(&mts_io_platform_device->dev,"Undefined product-id - has modem"); return 1; /* Product id invalid or empty, so instantiate a radio anyway */ } EXPORT_SYMBOL(mts_has_radio); @@ -855,7 +855,7 @@ mts_id_eeprom_load(void) noradio = 0; } - log_debug("mts_id_eeprom_load: noradio=%d",noradio); + dev_dbg(&mts_io_platform_device->dev,"mts_id_eeprom_load: noradio=%d",noradio); if (found_board(HW_VERSION_MTCAP_0_0,MTCAP_0_0,&hw_version_str,&mts_hw_version) || found_board(HW_VERSION_MTCAP_0_1,MTCAP_0_1,&hw_version_str,&mts_hw_version) || @@ -1410,7 +1410,7 @@ mts_id_eeprom_load(void) static void cleanup(void) { - log_info("cleaning up...."); + printk(KERN_INFO "mts-io: cleaning up...."); if (mts_io_platform_device != NULL && attr_group != NULL) { sysfs_remove_group(&mts_io_platform_device->dev.kobj, attr_group); @@ -1507,20 +1507,22 @@ static int __init mts_io_init(void) dev_dbg(&mts_io_platform_device->dev,"Request name:%s label: %s\n", pin->name, pin->pin.label); pin->desc = devm_gpiod_get_optional(&mts_io_platform_device->dev, pin->name, pin->pin.flags); if (IS_ERR(pin->desc)) { - log_warning( - "%s: Could not get gpio %s: Error: %ld\n", __func__, pin->name, PTR_ERR(pin->desc)); + dev_err(&mts_io_platform_device->dev, + "%s: Could not get gpio %s: Error: %ld\n", __func__, pin->name, PTR_ERR(pin->desc)); } else { - if (pin->desc == NULL) - dev_dbg(&mts_io_platform_device->dev,"gpio_desc is null for name: %s, label: %s\n", - pin->name, pin->pin.label); + if (pin->desc == NULL) + dev_dbg(&mts_io_platform_device->dev,"gpio_desc is null for name: %s, label: %s\n", + pin->name, pin->pin.label); else - dev_dbg(&mts_io_platform_device->dev,"Found gpio %s\n", pin->name); + dev_dbg(&mts_io_platform_device->dev,"Found gpio %s\n", pin->name); } } else { dev_dbg(&mts_io_platform_device->dev,"Request name:%s label: %s pin: %d\n", pin->name, pin->pin.label, pin->pin.gpio); ret = gpio_request_one(pin->pin.gpio, pin->pin.flags, pin->pin.label); if (ret) - log_warning("could not request pin %s (%d) but it could have already been requested under a different pin name\n", pin->name, ret); + dev_dbg(&mts_io_platform_device->dev, + "Could not request pin %s (%d) but it could have already been requested under a different pin name\n", + pin->name, ret); // Example: radio-reset, radio-power mapped to the same pin. } } } @@ -1547,8 +1549,12 @@ static int __init mts_io_init(void) return 0; } +#define GPIO_ATTR_MAX 256 static void __exit mts_io_exit(void) { + int old_pin[GPIO_ATTR_MAX]; + int old_last = 0; + int i,found; struct gpio_pin *pin; if (DEVICE_CAPA(id_eeprom.capa, CAPA_DOUT)) { spi_unregister_driver(&mts_spi_dout_driver); @@ -1565,13 +1571,32 @@ static void __exit mts_io_exit(void) for (pin = gpio_pins; *pin->name; pin++) { if (pin->capability == 0 || DEVICE_CAPA(id_eeprom.capa,pin->capability)) { - if (pin->do_gpio_desc) { - gpiod_put(pin->desc); - } else { - gpio_free(pin->pin.gpio); - } - } - } + if (pin->do_gpio_desc) { + dev_dbg(&mts_io_platform_device->dev,"Kernel removes when module is unloaded: GPIO descriptor case: pin->name=%s\n", + pin->name); + } else { + // TODO: Remove this code when the last pin is converted to the new GPIO model + dev_dbg(&mts_io_platform_device->dev,"Deprecated GPIO pin # case: pin->name=%s\n", + pin->name); + found = 0; + for(i=0; ipin.gpio == old_pin[i]) { + dev_dbg(&mts_io_platform_device->dev,"Deprecated GPIO pin #, skipping free of: pin->name=%s\n", + pin->name); + found = 1; + break; + } + } + if (!found) { + old_pin[old_last] = pin->pin.gpio; + gpio_free(pin->pin.gpio); + old_last++; + if(old_last > GPIO_ATTR_MAX) + panic("MTS-IO list of gpio pin numbers is full\n"); + } + } // else Old GPIO model + } // GPIO pin exists + } // End for gpio_pins cleanup_buttons(); @@ -1589,7 +1614,7 @@ static void __exit mts_io_exit(void) if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) && attr_group_lora) { mts_teardown_lora_port(); } - log_info("exiting"); + printk(KERN_INFO "mts-io exiting"); } module_init(mts_io_init); -- cgit v1.2.3