Пример #1
0
int chp_add_cmg_attr(struct channel_path *chp)
{
	int ret;

	ret = device_create_bin_file(&chp->dev, &chp_measurement_chars_attr);
	if (ret)
		return ret;
	ret = device_create_bin_file(&chp->dev, &chp_measurement_attr);
	if (ret)
		device_remove_bin_file(&chp->dev, &chp_measurement_chars_attr);
	return ret;
}
Пример #2
0
/**
 * tpd_classdev_register - register a new object of tpd_classdev_t class.
 * @parent: The device to register.
 * @tsp_fw_cdev: the tpd_classdev_t structure for this device.
 */
int tpd_classdev_register(struct device *parent, struct tpd_classdev_t *tsp_fw_cdev)
{
	int error = 0;
	
	tsp_fw_cdev->dev = device_create(tsp_fw_class, parent, 0, tsp_fw_cdev,
					  "%s", tsp_fw_cdev->name);
	if (IS_ERR(tsp_fw_cdev->dev))
		return PTR_ERR(tsp_fw_cdev->dev);

	error = device_create_bin_file(tsp_fw_cdev->dev, &firmware_attr_data);
	if (error) {
		dev_err(tsp_fw_cdev->dev, "%s: sysfs_create_bin_file failed\n", __func__);
	}

	/* add to the list of tp_firmware */
	down_write(&tp_firmware_list_lock);
	list_add_tail(&tsp_fw_cdev->node, &tp_firmware_list);
	up_write(&tp_firmware_list_lock);

	g_cdev = tsp_fw_cdev;

	mutex_init(&tsp_fw_cdev->flash_mutex);
	mutex_init(&tpd_sys_cmd_mutex);
	init_waitqueue_head(&tsp_fw_cdev->wait);
	INIT_WORK(&tsp_fw_cdev->sdcard_upgrade_work, tpd_image_file_work);
	INIT_WORK(&tsp_fw_cdev->check_fwinfo_work,tsp_fw_compare_work);
	TPD_DMESG(KERN_DEBUG "Registered tsp_fw device: %s\n",
			tsp_fw_cdev->name);
       DSX_FW("Exit %s@%d %s\n",__func__,__LINE__,tsp_fw_cdev->name); 
	return 0;
}
Пример #3
0
static int __init
hdmi_module_init(void)
{
	int ret = 0, err;

	__inf("hdmi_module_init\n");

	alloc_chrdev_region(&devid, 0, 1, "hdmi");
	my_cdev = cdev_alloc();
	cdev_init(my_cdev, &hdmi_fops);
	my_cdev->owner = THIS_MODULE;
	err = cdev_add(my_cdev, devid, 1);
	if (err) {
		__wrn("cdev_add fail.\n");
		return -1;
	}

	hdmi_class = class_create(THIS_MODULE, "hdmi");
	if (IS_ERR(hdmi_class)) {
		__wrn("class_create fail\n");
		return -1;
	}

	hdmi_edid_sysfs_dev = device_create(hdmi_class, NULL, devid, NULL, "hdmi");
	ret = device_create_bin_file(hdmi_edid_sysfs_dev, &dev_attr_edid);
	if(ret)
		printk("binfile create err %s %s %d\n",__FILE__,__func__,__LINE__);
	hdmi_edid_buf = edid_buf;

	ret = platform_device_register(&hdmi_device);
	if (ret == 0)
		ret = platform_driver_register(&hdmi_driver);

	return ret;
}
Пример #4
0
int usb_create_sysfs_dev_files(struct usb_device *udev)
{
    struct device *dev = &udev->dev;
    int retval;

    /* Unforunately these attributes cannot be created before
     * the uevent is broadcast.
     */
    retval = device_create_bin_file(dev, &dev_bin_attr_descriptors);
    if (retval)
        goto error;

    retval = add_persist_attributes(dev);
    if (retval)
        goto error;

    retval = add_power_attributes(dev);
    if (retval)
        goto error;

    retval = usb_create_ep_files(dev, &udev->ep0, udev);
    if (retval)
        goto error;
    return 0;
error:
    usb_remove_sysfs_dev_files(udev);
    return retval;
}
Пример #5
0
static int __init olpc_bat_init(void)
{
	int ret = 0;
	uint8_t status;

	if (!olpc_platform_info.ecver)
		return -ENXIO;

	/*
	 * We've seen a number of EC protocol changes; this driver requires
	 * the latest EC protocol, supported by 0x44 and above.
	 */
	if (olpc_platform_info.ecver < 0x44) {
		printk(KERN_NOTICE "OLPC EC version 0x%02x too old for "
			"battery driver.\n", olpc_platform_info.ecver);
		return -ENXIO;
	}

	ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &status, 1);
	if (ret)
		return ret;

	/* Ignore the status. It doesn't actually matter */

	bat_pdev = platform_device_register_simple("olpc-battery", 0, NULL, 0);
	if (IS_ERR(bat_pdev))
		return PTR_ERR(bat_pdev);

	ret = power_supply_register(&bat_pdev->dev, &olpc_ac);
	if (ret)
		goto ac_failed;

	olpc_bat.name = bat_pdev->name;

	ret = power_supply_register(&bat_pdev->dev, &olpc_bat);
	if (ret)
		goto battery_failed;

	ret = device_create_bin_file(olpc_bat.dev, &olpc_bat_eeprom);
	if (ret)
		goto eeprom_failed;

	ret = device_create_file(olpc_bat.dev, &olpc_bat_error);
	if (ret)
		goto error_failed;

	goto success;

error_failed:
	device_remove_bin_file(olpc_bat.dev, &olpc_bat_eeprom);
eeprom_failed:
	power_supply_unregister(&olpc_bat);
battery_failed:
	power_supply_unregister(&olpc_ac);
ac_failed:
	platform_device_unregister(bat_pdev);
success:
	return ret;
}
Пример #6
0
void create_sysfs_files() { int thread_id = corral_getThreadID();
  corral_atomic_begin();
  __hv_assume ((sysfs_lock) == (0));
  sysfs_lock = thread_id;
  corral_atomic_end();
  device_create_bin_file();
  sysfs_lock = 0;
}
Пример #7
0
static int __init olpc_bat_init(void)
{
	int ret = 0;
	uint8_t status;

	if (!olpc_platform_info.ecver)
		return -ENXIO;

	
	if (olpc_platform_info.ecver < 0x44) {
		printk(KERN_NOTICE "OLPC EC version 0x%02x too old for "
			"battery driver.\n", olpc_platform_info.ecver);
		return -ENXIO;
	}

	ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &status, 1);
	if (ret)
		return ret;

	

	bat_pdev = platform_device_register_simple("olpc-battery", 0, NULL, 0);
	if (IS_ERR(bat_pdev))
		return PTR_ERR(bat_pdev);

	ret = power_supply_register(&bat_pdev->dev, &olpc_ac);
	if (ret)
		goto ac_failed;

	olpc_bat.name = bat_pdev->name;

	ret = power_supply_register(&bat_pdev->dev, &olpc_bat);
	if (ret)
		goto battery_failed;

	ret = device_create_bin_file(olpc_bat.dev, &olpc_bat_eeprom);
	if (ret)
		goto eeprom_failed;

	ret = device_create_file(olpc_bat.dev, &olpc_bat_error);
	if (ret)
		goto error_failed;

	goto success;

error_failed:
	device_remove_bin_file(olpc_bat.dev, &olpc_bat_eeprom);
eeprom_failed:
	power_supply_unregister(&olpc_bat);
battery_failed:
	power_supply_unregister(&olpc_ac);
ac_failed:
	platform_device_unregister(bat_pdev);
success:
	return ret;
}
Пример #8
0
static int solo_sysfs_init(struct solo_dev *solo_dev)
{
	bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
	struct device *dev = &solo_dev->dev;
	const char *driver;
	int i;

	if (solo_dev->type == SOLO_DEV_6110)
		driver = "solo6110";
	else
		driver = "solo6010";

	dev->release = solo_device_release;
	dev->parent = &solo_dev->pdev->dev;
	set_dev_node(dev, dev_to_node(&solo_dev->pdev->dev));
	dev_set_name(dev, "%s-%d-%d", driver, solo_dev->vfd->num,
		     solo_dev->nr_chans);

	if (device_register(dev)) {
		dev->parent = NULL;
		return -ENOMEM;
	}

	for (i = 0; i < ARRAY_SIZE(solo_dev_attrs); i++) {
		if (device_create_file(dev, &solo_dev_attrs[i])) {
			device_unregister(dev);
			return -ENOMEM;
		}
	}

	sysfs_attr_init(&sdram_attr->attr);
	sdram_attr->attr.name = "sdram";
	sdram_attr->attr.mode = 0440;
	sdram_attr->read = sdram_show;
	sdram_attr->size = solo_dev->sdram_size;

	if (device_create_bin_file(dev, sdram_attr)) {
		device_unregister(dev);
		return -ENOMEM;
	}

	return 0;
}
Пример #9
0
int usb_create_sysfs_dev_files(struct usb_device *udev)
{
	struct device *dev = &udev->dev;
	int retval;

	retval = device_create_bin_file(dev, &dev_bin_attr_descriptors);
	if (retval)
		goto error;

	retval = add_persist_attributes(dev);
	if (retval)
		goto error;

	retval = add_power_attributes(dev);
	if (retval)
		goto error;
	return retval;
error:
	usb_remove_sysfs_dev_files(udev);
	return retval;
}
Пример #10
0
int usb_create_sysfs_dev_files(struct usb_device *udev)
{
	struct device *dev = &udev->dev;
	int retval;

	retval = sysfs_create_group(&dev->kobj, &dev_attr_grp);
	if (retval)
		return retval;

	retval = device_create_bin_file(dev, &dev_bin_attr_descriptors);
	if (retval)
		goto error;

	retval = add_power_attributes(dev);
	if (retval)
		goto error;

	if (udev->manufacturer) {
		retval = device_create_file(dev, &dev_attr_manufacturer);
		if (retval)
			goto error;
	}
	if (udev->product) {
		retval = device_create_file(dev, &dev_attr_product);
		if (retval)
			goto error;
	}
	if (udev->serial) {
		retval = device_create_file(dev, &dev_attr_serial);
		if (retval)
			goto error;
	}
	retval = usb_create_ep_files(dev, &udev->ep0, udev);
	if (retval)
		goto error;
	return 0;
error:
	usb_remove_sysfs_dev_files(udev);
	return retval;
}
Пример #11
0
int wlcore_sysfs_init(struct wl1271 *wl)
{
	int ret;

	/* Create sysfs file to control bt coex state */
	ret = device_create_file(wl->dev, &dev_attr_bt_coex_state);
	if (ret < 0) {
		wl1271_error("failed to create sysfs file bt_coex_state");
		goto out;
	}

	/* Create sysfs file to get HW PG version */
	ret = device_create_file(wl->dev, &dev_attr_hw_pg_ver);
	if (ret < 0) {
		wl1271_error("failed to create sysfs file hw_pg_ver");
		goto out_bt_coex_state;
	}

	/* Create sysfs file for the FW log */
	ret = device_create_bin_file(wl->dev, &fwlog_attr);
	if (ret < 0) {
		wl1271_error("failed to create sysfs file fwlog");
		goto out_hw_pg_ver;
	}

	goto out;

out_hw_pg_ver:
	device_remove_file(wl->dev, &dev_attr_hw_pg_ver);

out_bt_coex_state:
	device_remove_file(wl->dev, &dev_attr_bt_coex_state);

out:
	return ret;
}
Пример #12
0
static int
mic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
	int brdnum = mic_data.dd_numdevs;
	int err = 0;
	bd_info_t *bd_info;
	mic_ctx_t *mic_ctx;
#ifdef CONFIG_PCI_MSI
	int i=0;
#endif
	if ((bd_info = (bd_info_t *)kzalloc(sizeof(bd_info_t), GFP_KERNEL)) == NULL) {
		printk("MIC: probe failed allocating memory for bd_info\n");
		return -ENOSPC;
	}

	mic_ctx = &bd_info->bi_ctx;
	mic_ctx->bd_info = bd_info;
	mic_ctx->bi_id = brdnum;
	mic_ctx->bi_pdev = pdev;
	mic_ctx->msie = 0;
	mic_data.dd_bi[brdnum] = bd_info;

	if ((err = pci_enable_device(pdev))) {
		printk("pci_enable failed board #%d\n", brdnum);
		goto probe_freebd;
	}

	pci_set_master(pdev);
	err = pci_reenable_device(pdev);
	err = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
	if (err) {
		printk("mic %d: ERROR DMA not available\n", brdnum);
		goto probe_freebd;
	}
	err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
	if (err) {
		printk("mic %d: ERROR pci_set_consistent_dma_mask(64) %d\n", brdnum, err);
		err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
		if (err) {
			printk("mic %d: ERROR pci_set_consistent_dma_mask(32) %d\n", brdnum, err);
			goto probe_freebd;
		}
	}

	// Allocate bar 4 for MMIO and GTT
	bd_info->bi_ctx.mmio.pa = pci_resource_start(pdev, DLDR_MMIO_BAR);
	bd_info->bi_ctx.mmio.len = pci_resource_len(pdev, DLDR_MMIO_BAR);
	if (request_mem_region(bd_info->bi_ctx.mmio.pa,
	    bd_info->bi_ctx.mmio.len, "mic") == NULL) {
		printk("mic %d: failed to reserve mmio space\n", brdnum);
		goto probe_freebd;
	}

	// Allocate bar 0 for access Aperture
	bd_info->bi_ctx.aper.pa = pci_resource_start(pdev, DLDR_APT_BAR);
	bd_info->bi_ctx.aper.len = pci_resource_len(pdev, DLDR_APT_BAR);
	if (request_mem_region(bd_info->bi_ctx.aper.pa,
	    bd_info->bi_ctx.aper.len, "mic") == NULL) {
		printk("mic %d: failed to reserve aperture space\n", brdnum);
		goto probe_relmmio;
	}

#ifdef CONFIG_PCI_MSI
	if (mic_msi_enable){
		for (i = 0; i < MIC_NUM_MSIX_ENTRIES; i ++)
			bd_info->bi_msix_entries[i].entry = i;
		err = pci_enable_msix(mic_ctx->bi_pdev, bd_info->bi_msix_entries,
				      MIC_NUM_MSIX_ENTRIES);
		if (err == 0 ) {
			// Only support 1 MSIx for now
			err = request_irq(bd_info->bi_msix_entries[0].vector,
					  mic_irq_isr, 0, "mic", mic_ctx);
			if (err != 0) {
				printk("MIC: Error in request_irq %d\n", err);
				goto probe_relaper;
			}
			mic_ctx->msie = 1;
		}
	}
#endif

	// TODO: this needs to be hardened and actually return errors
	if ((err = adapter_init_device(mic_ctx)) != 0) {
		printk("MIC: Adapter init device failed %d\n", err);
		goto probe_relaper;
	}

	// Adding sysfs entries
	set_sysfs_entries(mic_ctx);

	bd_info->bi_sysfsdev = device_create(mic_lindata.dd_class, &pdev->dev,
			mic_lindata.dd_dev + 2 + mic_ctx->bd_info->bi_ctx.bi_id,
			NULL, "mic%d", mic_ctx->bd_info->bi_ctx.bi_id);
	err = sysfs_create_group(&mic_ctx->bd_info->bi_sysfsdev->kobj, &bd_attr_group);
	mic_ctx->sysfs_state = sysfs_get_dirent(mic_ctx->bd_info->bi_sysfsdev->kobj.sd,
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35))
				//NULL,
#endif
				"state");

	dev_set_drvdata(mic_ctx->bd_info->bi_sysfsdev, mic_ctx);

	if (!mic_ctx->msie)
		if ((err = request_irq(mic_ctx->bi_pdev->irq, mic_irq_isr,
				       IRQF_SHARED, "mic", mic_ctx)) != 0) {
			printk("MIC: Error in request_irq %d\n", err);
			goto probe_unmapaper;
		}

	adapter_probe(&bd_info->bi_ctx);

	if (mic_ctx->bi_psmi.enabled) {
		err = sysfs_create_group(&mic_ctx->bd_info->bi_sysfsdev->kobj,
						&psmi_attr_group);
		err = device_create_bin_file(mic_ctx->bd_info->bi_sysfsdev,
						&mic_psmi_ptes_attr);
	}

	adapter_wait_reset(mic_ctx);

	// Adding a board instance so increment the total number of MICs in the system.
	list_add_tail(&bd_info->bi_list, &mic_data.dd_bdlist);
	mic_data.dd_numdevs++;
	printk("mic_probe %d:%d:%d as board #%d\n", pdev->bus->number,
	       PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), brdnum);
	return 0;

probe_unmapaper:
	wait_event(mic_ctx->ioremapwq, mic_ctx->aper.va || mic_ctx->state == MIC_RESETFAIL);
	if (mic_ctx->aper.va)
		iounmap((void *)bd_info->bi_ctx.aper.va);
	iounmap((void *)bd_info->bi_ctx.mmio.va);

probe_relaper:
	release_mem_region(bd_info->bi_ctx.aper.pa, bd_info->bi_ctx.aper.len);

probe_relmmio:
	release_mem_region(bd_info->bi_ctx.mmio.pa, bd_info->bi_ctx.mmio.len);

probe_freebd:
	kfree(bd_info);
	return err;
}
Пример #13
0
static int olpc_battery_probe(struct platform_device *pdev)
{
	int ret;
	uint8_t status;

	/*
	 * We've seen a number of EC protocol changes; this driver requires
	 * the latest EC protocol, supported by 0x44 and above.
	 */
	if (olpc_platform_info.ecver < 0x44) {
		printk(KERN_NOTICE "OLPC EC version 0x%02x too old for "
			"battery driver.\n", olpc_platform_info.ecver);
		return -ENXIO;
	}

	ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &status, 1);
	if (ret)
		return ret;

	/* Ignore the status. It doesn't actually matter */

	olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, NULL);
	if (IS_ERR(olpc_ac))
		return PTR_ERR(olpc_ac);

	if (olpc_board_at_least(olpc_board_pre(0xd0))) { /* XO-1.5 */
		olpc_bat_desc.properties = olpc_xo15_bat_props;
		olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo15_bat_props);
	} else { /* XO-1 */
		olpc_bat_desc.properties = olpc_xo1_bat_props;
		olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props);
	}

	olpc_bat = power_supply_register(&pdev->dev, &olpc_bat_desc, NULL);
	if (IS_ERR(olpc_bat)) {
		ret = PTR_ERR(olpc_bat);
		goto battery_failed;
	}

	ret = device_create_bin_file(&olpc_bat->dev, &olpc_bat_eeprom);
	if (ret)
		goto eeprom_failed;

	ret = device_create_file(&olpc_bat->dev, &olpc_bat_error);
	if (ret)
		goto error_failed;

	if (olpc_ec_wakeup_available()) {
		device_set_wakeup_capable(&olpc_ac->dev, true);
		device_set_wakeup_capable(&olpc_bat->dev, true);
	}

	return 0;

error_failed:
	device_remove_bin_file(&olpc_bat->dev, &olpc_bat_eeprom);
eeprom_failed:
	power_supply_unregister(olpc_bat);
battery_failed:
	power_supply_unregister(olpc_ac);
	return ret;
}
Пример #14
0
struct c2port_device *c2port_device_register(char *name,
					struct c2port_ops *ops, void *devdata)
{
	struct c2port_device *c2dev;
	int id, ret;

	if (unlikely(!ops) || unlikely(!ops->access) || \
		unlikely(!ops->c2d_dir) || unlikely(!ops->c2ck_set) || \
		unlikely(!ops->c2d_get) || unlikely(!ops->c2d_set))
		return ERR_PTR(-EINVAL);

	c2dev = kmalloc(sizeof(struct c2port_device), GFP_KERNEL);
	if (unlikely(!c2dev))
		return ERR_PTR(-ENOMEM);

	ret = idr_pre_get(&c2port_idr, GFP_KERNEL);
	if (!ret) {
		ret = -ENOMEM;
		goto error_idr_get_new;
	}

	spin_lock_irq(&c2port_idr_lock);
	ret = idr_get_new(&c2port_idr, c2dev, &id);
	spin_unlock_irq(&c2port_idr_lock);

	if (ret < 0)
		goto error_idr_get_new;
	c2dev->id = id;

	c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
					"c2port%d", id);
	if (unlikely(!c2dev->dev)) {
		ret = -ENOMEM;
		goto error_device_create;
	}
	dev_set_drvdata(c2dev->dev, c2dev);

	strncpy(c2dev->name, name, C2PORT_NAME_LEN);
	c2dev->ops = ops;
	mutex_init(&c2dev->mutex);

	/* Create binary file */
	c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
	ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
	if (unlikely(ret))
		goto error_device_create_bin_file;

	/* By default C2 port access is off */
	c2dev->access = c2dev->flash_access = 0;
	ops->access(c2dev, 0);

	dev_info(c2dev->dev, "C2 port %s added\n", name);
	dev_info(c2dev->dev, "%s flash has %d blocks x %d bytes "
				"(%d bytes total)\n",
				name, ops->blocks_num, ops->block_size,
				ops->blocks_num * ops->block_size);

	return c2dev;

error_device_create_bin_file:
	device_destroy(c2port_class, 0);

error_device_create:
	spin_lock_irq(&c2port_idr_lock);
	idr_remove(&c2port_idr, id);
	spin_unlock_irq(&c2port_idr_lock);

error_idr_get_new:
	kfree(c2dev);

	return ERR_PTR(ret);
}
Пример #15
0
void create_sysfs_files() {
  lock(sysfs_lock);
  device_create_bin_file();
  unlock(sysfs_lock);
}
Пример #16
0
/*
** Called at initialization time.
*/
IMMVIBESPIAPI VibeStatus ImmVibeSPI_ForceOut_Initialize(void)
{
    struct i2c_adapter* adapter;
    struct i2c_client* client;
    int retVal = 0;

    DbgOut((DBL_VERBOSE, "ImmVibeSPI_ForceOut_Initialize.\n"));

    g_bAmpEnabled = true;	/* to force ImmVibeSPI_ForceOut_AmpDisable disabling the amp */

    /* From Xiaomi start*/
    vibe_strength = REAL_TIME_PLAYBACK_CALIBRATION_STRENGTH;
    if (get_hw_version_major() == 5)
        GPIO_VIBTONE_EN1 = 64;
    else
        GPIO_VIBTONE_EN1 = 86;

    if (gpio_request(GPIO_VIBTONE_EN1, "vibrator-en") < 0) {
        printk(KERN_ALERT"drv2604: error requesting gpio\n");
        return VIBE_E_FAIL;
    }
    /* From Xiaomi end */

    adapter = i2c_get_adapter(DEVICE_BUS);

    if (adapter) {
        client = i2c_new_device(adapter, &info);

        if (client) {
            retVal = i2c_add_driver(&drv2604_driver);

            if (retVal)
                return VIBE_E_FAIL;
        } else {
            DbgOut((DBL_VERBOSE, "drv2604: Cannot create new device.\n"));
            return VIBE_E_FAIL;
        }
    } else {
        DbgOut((DBL_VERBOSE, "ImmVibeSPI_ForceOut_AmpDisable.\n"));
        return VIBE_E_FAIL;
    }

    if(g_autotune_brake_enabled)
        g_workqueue = create_workqueue("tspdrv_workqueue");

    /* From Xiaomi start */
    if (timed_output_dev_register(&to_dev) < 0) {
        printk(KERN_ALERT"drv2604: fail to create timed output dev: enable\n");
        gpio_direction_output(GPIO_VIBTONE_EN1, GPIO_LEVEL_LOW);
        gpio_free(GPIO_VIBTONE_EN1);
        i2c_del_driver(&drv2604_driver);
        i2c_unregister_device(client);
        return VIBE_E_FAIL;
    }

    if ( device_create_bin_file(to_dev.dev, &drv2604_bin_attrs)) {
        printk(KERN_ALERT"drv2604: fail to create timed output dev: pattern\n");
        return VIBE_E_FAIL;
    }

    hrtimer_init(&vibdata.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
    vibdata.timer.function = vibrator_timer_func;
    INIT_WORK(&vibdata.work, vibrator_work);
    // INIT_WORK(&vibdata.work_play_eff, play_effect);

    wake_lock_init(&vibdata.wklock, WAKE_LOCK_SUSPEND, "vibrator");
    mutex_init(&vibdata.lock);

    /* PWM */
    /*
    vibdata.pwm_dev = pwm_request(PWM_CH_ID, "drv2604");
    if (IS_ERR(vibdata.pwm_dev))
    	dev_err(&client->dev, "%s: pwm request failed\n", __func__);
    */
    printk(KERN_ALERT"drv2604: initialized on M3\n");
    /* From Xiaomi end */

    ImmVibeSPI_ForceOut_AmpDisable(0);

    vibe_kobj = kobject_create_and_add("vibrator", NULL);
    if (!vibe_kobj)
        return VIBE_S_SUCCESS;

    retVal = sysfs_create_file(vibe_kobj, &dev_attr_pwmvalue.attr);

    if (retVal)
        DbgOut((DBL_VERBOSE, "drv2604: vibrator creat fail.\n"));

    return VIBE_S_SUCCESS;
}
Пример #17
0
static int cyttsp5_loader_probe(struct device *dev)
{
	struct cyttsp5_core_data *cd = dev_get_drvdata(dev);
	struct cyttsp5_loader_data *ld;
	struct cyttsp5_platform_data *pdata = dev_get_platdata(dev);
	int rc;

	if (!pdata || !pdata->loader_pdata) {
		dev_err(dev, "%s: Missing platform data\n", __func__);
		rc = -ENODEV;
		goto error_no_pdata;
	}

	ld = kzalloc(sizeof(*ld), GFP_KERNEL);
	if (!ld) {
		rc = -ENOMEM;
		goto error_alloc_data_failed;
	}

#ifdef CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP568_PLATFORM_FW_UPGRADE
	rc = device_create_file(dev, &dev_attr_forced_upgrade);
	if (rc) {
		dev_err(dev, "%s: Error, could not create forced_upgrade\n",
				__func__);
		goto error_create_forced_upgrade;
	}
#endif

#ifdef CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP568_BINARY_FW_UPGRADE
	rc = device_create_file(dev, &dev_attr_manual_upgrade);
	if (rc) {
		dev_err(dev, "%s: Error, could not create manual_upgrade\n",
				__func__);
		goto error_create_manual_upgrade;
	}
#endif

#ifdef CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP568_MANUAL_TTCONFIG_UPGRADE
	rc = device_create_file(dev, &dev_attr_config_loading);
	if (rc) {
		dev_err(dev, "%s: Error, could not create config_loading\n",
				__func__);
		goto error_create_config_loading;
	}

	rc = device_create_bin_file(dev, &bin_attr_config_data);
	if (rc) {
		dev_err(dev, "%s: Error, could not create config_data\n",
				__func__);
		goto error_create_config_data;
	}
#endif
/*** ZTEMT Added by luochangyang, 2013/09/12 ***/
    rc = device_create_file(dev, &dev_attr_fw_upgrade_flag);
    if(rc){
        dev_err(dev,"%s Error, could not create fw_upgrade_flag\n",
            __func__);
        goto error_create_manual_cali;
    }

	rc = device_create_file(dev, &dev_attr_manual_cali);
	if (rc) {
		dev_err(dev, "%s: Error, could not create manual_cali\n",
				__func__);
		goto error_create_manual_cali;
	}
/***ZTEMT END***/

	ld->loader_pdata = pdata->loader_pdata;
	ld->dev = dev;
	cd->cyttsp5_dynamic_data[CY_MODULE_LOADER] = ld;
/*** ZTEMT Added by luochangyang, 2013/09/12 ***/
	init_completion(&(ld->cyttsp_cali_complete));
/*** ZTEMT END ***/

#if CYTTSP5_FW_UPGRADE
	init_completion(&ld->int_running);
#ifdef CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP568_BINARY_FW_UPGRADE
	init_completion(&ld->builtin_bin_fw_complete);
#endif
	cmd->subscribe_attention(dev, CY_ATTEN_IRQ, CY_MODULE_LOADER,
		cyttsp5_loader_attention, CY_MODE_BOOTLOADER);

	cmd->subscribe_attention(dev, CY_ATTEN_LOADER, CY_MODULE_LOADER,
		cyttsp5_fw_upgrade_cb, CY_MODE_UNKNOWN);
#endif
#if CYTTSP5_FW_UPGRADE || CYTTSP5_TTCONFIG_UPGRADE
	init_completion(&ld->calibration_complete);
	INIT_WORK(&ld->calibration_work, cyttsp5_calibrate_idacs);
#endif
#ifdef CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP568_MANUAL_TTCONFIG_UPGRADE
	mutex_init(&ld->config_lock);
#endif

#ifdef UPGRADE_FW_AND_CONFIG_IN_PROBE
	/* Call FW and config upgrade directly in probe */
	cyttsp5_fw_and_config_upgrade(&ld->fw_and_config_upgrade);
#else
	INIT_WORK(&ld->fw_and_config_upgrade, cyttsp5_fw_and_config_upgrade);
	schedule_work(&ld->fw_and_config_upgrade);
#endif

	dev_info(dev, "%s: Successful probe %s\n", __func__, dev_name(dev));
	return 0;

error_create_manual_cali:

#ifdef CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP568_MANUAL_TTCONFIG_UPGRADE
error_create_config_data:
	device_remove_file(dev, &dev_attr_config_loading);
error_create_config_loading:
#endif
#ifdef CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP568_BINARY_FW_UPGRADE
	device_remove_file(dev, &dev_attr_manual_upgrade);
error_create_manual_upgrade:
#endif
#ifdef CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP568_PLATFORM_FW_UPGRADE
	device_remove_file(dev, &dev_attr_forced_upgrade);
error_create_forced_upgrade:
#endif
	cd->cyttsp5_dynamic_data[CY_MODULE_LOADER] = NULL;
	kfree(ld);
error_alloc_data_failed:
error_no_pdata:
	dev_err(dev, "%s failed.\n", __func__);
	return rc;
}