#define SWCONFIG_DEVNAME "switch%d"
+#include "swconfig_leds.c"
+
MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
MODULE_LICENSE("GPL");
struct switch_dev *sdev;
const int max_switches = 8 * sizeof(unsigned long);
unsigned long in_use = 0;
+ int err;
int i;
INIT_LIST_HEAD(&dev->dev_list);
}
i = find_first_zero_bit(&in_use, max_switches);
- if (i == max_switches)
+ if (i == max_switches) {
+ swconfig_unlock();
return -ENFILE;
+ }
/* fill device name */
snprintf(dev->devname, IFNAMSIZ, SWCONFIG_DEVNAME, i);
list_add(&dev->dev_list, &swdevs);
swconfig_unlock();
+ err = swconfig_create_led_trigger(dev);
+ if (err)
+ return err;
+
return 0;
}
EXPORT_SYMBOL_GPL(register_switch);
void
unregister_switch(struct switch_dev *dev)
{
+ swconfig_destroy_led_trigger(dev);
kfree(dev->portbuf);
spin_lock(&dev->lock);
swconfig_lock();