PX4FMU::~PX4FMU() { if (_task != -1) { /* tell the task we want it to go away */ _task_should_exit = true; unsigned i = 10; do { /* wait 50ms - it should wake every 100ms or so worst-case */ usleep(50000); /* if we have given up, kill it */ if (--i == 0) { task_delete(_task); break; } } while (_task != -1); } /* clean up the alternate device node */ if (_primary_pwm_device) unregister_driver(PWM_OUTPUT_DEVICE_PATH); g_fmu = nullptr; }
void watchdog_unregister(FAR void *handle) { FAR struct watchdog_upperhalf_s *upper; FAR struct watchdog_lowerhalf_s *lower; /* Recover the pointer to the upper-half driver state */ upper = (FAR struct watchdog_upperhalf_s *)handle; lower = upper->lower; DEBUGASSERT(upper && lower); wdvdbg("Unregistering: %s\n", upper->path); /* Disable the watchdog timer */ DEBUGASSERT(lower->ops->stop); /* Required */ (void)lower->ops->stop(lower); /* Unregister the watchdog timer device */ (void)unregister_driver(upper->path); /* Then free all of the driver resources */ kfree(upper->path); sem_destroy(&upper->exclsem); kfree(upper); }
/** * @brief Unregister a RTDM device * * Removes the device from the RTDM namespace. This routine waits until * all connections to @a device have been closed prior to unregistering. * * @param[in] dev Device descriptor. * * @coretags{secondary-only} */ void rtdm_dev_unregister(struct rtdm_device *dev) { struct rtdm_driver *drv = dev->driver; secondary_mode_only(); trace_cobalt_device_unregister(dev); /* Lock out any further connection. */ dev->magic = ~RTDM_DEVICE_MAGIC; /* Then wait for the ongoing connections to finish. */ wait_event(dev->putwq, atomic_read(&dev->refcount) == 0); mutex_lock(®ister_lock); if (drv->device_flags & RTDM_NAMED_DEVICE) xnregistry_remove(dev->named.handle); else xnid_remove(&protocol_devices, &dev->proto.id); device_destroy(rtdm_class, dev->rdev); unregister_driver(drv); mutex_unlock(®ister_lock); kfree(dev->name); }
int up_wdtinit(void) { int ret; dbg("C547x Watchdog Driver\n"); /* Register as /dev/wdt */ ret = register_driver("/dev/wdt", &g_wdtops, 0666, NULL); if (ret) { return ERROR; } /* Register for an interrupt level callback through wdt_interrupt */ dbg("Attach to IRQ=%d\n", C5471_IRQ_WATCHDOG); /* Make sure that the timer is stopped */ c5471_wdt_cntl = C5471_TIMER_STOP; /* Request the interrupt. */ ret = irq_attach(C5471_IRQ_WATCHDOG, wdt_interrupt); if (ret) { unregister_driver("/dev/wdt"); return ERROR; } return OK; }
static int module_uninitialize(FAR void *arg) { /* TODO: Check if there are any open references to the driver */ syslog(LOG_INFO, "module_uninitialize: arg=%p\n", arg); return unregister_driver("/dev/chardev"); }
bool iotjs_pwm_close(iotjs_pwm_t* pwm) { iotjs_pwm_platform_data_t* platform_data = pwm->platform_data; int fd = platform_data->device_fd; if (fd < 0) { DLOG("%s - file not opened", __func__); return false; } DDDLOG("%s", __func__); // Close file close(fd); platform_data->device_fd = -1; uint32_t timer = SYSIO_GET_TIMER(pwm->pin); char path[PWM_DEVICE_PATH_BUFFER_SIZE] = { 0 }; if (snprintf(path, PWM_DEVICE_PATH_BUFFER_SIZE - 1, PWM_DEVICE_PATH_FORMAT, timer) < 0) { return false; } // Release driver unregister_driver(path); iotjs_gpio_unconfig_nuttx(pwm->pin); return true; }
VDev::~VDev() { PX4_DEBUG("VDev::~VDev"); if (_registered) { unregister_driver(_devname); } }
VDev::~VDev() { PX4_DEBUG("VDev::~VDev"); if (_registered) { unregister_driver(_devname); } if (_pollset) { delete[](_pollset); } }
static void pty_destroy(FAR struct pty_devpair_s *devpair) { char devname[16]; /* Un-register the slave device */ #ifdef CONFIG_PSEUDOTERM_BSD snprintf(devname, 16, "/dev/ttyp%d", devpair->pp_minor); #else snprintf(devname, 16, "/dev/pts/%d", devpair->pp_minor); #endif (void)unregister_driver(devname); /* Un-register the master device (/dev/ptyN may have already been * unlinked). */ snprintf(devname, 16, "/dev/pty%d", (int)devpair->pp_minor); (void)unregister_driver(devname); /* Close the contained file structures */ (void)file_close_detached(&devpair->pp_master.pd_src); (void)file_close_detached(&devpair->pp_master.pd_sink); (void)file_close_detached(&devpair->pp_slave.pd_src); (void)file_close_detached(&devpair->pp_slave.pd_sink); #ifdef CONFIG_PSEUDOTERM_SUSV1 /* Free this minor number so that it can be reused */ ptmx_minor_free(devpair->pp_minor); #endif /* And free the device structure */ nxsem_destroy(&devpair->pp_exclsem); kmm_free(devpair); }
bool iotjs_adc_close(iotjs_adc_t* adc) { iotjs_adc_platform_data_t* platform_data = adc->platform_data; uint32_t pin = platform_data->pin; int32_t adc_number = ADC_GET_NUMBER(pin); char path[ADC_DEVICE_PATH_BUFFER_SIZE] = { 0 }; adc_get_path(path, adc_number); // Release driver if (unregister_driver(path) < 0) { return false; } iotjs_gpio_unconfig_nuttx(pin); return true; }
void ubxmdm_unregister(FAR void *handle) { FAR struct ubxmdm_upper *upper; FAR struct ubxmdm_lower *lower; upper = (FAR struct ubxmdm_upper*) handle; lower = upper->lower; DEBUGASSERT(upper && lower); m_info("Unregistering: %s\n", upper->path); DEBUGASSERT(lower->ops->poweroff); (void) lower->ops->poweroff(lower); (void) unregister_driver(upper->path); kmm_free(upper->path); kmm_free(upper); }
void sim_tcuninitialize(void) { FAR struct up_dev_s *priv = ( FAR struct up_dev_s *)&g_simtouchscreen; char devname[DEV_NAMELEN]; int ret; /* Get exclusive access */ do { ret = sem_wait(&priv->devsem); if (ret < 0) { /* This should only happen if the wait was canceled by an signal */ DEBUGASSERT(errno == EINTR); } } while (ret != OK); /* Stop the event loop (Hmm.. the caller must be sure that there are no * open references to the touchscreen driver. This might better be * done in close() using a reference count). */ g_eventloop = 0; /* Un-register the device*/ (void)snprintf(devname, DEV_NAMELEN, DEV_FORMAT, priv->minor); ivdbg("Un-registering %s\n", devname); ret = unregister_driver(devname); if (ret < 0) { idbg("uregister_driver() failed: %d\n", ret); } /* Clean up any resources. Ouch! While we are holding the semaphore? */ sem_destroy(&priv->waitsem); sem_destroy(&priv->devsem); }
void cleanup_module(void) { struct net_device *next_dev; islpci_private *private_config; #ifdef INTERSIL_EVENTS mgt_cleanup(); #endif unregister_driver(&islpci_ops); /* No need to check MOD_IN_USE, as sys_delete_module() checks. */ while (root_islpci_device) { private_config = (islpci_private *) root_islpci_device->priv; next_dev = private_config->next_module; #if VERBOSE > SHOW_ERROR_MESSAGES DEBUG(SHOW_TRACING, "Cleanup netdevice \n"); #endif // unregister the network device unregister_netdev(root_islpci_device); // free the PCI memory and unmap the remapped page islpci_free_memory( private_config, ALLOC_MEMORY_MODE ); iounmap(private_config->remapped_device_base); // free the separately allocated areas kfree(private_config); kfree(root_islpci_device); // change the root device pointer to the next device for clearing root_islpci_device = next_dev; } DEBUG(SHOW_ANYTHING, "Unloaded %s\n", DRIVER_NAME ); }
void cleanup_module(void) { #ifdef CARDBUS unregister_driver(ðerdev_ops); #endif /* No need to check MOD_IN_USE, as sys_delete_module() checks. */ while (root_net_dev) { struct netdev_private *np = (struct netdev_private *)(root_net_dev->priv); unregister_netdev(root_net_dev); #ifdef VIA_USE_IO release_region(root_net_dev->base_addr, pci_tbl[np->chip_id].io_size); #else iounmap((char *)(root_net_dev->base_addr)); #endif kfree(root_net_dev); root_net_dev = np->next_module; #if 0 kfree(np); /* Assumption: no struct realignment. */ #endif } }
static __exit void ce_samsung_timer_driver_exit(void) { unregister_driver(&ce_samsung_timer); }
static __exit void ledtrig_general_driver_exit(void) { unregister_driver(&ledtrig_general); }
static __exit void sdhci_v3s_driver_exit(void) { unregister_driver(&sdhci_v3s); }
static __exit void clk_mux_driver_exit(void) { unregister_driver(&clk_mux); }
static __exit void motor_gpio_driver_exit(void) { unregister_driver(&motor_gpio); }
static __exit void irq_gic400_driver_exit(void) { unregister_driver(&irq_gic400); }
/** * @brief Register a RTDM device * * Registers a device in the RTDM namespace. * * @param[in] dev Device descriptor. * * @return 0 is returned upon success. Otherwise: * * - -EINVAL is returned if the descriptor contains invalid * entries. RTDM_PROFILE_INFO() must appear in the list of * initializers for the driver properties. * * - -EEXIST is returned if the specified device name of protocol ID is * already in use. * * - -ENOMEM is returned if a memory allocation failed in the process * of registering the device. * * @coretags{secondary-only} */ int rtdm_dev_register(struct rtdm_device *dev) { int ret, pos, major, minor; struct device *kdev = NULL; struct rtdm_driver *drv; xnkey_t id; dev_t rdev; secondary_mode_only(); if (!realtime_core_enabled()) return -ENOSYS; mutex_lock(®ister_lock); dev->name = NULL; drv = dev->driver; pos = atomic_read(&drv->refcount); ret = register_driver(drv); if (ret) { mutex_unlock(®ister_lock); return ret; } dev->ops = drv->ops; if (drv->device_flags & RTDM_NAMED_DEVICE) dev->ops.socket = (typeof(dev->ops.socket))enosys; else dev->ops.open = (typeof(dev->ops.open))enosys; init_waitqueue_head(&dev->putwq); dev->ops.close = __rtdm_dev_close; /* Interpose on driver's handler. */ atomic_set(&dev->refcount, 0); if (drv->device_flags & RTDM_FIXED_MINOR) { minor = dev->minor; if (minor < 0 || minor >= drv->device_count) { ret = -EINVAL; goto fail; } } else dev->minor = minor = pos; if (drv->device_flags & RTDM_NAMED_DEVICE) { major = drv->named.major; dev->name = kasformat(dev->label, minor); if (dev->name == NULL) { ret = -ENOMEM; goto fail; } ret = xnregistry_enter(dev->name, dev, &dev->named.handle, NULL); if (ret) goto fail; rdev = MKDEV(major, minor); kdev = device_create(rtdm_class, NULL, rdev, dev, dev->label, minor); if (IS_ERR(kdev)) { xnregistry_remove(dev->named.handle); ret = PTR_ERR(kdev); goto fail; } } else { dev->name = kstrdup(dev->label, GFP_KERNEL); if (dev->name == NULL) { ret = -ENOMEM; goto fail; } rdev = MKDEV(0, 0); kdev = device_create(rtdm_class, NULL, rdev, dev, dev->name); if (IS_ERR(kdev)) { ret = PTR_ERR(kdev); goto fail; } id = get_proto_id(drv->protocol_family, drv->socket_type); ret = xnid_enter(&protocol_devices, &dev->proto.id, id); if (ret < 0) goto fail; } dev->rdev = rdev; dev->kdev = kdev; dev->magic = RTDM_DEVICE_MAGIC; mutex_unlock(®ister_lock); trace_cobalt_device_register(dev); return 0; fail: if (kdev) device_destroy(rtdm_class, rdev); unregister_driver(drv); mutex_unlock(®ister_lock); if (dev->name) kfree(dev->name); return ret; }
static __exit void i2c_gpio_driver_exit(void) { unregister_driver(&i2c_gpio); }
static int telnetd_close(FAR struct file *filep) { FAR struct inode *inode = filep->f_inode; FAR struct telnetd_dev_s *priv = inode->i_private; FAR char *devpath; int ret; nllvdbg("td_crefs: %d\n", priv->td_crefs); /* Get exclusive access to the device structures */ ret = sem_wait(&priv->td_exclsem); if (ret < 0) { ret = -errno; goto errout; } /* Decrement the references to the driver. If the reference count will * decrement to 0, then uninitialize the driver. */ if (priv->td_crefs > 1) { /* Just decrement the reference count and release the semaphore */ priv->td_crefs--; sem_post(&priv->td_exclsem); } else { /* Re-create the path to the driver. */ sched_lock(); ret = asprintf(&devpath, TELNETD_DEVFMT, priv->td_minor); if (ret < 0) { nlldbg("Failed to allocate the driver path\n"); } else { /* Unregister the character driver */ ret = unregister_driver(devpath); if (ret < 0) { nlldbg("Failed to unregister the driver %s: %d\n", devpath, ret); } free(devpath); } /* Close the socket */ closesocket(priv->td_psock); /* Release the driver memory. What if there are threads waiting on * td_exclsem? They will never be awakened! How could this happen? * crefs == 1 so there are no other open references to the driver. * But this could have if someone were trying to re-open the driver * after every other thread has closed it. That really should not * happen in the intended usage model. */ DEBUGASSERT(priv->td_exclsem.semcount == 0); sem_destroy(&priv->td_exclsem); free(priv); sched_unlock(); } ret = OK; errout: return ret; }
static __exit void spi_rk3128_driver_exit(void) { unregister_driver(&spi_rk3128); }
static __exit void console_sandbox_driver_exit(void) { unregister_driver(&console_sandbox); }
static __exit void reset_rk3128_driver_exit(void) { unregister_driver(&reset_rk3128); }
static __exit void led_pwm_bl_driver_exit(void) { unregister_driver(&led_pwm_bl); }
static __exit void wdog_bcm2836_driver_exit(void) { unregister_driver(&wdog_bcm2836); }
static __exit void gpio_bcm2836_virt_driver_exit(void) { unregister_driver(&gpio_bcm2836_virt); }
static __exit void compass_hmc5883l_driver_exit(void) { unregister_driver(&compass_hmc5883l); }