/* * Unregister a new MMC card with the driver model, and * (eventually) free it. */ void mmc_remove_card(struct mmc_card *card) { #ifdef CONFIG_DEBUG_FS mmc_remove_card_debugfs(card); #endif if (mmc_card_present(card)) { if (mmc_host_is_spi(card->host)) { pr_info("%s: SPI card removed\n", mmc_hostname(card->host)); } else { pr_info("%s: card %04x removed\n", mmc_hostname(card->host), card->rca); } device_del(&card->dev); } put_device(&card->dev); }
void tegra_dc_ext_unregister(struct tegra_dc_ext *ext) { int i; for (i = 0; i < ext->dc->n_windows; i++) { struct tegra_dc_ext_win *win = &ext->win[i]; flush_workqueue(win->flip_wq); destroy_workqueue(win->flip_wq); } nvmap_client_put(ext->nvmap); device_del(ext->dev); cdev_del(&ext->cdev); kfree(ext); head_count--; }
/* * Unregister a cec device node * * This unregisters the passed device. Future open calls will be met with * errors. * * This function can safely be called if the device node has never been * registered or has already been unregistered. */ static void cec_devnode_unregister(struct cec_devnode *devnode) { struct cec_fh *fh; /* Check if devnode was never registered or already unregistered */ if (!devnode->registered || devnode->unregistered) return; mutex_lock(&devnode->fhs_lock); list_for_each_entry(fh, &devnode->fhs, list) wake_up_interruptible(&fh->wait); mutex_unlock(&devnode->fhs_lock); devnode->registered = false; devnode->unregistered = true; device_del(&devnode->dev); cdev_del(&devnode->cdev); put_device(&devnode->dev); }
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) { struct usb_info *dev = the_usb_info; if (!dev) return -ENODEV; if (!driver || driver != dev->driver || !driver->unbind) return -EINVAL; device_remove_file(&dev->gadget.dev, &dev_attr_wakeup); driver->unbind(&dev->gadget); dev->gadget.dev.driver = NULL; dev->driver = NULL; device_del(&dev->gadget.dev); VDEBUG("unregistered gadget driver '%s'\n", driver->driver.name); return 0; }
void delete_partition(struct gendisk *disk, int partno) { struct disk_part_tbl *ptbl = disk->part_tbl; struct hd_struct *part; if (partno >= ptbl->len) return; part = ptbl->part[partno]; if (!part) return; rcu_assign_pointer(ptbl->part[partno], NULL); rcu_assign_pointer(ptbl->last_lookup, NULL); kobject_put(part->holder_dir); device_del(part_to_dev(part)); hd_struct_kill(part); }
/* * usb_disable_device - Disable all the endpoints for a USB device * @dev: the device whose endpoints are being disabled * @skip_ep0: 0 to disable endpoint 0, 1 to skip it. * * Disables all the device's endpoints, potentially including endpoint 0. * Deallocates hcd/hardware state for the endpoints (nuking all or most * pending urbs) and usbcore state for the interfaces, so that usbcore * must usb_set_configuration() before any interfaces could be used. */ void usb_disable_device(struct usb_device *dev, int skip_ep0) { int i; dev_dbg(&dev->dev, "%s nuking %s URBs\n", __FUNCTION__, skip_ep0 ? "non-ep0" : "all"); for (i = skip_ep0; i < 16; ++i) { usb_disable_endpoint(dev, i); usb_disable_endpoint(dev, i + USB_DIR_IN); } dev->toggle[0] = dev->toggle[1] = 0; /* getting rid of interfaces will disconnect * any drivers bound to them (a key side effect) */ if (dev->actconfig) { for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { struct usb_interface *interface; /* remove this interface if it has been registered */ interface = dev->actconfig->interface[i]; if (!klist_node_attached(&interface->dev.knode_bus)) continue; dev_dbg (&dev->dev, "unregistering interface %s\n", interface->dev.bus_id); usb_remove_sysfs_intf_files(interface); kfree(interface->cur_altsetting->string); interface->cur_altsetting->string = NULL; device_del (&interface->dev); } /* Now that the interfaces are unbound, nobody should * try to access them. */ for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { put_device (&dev->actconfig->interface[i]->dev); dev->actconfig->interface[i] = NULL; } dev->actconfig = NULL; if (dev->state == USB_STATE_CONFIGURED) usb_set_device_state(dev, USB_STATE_ADDRESS); } }
/** * platform_device_del - remove a platform-level device * @pdev: platform device we're removing * * Note that this function will also release all memory- and port-based * resources owned by the device (@dev->resource). This function must * _only_ be externally called in error cases. All other usage is a bug. */ void platform_device_del(struct platform_device *pdev) { int i; if (!IS_ERR_OR_NULL(pdev)) { device_del(&pdev->dev); if (pdev->id_auto) { ida_simple_remove(&platform_devid_ida, pdev->id); pdev->id = PLATFORM_DEVID_AUTO; } for (i = 0; i < pdev->num_resources; i++) { struct resource *r = &pdev->resource[i]; if (r->parent) release_resource(r); } } }
/* * Unregister a new MMC card with the driver model, and * (eventually) free it. */ void mmc_remove_card(struct mmc_card *card) { #ifdef CONFIG_DEBUG_FS mmc_remove_card_debugfs(card); #endif if (mmc_card_present(card)) { if (mmc_host_is_spi(card->host)) { printk(KERN_INFO "%s: SPI card removed\n", mmc_hostname(card->host)); } else { printk(KERN_INFO "%s: card %04x removed\n", mmc_hostname(card->host), card->rca); } printk("%s: device_del\n", __FUNCTION__); device_del(&card->dev); } put_device(&card->dev); }
/* * Unregister a new MMC card with the driver model, and * (eventually) free it. */ void mmc_remove_card(struct mmc_card *card) { #ifdef CONFIG_DEBUG_FS mmc_remove_card_debugfs(card); #endif if (mmc_card_present(card)) { if (mmc_host_is_spi(card->host)) { printk(KERN_INFO "%s: SPI card removed\n", mmc_hostname(card->host)); } else { printk(KERN_INFO "%s: card %04x removed\n", mmc_hostname(card->host), card->rca); } device_del(&card->dev); } kfree(card->wr_pack_stats.packing_events); put_device(&card->dev); }
/* * Unregister a new MMC card with the driver model, and * (eventually) free it. */ void mmc_remove_card(struct mmc_card *card) { #ifdef CONFIG_DEBUG_FS mmc_remove_card_debugfs(card); #endif if (mmc_card_present(card)) { //if(!HOST_IS_EMMC(card->host)) // mmc_card_clr_present(card); if (mmc_host_is_spi(card->host)) { printk(KERN_INFO "%s: SPI card removed\n", mmc_hostname(card->host)); } else { printk(KERN_INFO "%s: card %04x removed\n", mmc_hostname(card->host), card->rca); } device_del(&card->dev); } put_device(&card->dev); }
/* * remove a Memory Controller instance */ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) { int i; edac_dbg(0, "\n"); #ifdef CONFIG_EDAC_DEBUG debugfs_remove(mci->debugfs); #endif #ifdef CONFIG_EDAC_LEGACY_SYSFS edac_delete_csrow_objects(mci); #endif for (i = 0; i < mci->tot_dimms; i++) { struct dimm_info *dimm = mci->dimms[i]; if (dimm->nr_pages == 0) continue; edac_dbg(0, "removing device %s\n", dev_name(&dimm->dev)); put_device(&dimm->dev); device_del(&dimm->dev); } }
/* * Unregister a new MMC card with the driver model, and * (eventually) free it. */ void mmc_remove_card(struct mmc_card *card) { #ifdef CONFIG_DEBUG_FS mmc_remove_card_debugfs(card); #endif if (mmc_card_present(card)) { #if defined(CONFIG_SDMMC_RK29) && defined(CONFIG_SDMMC_RK29_OLD) mmc_card_clr_present(card); #endif if (mmc_host_is_spi(card->host)) { printk(KERN_INFO "%s: SPI card removed\n", mmc_hostname(card->host)); } else { printk(KERN_INFO "%s: card %04x removed\n", mmc_hostname(card->host), card->rca); } device_del(&card->dev); } put_device(&card->dev); }
/* * Unregister a new MMC card with the driver model, and * (eventually) free it. */ void mmc_remove_card(struct mmc_card *card) { #ifdef CONFIG_DEBUG_FS mmc_remove_card_debugfs(card); #endif if (mmc_card_present(card)) { if (mmc_host_is_spi(card->host)) { printk(KERN_INFO "%s: SPI card removed\n", mmc_hostname(card->host)); } else { printk(KERN_INFO "%s: card %04x removed\n", mmc_hostname(card->host), card->rca); } /*LGE_UPDATE_S DYLEE */ printk(KERN_INFO "[LGE] mmc device remove\n"); //LGE_UPDATE E720 BCPARK /*LGE_UPDATE_E DYLEE */ device_del(&card->dev); } put_device(&card->dev); }
/* * Unregister a new MMC card with the driver model, and * (eventually) free it. */ void mmc_remove_card(struct mmc_card *card) { #ifdef CONFIG_DEBUG_FS mmc_remove_card_debugfs(card); #endif if (mmc_card_present(card)) { if (mmc_host_is_spi(card->host)) { printk(KERN_INFO "%s: SPI card removed\n", mmc_hostname(card->host)); } else { printk(KERN_INFO "%s: card %04x removed\n", mmc_hostname(card->host), card->rca); } #ifdef CONFIG_MACH_SEMC_ZEUS mmc_card_set_removed(card); #endif /* CONFIG_MACH_SEMC_ZEUS */ device_del(&card->dev); } put_device(&card->dev); }
int __iio_trigger_register(struct iio_trigger *trig_info, struct module *this_mod) { int ret; trig_info->owner = this_mod; trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL); if (trig_info->id < 0) return trig_info->id; /* Set the name used for the sysfs directory etc */ dev_set_name(&trig_info->dev, "trigger%ld", (unsigned long) trig_info->id); ret = device_add(&trig_info->dev); if (ret) goto error_unregister_id; /* Add to list of available triggers held by the IIO core */ mutex_lock(&iio_trigger_list_lock); if (__iio_trigger_find_by_name(trig_info->name)) { pr_err("Duplicate trigger name '%s'\n", trig_info->name); ret = -EEXIST; goto error_device_del; } list_add_tail(&trig_info->list, &iio_trigger_list); mutex_unlock(&iio_trigger_list_lock); return 0; error_device_del: mutex_unlock(&iio_trigger_list_lock); device_del(&trig_info->dev); error_unregister_id: ida_simple_remove(&iio_trigger_ida, trig_info->id); return ret; }
static int scif_peer_add_device(struct scif_dev *scifdev) { struct scif_peer_dev *spdev = rcu_dereference(scifdev->spdev); char pool_name[16]; int ret; ret = device_add(&spdev->dev); put_device(&spdev->dev); if (ret) { dev_err(&scifdev->sdev->dev, "dnode %d: peer device_add failed\n", scifdev->node); goto put_spdev; } scnprintf(pool_name, sizeof(pool_name), "scif-%d", spdev->dnode); scifdev->signal_pool = dmam_pool_create(pool_name, &scifdev->sdev->dev, sizeof(struct scif_status), 1, 0); if (!scifdev->signal_pool) { dev_err(&scifdev->sdev->dev, "dnode %d: dmam_pool_create failed\n", scifdev->node); ret = -ENOMEM; goto del_spdev; } dev_dbg(&spdev->dev, "Added peer dnode %d\n", spdev->dnode); return 0; del_spdev: device_del(&spdev->dev); put_spdev: RCU_INIT_POINTER(scifdev->spdev, NULL); synchronize_rcu(); put_device(&spdev->dev); mutex_lock(&scif_info.conflock); scif_info.total--; mutex_unlock(&scif_info.conflock); return ret; }
static int accfix_remove(struct platform_device *xxx) { ACCFIX_DEBUG("[accfix]accfix_remove begin!\n"); if(g_accfix_first == 0) { free_irq(MT6575_ACCDET_IRQ_ID,NULL); } //cancel_delayed_work(&accfix_work); #ifdef ACCFIX_EINT destroy_workqueue(accfix_eint_workqueue); #endif destroy_workqueue(accfix_workqueue); switch_dev_unregister(&accfix_data); device_del(accfix_nor_device); class_destroy(accfix_class); cdev_del(accfix_cdev); unregister_chrdev_region(accfix_devno,1); input_unregister_device(kpd_accfix_dev); ACCFIX_DEBUG("[accfix]accfix_remove Done!\n"); return 0; }
int svc_update_connection(struct gb_interface *intf, struct gb_connection *connection) { struct gb_bundle *bundle; bundle = gb_bundle_create(intf, GB_SVC_BUNDLE_ID, GREYBUS_CLASS_SVC); if (!bundle) return -EINVAL; device_del(&connection->dev); connection->bundle = bundle; connection->dev.parent = &bundle->dev; dev_set_name(&connection->dev, "%s:%d", dev_name(&bundle->dev), GB_SVC_CPORT_ID); WARN_ON(device_add(&connection->dev)); spin_lock_irq(&gb_connections_lock); list_add(&connection->bundle_links, &bundle->connections); spin_unlock_irq(&gb_connections_lock); return 0; }
/* Unregister entry point for the peripheral controller driver. */ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) { struct s3c_udc *dev = the_controller; unsigned long flags; if (!dev) return -ENODEV; if (!driver || driver != dev->driver) return -EINVAL; spin_lock_irqsave(&dev->lock, flags); dev->driver = 0; stop_activity(dev, driver); spin_unlock_irqrestore(&dev->lock, flags); driver->unbind(&dev->gadget); device_del(&dev->gadget.dev); disable_irq(IRQ_USBD); printk("Unregistered gadget driver '%s'\n", driver->driver.name); return 0; }
static void edac_delete_csrow_objects(struct mem_ctl_info *mci) { int i, chan; struct csrow_info *csrow; for (i = mci->nr_csrows - 1; i >= 0; i--) { csrow = mci->csrows[i]; if (!nr_pages_per_csrow(csrow)) continue; for (chan = csrow->nr_channels - 1; chan >= 0; chan--) { if (!csrow->channels[chan]->dimm->nr_pages) continue; edac_dbg(1, "Removing csrow %d channel %d sysfs nodes\n", i, chan); device_remove_file(&csrow->dev, dynamic_csrow_dimm_attr[chan]); device_remove_file(&csrow->dev, dynamic_csrow_ce_count_attr[chan]); } put_device(&mci->csrows[i]->dev); device_del(&mci->csrows[i]->dev); } }
static int usbhsg_gadget_stop(struct usb_gadget_driver *driver) { struct usbhsg_gpriv *gpriv; struct usbhs_priv *priv; struct device *dev; if (!driver || !driver->unbind) return -EINVAL; /* * find controller */ usbhsg_for_each_controller(gpriv) { if (gpriv->driver == driver) goto find_matching_controller; } return -ENODEV; find_matching_controller: dev = usbhsg_gpriv_to_dev(gpriv); priv = usbhsg_gpriv_to_priv(gpriv); usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD); device_del(&gpriv->gadget.dev); gpriv->driver = NULL; if (driver->disconnect) driver->disconnect(&gpriv->gadget); driver->unbind(&gpriv->gadget); dev_dbg(dev, "unbind %s\n", driver->driver.name); return 0; }
/* Unregister entry point for the peripheral controller driver. */ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) { struct lh7a40x_udc *dev = the_controller; unsigned long flags; if (!dev) return -ENODEV; if (!driver || driver != dev->driver || !driver->unbind) return -EINVAL; spin_lock_irqsave(&dev->lock, flags); dev->driver = 0; stop_activity(dev, driver); spin_unlock_irqrestore(&dev->lock, flags); driver->unbind(&dev->gadget); dev->gadget.dev.driver = NULL; device_del(&dev->gadget.dev); udc_disable(dev); DEBUG("unregistered gadget driver '%s'\n", driver->driver.name); return 0; }
/* * Create a new Memory Controller kobject instance, * mc<id> under the 'mc' directory * * Return: * 0 Success * !0 Failure */ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) { int i, err; /* * The memory controller needs its own bus, in order to avoid * namespace conflicts at /sys/bus/edac. */ mci->bus.name = kasprintf(GFP_KERNEL, "mc%d", mci->mc_idx); if (!mci->bus.name) return -ENOMEM; edac_dbg(0, "creating bus %s\n", mci->bus.name); err = bus_register(&mci->bus); if (err < 0) return err; /* get the /sys/devices/system/edac subsys reference */ mci->dev.type = &mci_attr_type; device_initialize(&mci->dev); mci->dev.parent = mci_pdev; mci->dev.bus = &mci->bus; dev_set_name(&mci->dev, "mc%d", mci->mc_idx); dev_set_drvdata(&mci->dev, mci); pm_runtime_forbid(&mci->dev); edac_dbg(0, "creating device %s\n", dev_name(&mci->dev)); err = device_add(&mci->dev); if (err < 0) { bus_unregister(&mci->bus); kfree(mci->bus.name); return err; } /* * Create the dimm/rank devices */ for (i = 0; i < mci->tot_dimms; i++) { struct dimm_info *dimm = mci->dimms[i]; /* Only expose populated DIMMs */ if (dimm->nr_pages == 0) continue; #ifdef CONFIG_EDAC_DEBUG edac_dbg(1, "creating dimm%d, located at ", i); if (edac_debug_level >= 1) { int lay; for (lay = 0; lay < mci->n_layers; lay++) printk(KERN_CONT "%s %d ", edac_layer_name[mci->layers[lay].type], dimm->location[lay]); printk(KERN_CONT "\n"); } #endif err = edac_create_dimm_object(mci, dimm, i); if (err) { edac_dbg(1, "failure: create dimm %d obj\n", i); goto fail; } } #ifdef CONFIG_EDAC_LEGACY_SYSFS err = edac_create_csrow_objects(mci); if (err < 0) goto fail; #endif #ifdef CONFIG_EDAC_DEBUG edac_create_debug_nodes(mci); #endif return 0; fail: for (i--; i >= 0; i--) { struct dimm_info *dimm = mci->dimms[i]; if (dimm->nr_pages == 0) continue; put_device(&dimm->dev); device_del(&dimm->dev); } put_device(&mci->dev); device_del(&mci->dev); bus_unregister(&mci->bus); kfree(mci->bus.name); return err; }
struct tegra_dc_ext *tegra_dc_ext_register(struct nvhost_device *ndev, struct tegra_dc *dc) { int ret; struct tegra_dc_ext *ext; int devno; ext = kzalloc(sizeof(*ext), GFP_KERNEL); if (!ext) return ERR_PTR(-ENOMEM); BUG_ON(!tegra_dc_ext_devno); devno = tegra_dc_ext_devno + head_count + 1; cdev_init(&ext->cdev, &tegra_dc_devops); ext->cdev.owner = THIS_MODULE; ret = cdev_add(&ext->cdev, devno, 1); if (ret) { dev_err(&ndev->dev, "Failed to create character device\n"); goto cleanup_alloc; } ext->dev = device_create(tegra_dc_ext_class, &ndev->dev, devno, NULL, "tegra_dc_%d", ndev->id); if (IS_ERR(ext->dev)) { ret = PTR_ERR(ext->dev); goto cleanup_cdev; } ext->dc = dc; ext->nvmap = nvmap_create_client(nvmap_dev, "tegra_dc_ext"); if (!ext->nvmap) { ret = -ENOMEM; goto cleanup_device; } ret = tegra_dc_ext_setup_windows(ext); if (ret) goto cleanup_nvmap; mutex_init(&ext->cursor.lock); head_count++; return ext; cleanup_nvmap: nvmap_client_put(ext->nvmap); cleanup_device: device_del(ext->dev); cleanup_cdev: cdev_del(&ext->cdev); cleanup_alloc: kfree(ext); return ERR_PTR(ret); }
/* Why need this ?*/ static void memdev_dev_release(struct device *dev) { printk(KERN_INFO "%s is remove\n",dev_name(dev)); class_destroy(dev->class); device_del(dev); }
void __exit edac_mc_sysfs_exit(void) { put_device(mci_pdev); device_del(mci_pdev); edac_put_sysfs_subsys(); }
int usb_gadget_probe_driver(struct usb_gadget_driver *driver, int (*bind)(struct usb_gadget *)) { struct usb_info *ui = the_usb_info; int retval, n; if (!driver || driver->speed < USB_SPEED_FULL || !bind || !driver->disconnect || !driver->setup) return -EINVAL; if (!ui) return -ENODEV; if (ui->driver) return -EBUSY; /* first hook up the driver ... */ ui->driver = driver; ui->gadget.dev.driver = &driver->driver; ui->gadget.name = driver_name; INIT_LIST_HEAD(&ui->gadget.ep_list); ui->gadget.ep0 = &ui->ep0in.ep; INIT_LIST_HEAD(&ui->gadget.ep0->ep_list); ui->gadget.speed = USB_SPEED_UNKNOWN; for (n = 1; n < 16; n++) { struct msm_endpoint *ept = ui->ept + n; list_add_tail(&ept->ep.ep_list, &ui->gadget.ep_list); ept->ep.maxpacket = 512; } for (n = 17; n < 32; n++) { struct msm_endpoint *ept = ui->ept + n; list_add_tail(&ept->ep.ep_list, &ui->gadget.ep_list); ept->ep.maxpacket = 512; } retval = device_add(&ui->gadget.dev); if (retval) goto fail; retval = bind(&ui->gadget); if (retval) { INFO("bind to driver %s --> error %d\n", driver->driver.name, retval); device_del(&ui->gadget.dev); goto fail; } #ifdef CONFIG_USB_HTC_SWITCH_STUB retval = device_create_file(ui->gadget.dev.parent, &dev_attr_usb_function_switch); #endif /* create sysfs node for remote wakeup */ retval = device_create_file(&ui->gadget.dev, &dev_attr_wakeup); if (retval != 0) INFO("failed to create sysfs entry: (wakeup) error: (%d)\n", retval); INFO("msm72k_udc: registered gadget driver '%s'\n", driver->driver.name); usb_start(ui); return 0; fail: ui->driver = NULL; ui->gadget.dev.driver = NULL; return retval; }
/** * device_unregister - unregister device from system. * @dev: device going away. * * We do this in two parts, like we do device_register(). First, * we remove it from all the subsystems with device_del(), then * we decrement the reference count via put_device(). If that * is the final reference count, the device will be cleaned up * via device_release() above. Otherwise, the structure will * stick around until the final reference to the device is dropped. */ void device_unregister(struct device * dev) { pr_debug("DEV: Unregistering device. ID = '%s'\n", dev->bus_id); device_del(dev); put_device(dev); }
/** * mdio_device_remove - Remove a previously registered mdio device from the * MDIO bus * @mdiodev: mdio_device structure to remove * * This doesn't free the mdio_device itself, it merely reverses the effects * of mdio_device_register(). Use mdio_device_free() to free the device * after calling this function. */ void mdio_device_remove(struct mdio_device *mdiodev) { device_del(&mdiodev->dev); mdiobus_unregister_device(mdiodev); }
static void intel_th_device_remove(struct intel_th_device *thdev) { device_del(&thdev->dev); put_device(&thdev->dev); }