Example #1
0
static
int ufs_qcom_phy_base_init(struct platform_device *pdev,
                           struct ufs_qcom_phy *phy_common)
{
    struct device *dev = &pdev->dev;
    struct resource *res;
    int err = 0;

    res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy_mem");
    phy_common->mmio = devm_ioremap_resource(dev, res);
    if (IS_ERR((void const *)phy_common->mmio)) {
        err = PTR_ERR((void const *)phy_common->mmio);
        phy_common->mmio = NULL;
        dev_err(dev, "%s: ioremap for phy_mem resource failed %d\n",
                __func__, err);
        return err;
    }

    /* "dev_ref_clk_ctrl_mem" is optional resource */
    res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
                                       "dev_ref_clk_ctrl_mem");
    phy_common->dev_ref_clk_ctrl_mmio = devm_ioremap_resource(dev, res);
    if (IS_ERR((void const *)phy_common->dev_ref_clk_ctrl_mmio))
        phy_common->dev_ref_clk_ctrl_mmio = NULL;

    return 0;
}
static int __init omap4_l3_init(void)
{
    int l, i;
    struct omap_hwmod *oh[3];
    struct platform_device *pdev;
    char oh_name[L3_MODULES_MAX_LEN];


    if (of_have_populated_dt())
        return -ENODEV;

    if (!(cpu_is_omap44xx()))
        return -ENODEV;

    for (i = 0; i < L3_MODULES; i++) {
        l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);

        oh[i] = omap_hwmod_lookup(oh_name);
        if (!(oh[i]))
            pr_err("could not look up %s\n", oh_name);
    }

    pdev = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL,
                                0, NULL, 0, 0);

    WARN(IS_ERR(pdev), "could not build omap_device for %s\n", oh_name);

    return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
}
Example #3
0
static int sgtl5000_init(void)
{
	struct clk *clko;
	struct clk *new_parent;
	int rate;

	clko = clk_get(NULL, "clko_clk");
	if (IS_ERR(clko)) {
		pr_err("can't get CLKO clock.\n");
		return PTR_ERR(clko);
	}
	new_parent = clk_get(NULL, "ahb");
	if (!IS_ERR(new_parent)) {
		clk_set_parent(clko, new_parent);
		clk_put(new_parent);
	}
	rate = clk_round_rate(clko, 16000000);
	if (rate < 8000000 || rate > 27000000) {
		pr_err("Error:SGTL5000 mclk freq %d out of range!\n", rate);
		clk_put(clko);
		return -1;
	}

	plat_audio.sysclk = rate;
	clk_set_rate(clko, rate);
	clk_enable(clko);
	return 0;
}
Example #4
0
void __init ramips_soc_setup(void)
{
	struct clk *clk;

	rt3883_sysc_base = ioremap_nocache(RT3883_SYSC_BASE, PAGE_SIZE);
	rt3883_memc_base = ioremap_nocache(RT3883_MEMC_BASE, PAGE_SIZE);

	rt3883_clocks_init();

	clk = clk_get(NULL, "cpu");
	if (IS_ERR(clk))
		panic("unable to get CPU clock, err=%ld", PTR_ERR(clk));
	ramips_cpu_freq = clk_get_rate(clk);
	printk(KERN_INFO "%s running at %lu.%02lu MHz\n", ramips_sys_type,
		clk_get_rate(clk) / 1000000,
		(clk_get_rate(clk) % 1000000) * 100 / 1000000);

	_machine_restart = rt3883_restart;
	_machine_halt = rt3883_halt;
	pm_power_off = rt3883_halt;

	clk = clk_get(NULL, "uart");
	if (IS_ERR(clk))
		panic("unable to get UART clock, err=%ld", PTR_ERR(clk));

	ramips_early_serial_setup(0, RT3883_UART0_BASE, clk_get_rate(clk),
				  RT3883_INTC_IRQ_UART0);
	ramips_early_serial_setup(1, RT3883_UART1_BASE, clk_get_rate(clk),
				  RT3883_INTC_IRQ_UART1);
}
Example #5
0
struct dentry *
affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
{
	struct super_block *sb = dir->i_sb;
	struct buffer_head *bh;
	struct inode *inode = NULL;

	pr_debug("AFFS: lookup(\"%.*s\")\n",(int)dentry->d_name.len,dentry->d_name.name);

	affs_lock_dir(dir);
	bh = affs_find_entry(dir, dentry);
	affs_unlock_dir(dir);
	if (IS_ERR(bh))
		return ERR_CAST(bh);
	if (bh) {
		u32 ino = bh->b_blocknr;

		/* store the real header ino in d_fsdata for faster lookups */
		dentry->d_fsdata = (void *)(long)ino;
		switch (be32_to_cpu(AFFS_TAIL(sb, bh)->stype)) {
		//link to dirs disabled
		//case ST_LINKDIR:
		case ST_LINKFILE:
			ino = be32_to_cpu(AFFS_TAIL(sb, bh)->original);
		}
		affs_brelse(bh);
		inode = affs_iget(sb, ino);
		if (IS_ERR(inode))
			return ERR_PTR(PTR_ERR(inode));
	}
	dentry->d_op = AFFS_SB(sb)->s_flags & SF_INTL ? &affs_intl_dentry_operations : &affs_dentry_operations;
	d_add(dentry, inode);
	return NULL;
}
Example #6
0
static void usb20host_clock_init(void* pdata)
{
	struct dwc_otg_platform_data *usbpdata=pdata;
	struct clk* ahbclk, *phyclk, *phyclk_480m;

	ahbclk = devm_clk_get(usbpdata->dev, "hclk_usb1");
	if (IS_ERR(ahbclk)) {
		dev_err(usbpdata->dev, "Failed to get hclk_usb1\n");
		return;
	}

	phyclk = devm_clk_get(usbpdata->dev, "clk_usbphy1");
	if (IS_ERR(phyclk)) {
		dev_err(usbpdata->dev, "Failed to get clk_usbphy1\n");
		return;
	}

	phyclk_480m = devm_clk_get(usbpdata->dev, "usbphy_480m");
	if (IS_ERR(phyclk_480m)) {
		dev_err(usbpdata->dev, "Failed to get usbphy_480m\n");
		return;
	}

	usbpdata->phyclk = phyclk;
	usbpdata->ahbclk = ahbclk;
	usbpdata->phyclk_480m = phyclk_480m;
}
Example #7
0
/**
 * Write the special file which contains the list of llog catalogs IDs
 *
 * This function writes the CATALOG file which contains the array of llog
 * catalogs IDs. It is used mostly to store OSP llogs indexed by OST/MDT
 * number.
 *
 * \param[in]  env	execution environment
 * \param[in]  d	corresponding storage device
 * \param[in]  idx	position to start from, usually OST/MDT index
 * \param[in]  count	how many catalog IDs to write
 * \param[out] idarray	the buffer with the data to write.
 * \param[in]  fid	LLOG_CATALOGS_OID for CATALOG object
 *
 * \retval		0 on successful write of catalog IDs
 * \retval		negative value on error
 */
int llog_osd_put_cat_list(const struct lu_env *env, struct dt_device *d,
			  int idx, int count, struct llog_catid *idarray,
			  const struct lu_fid *fid)
{
	struct llog_thread_info	*lgi = llog_info(env);
	struct dt_object	*o = NULL;
	struct thandle		*th;
	int			 rc, size;

	if (count == 0)
		RETURN(0);

	LASSERT(d);

	size = sizeof(*idarray) * count;
	lgi->lgi_off = idx * sizeof(*idarray);
	lgi->lgi_fid = *fid;

	o = dt_locate(env, d, &lgi->lgi_fid);
	if (IS_ERR(o))
		RETURN(PTR_ERR(o));

	if (!dt_object_exists(o))
		GOTO(out, rc = -ENOENT);

	rc = dt_attr_get(env, o, &lgi->lgi_attr, BYPASS_CAPA);
	if (rc)
		GOTO(out, rc);

	if (!S_ISREG(lgi->lgi_attr.la_mode)) {
		CERROR("%s: CATALOGS is not a regular file!: mode = %o\n",
		       o->do_lu.lo_dev->ld_obd->obd_name,
		       lgi->lgi_attr.la_mode);
		GOTO(out, rc = -ENOENT);
	}

	th = dt_trans_create(env, d);
	if (IS_ERR(th))
		GOTO(out, rc = PTR_ERR(th));

	lgi->lgi_buf.lb_len = size;
	lgi->lgi_buf.lb_buf = idarray;
	rc = dt_declare_record_write(env, o, &lgi->lgi_buf, lgi->lgi_off, th);
	if (rc)
		GOTO(out, rc);

	rc = dt_trans_start_local(env, d, th);
	if (rc)
		GOTO(out_trans, rc);

	rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
	if (rc)
		CDEBUG(D_INODE, "can't write CATALOGS at index %d: rc = %d\n",
		       idx, rc);
out_trans:
	dt_trans_stop(env, d, th);
out:
	lu_object_put(env, &o->do_lu);
	RETURN(rc);
}
Example #8
0
int hfs_brec_goto(struct hfs_find_data *fd, int cnt)
{
    struct hfs_btree *tree;
    struct hfs_bnode *bnode;
    int idx, res = 0;
    u16 off, len, keylen;

    bnode = fd->bnode;
    tree = bnode->tree;

    if (cnt < 0) {
        cnt = -cnt;
        while (cnt > fd->record) {
            cnt -= fd->record + 1;
            fd->record = bnode->num_recs - 1;
            idx = bnode->prev;
            if (!idx) {
                res = -ENOENT;
                goto out;
            }
            hfs_bnode_put(bnode);
            bnode = hfs_bnode_find(tree, idx);
            if (IS_ERR(bnode)) {
                res = PTR_ERR(bnode);
                bnode = NULL;
                goto out;
            }
        }
        fd->record -= cnt;
    } else {
        while (cnt >= bnode->num_recs - fd->record) {
            cnt -= bnode->num_recs - fd->record;
            fd->record = 0;
            idx = bnode->next;
            if (!idx) {
                res = -ENOENT;
                goto out;
            }
            hfs_bnode_put(bnode);
            bnode = hfs_bnode_find(tree, idx);
            if (IS_ERR(bnode)) {
                res = PTR_ERR(bnode);
                bnode = NULL;
                goto out;
            }
        }
        fd->record += cnt;
    }

    len = hfs_brec_lenoff(bnode, fd->record, &off);
    keylen = hfs_brec_keylen(bnode, fd->record);
    fd->keyoffset = off;
    fd->keylength = keylen;
    fd->entryoffset = off + keylen;
    fd->entrylength = len - keylen;
    hfs_bnode_read(bnode, fd->key, off, keylen);
out:
    fd->bnode = bnode;
    return res;
}
Example #9
0
static int tas571x_set_bias_level(struct snd_soc_component *component,
				  enum snd_soc_bias_level level)
{
	struct tas571x_private *priv = snd_soc_component_get_drvdata(component);
	int ret;

	switch (level) {
	case SND_SOC_BIAS_ON:
		break;
	case SND_SOC_BIAS_PREPARE:
		break;
	case SND_SOC_BIAS_STANDBY:
		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
			if (!IS_ERR(priv->mclk)) {
				ret = clk_prepare_enable(priv->mclk);
				if (ret) {
					dev_err(component->dev,
						"Failed to enable master clock: %d\n",
						ret);
					return ret;
				}
			}
		}
		break;
	case SND_SOC_BIAS_OFF:
		if (!IS_ERR(priv->mclk))
			clk_disable_unprepare(priv->mclk);
		break;
	}

	return 0;
}
Example #10
0
int asoc_simple_card_parse_clk(struct device *dev,
			       struct device_node *node,
			       struct device_node *dai_of_node,
			       struct asoc_simple_dai *simple_dai,
			       const char *name)
{
	struct clk *clk;
	u32 val;

	/*
	 * Parse dai->sysclk come from "clocks = <&xxx>"
	 * (if system has common clock)
	 *  or "system-clock-frequency = <xxx>"
	 *  or device's module clock.
	 */
	clk = devm_get_clk_from_child(dev, node, NULL);
	if (!IS_ERR(clk)) {
		simple_dai->sysclk = clk_get_rate(clk);

		asoc_simple_card_clk_register(simple_dai, clk);
	} else if (!of_property_read_u32(node, "system-clock-frequency", &val)) {
		simple_dai->sysclk = val;
	} else {
		clk = devm_get_clk_from_child(dev, dai_of_node, NULL);
		if (!IS_ERR(clk))
			simple_dai->sysclk = clk_get_rate(clk);
	}

	dev_dbg(dev, "%s : sysclk = %d\n", name, simple_dai->sysclk);

	return 0;
}
Example #11
0
File: gem.c Project: JaneDu/ath
static int tegra_bo_get_pages(struct drm_device *drm, struct tegra_bo *bo)
{
	struct scatterlist *s;
	unsigned int i;

	bo->pages = drm_gem_get_pages(&bo->gem);
	if (IS_ERR(bo->pages))
		return PTR_ERR(bo->pages);

	bo->num_pages = bo->gem.size >> PAGE_SHIFT;

	bo->sgt = drm_prime_pages_to_sg(bo->pages, bo->num_pages);
	if (IS_ERR(bo->sgt))
		goto put_pages;

	/*
	 * Fake up the SG table so that dma_sync_sg_for_device() can be used
	 * to flush the pages associated with it.
	 *
	 * TODO: Replace this by drm_clflash_sg() once it can be implemented
	 * without relying on symbols that are not exported.
	 */
	for_each_sg(bo->sgt->sgl, s, bo->sgt->nents, i)
		sg_dma_address(s) = sg_phys(s);

	dma_sync_sg_for_device(drm->dev, bo->sgt->sgl, bo->sgt->nents,
			       DMA_TO_DEVICE);

	return 0;

put_pages:
	drm_gem_put_pages(&bo->gem, bo->pages, false, false);
	return PTR_ERR(bo->sgt);
}
Example #12
0
File: xattr.c Project: Abioy/kasan
static struct dentry *open_xa_dir(const struct inode *inode, int flags)
{
	struct dentry *xaroot, *xadir;
	char namebuf[17];

	xaroot = open_xa_root(inode->i_sb, flags);
	if (IS_ERR(xaroot))
		return xaroot;

	snprintf(namebuf, sizeof(namebuf), "%X.%X",
		 le32_to_cpu(INODE_PKEY(inode)->k_objectid),
		 inode->i_generation);

	mutex_lock_nested(&xaroot->d_inode->i_mutex, I_MUTEX_XATTR);

	xadir = lookup_one_len(namebuf, xaroot, strlen(namebuf));
	if (!IS_ERR(xadir) && !xadir->d_inode) {
		int err = -ENODATA;

		if (xattr_may_create(flags))
			err = xattr_mkdir(xaroot->d_inode, xadir, 0700);
		if (err) {
			dput(xadir);
			xadir = ERR_PTR(err);
		}
	}

	mutex_unlock(&xaroot->d_inode->i_mutex);
	dput(xaroot);
	return xadir;
}
Example #13
0
File: pcie.c Project: Lyude/linux
static int qtnf_pcie_init_memory(struct qtnf_pcie_bus_priv *priv)
{
	int ret = -ENOMEM;

	priv->sysctl_bar = qtnf_map_bar(priv, QTN_SYSCTL_BAR);
	if (IS_ERR(priv->sysctl_bar)) {
		pr_err("failed to map BAR%u\n", QTN_SYSCTL_BAR);
		return ret;
	}

	priv->dmareg_bar = qtnf_map_bar(priv, QTN_DMA_BAR);
	if (IS_ERR(priv->dmareg_bar)) {
		pr_err("failed to map BAR%u\n", QTN_DMA_BAR);
		return ret;
	}

	priv->epmem_bar = qtnf_map_bar(priv, QTN_SHMEM_BAR);
	if (IS_ERR(priv->epmem_bar)) {
		pr_err("failed to map BAR%u\n", QTN_SHMEM_BAR);
		return ret;
	}

	priv->pcie_reg_base = priv->dmareg_bar;
	priv->bda = priv->epmem_bar;
	writel(priv->msi_enabled, &priv->bda->bda_rc_msi_enabled);

	return 0;
}
static int ts_led_power_on(bool on)
{
	struct regulator *regulator;

	if (on) {
		regulator = regulator_get(NULL, "key_led_3.3v");
		if (IS_ERR(regulator)) {
			printk(KERN_ERR "[TSP_KEY] ts_led_power_on : TK_LED regulator_get failed\n");
			return -EIO;
		}

		regulator_enable(regulator);
		regulator_put(regulator);
	} else {
		regulator = regulator_get(NULL, "key_led_3.3v");
		if (IS_ERR(regulator)) {
			printk(KERN_ERR "[TSP_KEY] ts_led_power_on : TK_LED regulator_get failed\n");
			return -EIO;
		}

		if (regulator_is_enabled(regulator))
			regulator_force_disable(regulator);
		regulator_put(regulator);
	}

	printk(KERN_ERR "[TSP_KEY] %s %s\n", __func__, on ? "on" : "off");

	return 0;
}
Example #15
0
int osd_compat_seq_init(struct osd_device *osd, int seq)
{
        struct osd_compat_objid_seq *grp;
        struct osd_compat_objid     *map;
        struct dentry               *d;
        int                          rc = 0;
        char                         name[32];
        int                          i;
        ENTRY;

        map = osd->od_ost_map;
        LASSERT(map);
        LASSERT(map->root);
        grp = &map->groups[seq];

        if (grp->groot != NULL)
                RETURN(0);

        cfs_down(&grp->dir_init_sem);

        sprintf(name, "%d", seq);
        d = simple_mkdir(map->root, osd->od_mnt, name, 0755, 1);
        if (IS_ERR(d)) {
                rc = PTR_ERR(d);
                GOTO(out, rc);
        } else if (d->d_inode == NULL) {
                rc = -EFAULT;
                dput(d);
                GOTO(out, rc);
        }

        LASSERT(grp->dirs == NULL);
        OBD_ALLOC(grp->dirs, sizeof(d) * map->subdir_count);
        if (grp->dirs == NULL) {
                dput(d);
                GOTO(out, rc = -ENOMEM);
        }

        grp->groot = d;
        for (i = 0; i < map->subdir_count; i++) {
                sprintf(name, "d%d", i);
                d = simple_mkdir(grp->groot, osd->od_mnt, name, 0755, 1);
                if (IS_ERR(d)) {
                        rc = PTR_ERR(d);
                        break;
                } else if (d->d_inode == NULL) {
                        rc = -EFAULT;
                        dput(d);
                        break;
                }

                grp->dirs[i] = d;
        }

        if (rc)
                osd_compat_seq_fini(osd, seq);
out:
        cfs_up(&grp->dir_init_sem);
        RETURN(rc);
}
Example #16
0
static int __init ebbchar_init(void){
	printk(KERN_INFO "EBBChar: Initializing the EBBChar LKM\n");

	// Try to dynamically allocate a major number for the device -- more difficult but worth it
	majorNumber = register_chrdev(0, DEVICE_NAME, &fops);
	if (majorNumber<0){
		printk(KERN_ALERT "EBBChar failed to register device\n");
		return majorNumber;
	}
	printk(KERN_INFO "EBBChar: registered correctly with major number %d\n", majorNumber);

	ebbcharClass = class_create(THIS_MODULE, CLASS_NAME);
	if (IS_ERR(ebbcharClass)){
		unregister_chrdev(majorNumber, DEVICE_NAME);
		printk(KERN_ALERT "Failed to register device class\n");
		return PTR_ERR(ebbcharClass);
	}
	printk(KERN_INFO "EBBChar: device class registered correctly\n");

	ebbcharDevice = device_create(ebbcharClass, NULL, MKDEV(majorNumber, 0), NULL, DEVICE_NAME);
	if (IS_ERR(ebbcharDevice)){
		class_destroy(ebbcharClass);
		unregister_chrdev(majorNumber, DEVICE_NAME);
		printk(KERN_ALERT "Failed to create the device\n");
		return PTR_ERR(ebbcharDevice);
	}
	printk(KERN_INFO "EBBChar: device class created correctly\n");
	return 0;
}
/* utility to rename a file */
int lustre_rename(struct dentry *dir, struct vfsmount *mnt,
		  char *oldname, char *newname)
{
	struct dentry *dchild_old, *dchild_new;
	int err = 0;

	ASSERT_KERNEL_CTXT("kernel doing rename outside kernel context\n");
	CDEBUG(D_INODE, "renaming file %.*s to %.*s\n",
	       (int)strlen(oldname), oldname, (int)strlen(newname), newname);

	dchild_old = ll_lookup_one_len(oldname, dir, strlen(oldname));
	if (IS_ERR(dchild_old))
		return PTR_ERR(dchild_old);

	if (!dchild_old->d_inode)
		GOTO(put_old, err = -ENOENT);

	dchild_new = ll_lookup_one_len(newname, dir, strlen(newname));
	if (IS_ERR(dchild_new))
		GOTO(put_old, err = PTR_ERR(dchild_new));

	err = ll_vfs_rename(dir->d_inode, dchild_old, mnt,
			    dir->d_inode, dchild_new, mnt, NULL);

	dput(dchild_new);
put_old:
	dput(dchild_old);
	return err;
}
Example #18
0
static int __init omap3_l3_init(void)
{
	int l;
	struct omap_hwmod *oh;
	struct omap_device *od;
	char oh_name[L3_MODULES_MAX_LEN];

	/*
	 * To avoid code running on other OMAPs in
	 * multi-omap builds
	 */
	if (!(cpu_is_omap34xx()))
		return -ENODEV;

	l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");

	oh = omap_hwmod_lookup(oh_name);

	if (!oh)
		pr_err("could not look up %s\n", oh_name);

	od = omap_device_build("omap_l3_smx", 0, oh, NULL, 0,
							   NULL, 0, 0);

	WARN(IS_ERR(od), "could not build omap_device for %s\n", oh_name);

	return IS_ERR(od) ? PTR_ERR(od) : 0;
}
Example #19
0
static void rk_hsic_clock_init(void* pdata)
{
	/* By default, hsicphy_480m's parent is otg phy 480MHz clk
	 * rk3188 must use host phy 480MHz clk, because if otg bypass
	 * to uart mode, otg phy 480MHz clk will be closed automatically
	 */
	struct rkehci_platform_data *usbpdata=pdata;
	struct clk *ahbclk, *phyclk480m_hsic, *phyclk12m_hsic;

	phyclk480m_hsic = devm_clk_get(usbpdata->dev, "hsicphy_480m");
	if (IS_ERR(phyclk480m_hsic)) {
		dev_err(usbpdata->dev, "Failed to get hsicphy_480m\n");
		return;
	}

	phyclk12m_hsic = devm_clk_get(usbpdata->dev, "hsicphy_12m");
	if (IS_ERR(phyclk12m_hsic)) {
		dev_err(usbpdata->dev, "Failed to get hsicphy_12m\n");
		return;
	}

	ahbclk = devm_clk_get(usbpdata->dev, "hclk_hsic");
	if (IS_ERR(ahbclk)) {
		dev_err(usbpdata->dev, "Failed to get hclk_hsic\n");
		return;
	}

	usbpdata->hclk_hsic = ahbclk;
	usbpdata->hsic_phy_480m = phyclk480m_hsic;
	usbpdata->hsic_phy_12m = phyclk12m_hsic;
}
Example #20
0
static int __init omap4_l3_init(void)
{
	int l, i;
	struct omap_hwmod *oh[3];
	struct omap_device *od;
	char oh_name[L3_MODULES_MAX_LEN];

	/*
	 * To avoid code running on other OMAPs in
	 * multi-omap builds
	 */
	if (!(cpu_is_omap44xx()))
		return -ENODEV;

	for (i = 0; i < L3_MODULES; i++) {
		l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);

		oh[i] = omap_hwmod_lookup(oh_name);
		if (!(oh[i]))
			pr_err("could not look up %s\n", oh_name);
	}

	od = omap_device_build_ss("omap_l3_noc", 0, oh, 3, NULL,
						     0, NULL, 0, 0);

	WARN(IS_ERR(od), "could not build omap_device for %s\n", oh_name);

	return IS_ERR(od) ? PTR_ERR(od) : 0;
}
Example #21
0
static int __init __ftm_clk_init(struct device_node *np, char *cnt_name,
				 char *ftm_name)
{
	struct clk *clk;
	int err;

	clk = of_clk_get_by_name(np, cnt_name);
	if (IS_ERR(clk)) {
		pr_err("ftm: Cannot get \"%s\": %ld\n", cnt_name, PTR_ERR(clk));
		return PTR_ERR(clk);
	}
	err = clk_prepare_enable(clk);
	if (err) {
		pr_err("ftm: clock failed to prepare+enable \"%s\": %d\n",
			cnt_name, err);
		return err;
	}

	clk = of_clk_get_by_name(np, ftm_name);
	if (IS_ERR(clk)) {
		pr_err("ftm: Cannot get \"%s\": %ld\n", ftm_name, PTR_ERR(clk));
		return PTR_ERR(clk);
	}
	err = clk_prepare_enable(clk);
	if (err)
		pr_err("ftm: clock failed to prepare+enable \"%s\": %d\n",
			ftm_name, err);

	return clk_get_rate(clk);
}
Example #22
0
static int meson6_dwmac_probe(struct platform_device *pdev)
{
	struct plat_stmmacenet_data *plat_dat;
	struct stmmac_resources stmmac_res;
	struct meson_dwmac *dwmac;
	struct resource *res;
	int ret;

	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
	if (ret)
		return ret;

	plat_dat = stmmac_probe_config_dt(pdev, &stmmac_res.mac);
	if (IS_ERR(plat_dat))
		return PTR_ERR(plat_dat);

	dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
	if (!dwmac)
		return -ENOMEM;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
	dwmac->reg = devm_ioremap_resource(&pdev->dev, res);
	if (IS_ERR(dwmac->reg))
		return PTR_ERR(dwmac->reg);

	plat_dat->bsp_priv = dwmac;
	plat_dat->fix_mac_speed = meson6_dwmac_fix_mac_speed;

	return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
}
Example #23
0
static void _add_clkdev(struct omap_device *od, const char *clk_alias,
                        const char *clk_name)
{
    struct clk *r;
    struct clk_lookup *l;

    if (!clk_alias || !clk_name)
        return;

    dev_dbg(&od->pdev->dev, "Creating %s -> %s\n", clk_alias, clk_name);

    r = clk_get_sys(dev_name(&od->pdev->dev), clk_alias);
    if (!IS_ERR(r)) {
        dev_dbg(&od->pdev->dev,
                "alias %s already exists\n", clk_alias);
        clk_put(r);
        return;
    }

    r = clk_get(NULL, clk_name);
    if (IS_ERR(r)) {
        dev_err(&od->pdev->dev,
                "clk_get for %s failed\n", clk_name);
        return;
    }

    l = clkdev_alloc(r, clk_alias, dev_name(&od->pdev->dev));
    if (!l) {
        dev_err(&od->pdev->dev,
                "clkdev_alloc for %s failed\n", clk_alias);
        return;
    }

    clkdev_add(l);
}
Example #24
0
static int corgi_lcd_probe(struct spi_device *spi)
{
	struct backlight_properties props;
	struct corgi_lcd_platform_data *pdata = spi->dev.platform_data;
	struct corgi_lcd *lcd;
	int ret = 0;

	if (pdata == NULL) {
		dev_err(&spi->dev, "platform data not available\n");
		return -EINVAL;
	}

	lcd = devm_kzalloc(&spi->dev, sizeof(struct corgi_lcd), GFP_KERNEL);
	if (!lcd) {
		dev_err(&spi->dev, "failed to allocate memory\n");
		return -ENOMEM;
	}

	lcd->spi_dev = spi;

	lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev,
					lcd, &corgi_lcd_ops);
	if (IS_ERR(lcd->lcd_dev))
		return PTR_ERR(lcd->lcd_dev);

	lcd->power = FB_BLANK_POWERDOWN;
	lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA;

	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;
	props.max_brightness = pdata->max_intensity;
	lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, lcd,
						&corgi_bl_ops, &props);
	if (IS_ERR(lcd->bl_dev)) {
		ret = PTR_ERR(lcd->bl_dev);
		goto err_unregister_lcd;
	}
	lcd->bl_dev->props.brightness = pdata->default_intensity;
	lcd->bl_dev->props.power = FB_BLANK_UNBLANK;

	ret = setup_gpio_backlight(lcd, pdata);
	if (ret)
		goto err_unregister_bl;

	lcd->kick_battery = pdata->kick_battery;

	dev_set_drvdata(&spi->dev, lcd);
	corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK);
	backlight_update_status(lcd->bl_dev);

	lcd->limit_mask = pdata->limit_mask;
	the_corgi_lcd = lcd;
	return 0;

err_unregister_bl:
	backlight_device_unregister(lcd->bl_dev);
err_unregister_lcd:
	lcd_device_unregister(lcd->lcd_dev);
	return ret;
}
Example #25
0
static int init_threads(struct gfs2_sbd *sdp)
{
	struct task_struct *p;
	int error = 0;

	p = kthread_run(gfs2_logd, sdp, "gfs2_logd");
	if (IS_ERR(p)) {
		error = PTR_ERR(p);
		fs_err(sdp, "can't start logd thread: %d\n", error);
		return error;
	}
	sdp->sd_logd_process = p;

	p = kthread_run(gfs2_quotad, sdp, "gfs2_quotad");
	if (IS_ERR(p)) {
		error = PTR_ERR(p);
		fs_err(sdp, "can't start quotad thread: %d\n", error);
		goto fail;
	}
	sdp->sd_quotad_process = p;
	return 0;

fail:
	kthread_stop(sdp->sd_logd_process);
	return error;
}
Example #26
0
static int vocpcm_open(struct inode *inode, struct file *file)
{
    struct voc_rpc *voc_rpc = &the_voc_proc;
    struct voc_ctxt *ctxt = voc_minor_to_ctxt(MINOR(inode->i_rdev));
    int rc = 0;

    if (!ctxt) {
        pr_err("unknown voc misc %d\n", MINOR(inode->i_rdev));
        return -ENODEV;
    }

    mutex_lock(&voc_rpc->lock);
    if (voc_rpc->inited == 0) {
        voc_rpc->ept = create_rpc_connect(RPC_SND_PROG, RPC_SND_VERS,
                                          MSM_RPC_UNINTERRUPTIBLE |
                                          MSM_RPC_ENABLE_RECEIVE);
        if (IS_ERR(voc_rpc->ept)) {
            rc = PTR_ERR(voc_rpc->ept);
            voc_rpc->ept = NULL;
            pr_err("vocpcm: failed to connect snd svc\n");
            return rc;
        }

        voc_rpc->task = create_snd_rpc_kthread();
        if (IS_ERR(voc_rpc->task)) {
            rc = PTR_ERR(voc_rpc->task);
            voc_rpc->task = NULL;
            msm_rpc_close(voc_rpc->ept);
            voc_rpc->ept = NULL;
            return rc;
        }
        voc_rpc->inited = 1;
    }
    mutex_unlock(&voc_rpc->lock);

    mutex_lock(&ctxt->lock);
    if (ctxt->opened) {
        pr_err("vocpcm already opened.\n");
        rc = -EBUSY;
        goto err;
    }

    file->private_data = ctxt;
    ctxt->head = 0;
    ctxt->tail = 0;
    ctxt->client = 0;

    memset(ctxt->buf[0].data, 0, sizeof(ctxt->buf[0].data));
    memset(ctxt->buf[1].data, 0, sizeof(ctxt->buf[1].data));
    ctxt->buf[0].index = 0;
    ctxt->buf[1].index = 0;
    ctxt->opened = 1;
    ctxt->count = 0;
    ctxt->s_ptr = 0;
    ctxt->final_input = 0;

err:
    mutex_unlock(&ctxt->lock);
    return rc;
}
Example #27
0
static int msm_usb_reset(struct usb_phy *phy)
{
	struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
	int ret;

	if (!IS_ERR(motg->core_clk))
		clk_prepare_enable(motg->core_clk);

	ret = msm_link_reset(motg);
	if (ret) {
		dev_err(phy->dev, "phy_reset failed\n");
		return ret;
	}

	ret = msm_otg_reset(&motg->phy);
	if (ret) {
		dev_err(phy->dev, "link reset failed\n");
		return ret;
	}

	msleep(100);

	/* Reset USB PHY after performing USB Link RESET */
	msm_phy_reset(motg);

	if (!IS_ERR(motg->core_clk))
		clk_disable_unprepare(motg->core_clk);

	return 0;
}
Example #28
0
static int bq24192_create_debugfs_entries(struct bq24192_chip *chip)
{
	int i;

	chip->dent = debugfs_create_dir(BQ24192_NAME, NULL);
	if (IS_ERR(chip->dent)) {
		pr_err("bq24192 driver couldn't create debugfs dir\n");
		return -EFAULT;
	}

	for (i = 0 ; i < ARRAY_SIZE(bq24192_debug_regs) ; i++) {
		char *name = bq24192_debug_regs[i].name;
		u32 reg = bq24192_debug_regs[i].reg;
		struct dentry *file;

		file = debugfs_create_file(name, 0644, chip->dent,
					(void *) reg, &reg_fops);
		if (IS_ERR(file)) {
			pr_err("debugfs_create_file %s failed.\n", name);
			return -EFAULT;
		}
	}

	return 0;
}
Example #29
0
static struct dentry *logfs_lookup(struct inode *dir, struct dentry *dentry,
		struct nameidata *nd)
{
	struct page *page;
	struct logfs_disk_dentry *dd;
	pgoff_t index;
	u64 ino = 0;
	struct inode *inode;

	page = logfs_get_dd_page(dir, dentry);
	if (IS_ERR(page))
		return ERR_CAST(page);
	if (!page) {
		d_add(dentry, NULL);
		return NULL;
	}
	index = page->index;
	dd = kmap_atomic(page, KM_USER0);
	ino = be64_to_cpu(dd->ino);
	kunmap_atomic(dd, KM_USER0);
	page_cache_release(page);

	inode = logfs_iget(dir->i_sb, ino);
	if (IS_ERR(inode)) {
		printk(KERN_ERR"LogFS: Cannot read inode #%llx for dentry (%lx, %lx)n",
				ino, dir->i_ino, index);
		return ERR_CAST(inode);
	}
	return d_splice_alias(inode, dentry);
}
Example #30
0
static int crypto_ccm_init_tfm(struct crypto_tfm *tfm)
{
	struct crypto_instance *inst = (void *)tfm->__crt_alg;
	struct ccm_instance_ctx *ictx = crypto_instance_ctx(inst);
	struct crypto_ccm_ctx *ctx = crypto_tfm_ctx(tfm);
	struct crypto_cipher *cipher;
	struct crypto_ablkcipher *ctr;
	unsigned long align;
	int err;

	cipher = crypto_spawn_cipher(&ictx->cipher);
	if (IS_ERR(cipher))
		return PTR_ERR(cipher);

	ctr = crypto_spawn_skcipher(&ictx->ctr);
	err = PTR_ERR(ctr);
	if (IS_ERR(ctr))
		goto err_free_cipher;

	ctx->cipher = cipher;
	ctx->ctr = ctr;

	align = crypto_tfm_alg_alignmask(tfm);
	align &= ~(crypto_tfm_ctx_alignment() - 1);
	tfm->crt_aead.reqsize = align +
				sizeof(struct crypto_ccm_req_priv_ctx) +
				crypto_ablkcipher_reqsize(ctr);

	return 0;

err_free_cipher:
	crypto_free_cipher(cipher);
	return err;
}