Example #1
0
static void __init zfcp_init_device_setup(char *devstr)
{
	char *token;
	char *str, *str_saved;
	char busid[ZFCP_BUS_ID_SIZE];
	u64 wwpn, lun;

	/* duplicate devstr and keep the original for sysfs presentation*/
	str_saved = kstrdup(devstr, GFP_KERNEL);
	str = str_saved;
	if (!str)
		return;

	token = strsep(&str, ",");
	if (!token || strlen(token) >= ZFCP_BUS_ID_SIZE)
		goto err_out;
	strncpy(busid, token, ZFCP_BUS_ID_SIZE);

	token = strsep(&str, ",");
	if (!token || strict_strtoull(token, 0, (unsigned long long *) &wwpn))
		goto err_out;

	token = strsep(&str, ",");
	if (!token || strict_strtoull(token, 0, (unsigned long long *) &lun))
		goto err_out;

	kfree(str_saved);
	zfcp_init_device_configure(busid, wwpn, lun);
	return;

err_out:
	kfree(str_saved);
	pr_err("%s is not a valid SCSI device\n", devstr);
}
Example #2
0
int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port)
{
    struct ib_smp *in_mad  = NULL;
    struct ib_smp *out_mad = NULL;
    int err = -ENOMEM;
    u16 packet_error;

    in_mad  = kzalloc(sizeof(*in_mad), GFP_KERNEL);
    out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
    if (!in_mad || !out_mad)
        goto out;

    init_query_mad(in_mad);
    in_mad->attr_id = MLX5_ATTR_EXTENDED_PORT_INFO;
    in_mad->attr_mod = cpu_to_be32(port);

    err = mlx5_MAD_IFC(dev, 1, 1, 1, NULL, NULL, in_mad, out_mad);

    packet_error = be16_to_cpu(out_mad->status);

    dev->mdev.caps.ext_port_cap[port - 1] = (!err && !packet_error) ?
                                            MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO : 0;

out:
    kfree(in_mad);
    kfree(out_mad);
    return err;
}
Example #3
0
/*
 * Destroy an RPC service. Should be called with appropriate locking to
 * protect the sv_nrthreads, sv_permsocks and sv_tempsocks.
 */
void
svc_destroy(struct svc_serv *serv)
{
	dprintk("svc: svc_destroy(%s, %d)\n",
				serv->sv_program->pg_name,
				serv->sv_nrthreads);

	if (serv->sv_nrthreads) {
		if (--(serv->sv_nrthreads) != 0) {
			svc_sock_update_bufs(serv);
			return;
		}
	} else
		printk("svc_destroy: no threads for serv=%p!\n", serv);

	del_timer_sync(&serv->sv_temptimer);

	/*
	 * The last user is gone and thus all sockets have to be destroyed to
	 * the point. Check this.
	 */
	BUG_ON(!list_empty(&serv->sv_permsocks));
	BUG_ON(!list_empty(&serv->sv_tempsocks));

	cache_clean_deferred(serv);

	if (svc_serv_is_pooled(serv))
		svc_pool_map_put();

	kfree(serv->sv_pools);
	kfree(serv);
}
Example #4
0
void curse_free_alloc (struct task_struct *h, void *mem_to_free)
{
	/*Must be called with a pointer allocated with curse_get_alloc, else the system may get destalibized.*/
	unsigned long tfs;
	struct task_curse_struct *hi;
	struct curse_inside_data *prev, *cur;

	hi = &(h->curse_data);
	spin_lock_irqsave(&((h->curse_data).protection), tfs);
	cur = (hi->use_by_interface).head;
	prev = cur;
	if (prev !=NULL) {
		while (cur != NULL) {
			/*Search for proper data pointer*/
			if (cur->elem == mem_to_free)
				break;
			prev = cur;
			cur = cur->next;
		}
		if (cur == NULL)
			goto out;
		/*Free data (and remove node too)*/
		kfree(cur->elem);
		if (((hi->use_by_interface).head) == cur)
			(hi->use_by_interface).head = (hi->use_by_interface).head->next;
		else
			prev->next = cur->next;
		kfree(cur);
	}
out:
	spin_unlock_irqrestore(&((h->curse_data).protection), tfs);
}
Example #5
0
struct semaphore *
sem_create(const char *name, int initial_count)
{
        struct semaphore *sem;

        KASSERT(initial_count >= 0);

        sem = kmalloc(sizeof(struct semaphore));
        if (sem == NULL) {
                return NULL;
        }

        sem->sem_name = kstrdup(name);
        if (sem->sem_name == NULL) {
                kfree(sem);
                return NULL;
        }

	sem->sem_wchan = wchan_create(sem->sem_name);
	if (sem->sem_wchan == NULL) {
		kfree(sem->sem_name);
		kfree(sem);
		return NULL;
	}

	spinlock_init(&sem->sem_lock);
        sem->sem_count = initial_count;

        return sem;
}
static int __devexit gpio_keys_remove(struct platform_device *pdev)
{
	struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev);
	struct input_dev *input = ddata->input;
	int i;

	sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group);

	device_init_wakeup(&pdev->dev, 0);

	for (i = 0; i < ddata->n_buttons; i++)
		gpio_remove_key(&ddata->data[i]);

	input_unregister_device(input);

#ifdef CONFIG_SENSORS_HALL
	wake_lock_destroy(&ddata->flip_wake_lock);
#endif
	/*
	 * If we had no platform_data, we allocated buttons dynamically, and
	 * must free them here. ddata->data[0].button is the pointer to the
	 * beginning of the allocated array.
	 */
	if (!pdev->dev.platform_data)
		kfree(ddata->data[0].button);

	kfree(ddata);

	return 0;
}
Example #7
0
File: inode.c Project: kprog/linux
static void ncp_put_super(struct super_block *sb)
{
	struct ncp_server *server = NCP_SBP(sb);

	ncp_lock_server(server);
	ncp_disconnect(server);
	ncp_unlock_server(server);

	ncp_stop_tasks(server);

#ifdef CONFIG_NCPFS_NLS
	/* unload the NLS charsets */
	unload_nls(server->nls_vol);
	unload_nls(server->nls_io);
#endif /* CONFIG_NCPFS_NLS */
	mutex_destroy(&server->rcv.creq_mutex);
	mutex_destroy(&server->root_setup_lock);
	mutex_destroy(&server->mutex);

	if (server->info_filp)
		fput(server->info_filp);
	fput(server->ncp_filp);
	kill_pid(server->m.wdog_pid, SIGTERM, 1);
	put_pid(server->m.wdog_pid);

	bdi_destroy(&server->bdi);
	kfree(server->priv.data);
	kfree(server->auth.object_name);
	vfree(server->rxbuf);
	vfree(server->txbuf);
	vfree(server->packet);
	sb->s_fs_info = NULL;
	kfree(server);
}
Example #8
0
static int s3c_csis_probe(struct platform_device *pdev)
{
	struct s3c_platform_csis *pdata;
	struct resource *res;
	int ret = 0;

	ret = s3c_csis_set_info(pdev);

	s3c_csis[pdev->id]->dev = &pdev->dev;

	pdata = to_csis_plat(&pdev->dev);
	if (pdata->cfg_gpio)
		pdata->cfg_gpio();

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res) {
		err("failed to get io memory region\n");
		ret = -ENOENT;
		goto err_info;
	}

	s3c_csis[pdev->id]->regs_res = request_mem_region(res->start,
				resource_size(res), pdev->name);
	if (!s3c_csis[pdev->id]->regs_res) {
		err("failed to request io memory region\n");
		ret = -ENOENT;
		goto err_info;
	}

	/* ioremap for register block */
	s3c_csis[pdev->id]->regs = ioremap(res->start, resource_size(res));
	if (!s3c_csis[pdev->id]->regs) {
		err("failed to remap io region\n");
		ret = -ENXIO;
		goto err_req_region;
	}

	/* irq */
	s3c_csis[pdev->id]->irq = platform_get_irq(pdev, 0);
	ret = request_irq(s3c_csis[pdev->id]->irq, s3c_csis_irq, IRQF_DISABLED,
			s3c_csis[pdev->id]->name, pdev);
	if (ret) {
		err("request_irq failed\n");
		goto err_regs_unmap;
	}

	info("Samsung MIPI-CSIS%d driver probed successfully\n", pdev->id);

	return 0;

err_regs_unmap:
	iounmap(s3c_csis[pdev->id]->regs);
err_req_region:
	release_resource(s3c_csis[pdev->id]->regs_res);
	kfree(s3c_csis[pdev->id]->regs_res);
err_info:
	kfree(s3c_csis[pdev->id]);

	return ret;
}
Example #9
0
static int rc32434_remove(struct platform_device *pdev)
{
	struct korina_device *bif = (struct korina_device *) pdev->dev.platform_data;
	
	if (bif->dev != NULL) {
		struct rc32434_local *lp = (struct rc32434_local *)bif->dev->priv;
		if (lp != NULL) {
			if (lp->eth_regs)
				iounmap((void*)lp->eth_regs);
			if (lp->rx_dma_regs)
				iounmap((void*)lp->rx_dma_regs);
			if (lp->tx_dma_regs)
				iounmap((void*)lp->tx_dma_regs);
			if (lp->td_ring)
				kfree((void*)KSEG0ADDR(lp->td_ring));
			
#ifdef RC32434_PROC_DEBUG
			if (lp->ps) {
				remove_proc_entry(bif->name, proc_net);
			}
#endif
			kfree(lp);
		}
		
		platform_set_drvdata(pdev, NULL);
		unregister_netdev(bif->dev);
		free_netdev(bif->dev);
		kfree(bif->dev);
	}
	return 0;
}
Example #10
0
static void fjes_hw_cleanup(struct fjes_hw *hw)
{
	int epidx;

	if (!hw->ep_shm_info)
		return;

	fjes_hw_free_shared_status_region(hw);

	kfree(hw->hw_info.req_buf);
	hw->hw_info.req_buf = NULL;

	kfree(hw->hw_info.res_buf);
	hw->hw_info.res_buf = NULL;

	for (epidx = 0; epidx < hw->max_epid ; epidx++) {
		if (epidx == hw->my_epid)
			continue;
		fjes_hw_free_epbuf(&hw->ep_shm_info[epidx].tx);
		fjes_hw_free_epbuf(&hw->ep_shm_info[epidx].rx);
	}

	kfree(hw->ep_shm_info);
	hw->ep_shm_info = NULL;
}
Example #11
0
static int __devexit brcmnanddrv_remove(struct platform_device *pdev)
{
	struct brcmnand_info *info = dev_get_drvdata(&pdev->dev);
	//struct resource *res = pdev->resource;
	//unsigned long size = res->end - res->start + 1;

	dev_set_drvdata(&pdev->dev, NULL);

	if (info) {
#ifdef CONFIG_MTD_PARTITIONS
		if (info->parts)
			del_mtd_partitions(&info->mtd);
		else
			del_mtd_device(&info->mtd);
#else
		del_mtd_device(&info->mtd);
#endif

		brcmnand_release(&info->mtd);
		//release_mem_region(res->start, size);
		//iounmap(info->brcmnand.base);
		kfree(gPageBuffer);
		kfree(info);
	}

	return 0;
}
static ssize_t driver_override_store(struct device *_dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{
	struct amba_device *dev = to_amba_device(_dev);
	char *driver_override, *old = dev->driver_override, *cp;

	if (count > PATH_MAX)
		return -EINVAL;

	driver_override = kstrndup(buf, count, GFP_KERNEL);
	if (!driver_override)
		return -ENOMEM;

	cp = strchr(driver_override, '\n');
	if (cp)
		*cp = '\0';

	if (strlen(driver_override)) {
		dev->driver_override = driver_override;
	} else {
	       kfree(driver_override);
	       dev->driver_override = NULL;
	}

	kfree(old);

	return count;
}
static int bridge_release(struct inode *ip, struct file *filp)
{
	int status = 0;
	struct process_context *pr_ctxt;

	if (!filp->private_data) {
		status = -EIO;
		goto err;
	}

	pr_ctxt = filp->private_data;
	flush_signals(current);
	drv_remove_all_resources(pr_ctxt);
	proc_detach(pr_ctxt);
	kfree(pr_ctxt->node_id);
	kfree(pr_ctxt->stream_id);
	kfree(pr_ctxt);

	filp->private_data = NULL;

err:
#ifdef CONFIG_TIDSPBRIDGE_RECOVERY
	if (!atomic_dec_return(&bridge_cref))
		complete(&bridge_comp);
#endif
	return status;
}
Example #14
0
/*
 * sfs_getdirentry - according to the iob->io_offset, calculate the dir entry's slot in disk block,
                     get dir entry content from the disk
 */
static int
sfs_getdirentry(struct inode *node, struct iobuf *iob) {
    struct sfs_disk_entry *entry;
    if ((entry = kmalloc(sizeof(struct sfs_disk_entry))) == NULL) {
        return -E_NO_MEM;
    }

    struct sfs_fs *sfs = fsop_info(vop_fs(node), sfs);
    struct sfs_inode *sin = vop_info(node, sfs_inode);

    int ret, slot;
    off_t offset = iob->io_offset;
    if (offset < 0 || offset % sfs_dentry_size != 0) {
        kfree(entry);
        return -E_INVAL;
    }
    if ((slot = offset / sfs_dentry_size) > sin->din->blocks) {
        kfree(entry);
        return -E_NOENT;
    }
    lock_sin(sin);
    if ((ret = sfs_getdirentry_sub_nolock(sfs, sin, slot, entry)) != 0) {
        unlock_sin(sin);
        goto out;
    }
    unlock_sin(sin);
    ret = iobuf_move(iob, entry->name, sfs_dentry_size, 1, NULL);
out:
    kfree(entry);
    return ret;
}
/**
 * avc_dump_query - Display a SID pair and a class in human-readable form.
 * @ssid: source security identifier
 * @tsid: target security identifier
 * @tclass: target security class
 */
static void avc_dump_query(struct audit_buffer *ab, u32 ssid, u32 tsid, u16 tclass)
{
	int rc;
	char *scontext;
	u32 scontext_len;

	rc = security_sid_to_context(ssid, &scontext, &scontext_len);
	if (rc)
		audit_log_format(ab, "ssid=%d", ssid);
	else {
		audit_log_format(ab, "scontext=%s", scontext);
		kfree(scontext);
	}

	rc = security_sid_to_context(tsid, &scontext, &scontext_len);
	if (rc)
		audit_log_format(ab, " tsid=%d", tsid);
	else {
		audit_log_format(ab, " tcontext=%s", scontext);
		kfree(scontext);
	}

	BUG_ON(tclass >= ARRAY_SIZE(secclass_map));
	audit_log_format(ab, " tclass=%s", secclass_map[tclass-1].name);
}
/* should be called late in the CPU removal sequence so that the stats
 * memory is still available in case someone tries to use it.
 */
static void cpufreq_stats_free_table(unsigned int cpu)
{
	struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, cpu);
	struct cpufreq_stats *prev_stat = per_cpu(prev_cpufreq_stats_table, cpu);
	size_t alloc_size;

	if (stat) {
		prev_stat = kzalloc(sizeof(*stat), GFP_KERNEL);
		if (!prev_stat) {
			pr_err("%s: prev_stat kzalloc failed\n", __func__);
			return;
		}

		memcpy(prev_stat, stat, sizeof(*stat));
		per_cpu(prev_cpufreq_stats_table, cpu) = prev_stat;

		alloc_size = stat->max_state * sizeof(int) + stat->max_state * sizeof(u64);
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
		alloc_size = stat->max_state * stat->max_state * sizeof(int);
#endif
		prev_stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
		if (!prev_stat->time_in_state) {
			pr_err("%s: prev_stat time_in_state kzalloc failed\n", __func__);
			kfree(prev_stat);
			return;
		}
		memcpy(prev_stat->time_in_state, stat->time_in_state, alloc_size);

		pr_debug("%s: Free stat table\n", __func__);
		kfree(stat->time_in_state);
		kfree(stat);
		per_cpu(cpufreq_stats_table, cpu) = NULL;
	}
}
Example #17
0
int kmalloc_test(void)
{
	char *p, *pp;

	if (init_kmalloc_area()) {
		printk("init_kmalloc_area is failed\n");
		return -1;
	}

	p = kmalloc(400);
	printk("ret is 0x%x\n", p);
	kfree(p);

	p = kmalloc(400);
	printk("ret is 0x%x\n", p);

	pp = kmalloc(400);
	printk("ret is 0x%x\n", pp);

	kfree(p);
	p = kmalloc(500);
	printk("ret is 0x%x\n", p);

	kfree(pp);
	p = kmalloc(500);
	printk("ret is 0x%x\n", p);

	return 0;
}
Example #18
0
static void omfs_put_super(struct super_block *sb)
{
	struct omfs_sb_info *sbi = OMFS_SB(sb);
	kfree(sbi->s_imap);
	kfree(sbi);
	sb->s_fs_info = NULL;
}
Example #19
0
void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev)
{
    struct sram_channel *sram_ch =
            dev->channels[VID_UPSTREAM_SRAM_CHANNEL_I].sram_channels;
    u32 tmp = 0;

    if (!dev->_is_running) {
        pr_info("No video file is currently running so return!\n");
        return;
    }
    /* Disable RISC interrupts */
    tmp = cx_read(sram_ch->int_msk);
    cx_write(sram_ch->int_msk, tmp & ~_intr_msk);

    /* Turn OFF risc and fifo enable */
    tmp = cx_read(sram_ch->dma_ctl);
    cx_write(sram_ch->dma_ctl, tmp & ~(FLD_VID_FIFO_EN | FLD_VID_RISC_EN));

    /* Clear data buffer memory */
    if (dev->_data_buf_virt_addr)
        memset(dev->_data_buf_virt_addr, 0, dev->_data_buf_size);

    dev->_is_running = 0;
    dev->_is_first_frame = 0;
    dev->_frame_count = 0;
    dev->_file_status = END_OF_FILE;

    kfree(dev->_irq_queues);
    dev->_irq_queues = NULL;

    kfree(dev->_filename);

    tmp = cx_read(VID_CH_MODE_SEL);
    cx_write(VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
}
Example #20
0
int
acpi_pci_bind_root (
    struct acpi_device	*device,
    struct acpi_pci_id	*id,
    struct pci_bus		*bus)
{
    int			result = 0;
    acpi_status		status = AE_OK;
    struct acpi_pci_data	*data = NULL;
    char			*pathname = NULL;
    struct acpi_buffer	buffer = {0, NULL};

    ACPI_FUNCTION_TRACE("acpi_pci_bind_root");

    pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
    if(!pathname)
        return_VALUE(-ENOMEM);
    memset(pathname, 0, ACPI_PATHNAME_MAX);

    buffer.length = ACPI_PATHNAME_MAX;
    buffer.pointer = pathname;

    if (!device || !id || !bus) {
        kfree(pathname);
        return_VALUE(-EINVAL);
    }

    data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
    if (!data) {
        kfree(pathname);
        return_VALUE(-ENOMEM);
    }
    memset(data, 0, sizeof(struct acpi_pci_data));

    data->id = *id;
    data->bus = bus;
    device->ops.bind = acpi_pci_bind;
    device->ops.unbind = acpi_pci_unbind;

    acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);

    ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to "
                      "%02x:%02x\n", pathname, id->segment, id->bus));

    status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
    if (ACPI_FAILURE(status)) {
        ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
                          "Unable to attach ACPI-PCI context to device %s\n",
                          pathname));
        result = -ENODEV;
        goto end;
    }

end:
    kfree(pathname);
    if (result != 0)
        kfree(data);

    return_VALUE(result);
}
static int __devexit matrix_keypad_remove(struct platform_device *pdev)
{
	struct matrix_keypad *keypad = platform_get_drvdata(pdev);
	const struct matrix_keypad_platform_data *pdata = keypad->pdata;
	int i;

	device_init_wakeup(&pdev->dev, 0);

	if (pdata->clustered_irq > 0) {
		free_irq(pdata->clustered_irq, keypad);
	} else {
		for (i = 0; i < pdata->num_row_gpios; i++)
			free_irq(gpio_to_irq(pdata->row_gpios[i]), keypad);
	}

	for (i = 0; i < pdata->num_row_gpios; i++)
		gpio_free(pdata->row_gpios[i]);

	for (i = 0; i < pdata->num_col_gpios; i++)
		gpio_free(pdata->col_gpios[i]);

	mutex_destroy(&keypad->lock);
	input_unregister_device(keypad->input_dev);
	platform_set_drvdata(pdev, NULL);
	kfree(keypad->keycodes);
	kfree(keypad);

	return 0;
}
Example #22
0
static int xfifo_dma_remove(struct platform_device *pdev)
{
        cdev_del(&xfifo_dma_dev->cdev);
 
        remove_proc_entry("driver/xfifo_dma", NULL);
 
        unregister_chrdev_region(xfifo_dma_dev->devno, 1);
 
        /* Unmap the I/O memory */
        if (xfifo_dma_dev->dev_virtaddr) {
                iounmap(xfifo_dma_dev->dev_virtaddr);
                release_mem_region(xfifo_dma_dev->dev_physaddr,
                        xfifo_dma_dev->dev_addrsize);
        }
 
        /* Free the PL330 buffer client data descriptors */
        if (xfifo_dma_dev->client_data) {
                kfree(xfifo_dma_dev->client_data);
        }
 
        if (xfifo_dma_dev) {
                kfree(xfifo_dma_dev);
        }
 
        return 0;
}
Example #23
0
struct cv *
cv_create(const char *name)
{
        struct cv *cv;

        cv = kmalloc(sizeof(struct cv));
        if (cv == NULL) {
                return NULL;
        }

        cv->cv_name = kstrdup(name);
        if (cv->cv_name==NULL) {
                kfree(cv);
                return NULL;
        }
        
        // add stuff here as needed
	        
		#if OPT_A1
		cv->cv_wchan = wchan_create(cv->cv_name);
        if (cv->cv_wchan == NULL) {
            kfree(cv->cv_name);
            kfree(cv);
            return NULL;
        }
		#endif


        return cv;
}
static int mon_close(struct inode *inode, struct file *filp)
{
	int rc, i;
	struct mon_private *monpriv = filp->private_data;

	/*
	 * Close IUCV connection and unregister
	 */
	if (monpriv->path) {
		rc = iucv_path_sever(monpriv->path, user_data_sever);
		if (rc)
			pr_warning("Disconnecting the z/VM *MONITOR system "
				   "service failed with rc=%i\n", rc);
		iucv_path_free(monpriv->path);
	}

	atomic_set(&monpriv->iucv_severed, 0);
	atomic_set(&monpriv->iucv_connected, 0);
	atomic_set(&monpriv->read_ready, 0);
	atomic_set(&monpriv->msglim_count, 0);
	monpriv->write_index  = 0;
	monpriv->read_index   = 0;
	dev_set_drvdata(monreader_device, NULL);

	for (i = 0; i < MON_MSGLIM; i++)
		kfree(monpriv->msg_array[i]);
	kfree(monpriv);
	clear_bit(MON_IN_USE, &mon_in_use);
	return 0;
}
static int __devexit pm8921_remove(struct platform_device *pdev)
{
	struct pm8xxx_drvdata *drvdata;
	struct pm8921 *pmic = NULL;
	int i;

	drvdata = platform_get_drvdata(pdev);
	if (drvdata)
		pmic = drvdata->pm_chip_data;
	if (pmic) {
		if (pmic->dev)
			mfd_remove_devices(pmic->dev);
		if (pmic->irq_chip)
			pm8xxx_irq_exit(pmic->irq_chip);
		if (pmic->mfd_regulators) {
			for (i = 0; i < ARRAY_SIZE(regulator_data); i++)
				mutex_destroy(&regulator_data[i].pc_lock);
		}
		kfree(pmic->mfd_regulators);
		kfree(pmic->regulator_cdata);
		kfree(pmic);
	}
	platform_set_drvdata(pdev, NULL);

	return 0;
}
Example #26
0
static u64 __devinit
add_io_space (struct pci_root_info *info, struct acpi_resource_address64 *addr)
{
	struct resource *resource;
	char *name;
	u64 base, min, max, base_port;
	unsigned int sparse = 0, space_nr, len;

	resource = kzalloc(sizeof(*resource), GFP_KERNEL);
	if (!resource) {
		printk(KERN_ERR "PCI: No memory for %s I/O port space\n",
			info->name);
		goto out;
	}

	len = strlen(info->name) + 32;
	name = kzalloc(len, GFP_KERNEL);
	if (!name) {
		printk(KERN_ERR "PCI: No memory for %s I/O port space name\n",
			info->name);
		goto free_resource;
	}

	min = addr->minimum;
	max = min + addr->address_length - 1;
	if (addr->info.io.translation_type == ACPI_SPARSE_TRANSLATION)
		sparse = 1;

	space_nr = new_space(addr->translation_offset, sparse);
	if (space_nr == ~0)
		goto free_name;

	base = __pa(io_space[space_nr].mmio_base);
	base_port = IO_SPACE_BASE(space_nr);
	snprintf(name, len, "%s I/O Ports %08lx-%08lx", info->name,
		base_port + min, base_port + max);

	/*
	 * The SDM guarantees the legacy 0-64K space is sparse, but if the
	 * mapping is done by the processor (not the bridge), ACPI may not
	 * mark it as sparse.
	 */
	if (space_nr == 0)
		sparse = 1;

	resource->name  = name;
	resource->flags = IORESOURCE_MEM;
	resource->start = base + (sparse ? IO_SPACE_SPARSE_ENCODING(min) : min);
	resource->end   = base + (sparse ? IO_SPACE_SPARSE_ENCODING(max) : max);
	insert_resource(&iomem_resource, resource);

	return base_port;

free_name:
	kfree(name);
free_resource:
	kfree(resource);
out:
	return ~0;
}
Example #27
0
File: super.c Project: avagin/linux
static void ext2_put_super (struct super_block * sb)
{
	int db_count;
	int i;
	struct ext2_sb_info *sbi = EXT2_SB(sb);

	ext2_quota_off_umount(sb);

	ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
	sbi->s_ea_block_cache = NULL;

	if (!sb_rdonly(sb)) {
		struct ext2_super_block *es = sbi->s_es;

		spin_lock(&sbi->s_lock);
		es->s_state = cpu_to_le16(sbi->s_mount_state);
		spin_unlock(&sbi->s_lock);
		ext2_sync_super(sb, es, 1);
	}
	db_count = sbi->s_gdb_count;
	for (i = 0; i < db_count; i++)
		if (sbi->s_group_desc[i])
			brelse (sbi->s_group_desc[i]);
	kfree(sbi->s_group_desc);
	kfree(sbi->s_debts);
	percpu_counter_destroy(&sbi->s_freeblocks_counter);
	percpu_counter_destroy(&sbi->s_freeinodes_counter);
	percpu_counter_destroy(&sbi->s_dirs_counter);
	brelse (sbi->s_sbh);
	sb->s_fs_info = NULL;
	kfree(sbi->s_blockgroup_lock);
	fs_put_dax(sbi->s_daxdev);
	kfree(sbi);
}
Example #28
0
struct pci_bus * __devinit
pci_acpi_scan_root(struct acpi_device *device, int domain, int bus)
{
	struct pci_root_info info;
	struct pci_controller *controller;
	unsigned int windows = 0;
	struct pci_bus *pbus;
	char *name;
	int pxm;

	controller = alloc_pci_controller(domain);
	if (!controller)
		goto out1;

	controller->acpi_handle = device->handle;

	pxm = acpi_get_pxm(controller->acpi_handle);
#ifdef CONFIG_NUMA
	if (pxm >= 0)
		controller->node = pxm_to_node(pxm);
#endif

	acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window,
			&windows);
	if (windows) {
		controller->window =
			kmalloc_node(sizeof(*controller->window) * windows,
				     GFP_KERNEL, controller->node);
		if (!controller->window)
			goto out2;
	}

	name = kmalloc(16, GFP_KERNEL);
	if (!name)
		goto out3;

	sprintf(name, "PCI Bus %04x:%02x", domain, bus);
	info.controller = controller;
	info.name = name;
	acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window,
			&info);
	/*
	 * See arch/x86/pci/acpi.c.
	 * The desired pci bus might already be scanned in a quirk. We
	 * should handle the case here, but it appears that IA64 hasn't
	 * such quirk. So we just ignore the case now.
	 */
	pbus = pci_scan_bus_parented(NULL, bus, &pci_root_ops, controller);
	if (pbus)
		pcibios_setup_root_windows(pbus, controller);

	return pbus;

out3:
	kfree(controller->window);
out2:
	kfree(controller);
out1:
	return NULL;
}
Example #29
0
void ath10k_htt_tx_detach(struct ath10k_htt *htt)
{
	ath10k_htt_tx_cleanup_pending(htt);
	kfree(htt->pending_tx);
	kfree(htt->used_msdu_ids);
	return;
}
Example #30
0
void remove_vfsmnt(kdev_t dev)
{
	struct vfsmount *lptr, *tofree;

	if (vfsmntlist == (struct vfsmount *)NULL)
		return;
	lptr = vfsmntlist;
	if (lptr->mnt_dev == dev) {
		tofree = lptr;
		vfsmntlist = lptr->mnt_next;
		if (vfsmnttail->mnt_dev == dev)
			vfsmnttail = vfsmntlist;
	} else {
		while (lptr->mnt_next != (struct vfsmount *)NULL) {
			if (lptr->mnt_next->mnt_dev == dev)
				break;
			lptr = lptr->mnt_next;
		}
		tofree = lptr->mnt_next;
		if (tofree == (struct vfsmount *)NULL)
			return;
		lptr->mnt_next = lptr->mnt_next->mnt_next;
		if (vfsmnttail->mnt_dev == dev)
			vfsmnttail = lptr;
	}
	kfree(tofree->mnt_devname);
	kfree(tofree->mnt_dirname);
	kfree_s(tofree, sizeof(struct vfsmount));
}