summaryrefslogtreecommitdiff
path: root/io-module/mts_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io-module/mts_io.c')
-rw-r--r--io-module/mts_io.c138
1 files changed, 30 insertions, 108 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index fa61e1f..0710345 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -98,9 +98,6 @@ static DEFINE_MUTEX(mts_io_mutex);
#include "mtac_gpiob.c"
#include "mtac_mfser.c"
-/* telit radio reset handling */
-#include "telit_radio.c"
-
/* reset button handling */
#define RESET_CHECK_PER_SEC 8
#define RESET_INTERVAL (HZ / RESET_CHECK_PER_SEC)
@@ -250,62 +247,12 @@ static ssize_t mts_attr_store_radio_reset(struct device *dev,
return count;
}
-static ssize_t mts_attr_store_ndc_reset(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
-{
- int value;
- int err;
- struct gpio_pin *pin;
-
- if (sscanf(buf, "%i", &value) != 1) {
- return -EINVAL;
- }
- if (value != 0) {
- return -EINVAL;
- }
-
- pin = gpio_pin_by_name("NDC_RESET");
-
- if (!pin) {
- return -ENODEV;
- }
-
- mutex_lock(&mts_io_mutex);
-
- // 1ms low reset
- err = reset_gpio_pin(pin, 1, 0);
-
- mutex_unlock(&mts_io_mutex);
-
- if (err) {
- return err;
- }
-
- return count;
-}
-
static DEVICE_ATTR_MTS(dev_attr_radio_reset, "radio-reset",
mts_attr_show_gpio_pin, mts_attr_store_radio_reset);
-static DEVICE_ATTR_MTS(dev_attr_ndc_reset, "ndc-reset",
- mts_attr_show_gpio_pin, mts_attr_store_ndc_reset);
/* shared gpio attributes */
static DEVICE_ATTR_MTS(dev_attr_radio_power, "radio-power",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_eth0_enabled, "eth0-enabled",
- mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_bt_enabled, "bt-enabled",
- mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_wlan_enabled, "wlan-enabled",
- mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_RO_MTS(dev_attr_extserial_dtr, "extserial-dtr",
- mts_attr_show_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_extserial_dsr_gpio, "extserial-dsr",
- mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_extserial_ri_gpio, "extserial-ri",
- mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_extserial_dcd_gpio, "extserial-dcd",
- mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
/* shared gpio-based LEDs */
static DEVICE_ATTR_MTS(dev_attr_led_status, "led-status",
@@ -321,8 +268,6 @@ static DEVICE_ATTR_RO_MTS(dev_attr_led_ls, "led-ls",
mts_attr_show_gpio_pin);
#endif
-static DEVICE_ATTR_MTS(dev_attr_led_wifi_gpio, "led-wifi",
- mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
static DEVICE_ATTR_MTS(dev_attr_led_b_gpio, "led-b",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
@@ -342,9 +287,6 @@ static DEVICE_ATTR_MTS(dev_attr_led_d_gpio, "led-d",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
static DEVICE_ATTR_MTS(dev_attr_led_e_gpio, "led-e",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_led_f_gpio, "led-f",
- mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-
/* eeprom info */
static ssize_t mts_attr_show_product_info(struct device *dev,
@@ -515,29 +457,46 @@ static int mts_id_eeprom_load(void)
return 0;
}
+static void cleanup(void)
+{
+ int port;
+ int port_index;
+
+ log_info("cleaning up....");
+ sysfs_remove_link(&mts_io_platform_device->dev.parent->kobj, "mtcdp");
+ platform_device_unregister(mts_io_platform_device);
+ for (port_index = 0, port = 1; port_index < NUM_AP; port_index++, port++) {
+ if (port_info[port_index]) {
+ port_info[port_index]->teardown(port);
+ kfree(port_info[port_index]);
+ }
+ }
+ log_info("done cleaning up....");
+}
+
static int __init mts_io_init(void)
{
- struct gpio_pin *pin;
int ret;
- int port;
int port_index;
log_info("init: " DRIVER_VERSION);
ret = mts_id_eeprom_load();
if (ret) {
- goto error1;
+ cleanup();
+ return ret;
}
mts_io_platform_device = platform_device_alloc(PLATFORM_NAME, -1);
if (!mts_io_platform_device) {
- ret = -ENOMEM;
- goto error1;
+ cleanup();
+ return -ENOMEM;
}
ret = platform_device_add(mts_io_platform_device);
if (ret) {
- goto error2;
+ cleanup();
+ return ret;
}
/* preserve backwards compatibility with old mtcdp platform name */
@@ -546,71 +505,34 @@ static int __init mts_io_init(void)
"mtcdp");
if (ret) {
log_error("sysfs_create_link failed: %d", ret);
- goto error3;
+ cleanup();
+ return ret;
}
if (NUM_AP) {
- for (port = 0; port < NUM_AP; port++) {
- port_info[port] = NULL;
+ for (port_index = 0; port_index < NUM_AP; port_index++) {
+ port_info[port_index] = NULL;
}
init_accessory_ports();
}
ret = sysfs_create_group(&mts_io_platform_device->dev.kobj, attr_group);
if (ret) {
- goto error4;
- }
-
- for (pin = gpio_pins; *pin->name; pin++) {
- ret = gpio_request_one(pin->pin.gpio, pin->pin.flags, pin->pin.label);
- if (ret) {
- log_debug("could not request pin %s (%d) but it could have already been requested under a different pin name", pin->name, ret);
- }
+ cleanup();
+ return ret;
}
// start the reset handler
reset_callback(NULL);
return 0;
-
-error4:
- sysfs_remove_group(&mts_io_platform_device->dev.kobj, attr_group);
- sysfs_remove_link(&mts_io_platform_device->dev.parent->kobj, "mtcdp");
-error3:
- platform_device_del(mts_io_platform_device);
-error2:
- platform_device_put(mts_io_platform_device);
-error1:
- log_error("init failed: %d", ret);
- for (port = 0, port_index = 1; port < NUM_AP; port++, port_index++) {
- if (port_info[port]) {
- port_info[port]->teardown(port_index);
- kfree(port_info[port]);
- }
- }
-
- return ret;
}
static void __exit mts_io_exit(void)
{
- int port;
- int port_index;
-
cancel_delayed_work_sync(&reset_work);
- sysfs_remove_group(&mts_io_platform_device->dev.kobj, attr_group);
-
- sysfs_remove_link(&mts_io_platform_device->dev.parent->kobj, "mtcdp");
-
- platform_device_unregister(mts_io_platform_device);
-
- for (port = 0, port_index = 1; port < NUM_AP; port++, port_index++) {
- if (port_info[port]) {
- port_info[port]->teardown(port_index);
- kfree(port_info[port]);
- }
- }
+ cleanup();
log_info("exiting");
}