示例#1
1
void afhba_create_sysfs_class(struct AFHBA_DEV *adev)
{
	int rc;
	dev_dbg(pdev(adev), "01");

	rc = sysfs_create_files(&adev->class_dev->kobj, class_attrs);
	if (rc){
		dev_err(pdev(adev), "failed to create files");
		return;
	}
	rc = sysfs_create_link(
		&adev->class_dev->kobj, &adev->pci_dev->dev.kobj, "device");
	if (rc) {
		dev_err(pdev(adev), "failed to create symlink %s\n", "device");
	}
	dev_dbg(pdev(adev), "9");
}
示例#2
0
int __init tegra_init_shared_bus_cap(
	struct core_bus_cap_table *table, int table_size,
	struct kobject *cap_kobj)
{
	int i, j;
	struct clk *c = NULL;

	if (!table || !table_size || (table_size > MAX_BUS_NUM))
		return -EINVAL;

	for (i = 0, j = 0; i < table_size; i++) {
		c = tegra_get_clock_by_name(table[i].cap_name);
		if (!c) {
			pr_err("%s: failed to initialize %s table\n",
			       __func__, table[i].cap_name);
			continue;
		}
		table[i].cap_clk = c;
		table[i].level = clk_get_max_rate(c);
		table[i].refcnt = 0;
		table[i].refcnt_attr.show = bus_cap_state_show;
		table[i].refcnt_attr.store = bus_cap_state_store;
		table[i].level_attr.show = bus_cap_level_show;
		table[i].level_attr.store = bus_cap_level_store;
		bus_cap_attributes[j++] = &table[i].refcnt_attr.attr;
		bus_cap_attributes[j++] = &table[i].level_attr.attr;
	}
	bus_cap_attributes[j] = NULL;

	if (!cap_kobj || sysfs_create_files(cap_kobj, bus_cap_attributes))
		return -ENOMEM;
	return 0;
}
static int __init tegra_dvfs_init_core_cap(void)
{
	int i;
	struct clk *c = NULL;

	for (i = 0; i < ARRAY_SIZE(core_cap_table); i++) {
		c = tegra_get_clock_by_name(core_cap_table[i].cap_name);
		if (!c || !c->parent ||
		    init_core_cap_one(c, core_cap_table[i].freqs)) {
			pr_err("tegra3_dvfs: failed to initialize %s frequency"
			       " table", core_cap_table[i].cap_name);
			continue;
		}
		core_cap_table[i].cap_clk = c;
	}
	core_cap_level = tegra3_dvfs_rail_vdd_core.max_millivolts;

	cap_kobj = kobject_create_and_add("tegra_cap", kernel_kobj);
	if (!cap_kobj) {
		pr_err("tegra3_dvfs: failed to create sysfs cap object");
		return 0;
	}

	if (sysfs_create_files(cap_kobj, cap_attributes)) {
		pr_err("tegra3_dvfs: failed to create sysfs cap interface");
		return 0;
	}
	pr_info("tegra dvfs: tegra sysfs cap interface is initialized\n");

	return 0;
}
static inline int __create_sysfs_file_common(void)
{
    int ret = 0;

    if((ret = sysfs_create_files(&kset_gpu->kobj, (const struct attribute **)gc_default_attrs)))
        printk("fail to create sysfs files gc_default_attrs\n");

    return ret;
}
示例#5
0
void afhba_create_sysfs(struct AFHBA_DEV *adev)
{
	int rc;
	rc = sysfs_create_files(&adev->class_dev->kobj, dev_attrs);
	if (rc){
		dev_err(pdev(adev), "failed to create files");
		return;
	}
}
示例#6
0
int cavan_sensor_device_probe(struct cavan_input_device *dev)
{
	int ret;
	struct input_dev *input = dev->input;
	struct cavan_sensor_device *sensor = (struct cavan_sensor_device *) dev;

	switch (dev->type)
	{
	case CAVAN_INPUT_DEVICE_TYPE_ACCELEROMETER:
	case CAVAN_INPUT_DEVICE_TYPE_MAGNETIC_FIELD:
	case CAVAN_INPUT_DEVICE_TYPE_ORIENTATION:
	case CAVAN_INPUT_DEVICE_TYPE_GYROSCOPE:
	case CAVAN_INPUT_DEVICE_TYPE_GRAVITY:
	case CAVAN_INPUT_DEVICE_TYPE_ROTATION_VECTOR:
	case CAVAN_INPUT_DEVICE_TYPE_LINEAR_ACCELERATION:
		if (sensor->axis_count < 2)
		{
			sensor->axis_count = 3;
		}

		input_set_abs_params(input, ABS_X, 0, sensor->resolution, dev->fuzz, dev->flat);
		input_set_abs_params(input, ABS_Y, 0, sensor->resolution, dev->fuzz, dev->flat);
		input_set_abs_params(input, ABS_Z, 0, sensor->resolution, dev->fuzz, dev->flat);
		break;

	case CAVAN_INPUT_DEVICE_TYPE_LIGHT:
	case CAVAN_INPUT_DEVICE_TYPE_PRESSURE:
	case CAVAN_INPUT_DEVICE_TYPE_TEMPERATURE:
	case CAVAN_INPUT_DEVICE_TYPE_PROXIMITY:
		sensor->axis_count = 1;
		input_set_abs_params(input, ABS_MISC, 0, sensor->resolution, dev->fuzz, dev->flat);
		break;

	default:
		pr_red_info("Invalid sensor type %d", dev->type);
		return -EINVAL;
	}

	set_bit(EV_ABS, input->evbit);

	ret = sysfs_create_files(&dev->misc_dev.dev->kobj, cavan_sensor_device_attributes);
	if (ret < 0)
	{
		pr_red_info("sysfs_create_files");
		return ret;
	}

	dev->remove = cavan_sensor_device_remove;
	dev->ioctl = cavan_sensor_device_ioctl;

	pr_green_info("cavan sensor %s probe complete", dev->name);

	return 0;
}
示例#7
0
static int fme_hdr_init(struct platform_device *pdev,
			struct dfl_feature *feature)
{
	void __iomem *base = feature->ioaddr;
	int ret;

	dev_dbg(&pdev->dev, "FME HDR Init.\n");
	dev_dbg(&pdev->dev, "FME cap %llx.\n",
		(unsigned long long)readq(base + FME_HDR_CAP));

	ret = sysfs_create_files(&pdev->dev.kobj, fme_hdr_attrs);
	if (ret)
		return ret;

	return 0;
}
示例#8
0
int tegra_auto_hotplug_init(struct mutex *cpu_lock)
{
	/*
	 * Not bound to the issuer CPU (=> high-priority), has rescue worker
	 * task, single-threaded, freezable.
	 */
	hotplug_wq = alloc_workqueue(
		"cpu-tegra3", WQ_UNBOUND | WQ_RESCUER | WQ_FREEZABLE, 1);
	if (!hotplug_wq)
		return -ENOMEM;
	INIT_DELAYED_WORK(&hotplug_work, tegra_auto_hotplug_work_func);

	cpu_clk = clk_get_sys(NULL, "cpu");
	cpu_g_clk = clk_get_sys(NULL, "cpu_g");
	cpu_lp_clk = clk_get_sys(NULL, "cpu_lp");
	if (IS_ERR(cpu_clk) || IS_ERR(cpu_g_clk) || IS_ERR(cpu_lp_clk))
		return -ENOENT;

	idle_top_freq = clk_get_max_rate(cpu_lp_clk) / 1000;
	idle_bottom_freq = clk_get_min_rate(cpu_g_clk) / 1000;

	up2g0_delay = msecs_to_jiffies(UP2G0_DELAY_MS);
	up2gn_delay = msecs_to_jiffies(UP2Gn_DELAY_MS);
	down_delay = msecs_to_jiffies(DOWN_DELAY_MS);

	tegra3_cpu_lock = cpu_lock;
	hp_state = INITIAL_STATE;
	hp_init_stats();
	pr_info("Tegra auto-hotplug initialized: %s\n",
		(hp_state == TEGRA_HP_DISABLED) ? "disabled" : "enabled");

	if (pm_qos_add_notifier(PM_QOS_MIN_ONLINE_CPUS, &min_cpus_notifier))
		pr_err("%s: Failed to register min cpus PM QoS notifier\n",
			__func__);

	rt_cfg_kobj = kobject_create_and_add("rt_config", kernel_kobj);
	if (!rt_cfg_kobj) {
		pr_err("cpu_tegra3: failed to create sysfs rt_cfg_kobj object");
		return 0;
	}
	if (sysfs_create_files(rt_cfg_kobj, rt_cfg_attributes)) {
		pr_err("tegra3_dvfs: failed to create sysfs rt_cfg_kobj interface");
		return 0;
	}
	return 0;
}
static int volt_cap_sysfs_init(void)
{
	volt_cap_kobj = kobject_create_and_add("tegra_cpu_volt_cap",
		kernel_kobj);

	if (!volt_cap_kobj) {
		pr_info("CPU volt_cap failed\n");
		return -1;
	}

	if (sysfs_create_files(volt_cap_kobj, tegra_volt_cap_attrs)) {
		pr_err("tegra:failed to create sysfs cap interface\n");
		return -1;
	}

	return 0;
}
示例#10
0
static int __init tegra_nct_sysfs_init(void)
{
	if (!tegra_nct_is_init()) {
		pr_err("tegra_nct: not initialized\n");
		return 0;
	}

	nct_kobj = kobject_create_and_add("tegra_nct", kernel_kobj);
	if (!nct_kobj) {
		pr_err("tegra_nct: failed to create sysfs nct object\n");
		return 0;
	}

	if (sysfs_create_files(nct_kobj, nct_item_attrs)) {
		pr_err("%s: failed to create nct item sysfs files\n", __func__);
		kobject_del(nct_kobj);
		nct_kobj = 0;
	}

	return 0;
}
int __init tegra_init_core_cap(
	struct core_dvfs_cap_table *table, int table_size,
	const int *millivolts, int millivolts_num,
	struct kobject *cap_kobj)
{
	int i;
	struct clk *c = NULL;

	if (!table || !table_size || !millivolts || !millivolts_num)
		return -EINVAL;

	core_nominal_mv =
		tegra_dvfs_rail_get_nominal_millivolts(tegra_core_rail);
	if (core_nominal_mv <= 0)
		return -ENODATA;

	cap_millivolts = millivolts;
	cap_millivolts_num = millivolts_num;
	core_buses_cap.level = kdvfs_core_cap.level = user_core_cap.level =
		core_nominal_mv;

	for (i = 0; i < table_size; i++) {
		c = tegra_get_clock_by_name(table[i].cap_name);
		if (!c || !c->parent ||
		    init_core_cap_one(c, table[i].freqs)) {
			pr_err("%s: failed to initialize %s table\n",
			       __func__, table[i].cap_name);
			continue;
		}
		table[i].cap_clk = c;
	}

	if (!cap_kobj || sysfs_create_files(cap_kobj, cap_attributes))
		return -ENOMEM;

	core_cap_table = table;
	core_cap_table_size = table_size;
	return 0;
}
示例#12
0
static int dram_probe(struct platform_device *pdev)
{
	int ret,i;
    char host_port_name[16] = {0};

	device_create(dram_class, &pdev->dev, 0, NULL, "dram.0");

    for (i=0;i<ARRAY_SIZE(host_port);i++) {
        sprintf(host_port_name, "port.%d", host_port[i]);
        port_kobj[i] = kobject_create_and_add(host_port_name, &pdev->dev.kobj);
        if (!port_kobj[i]) {
            ret = -ENOMEM;
            DRAM_DBG("host port: Failed to create dram kobj\n");
            goto out_err1;
        }

        ret = sysfs_create_files(port_kobj[i], host_port_attrs);
        if (ret) {
            DRAM_DBG("host port: Failed to add attrs");
            goto out_err2;
        }
    }

    ret = dram_fetch_sysconfig_para();
    if (ret) {
        DRAM_DBG("fetch dram sysconfig failed\n");
        goto out_err2;
    }
    DRAM_DBG("%s finished!\n", __func__);

	return 0;

out_err2:
    kobject_put(port_kobj[i]);
out_err1:
    return ret;
}
示例#13
0
文件: core.c 项目: grate-driver/linux
static int kp2000_pcie_probe(struct pci_dev *pdev,
			     const struct pci_device_id *id)
{
	int err = 0;
	struct kp2000_device *pcard;
	int rv;
	unsigned long reg_bar_phys_addr;
	unsigned long reg_bar_phys_len;
	unsigned long dma_bar_phys_addr;
	unsigned long dma_bar_phys_len;
	u16 regval;

	dev_dbg(&pdev->dev, "kp2000_pcie_probe(pdev = [%p], id = [%p])\n",
		pdev, id);

	/*
	 * Step 1: Allocate a struct for the pcard
	 */
	pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL);
	if (NULL == pcard) {
		dev_err(&pdev->dev,
			"probe: failed to allocate private card data\n");
		return -ENOMEM;
	}
	dev_dbg(&pdev->dev, "probe: allocated struct kp2000_device @ %p\n",
		pcard);

	/*
	 * Step 2: Initialize trivial pcard elements
	 */
	err = ida_simple_get(&card_num_ida, 1, INT_MAX, GFP_KERNEL);
	if (err < 0) {
		dev_err(&pdev->dev, "probe: failed to get card number (%d)\n",
			err);
		goto out2;
	}
	pcard->card_num = err;
	scnprintf(pcard->name, 16, "kpcard%u", pcard->card_num);

	mutex_init(&pcard->sem);
	mutex_lock(&pcard->sem);

	pcard->pdev = pdev;
	pci_set_drvdata(pdev, pcard);

	/*
	 * Step 3: Enable PCI device
	 */
	err = pci_enable_device(pcard->pdev);
	if (err) {
		dev_err(&pcard->pdev->dev,
			"probe: failed to enable PCIE2000 PCIe device (%d)\n",
			err);
		goto out3;
	}

	/*
	 * Step 4: Setup the Register BAR
	 */
	reg_bar_phys_addr = pci_resource_start(pcard->pdev, REG_BAR);
	reg_bar_phys_len = pci_resource_len(pcard->pdev, REG_BAR);

	pcard->regs_bar_base = ioremap_nocache(reg_bar_phys_addr, PAGE_SIZE);
	if (NULL == pcard->regs_bar_base) {
		dev_err(&pcard->pdev->dev,
			"probe: REG_BAR could not remap memory to virtual space\n");
		err = -ENODEV;
		goto out4;
	}
	dev_dbg(&pcard->pdev->dev,
		"probe: REG_BAR virt hardware address start [%p]\n",
		pcard->regs_bar_base);

	err = pci_request_region(pcard->pdev, REG_BAR, KP_DRIVER_NAME_KP2000);
	if (err) {
		iounmap(pcard->regs_bar_base);
		dev_err(&pcard->pdev->dev,
			"probe: failed to acquire PCI region (%d)\n",
			err);
		err = -ENODEV;
		goto out4;
	}

	pcard->regs_base_resource.start = reg_bar_phys_addr;
	pcard->regs_base_resource.end   = reg_bar_phys_addr +
					  reg_bar_phys_len - 1;
	pcard->regs_base_resource.flags = IORESOURCE_MEM;

	/*
	 * Step 5: Setup the DMA BAR
	 */
	dma_bar_phys_addr = pci_resource_start(pcard->pdev, DMA_BAR);
	dma_bar_phys_len = pci_resource_len(pcard->pdev, DMA_BAR);

	pcard->dma_bar_base = ioremap_nocache(dma_bar_phys_addr,
					      dma_bar_phys_len);
	if (NULL == pcard->dma_bar_base) {
		dev_err(&pcard->pdev->dev,
			"probe: DMA_BAR could not remap memory to virtual space\n");
		err = -ENODEV;
		goto out5;
	}
	dev_dbg(&pcard->pdev->dev,
		"probe: DMA_BAR virt hardware address start [%p]\n",
		pcard->dma_bar_base);

	pcard->dma_common_regs = pcard->dma_bar_base + KPC_DMA_COMMON_OFFSET;

	err = pci_request_region(pcard->pdev, DMA_BAR, "kp2000_pcie");
	if (err) {
		iounmap(pcard->dma_bar_base);
		dev_err(&pcard->pdev->dev,
			"probe: failed to acquire PCI region (%d)\n", err);
		err = -ENODEV;
		goto out5;
	}

	pcard->dma_base_resource.start = dma_bar_phys_addr;
	pcard->dma_base_resource.end   = dma_bar_phys_addr +
					 dma_bar_phys_len - 1;
	pcard->dma_base_resource.flags = IORESOURCE_MEM;

	/*
	 * Step 6: System Regs
	 */
	pcard->sysinfo_regs_base = pcard->regs_bar_base;
	err = read_system_regs(pcard);
	if (err)
		goto out6;

	// Disable all "user" interrupts because they're not used yet.
	writeq(0xFFFFFFFFFFFFFFFF,
	       pcard->sysinfo_regs_base + REG_INTERRUPT_MASK);

	/*
	 * Step 7: Configure PCI thingies
	 */
	// let the card master PCIe
	pci_set_master(pcard->pdev);
	// enable IO and mem if not already done
	pci_read_config_word(pcard->pdev, PCI_COMMAND, &regval);
	regval |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
	pci_write_config_word(pcard->pdev, PCI_COMMAND, regval);

	// Clear relaxed ordering bit
	pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL,
					   PCI_EXP_DEVCTL_RELAX_EN, 0);

	// Set Max_Payload_Size and Max_Read_Request_Size
	regval = (0x0) << 5; // Max_Payload_Size = 128 B
	pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL,
					   PCI_EXP_DEVCTL_PAYLOAD, regval);
	regval = (0x0) << 12; // Max_Read_Request_Size = 128 B
	pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL,
					   PCI_EXP_DEVCTL_READRQ, regval);

	// Enable error reporting for: Correctable Errors, Non-Fatal Errors,
	// Fatal Errors, Unsupported Requests
	pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, 0,
					   PCI_EXP_DEVCTL_CERE |
					   PCI_EXP_DEVCTL_NFERE |
					   PCI_EXP_DEVCTL_FERE |
					   PCI_EXP_DEVCTL_URRE);

	err = dma_set_mask(PCARD_TO_DEV(pcard), DMA_BIT_MASK(64));
	if (err) {
		dev_err(&pcard->pdev->dev,
			"CANNOT use DMA mask %0llx\n", DMA_BIT_MASK(64));
		goto out7;
	}
	dev_dbg(&pcard->pdev->dev,
		"Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard)));

	/*
	 * Step 8: Configure IRQs
	 */
	err = pci_enable_msi(pcard->pdev);
	if (err < 0)
		goto out8a;

	rv = request_irq(pcard->pdev->irq, kp2000_irq_handler, IRQF_SHARED,
			 pcard->name, pcard);
	if (rv) {
		dev_err(&pcard->pdev->dev,
			"kp2000_pcie_probe: failed to request_irq: %d\n", rv);
		goto out8b;
	}

	/*
	 * Step 9: Setup sysfs attributes
	 */
	err = sysfs_create_files(&(pdev->dev.kobj), kp_attr_list);
	if (err) {
		dev_err(&pdev->dev, "Failed to add sysfs files: %d\n", err);
		goto out9;
	}

	/*
	 * Step 10: Setup misc device
	 */
	pcard->miscdev.minor = MISC_DYNAMIC_MINOR;
	pcard->miscdev.fops = &kp2000_fops;
	pcard->miscdev.parent = &pcard->pdev->dev;
	pcard->miscdev.name = pcard->name;

	err = misc_register(&pcard->miscdev);
	if (err) {
		dev_err(&pcard->pdev->dev,
			"kp2000_pcie_probe: misc_register failed: %d\n", err);
		goto out10;
	}

	/*
	 * Step 11: Probe cores
	 */
	err = kp2000_probe_cores(pcard);
	if (err)
		goto out11;

	/*
	 * Step 12: Enable IRQs in HW
	 */
	writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE,
	       pcard->dma_common_regs);

	dev_dbg(&pcard->pdev->dev, "kp2000_pcie_probe() complete!\n");
	mutex_unlock(&pcard->sem);
	return 0;

out11:
	misc_deregister(&pcard->miscdev);
out10:
	sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list);
out9:
	free_irq(pcard->pdev->irq, pcard);
out8b:
	pci_disable_msi(pcard->pdev);
out8a:
out7:
out6:
	iounmap(pcard->dma_bar_base);
	pci_release_region(pdev, DMA_BAR);
	pcard->dma_bar_base = NULL;
out5:
	iounmap(pcard->regs_bar_base);
	pci_release_region(pdev, REG_BAR);
	pcard->regs_bar_base = NULL;
out4:
	pci_disable_device(pcard->pdev);
out3:
	mutex_unlock(&pcard->sem);
	ida_simple_remove(&card_num_ida, pcard->card_num);
out2:
	kfree(pcard);
	return err;
}
示例#14
0
static int __init dram_init(void)
{
    int ret, i, j, k, m, n, p, q, s;
    char mmcr_name[16] = {0};
    char mbacr_name[16] = {0};

    dram_dev = device_create(sunxi_class, &sunxi_dram_device.dev, 0, NULL,
            (char *)sunxi_dram_device.dev.platform_data);

    ret = device_create_file(dram_dev, arbiter_attrs[0]);
    if (ret)
        goto out_err1;

    for (i = 0; i < ARRAY_SIZE(rmcr_port); i++) {
        sprintf(mmcr_name, "rmcr.%d", id_serial[rmcr_port[i]].serial);
        rmcr_port_kobj[i] = kobject_create_and_add(mmcr_name, &dram_dev->kobj);
        if (!rmcr_port_kobj[i]) {
            ret = -ENOMEM;
            printk("rmcr port: Failed to create dram kobj\n");
            goto out_err2;
        }

        ret = sysfs_create_files(rmcr_port_kobj[i], port_attrs);
        if (ret) {
            printk("rmcr port: Failed to add attrs");
            goto out_err3;
        }
    }

    for (j = 0; j < ARRAY_SIZE(mmcr_port); j++) {
        sprintf(mbacr_name, "mmcr.%d", id_serial[mmcr_port[j]].serial);
        mmcr_port_kobj[j] = kobject_create_and_add(mbacr_name, &dram_dev->kobj);
        if (!mmcr_port_kobj[j]) {
            ret = -ENOMEM;
            printk("mmcr port: Failed to create dram kobj\n");
            goto out_err4;
        }

        ret = sysfs_create_files(mmcr_port_kobj[j], port_attrs);
        if (ret) {
            printk("mmcr port: Failed to add attrs");
            goto out_err5;
        }
    }

    for (k = 0; k < ARRAY_SIZE(mbacr_port); k++) {
        sprintf(mbacr_name, "mbacr.%d", id_serial[mbacr_port[k]].serial);
        mbacr_port_kobj[k] = kobject_create_and_add(mbacr_name, &dram_dev->kobj);
        if (!mbacr_port_kobj[k]) {
            ret = -ENOMEM;
            printk("mbacr port: Failed to create dram kobj\n");
            goto out_err6;
        }

        ret = sysfs_create_files(mbacr_port_kobj[k], port_attrs);
        if (ret) {
            printk("mbacr port: Failed to add attrs");
            goto out_err7;
        }
    }

    return 0;

out_err7:
    for (s = 0; s < k; s++) {
        sysfs_remove_file(mbacr_port_kobj[s], port_attrs);
    }
    if (k < ARRAY_SIZE(mbacr_port)) {
        kobject_put(mbacr_port_kobj[k]);
    }
out_err6:
    for (q = 0; q < k; q++) {
        kobject_put(mbacr_port_kobj[q]);
    }
out_err5:
    for (n = 0; n < j; n++) {
        sysfs_remove_file(mmcr_port_kobj[n], port_attrs);
    }
    if (j < ARRAY_SIZE(mmcr_port)) {
        kobject_put(mmcr_port_kobj[j]);
    }
out_err4:
    for (p = 0; p < j; p++) {
        kobject_put(mmcr_port_kobj[p]);
    }
out_err3:
    for (m = 0; m < i; m++) {
        sysfs_remove_file(rmcr_port_kobj[m], port_attrs);
    }
    if (i < ARRAY_SIZE(rmcr_port)) {
        kobject_put(rmcr_port_kobj[i]);
    }
out_err2:
    for (n = 0; n < i; n++) {
        kobject_put(rmcr_port_kobj[n]);
    }
    device_remove_file(dram_dev, arbiter_attrs[0]);
out_err1:
    return ret;
}
示例#15
0
int hua_ts_device_probe(struct hua_input_device *dev)
{
	int ret;
	struct hua_ts_device *ts = (struct hua_ts_device *) dev;
	struct hua_input_chip *chip = dev->chip;
	struct hua_input_core *core = chip->core;
	struct input_dev *input = dev->input;
	const struct hua_ts_touch_key *key, *key_end;
	const char *name;

	ret = hua_input_add_kobject(&core->prop_kobj, "board_properties");
	if (ret < 0 && ret != -EEXIST)
	{
		pr_red_info("hua_input_add_kobject");
		return ret;
	}

	name = kasprintf(GFP_KERNEL, "virtualkeys.%s", input->name);
	if (name == NULL)
	{
		ret = -ENOMEM;
		pr_red_info("kasprintf");
		goto out_hua_input_remove_kobject;
	}

	hua_ts_board_properties_attr.attr.name = name;

	ret = hua_input_create_sysfs_files(dev, &core->prop_kobj, &hua_ts_board_properties_attr, 1);
	if (ret < 0)
	{
		pr_red_info("hua_input_add_kobject");
		goto out_kfree_name;
	}

	ret = sysfs_create_files(&dev->misc_dev.dev->kobj, hua_ts_device_attributes);
	if (ret < 0)
	{
		pr_red_info("sysfs_create_files");
		goto out_hua_input_remove_sysfs_files;
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	ts->early_suspend.suspend = hua_ts_suspend;
	ts->early_suspend.resume = hua_ts_resume;
	register_early_suspend(&ts->early_suspend);
#elif defined(CONFIG_FB) && defined(CONFIG_HUAMOBILE_USE_FB_NOTIFILER)
	ts->fb_notifier.notifier_call = hua_ts_fb_notifier_call;
	ret = fb_register_client(&ts->fb_notifier);
	if (ret < 0)
	{
		pr_red_info("fb_register_client");
	}
#else
	ts->pm_notifier.notifier_call = hua_ts_pm_notifier_call;
	ret = register_pm_notifier(&ts->pm_notifier);
	if (ret < 0)
	{
		pr_red_info("register_pm_notifier");
	}
#endif

	set_bit(INPUT_PROP_DIRECT, input->propbit);

	set_bit(EV_KEY, input->evbit);
	set_bit(BTN_TOUCH, input->keybit);

	if (ts->keys && ts->key_count)
	{
		for (key = ts->keys, key_end = key + ts->key_count; key < key_end; key++)
		{
			set_bit(key->code, input->keybit);
		}
	}

	set_bit(EV_ABS, input->evbit);
	input_set_abs_params(input, ABS_MT_POSITION_X, ts->xmin, ts->xmax, dev->fuzz, dev->flat);
	input_set_abs_params(input, ABS_MT_POSITION_Y, ts->ymin, ts->ymax, 0, 0);
	input_set_abs_params(input, ABS_MT_TRACKING_ID, 0, ts->point_count - 1, 0, 0);

	input->open = hua_ts_device_open;
	dev->remove = hua_ts_device_remove;

	ts->touch_count = 0;

	pr_green_info("huamobile touch screen %s probe complete", dev->name);

	return 0;

out_hua_input_remove_sysfs_files:
	hua_input_remove_sysfs_files(&core->prop_kobj, &hua_ts_board_properties_attr, 1);
out_kfree_name:
	kfree(name);
out_hua_input_remove_kobject:
	hua_input_remove_kobject(&core->prop_kobj);
	return ret;
}