Esempio n. 1
13
File: scsi.c Progetto: PyroOS/Pyro
void scsi_remove_host( SCSI_host_s * psHost )
{
	/* Look for all devices that belong to this host */
	SCSI_device_s *psDevice = g_psFirstDevice;
	SCSI_device_s *psPrev = g_psFirstDevice;
	SCSI_device_s *psPartition;

restart:
	psDevice = g_psFirstDevice;
	psPrev = g_psFirstDevice;

	while( psDevice )
	{
		if( psDevice->psHost == psHost )
		{
			/* First remove all partitions */
			for( psPartition = psDevice->psFirstPartition; psPartition != NULL; psPartition = psPartition->psNext )
			{
				printk( "SCSI: Removing partition %s\n", psPartition->zName );
				if( atomic_read( &psPartition->nOpenCount ) > 0 )
				{
					printk( "SCSI: Warning: Device still opened\n" );
				}
				delete_device_node( psPartition->nNodeHandle );
			}
			/* Then the raw device */
			printk( "SCSI: Removing device %s\n", psDevice->zName );
			if( atomic_read( &psDevice->nOpenCount ) > 0 )
			{
				printk( "SCSI: Warning: Device still opened\n" );
			}
			delete_device_node( psDevice->nNodeHandle );

			g_nIDTable[psDevice->nID] = false;

			release_device( psDevice->nDeviceHandle );
			unregister_device( psDevice->nDeviceHandle );
			kfree( psDevice->pDataBuffer );
			if( psPrev == psDevice )
			{
				g_psFirstDevice = psDevice->psNext;
			}
			else
			{
				psPrev->psNext = psDevice->psNext;
			}
			kfree( psDevice );
			goto restart;
		}
		psPrev = psDevice;
		psDevice = psDevice->psNext;
	}
}
Esempio n. 2
0
static int __init alsa_seq_oss_init(void)
{
	int rc;

	if ((rc = register_device()) < 0)
		goto error;
	if ((rc = register_proc()) < 0) {
		unregister_device();
		goto error;
	}
	if ((rc = snd_seq_oss_create_client()) < 0) {
		unregister_proc();
		unregister_device();
		goto error;
	}

	rc = snd_seq_driver_register(&seq_oss_synth_driver);
	if (rc < 0) {
		snd_seq_oss_delete_client();
		unregister_proc();
		unregister_device();
		goto error;
	}

	/* success */
	snd_seq_oss_synth_init();

 error:
	return rc;
}
Esempio n. 3
0
static void __exit alsa_seq_oss_exit(void)
{
	snd_seq_driver_unregister(&seq_oss_synth_driver);
	snd_seq_oss_delete_client();
	unregister_proc();
	unregister_device();
}
Esempio n. 4
0
int remove_untached_device(int i, int j)
{
	int n;
	IDEV *p;
	/* find which device it belongs */
	n = find_device_file_in_use(i, j);
	if (n == -1)	/* not found */
		return -1;

	p = dev_list.dev[n].idev;

	/* added 3-26: 
	   before we try to obtain the device lock, we have to tell
	   everyone using the device, that "THE DEVICE IS DYING!!"*/
	idev_set_status(p, UNTACHED);
	while (idev_get_status(p) != DEAD) 
		/* wait the response from daemon thread */
		sleep(1);

	/* unregister device from list */
	if (unregister_device(n))
		return -2;

	/* remove that device, and it's related devices */
	return 0;
}
Esempio n. 5
0
bool_t unregister_clocksource(struct clocksource_t * cs)
{
	struct device_t * dev;
	struct clocksource_t * c;
	irq_flags_t flags;

	if(!cs || !cs->name || !cs->read)
		return FALSE;

	dev = search_device(cs->name, DEVICE_TYPE_CLOCKSOURCE);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	timer_cancel(&cs->keeper.timer);
	if(__clocksource == cs)
	{
		if(!(c = search_first_clocksource()))
			c = &__cs_dummy;

		spin_lock_irqsave(&__clocksource_lock, flags);
		__clocksource = c;
		spin_unlock_irqrestore(&__clocksource_lock, flags);
	}

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}
/****************************************************************************
NAME
	connectionAuthDeleteDevice

FUNCTION
	This function is called to remove a trusted device from the persistent 
    trusted device list.  A flag indicating if the device was successfully removed 
    is returned.
*/
uint16 connectionAuthDeleteDevice(const bdaddr* peer_bd_addr)
{
    /* Holds the position of a device in the trusted device list (TDL) */
	uint16		position = 0;

    /* Defines the order or the device in the TDI */
	uint16		order = 0;

    /* Flag to indicate if the device was deleted */
    uint16      deleted = FALSE;

	
    /* Search the trusted device list for the specified device */
	position = find_trusted_device(peer_bd_addr);
	
	/* If the device is in the TDL */
	if(position)
	{
        /* Find this device in the TDI */
		order = search_trusted_device_index(position);

        /* Delete it and re-order TDI */
        (void) delete_from_trusted_device_index(order, NO_DEVICES_TO_MANAGE);

        /* Delete device from TDL */
        (void) PsStore(TRUSTED_DEVICE_LIST_BASE + position - 1, NULL, 0);

        /* Remove from the BlueStack security datatbase */
		unregister_device(peer_bd_addr);

		deleted = TRUE;	
	}
	return deleted;
}
Esempio n. 7
0
static void __exit alsa_seq_oss_exit(void)
{
    snd_seq_device_unregister_driver(SNDRV_SEQ_DEV_ID_OSS);
    snd_seq_oss_delete_client();
    unregister_proc();
    unregister_device();
}
Esempio n. 8
0
bool_t unregister_console(struct console_t * console)
{
	struct device_t * dev;
	struct console_t * c;
	irq_flags_t flags;

	if(!console || !console->name)
		return FALSE;

	dev = search_device(console->name, DEVICE_TYPE_CONSOLE);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	if(__console == console)
	{
		if(!(c = search_first_console()))
			c = &__console_dummy;

		spin_lock_irqsave(&__console_lock, flags);
		__console = c;
		spin_unlock_irqrestore(&__console_lock, flags);
	}

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}
Esempio n. 9
0
bool_t unregister_watchdog(struct watchdog_t * watchdog)
{
	struct device_t * dev;
	struct watchdog_t * driver;

	if(!watchdog || !watchdog->name)
		return FALSE;

	dev = search_device_with_type(watchdog->name, DEVICE_TYPE_WATCHDOG);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	driver = (struct watchdog_t *)(dev->driver);
	if(driver)
	{
		if(driver->set)
			(driver->set)(driver, 0);

		if(driver->exit)
			(driver->exit)(driver);
	}

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}
Esempio 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;
	unregister_device(&vol->dev);
	devfs_remove(&vol->cdev);
}
Esempio n. 11
0
void mdiobus_unregister(struct mii_bus *bus)
{
	int i;

	for (i = 0; i < PHY_MAX_ADDR; i++) {
		if (bus->phy_map[i])
			unregister_device(&bus->phy_map[i]->dev);
		bus->phy_map[i] = NULL;
	}
}
Esempio n. 12
0
void dundee_device_unregister(struct dundee_device *device)
{
    DBG("%p", device);

    unregister_device(device);

    device->registered = FALSE;

    g_hash_table_remove(device_hash, device->path);
}
Esempio n. 13
0
/**
 * ubi_remove_volume - remove volume.
 * @desc: volume descriptor
 * @no_vtbl: do not change volume table if not zero
 *
 * This function removes volume described by @desc. The volume has to be opened
 * in "exclusive" mode. Returns zero in case of success and a negative error
 * code in case of failure. The caller has to have the @ubi->device_mutex
 * locked.
 */
int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
{
	struct ubi_volume *vol = desc->vol;
	struct ubi_device *ubi = vol->ubi;
	int i, err, vol_id = vol->vol_id, reserved_pebs = vol->reserved_pebs;

	dbg_gen("remove device %d, volume %d", ubi->ubi_num, vol_id);
	ubi_assert(desc->mode == UBI_EXCLUSIVE);
	ubi_assert(vol == ubi->volumes[vol_id]);

	if (ubi->ro_mode)
		return -EROFS;

	if (vol->ref_count > 1) {
		/*
		 * The volume is busy, probably someone is reading one of its
		 * sysfs files.
		 */
		err = -EBUSY;
		goto out_unlock;
	}
	ubi->volumes[vol_id] = NULL;

	if (!no_vtbl) {
		err = ubi_change_vtbl_record(ubi, vol_id, NULL);
		if (err)
			goto out_err;
	}

	for (i = 0; i < vol->reserved_pebs; i++) {
		err = ubi_eba_unmap_leb(ubi, vol, i);
		if (err)
			goto out_err;
	}

	unregister_device(&vol->dev);
	devfs_remove(&vol->cdev);

	ubi->rsvd_pebs -= reserved_pebs;
	ubi->avail_pebs += reserved_pebs;
	ubi_update_reserved(ubi);
	ubi->vol_count -= 1;

	ubi_volume_notify(ubi, vol, UBI_VOLUME_REMOVED);
	if (!no_vtbl)
		self_check_volumes(ubi);

	return err;

out_err:
	ubi_err(ubi, "cannot remove volume %d, error %d", vol_id, err);
	ubi->volumes[vol_id] = vol;
out_unlock:
	return err;
}
Esempio n. 14
0
void clear_dead_modules(void)
{
	int i;
	for (i = 0; i < MAX_DEVICE_NO; i++) {
		IDEV *p = dev_list.dev[i].idev;
		if (dev_list.dev[i].active && p->status == DEAD) {
			dm_log(NULL, "device[%d] %s type %s is dead, freeing the device.", 
					i, p->name, dev_model[p->type].name);
			unregister_device(i);
		}
	}
}
Esempio n. 15
0
void ubi_volume_cdev_remove(struct ubi_volume *vol)
{
	struct cdev *cdev = &vol->cdev;
	struct ubi_volume_cdev_priv *priv = cdev->priv;

	list_del(&vol->list);

	devfs_remove(cdev);
	unregister_device(&vol->dev);
	kfree(cdev->name);
	kfree(priv);
}
Esempio n. 16
0
int console_unregister(struct console_device *cdev)
{
	struct device_d *dev = &cdev->class_dev;
	int status;

	list_del(&cdev->list);
	if (list_empty(&console_list))
		initialized = CONSOLE_UNINITIALIZED;

	status = unregister_device(dev);
	if (!status)
		memset(cdev, 0, sizeof(*cdev));
	return status;
}
Esempio n. 17
0
int del_mtd_device (struct mtd_info *mtd)
{
	struct mtddev_hook *hook;

	list_for_each_entry(hook, &mtd_register_hooks, hook)
		if (hook->del_mtd_device)
			hook->del_mtd_device(mtd, &hook->priv);

	devfs_remove(&mtd->cdev);
	unregister_device(&mtd->class_dev);
	free(mtd->param_size.value);
	free(mtd->cdev.name);
	return 0;
}
Esempio n. 18
0
static int __init alsa_seq_oss_init(void)
{
    int rc;
    static struct snd_seq_dev_ops ops = {
        snd_seq_oss_synth_register,
        snd_seq_oss_synth_unregister,
    };

    snd_seq_autoload_lock();
    if ((rc = register_device()) < 0)
        goto error;
    if ((rc = register_proc()) < 0) {
        unregister_device();
        goto error;
    }
    if ((rc = snd_seq_oss_create_client()) < 0) {
        unregister_proc();
        unregister_device();
        goto error;
    }

    if ((rc = snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_OSS, &ops,
              sizeof(struct snd_seq_oss_reg))) < 0) {
        snd_seq_oss_delete_client();
        unregister_proc();
        unregister_device();
        goto error;
    }

    /* success */
    snd_seq_oss_synth_init();

error:
    snd_seq_autoload_unlock();
    return rc;
}
Esempio n. 19
0
void usbnet_disconnect(struct usb_device *usbdev)
{
	struct usbnet *undev = usbdev->drv_data;
	struct eth_device *edev = &undev->edev;
	struct driver_info *info;

	eth_unregister(edev);
	unregister_device(&edev->dev);

	info = undev->driver_info;
	if (info->unbind)
		info->unbind(undev);

	free(undev);
}
/****************************************************************************
NAME
	connectionAuthDeleteAllDevices

FUNCTION
	This function is called to remove all trusted devices from the persistent 
    trusted device list.  A flag indicating if all the devices were successfully 
	removed is returned.
*/
uint16 connectionAuthDeleteAllDevice(uint16 ps_base)
{
	/* Flag to indicate if the devices were deleted */
    uint16      				deleted = FALSE;
	
	/* Trusted device list record index */
	uint16						rec = 0;
	
	/* Trusted device record */
	TrustedDeviceRecordType     record;
	
	/* trusted device index */
	TrustedDeviceIndexType		tdi;
	
	/* Loop through list of trusted devices */
	for(rec = 0; rec < NO_DEVICES_TO_MANAGE; rec++)
	{
		if(PsRetrieve(TRUSTED_DEVICE_LIST_BASE + rec, &record, sizeof(TrustedDeviceRecordType)))
		{
			/* Unregister with Bluestack security manager */
			unregister_device(&record.bd_addr);
			
			/* Delete entry from TDL */
			(void)PsStore(TRUSTED_DEVICE_LIST_BASE + rec, NULL, 0);

			deleted = TRUE;
		}

		/* Delete any associated attribute data */
		if(ps_base)
		{
			(void)PsStore(ps_base + rec, NULL, 0);
		}
	}
	
	/* Delete TDI */
	if(deleted)
	{
		memset(&tdi, 0, sizeof(TrustedDeviceIndexType));
		(void)PsStore(TRUSTED_DEVICE_INDEX, &tdi, sizeof(tdi));
	}
	
	return deleted;
}
Esempio n. 21
0
/*
 * unregister char device from chrdev_list
 */
bool_t unregister_chrdev(const char * name)
{
	struct device * device;

	if(!name)
		return FALSE;

	device = search_device(name);
	if(!device && device->type == CHAR_DEVICE)
		return FALSE;

	if(unregister_device(device))
	{
		free(device);
		return TRUE;
	}

	return FALSE;
}
Esempio n. 22
0
File: input.c Progetto: xboot/xboot
bool_t unregister_input(struct input_t * input)
{
	struct device_t * dev;

	if(!input || !input->name)
		return FALSE;

	dev = search_device(input->name, DEVICE_TYPE_INPUT);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}
Esempio n. 23
0
bool_t unregister_battery(struct battery_t * bat)
{
	struct device_t * dev;

	if(!bat || !bat->name)
		return FALSE;

	dev = search_device_with_type(bat->name, DEVICE_TYPE_BATTERY);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}
Esempio n. 24
0
bool_t unregister_i2c(struct i2c_t * i2c)
{
	struct device_t * dev;

	if(!i2c || !i2c->name)
		return FALSE;

	dev = search_device(i2c->name, DEVICE_TYPE_I2C);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}
Esempio n. 25
0
File: clk.c Progetto: xboot/xboot
bool_t unregister_clk(struct clk_t * clk)
{
	struct device_t * dev;

	if(!clk || !clk->name)
		return FALSE;

	dev = search_device(clk->name, DEVICE_TYPE_CLK);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}
Esempio n. 26
0
bool_t unregister_led(struct led_t * led)
{
	struct device_t * dev;

	if(!led || !led->name)
		return FALSE;

	dev = search_device(led->name, DEVICE_TYPE_LED);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}
Esempio n. 27
0
bool_t unregister_stepper(struct stepper_t * m)
{
	struct device_t * dev;

	if(!m || !m->name)
		return FALSE;

	dev = search_device(m->name, DEVICE_TYPE_STEPPER);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}
Esempio n. 28
0
bool_t unregister_buzzer(struct buzzer_t * buzzer)
{
	struct device_t * dev;

	if(!buzzer || !buzzer->name)
		return FALSE;

	dev = search_device(buzzer->name, DEVICE_TYPE_BUZZER);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}
Esempio n. 29
0
bool_t unregister_rtc(struct rtc_t * rtc)
{
	struct device_t * dev;

	if(!rtc || !rtc->name)
		return FALSE;

	dev = search_device(rtc->name, DEVICE_TYPE_RTC);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}
Esempio n. 30
0
bool_t unregister_block(struct block_t * blk)
{
	struct device_t * dev;

	if(!blk || !blk->name)
		return FALSE;

	dev = search_device(blk->name, DEVICE_TYPE_BLOCK);
	if(!dev)
		return FALSE;

	if(!unregister_device(dev))
		return FALSE;

	kobj_remove_self(dev->kobj);
	free(dev->name);
	free(dev);
	return TRUE;
}