Ejemplo n.º 1
0
static void mtd_notify_remove(struct mtd_info* mtd)
{
	if (!mtd)
		return;
	devfs_remove("mtd/%d", mtd->index);
	devfs_remove("mtd/%dro", mtd->index);
}
Ejemplo n.º 2
0
static void __exit adc_exit(void)
{
#ifdef CONFIG_DEVFS_FS 
 devfs_remove("adc/%d", 0); 
 devfs_remove("adc");   
#endif 
iounmap(peter_base_addr);
 unregister_chrdev(adc_major,DEVICE_NAME); 
 
printk("i am adc_exit, you see me, which means the module is rmmoved\n"); 
}
Ejemplo n.º 3
0
static void __exit raw_exit(void)
{
	int i;

	for (i = 1; i < MAX_RAW_MINORS; i++)
		devfs_remove("raw/raw%d", i);
	devfs_remove("raw/rawctl");
	devfs_remove("raw");
	cdev_del(&raw_cdev);
	unregister_chrdev_region(MKDEV(RAW_MAJOR, 0), MAX_RAW_MINORS);
}
Ejemplo n.º 4
0
void cleanup_module(void)
{
	/*
	 * Unregister the device
	 */
	devfs_remove("dvb/adapter0/frontend0");
	class_simple_device_remove(MKDEV(DVB_MAJOR, 3));
	devfs_remove("dvb");
	class_simple_destroy(my_class);
	cdev_del(&device_cdev);
	unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), 64);
	printk(KERN_INFO "[td-dvb-fe] unload successful\n");
}
Ejemplo n.º 5
0
void
ddi_remove_minor_node(dev_info_t *dip, char *name)
{
    //printf("zvol: remove minor: '%s'\n", name ? name : "");
    if (dip->devc) {
        devfs_remove(dip->devc);
        dip->devc = NULL;
    }
    if (dip->devb) {
        devfs_remove(dip->devb);
        dip->devb = NULL;
    }
}
Ejemplo n.º 6
0
static void mtd_notify_remove(struct mtd_info* mtd)
{
	if (!mtd)
		return;

#ifdef CONFIG_DEVFS_FS
	devfs_remove("mtd/%d", mtd->index);
	devfs_remove("mtd/%dro", mtd->index);
#else
	class_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2));
	class_device_destroy(mtd_class, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1));
#endif
}
Ejemplo n.º 7
0
void devfs_remove_disk(struct gendisk *disk)
{
	if (disk->minors != 1) {
		devfs_remove("discs/disc%d", disk->number);
		dealloc_unique_number(&disc_numspace, disk->number);
		devfs_remove("%s/disc", disk->devfs_name);
	}
	if (disk->flags & GENHD_FL_CD) {
		devfs_remove("cdroms/cdrom%d", disk->number);
		dealloc_unique_number(&cdrom_numspace, disk->number);
	}
	devfs_remove(disk->devfs_name);
}
Ejemplo n.º 8
0
static void devfs_unregister_card(struct em84xx *card)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,69)
    devfs_unregister(em8300_handle[0]);
    devfs_unregister(em8300_handle[1]);
    devfs_unregister(em8300_handle[2]);
    devfs_unregister(em8300_handle[3]);
#else
    devfs_remove("%s%d", REALMAGIC_DEVICE_NAME, 0);
    devfs_remove("%s%d", REALMAGIC_DEVICE_NAME, 1);
    devfs_remove("%s%d", REALMAGIC_DEVICE_NAME, 2);
    devfs_remove("%s%d", REALMAGIC_DEVICE_NAME, 3);
#endif
}
Ejemplo n.º 9
0
static void __exit bpp_cleanup(void)
{
	unsigned idx;

	for (idx = 0; idx < BPP_NO; idx++)
		devfs_remove("bpp/%d", idx);
	devfs_remove("bpp");
	unregister_chrdev(BPP_MAJOR, dev_name);

	for (idx = 0;  idx < BPP_NO; idx++) {
		if (instances[idx].present)
			freeLptPort(idx);
	}
}
Ejemplo n.º 10
0
/**
 * ubi_free_volume - free volume.
 * @ubi: UBI device description object
 * @vol: volume description object
 *
 * This function frees all resources for volume @vol but does not remove it.
 * Used only when the UBI device is detached.
 */
void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol)
{
	dbg_gen("free volume %d", vol->vol_id);

	ubi->volumes[vol->vol_id] = NULL;
	devfs_remove(&vol->cdev);
}
Ejemplo n.º 11
0
static void lpp_remove_one (struct pci_dev *pdev)
    {
	DEV *dev = pci_get_drvdata(pdev);
    dbg("%s(): dev=%08X pci_dev->vendor=%04X device=%04X",
        __FUNCTION__, (uint)dev, 
        pdev->vendor, pdev->device);
	if (!dev)  BUG();

    down (&minor_table_mutex);
#ifdef CONFIG_DEVFS_FS
	devfs_remove("lpc/%d", dev->minor);
#endif
    minor_table[dev->minor] = NULL;
//	unregister_netdev(dev);
//	iounmap(cp->regs);
	pci_release_regions(pdev);
	pci_clear_mwi(pdev);
	pci_disable_device(pdev);
	pci_set_drvdata(pdev, NULL);
    tasklet_kill(&dev->Dpc);
    kfree(dev);

    info(DRIVER_DESC " " DRIVER_DEV_NAME "%d now disconnected", dev->minor);
    up (&minor_table_mutex);
    }
Ejemplo n.º 12
0
/**
 * uif_init - initialize user interfaces for an UBI device.
 * @ubi: UBI device description object
 * @ref: set to %1 on exit in case of failure if a reference to @ubi->dev was
 *       taken, otherwise set to %0
 *
 * This function initializes various user interfaces for an UBI device. If the
 * initialization fails at an early stage, this function frees all the
 * resources it allocated, returns an error, and @ref is set to %0. However,
 * if the initialization fails after the UBI device was registered in the
 * driver core subsystem, this function takes a reference to @ubi->dev, because
 * otherwise the release function ('dev_release()') would free whole @ubi
 * object. The @ref argument is set to %1 in this case. The caller has to put
 * this reference.
 *
 * This function returns zero in case of success and a negative error code in
 * case of failure.
 */
static int uif_init(struct ubi_device *ubi, int *ref)
{
	int i, err;

	*ref = 0;
	sprintf(ubi->ubi_name, UBI_NAME_STR "%d", ubi->ubi_num);

	err = ubi_cdev_add(ubi);
	if (err) {
		ubi_err("cannot add character device");
		goto out_unreg;
	}

	for (i = 0; i < ubi->vtbl_slots; i++)
		if (ubi->volumes[i]) {
			err = ubi_add_volume(ubi, ubi->volumes[i]);
			if (err) {
				ubi_err("cannot add volume %d", i);
				goto out_volumes;
			}
		}

	return 0;

out_volumes:
	kill_volumes(ubi);
	devfs_remove(&ubi->cdev);
out_unreg:
	ubi_err("cannot initialize UBI %s, error %d", ubi->ubi_name, err);
	return err;
}
Ejemplo n.º 13
0
static void miiphy_remove(struct device_d *dev)
{
	struct miiphy_device *mdev = dev->priv;

	free(mdev->cdev.name);
	devfs_remove(&mdev->cdev);
}
Ejemplo n.º 14
0
static void __exit dsp56k_cleanup_driver(void)
{
	class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
	class_simple_destroy(dsp56k_class);
	unregister_chrdev(DSP56K_MAJOR, "dsp56k");
	devfs_remove("dsp56k");
}
Ejemplo n.º 15
0
/**
 * usb_deregister_dev - deregister a USB device's dynamic minor.
 * @intf: pointer to the usb_interface that is being deregistered
 * @class_driver: pointer to the usb_class_driver for this device
 *
 * Used in conjunction with usb_register_dev().  This function is called
 * when the USB driver is finished with the minor numbers gotten from a
 * call to usb_register_dev() (usually when the device is disconnected
 * from the system.)
 *
 * This function also cleans up the devfs file for the usb device, if devfs
 * is enabled, and removes the usb class device from the sysfs tree.
 * 
 * This should be called by all drivers that use the USB major number.
 */
void usb_deregister_dev(struct usb_interface *intf,
			struct usb_class_driver *class_driver)
{
	int minor_base = class_driver->minor_base;
	char name[BUS_ID_SIZE];

#ifdef CONFIG_USB_DYNAMIC_MINORS
	minor_base = 0;
#endif

	if (intf->minor == -1)
		return;

	dbg ("removing %d minor", intf->minor);

	spin_lock (&minor_lock);
	usb_minors[intf->minor] = NULL;
	spin_unlock (&minor_lock);

	snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base);
	devfs_remove (name);
	class_device_destroy(usb_class, MKDEV(USB_MAJOR, intf->minor));
	intf->class_dev = NULL;
	intf->minor = -1;
}
Ejemplo n.º 16
0
kern_return_t OsqueryStop(kmod_info_t *ki, void *d) {
    dbg_printf("Kernel module stoping!\n");

    lck_mtx_lock(osquery.mtx);
    if (osquery.open_count > 0) {
        lck_mtx_unlock(osquery.mtx);
        return KERN_FAILURE;
    }

    if (osquery_cqueue_teardown(&osquery.cqueue)) {
        lck_mtx_unlock(osquery.mtx);
        return KERN_FAILURE;
    }

    devfs_remove(osquery.devfs);
    osquery.devfs = NULL;

    if (cdevsw_remove(osquery.major_number, &osquery_cdevsw) < 0) {
        panic("osquery kext: Cannot remove osquery from cdevsw");
    }

    lck_mtx_unlock(osquery.mtx);
    teardown_locks();

    return KERN_SUCCESS;
}
Ejemplo n.º 17
0
kern_return_t OsqueryStop(kmod_info_t *ki, void *d) {
  dbg_printf("Kernel module stopping!\n");

  // Only stop if there are no connected daemons.
  lck_mtx_lock(osquery.mtx);
  if (osquery.open_count > 0) {
    lck_mtx_unlock(osquery.mtx);
    return KERN_FAILURE;
  }

  // Stop sharing the queue and remove queue locks.
  // This will potentially block as heuristics are applied to make sure the
  // queue is no longer is use.
  if (osquery_cqueue_teardown(&osquery.cqueue)) {
    lck_mtx_unlock(osquery.mtx);
    return KERN_FAILURE;
  }

  // Remove the device node.
  devfs_remove(osquery.devfs);
  osquery.devfs = NULL;

  // Tear down the device node data.
  if (cdevsw_remove(osquery.major_number, &osquery_cdevsw) < 0) {
    panic("osquery kext: Cannot remove osquery from cdevsw");
  }

  // Deallocate the IOCTL and kernel API locks.
  lck_mtx_unlock(osquery.mtx);
  teardown_locks();

  return KERN_SUCCESS;
}
Ejemplo n.º 18
0
void
vnclear(struct vn_softc *vn, vfs_context_t ctx)
{
	if (vn->sc_vp != NULL) {
		/* release long-term reference */
		(void)vn_close(vn->sc_vp, vn->sc_open_flags, ctx);
		vn->sc_vp = NULL;
	}
	if (vn->sc_shadow_vp != NULL) {
		/* release long-term reference */
		(void)vn_close(vn->sc_shadow_vp, FREAD | FWRITE, ctx);
		vn->sc_shadow_vp = NULL;
	}
	if (vn->sc_shadow_map != NULL) {
		shadow_map_free(vn->sc_shadow_map);
		vn->sc_shadow_map = NULL;
	}
	vn->sc_flags &= ~(VNF_INITED | VNF_READONLY);
	if (vn->sc_cred) {
		kauth_cred_unref(&vn->sc_cred);
	}
	vn->sc_size = 0;
	vn->sc_fsize = 0;
	if (vn->sc_cdev) {
		devfs_remove(vn->sc_cdev);
		vn->sc_cdev = NULL;
	}
}
Ejemplo n.º 19
0
// Tries to free all resources and also passes through any errors
//
// args: the error arg will be overwritten with KERN_FAILURE in case of an error
//       or returned unmodified in case everything went well.
// return: the given error argument or KERN_FAILURE if anything went wrong
static int pmem_cleanup(int error) {
  if (pmem_zero_page) {
    OSFree(pmem_zero_page, PAGE_SIZE, pmem_tag);
  }
  if (pte_mmap != NULL) {
    pte_mmap_osx_delete(pte_mmap);
  }
  if (pmem_tag) {
    OSMalloc_Tagfree(pmem_tag);
  }
  if (pmem_devpmemnode) {
    devfs_remove(pmem_devpmemnode);
  }
  if (pmem_devmajor != -1) {
    int devindex = 0;
    devindex = cdevsw_remove(pmem_devmajor, &pmem_cdevsw);
    if (devindex != pmem_devmajor) {
      pmem_error("Failed to remove cdevsw, cdevsw_remove() returned %d,"
                 "should be %d", devindex, pmem_devmajor);
      pmem_error("Kext will not be unloaded as an uio could result"
                 " in calling non-existent code");
      error = KERN_FAILURE;
    }
  }

  return error;
}
Ejemplo n.º 20
0
static void __devexit cpqarray_remove_one(int i)
{
	int j;
	char buff[4];

	/* sendcmd will turn off interrupt, and send the flush...
	 * To write all data in the battery backed cache to disks
	 * no data returned, but don't want to send NULL to sendcmd */
	if( sendcmd(FLUSH_CACHE, i, buff, 4, 0, 0, 0))
	{
		printk(KERN_WARNING "Unable to flush cache on controller %d\n",
				i);
	}
	free_irq(hba[i]->intr, hba[i]);
	iounmap(hba[i]->vaddr);
	unregister_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname);
	del_timer(&hba[i]->timer);
	remove_proc_entry(hba[i]->devname, proc_array);
	pci_free_consistent(hba[i]->pci_dev,
			NR_CMDS * sizeof(cmdlist_t), (hba[i]->cmd_pool),
			hba[i]->cmd_pool_dhandle);
	kfree(hba[i]->cmd_pool_bits);
	for(j = 0; j < NWD; j++) {
		if (ida_gendisk[i][j]->flags & GENHD_FL_UP)
			del_gendisk(ida_gendisk[i][j]);
		devfs_remove("ida/c%dd%d",i,j);
		put_disk(ida_gendisk[i][j]);
	}
	blk_cleanup_queue(hba[i]->queue);
	release_io_mem(hba[i]);
	free_hba(i);
}
Ejemplo n.º 21
0
/*
* Module init/exit
*/
static int __init venus_ir_wo_init_module(void) {
    int result;

    /* MKDEV */
    dev_venus_ir_wo = MKDEV(VENUS_IR_WO_MAJOR, VENUS_IR_WO_MINOR_RP);

    /* Request Device Number */
    result = register_chrdev_region(dev_venus_ir_wo, VENUS_IR_WO_DEVICE_NUM, "venus_ir_wo");
    if (result < 0) {
        printk(KERN_WARNING "venus_ir_wo: can't register device number.\n");
        goto fail_alloc_dev;
    }

    venus_ir_wo_devs = platform_device_register_simple("VenusIR_W", -1, NULL, 0);
    if (driver_register(&venus_ir_wo_driver) != 0)
        goto fail_device_register;

    /* create sysfs files */
    device_create_file(&venus_ir_wo_devs->dev, &dev_attr_fakekey);

    /* Char Device Registration */
    venus_ir_wo_cdev = cdev_alloc();
    if (venus_ir_wo_cdev == NULL) {
        printk(KERN_ERR "venus_ir_wo: can't allocate cdev\n");
        result = -ENOMEM;
        goto fail_cdev_alloc;
    }
    venus_ir_wo_cdev->ops = &venus_ir_wo_fops;
    if (cdev_add(venus_ir_wo_cdev, MKDEV(VENUS_IR_WO_MAJOR, VENUS_IR_WO_MINOR_RP), 1)) {
        printk(KERN_ERR "venus_ir_wo: can't add character device\n");
        result = -ENOMEM;
        goto fail_cdev_add;
    }

    /* use devfs to create device file */
    devfs_mk_cdev(MKDEV(VENUS_IR_WO_MAJOR, VENUS_IR_WO_MINOR_RP), S_IFCHR|S_IRUSR|S_IWUSR, VENUS_IR_WO_DEVICE_FILE);

    /* rest of the init */
    result = venus_ir_wo_init();
    if (result)
        goto fail_init;

    printk(KERN_INFO "venus_ir_wo: driver loaded\n");
    return 0;	/* success */

fail_init:
    devfs_remove(VENUS_IR_WO_DEVICE_FILE);
fail_cdev_add:
    cdev_del(venus_ir_wo_cdev);
fail_cdev_alloc:
    driver_unregister(&venus_ir_wo_driver);
    device_remove_file(&venus_ir_wo_devs->dev, &dev_attr_fakekey);
fail_device_register:
    if (!IS_ERR(venus_ir_wo_devs))
        platform_device_unregister(venus_ir_wo_devs);
    unregister_chrdev_region(dev_venus_ir_wo, VENUS_IR_WO_DEVICE_NUM);
fail_alloc_dev:
    return result;
}
Ejemplo n.º 22
0
static void deinit_vfc_device(struct vfc_dev *dev)
{
	if(dev == NULL)
		return;
	devfs_remove("vfc/%d", dev->instance);
	sbus_iounmap((unsigned long)dev->regs, sizeof(struct vfc_regs));
	kfree(dev);
}
Ejemplo n.º 23
0
static void jtag_remove(struct device_d *pdev)
{
	struct jtag_info *info = (struct jtag_info *) pdev->priv;

	devfs_remove(&info->cdev);
	pdev->priv = NULL;
	free(info);
	dev_notice(pdev, "Device removed\n");
}
Ejemplo n.º 24
0
void ubi_cdev_remove(struct ubi_device *ubi)
{
	struct cdev *cdev = &ubi->cdev;

	ubi_msg(ubi, "removing %s", cdev->name);

	devfs_remove(cdev);
	kfree(cdev->name);
}
Ejemplo n.º 25
0
/*------------------------------------------------------------------
 * Func : mcp_module_exit
 *
 * Desc : mcp module exit function
 *
 * Parm : N/A
 *         
 * Retn : N/A
 *------------------------------------------------------------------*/
static void __exit mcp_module_exit(void)
{    	    
    platform_device_unregister(mcp_device);

    cdev_del(&mcp_dev);
    devfs_remove(MCP_DEV_FILE_NAME);
    unregister_chrdev_region(devno, 1);            
    mcp_uninit();
}
Ejemplo n.º 26
0
static void __exit mbd_cleanup(void)
{
	devfs_remove("mambobd");

	if (unregister_blkdev(MAJOR_NR, "mbd") != 0)
		printk("mbd: cleanup_module failed\n");
	else
		printk("mbd: module cleaned up.\n");
}
Ejemplo n.º 27
0
void ubi_cdev_remove(struct ubi_device *ubi)
{
	struct cdev *cdev = &ubi->cdev;

	printf("removing %s\n", cdev->name);

	devfs_remove(cdev);
	kfree(cdev->name);
}
Ejemplo n.º 28
0
/**
 * Unload the module.
 */
static void __exit VBoxDrvLinuxUnload(void)
{
    int                 rc;
    Log(("VBoxDrvLinuxUnload\n"));
    NOREF(rc);

#ifdef VBOX_WITH_SUSPEND_NOTIFICATION
    platform_device_unregister(&gPlatformDevice);
    platform_driver_unregister(&gPlatformDriver);
#endif

    /*
     * I Don't think it's possible to unload a driver which processes have
     * opened, at least we'll blindly assume that here.
     */
#ifdef CONFIG_VBOXDRV_AS_MISC
    rc = misc_deregister(&gMiscDeviceUsr);
    if (rc < 0)
    {
        Log(("misc_deregister failed with rc=%#x on vboxdrvu\n", rc));
    }
    rc = misc_deregister(&gMiscDeviceSys);
    if (rc < 0)
    {
        Log(("misc_deregister failed with rc=%#x on vboxdrv\n", rc));
    }
#else  /* !CONFIG_VBOXDRV_AS_MISC */
# ifdef CONFIG_DEVFS_FS
    /*
     * Unregister a device entry
     */
    devfs_remove(DEVICE_NAME_USR);
    devfs_remove(DEVICE_NAME_SYS);
# endif /* devfs */
    unregister_chrdev(g_iModuleMajorUsr, DEVICE_NAME_USR);
    unregister_chrdev(g_iModuleMajorSys, DEVICE_NAME_SYS);
#endif /* !CONFIG_VBOXDRV_AS_MISC */

    /*
     * Destroy GIP, delete the device extension and terminate IPRT.
     */
    supdrvDeleteDevExt(&g_DevExt);
    RTR0TermForced();
}
Ejemplo n.º 29
0
static int del_mtdoob_device(struct mtd_info *mtd, void **priv)
{
	struct mtdoob *mtdoob;

	mtdoob = *priv;
	devfs_remove(&mtdoob->cdev);
	free(mtdoob);

	return 0;
}
Ejemplo n.º 30
0
static int del_mtdraw_device(struct mtd_info *mtd, void **priv)
{
	struct mtdraw *mtdraw;

	mtdraw = *priv;
	devfs_remove(&mtdraw->cdev);
	free(mtdraw);

	return 0;
}