int felica_snfc_unregister(struct device *dev)
{
	struct felica_dev *d = dev_get_drvdata(dev);

	dev_dbg(dev, "%s\n", __func__);

	if (!dev || !reg_device || reg_device != dev)
		return -EINVAL;

	remove_sysfs_interfaces(&d->sysfs_dev);
	device_unregister(&d->sysfs_dev);

	felica_rws_remove_func(d);
	felica_int_remove_func(d);
	felica_rfs_remove_func(d);
	felica_pon_remove_func(d);
	felica_cen_remove_func(d);

	if (FELICA_SNFC == d->felica_data->type) {
		nfc_available_poll_remove_func(d);
		nfc_intu_poll_remove_func(d);
		nfc_hsel_remove_func(d);
	}

	kfree(d);

	reg_device = 0;

	return 0;
}
static int felica_remove(struct platform_device *pdev)
{
	struct felica_dev *dev = platform_get_drvdata(pdev);
	struct felica_platform_data *flc_pfdata;

	dev_dbg(&pdev->dev, "%s\n", __func__);

	remove_sysfs_interfaces(&pdev->dev);

	felica_rws_remove_func(dev);
	felica_int_remove_func(dev);
	felica_rfs_remove_func(dev);
	felica_pon_remove_func(dev);
	felica_cen_remove_func(dev);

#ifdef CONFIG_SONY_FELICA_NFC_SUPPORT
	snfc_available_poll_remove_func(dev);
	snfc_intu_poll_remove_func(dev);
	snfc_hsel_remove_func(dev);
#endif

	flc_pfdata = pdev->dev.platform_data;
	flc_pfdata->reg_release(dev);

	kfree(dev);

	return 0;
}
static int __devexit lsm303dlh_mag_remove(struct i2c_client *client)
{
	struct lsm303dlh_mag_data *mag = i2c_get_clientdata(client);

	input_unregister_device(mag->input_dev);
	remove_sysfs_interfaces(&client->dev);
	kfree(mag);
	return 0;
}
Example #4
0
static int __devexit lm356x_remove(struct i2c_client *client)
{
	struct lm356x_drv_data *data = dev_get_drvdata(&client->dev);
	struct lm356x_platform_data *pdata = client->dev.platform_data;

	remove_sysfs_interfaces(&client->dev);
	pdata->hw_disable();
	kfree(data);
	return 0;
}
Example #5
0
static int __devexit lsm303dlhc_mag_remove(struct i2c_client *client)
{
    struct lsm303dlhc_mag_data *mag = i2c_get_clientdata(client);

    device_remove_file(&mag->input_dev->dev,&dev_attr_enable);
    input_unregister_device(mag->input_dev);
    remove_sysfs_interfaces(mag->dev);
    sensors_classdev_unregister(mag->dev);
    kfree(mag);
    return 0;
}
static int __devexit lm3561_remove(struct i2c_client *client)
{
	struct lm3561_drv_data *data = dev_get_drvdata(&client->dev);
	struct lm3561_platform_data *pdata = client->dev.platform_data;

	remove_sysfs_interfaces(&client->dev);
	pm_runtime_suspend(&client->dev);
	pm_runtime_disable(&client->dev);
	if (pdata->platform_init)
		pdata->platform_init(&client->dev, false);
	kfree(data);
	return 0;
}
Example #7
0
static int gps_remove(struct platform_device *pdev)
{
	struct gps_dev *dev = _gps_dev;
	struct gps_config_info *gps_info = &dev->gps_info;
	
	remove_sysfs_interfaces(&pdev->dev);
	
	if(gps_info->gps_clk && strcmp(gps_info->gps_clk, "")){
		enable_gps_32k(0);
		clk_put(gps_32k);
	}
	return 0;
}
static int __devexit mpu_remove(struct i2c_client *client)
{
	struct mpu_data *mpu = i2c_get_clientdata(client);

	dev_dbg(&client->dev, "enter %s\n", __func__);
	if (client->irq > 0) {
		free_irq(client->irq, mpu);
		gpio_free(mpu->gpio);
	}

	disable_irq(mpu->client->irq);
	input_unregister_device(mpu->input_dev);
	mpu_disable(mpu);
	remove_sysfs_interfaces(&client->dev);
	kfree(mpu);
	return 0;
}
static int __devexit mma8452_remove(struct i2c_client *client)
{
    int ret;
    struct gs_mma8452_data *mma=i2c_get_clientdata(client);
    struct mma8452_acc_platform_data *devpd = client->dev.platform_data;
    ret = mma8452_disable(mma);

    input_unregister_device(mma->input_dev);
    input_free_device(mma->input_dev);

    remove_sysfs_interfaces(&client->dev);

    kfree(mma);
    if(devpd->power_off)
           devpd->power_off();
    return ret;
}
Example #10
0
static int simple_remote_remove(struct platform_device *pdev)
{
	struct simple_remote_driver *jack = platform_get_drvdata(pdev);

	if (switch_get_state(&jack->swdev)) {
		jack->interface->unregister_hssd_button_interrupt(jack);
		jack->interface->enable_mic_bias(0);
		switch_set_state(&jack->swdev, NO_DEVICE);
	}
	jack->interface->unregister_plug_detect_interrupt(jack);
	remove_sysfs_interfaces(&pdev->dev);
	input_unregister_device(jack->indev_appkey);
	input_unregister_device(jack->indev);
	switch_dev_unregister(&jack->swdev);
	kzfree(jack);

	return 0;
}
static int __devexit mipi_r63306_lcd_remove(struct platform_device *pdev)
{
	struct mipi_dsi_data *dsi_data;

	dsi_data = platform_get_drvdata(pdev);
	if (!dsi_data)
		return -ENODEV;

#ifdef CONFIG_DEBUG_FS
	mipi_dsi_panel_remove_debugfs(pdev);
#endif
#ifdef CONFIG_FB_MSM_RECOVER_PANEL
	remove_sysfs_interfaces(&pdev->dev);
#endif
	platform_set_drvdata(pdev, NULL);
	mipi_dsi_buf_release(&dsi_data->tx_buf);
	mipi_dsi_buf_release(&dsi_data->rx_buf);
	kfree(dsi_data);
	return 0;
}
Example #12
0
static int __devexit bma250_remove(struct i2c_client *ic_dev)
{
    struct driver_data *dd = bma250_ic_get_data(ic_dev);
    int                 rc;

    rc = bma250_power_down(dd);
    if (rc)
        dev_err(&dd->ip_dev->dev,
                "%s: power down failed with error %d\n",
                __func__, rc);
    remove_sysfs_interfaces(&dd->ip_dev->dev);
    input_unregister_device(dd->ip_dev);
    bma250_remove_dbfs_entry(dd);
    bma250_ic_set_data(ic_dev, NULL);
    mutex_lock(&bma250_dd_lock);
    list_del(&dd->next_dd);
    mutex_unlock(&bma250_dd_lock);
    kfree(dd);
    return 0;
}
Example #13
0
static int felica_remove(struct platform_device *pdev)
{
	struct felica_dev *dev = platform_get_drvdata(pdev);
	struct felica_platform_data	*flc_pfdata;

	dev_dbg(&pdev->dev, "%s\n", __func__);

	remove_sysfs_interfaces(&pdev->dev);

	felica_rws_remove_func(dev);
	felica_int_remove_func(dev);
	felica_rfs_remove_func(dev);
	felica_pon_remove_func(dev);
	felica_cen_remove_func(dev);

	flc_pfdata = pdev->dev.platform_data;
	flc_pfdata->reg_release(dev);

	kfree(dev);

	return 0;
}
static int l3g4200d_remove(struct i2c_client *client)
{
	struct l3g4200d_data *gyro = i2c_get_clientdata(client);

	dev_info(&client->dev, "L3G4200D driver removing\n");

	remove_sysfs_interfaces(&client->dev);
	unregister_early_suspend(&gyro->es);

	mutex_lock(&gyro->lock);
	l3g4200d_disable(gyro);
	mutex_unlock(&gyro->lock);

	/* there may be still a delayed work in execution, we must wait for
	 * its completion before we could reclaim resources.
	 */
	cancel_delayed_work_sync(&gyro->work);

	mutex_destroy(&gyro->lock);
	input_unregister_device(gyro->input_dev);
	kfree(gyro->pdata);
	kfree(gyro);
	return 0;
}
static int __devinit lsm303dlh_mag_probe(struct i2c_client *client,
				  const struct i2c_device_id *id)
{
	struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
	struct lsm303dlh_mag_platform_data *pdata = client->dev.platform_data;
	struct lsm303dlh_mag_data *mag;
	int result = 0;

	dev_info(&client->dev, "%s\n", __func__);
	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
		result = -EIO;
		goto err_check_functionality;
	}
	if (!pdata) {
		result = -EINVAL;
		dev_err(&client->dev, "%s: platform data required.\n",
			__func__);
		goto err_no_platform_data;
	}
	mag = kzalloc(sizeof(*mag), GFP_KERNEL);
	if (NULL == mag) {
		result = -ENOMEM;
		goto err_alloc_data_failed;
	}
	mag->client = client;
	mag->poll_interval_ms = pdata->poll_interval_ms;
	mag->range = pdata->range;
	i2c_set_clientdata(client, mag);
	if (pdata->power_on)
		mag->power_on = pdata->power_on;
	else
		mag->power_on = lsm303dlh_mag_power_stub;
	if (pdata->power_off)
		mag->power_off = pdata->power_off;
	else
		mag->power_off = lsm303dlh_mag_power_stub;
	mag->power_on();
	result = i2c_smbus_write_byte_data(client, MR_REG_M, IDLE_MODE);
	mag->power_off();
	if (result) {
		dev_err(&client->dev, "%s: Device not responding.\n",
			__func__);
		goto err_not_responding;
	}
	INIT_DELAYED_WORK(&mag->work, lsm303dlh_mag_poll_func);
	mutex_init(&mag->lock);
	result = create_sysfs_interfaces(&client->dev);
	if (result)
		goto err_sys_attr;
	mag->input_dev = input_allocate_device();
	if (!mag->input_dev) {
		dev_err(&client->dev, "%s: input_allocate_device failed\n",
			__func__);
		result = -ENOMEM;
		goto err_allocate_device;
	}
	input_set_drvdata(mag->input_dev, mag);

	mag->input_dev->open = lsm303dlh_mag_open;
	mag->input_dev->close = lsm303dlh_mag_close;
	mag->input_dev->name = LSM303DLH_MAG_DEV_NAME;
	set_bit(EV_ABS, mag->input_dev->evbit);
	set_bit(ABS_X, mag->input_dev->absbit);
	set_bit(ABS_Y, mag->input_dev->absbit);
	set_bit(ABS_Z, mag->input_dev->absbit);
	input_set_abs_params(mag->input_dev, ABS_X, -MAG_RANGE_MG,
			MAG_RANGE_MG - 1, 0, 0);
	input_set_abs_params(mag->input_dev, ABS_Y, -MAG_RANGE_MG,
			MAG_RANGE_MG - 1, 0, 0);
	input_set_abs_params(mag->input_dev, ABS_Z, -MAG_RANGE_MG,
			MAG_RANGE_MG - 1, 0, 0);

	result = input_register_device(mag->input_dev);
	if (result) {
		dev_err(&client->dev, "%s: input_register_device failed!",
			__func__);
		goto err_register_device;
	}

	dev_info(&client->dev, "%s completed.\n", __func__);
	return 0;

err_register_device:
	input_free_device(mag->input_dev);
err_allocate_device:
	remove_sysfs_interfaces(&client->dev);
err_sys_attr:
err_not_responding:
	kfree(mag);
err_alloc_data_failed:
err_no_platform_data:
err_check_functionality:
	dev_err(&client->dev, "%s failed.\n", __func__);
	return result;
}
Example #16
0
static int __devinit lsm303dlhc_mag_probe(struct i2c_client *client,
        const struct i2c_device_id *id)
{
    struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
    struct lsm303dlhc_mag_platform_data *pdata = client->dev.platform_data;
    struct lsm303dlhc_mag_data *mag;
    int result = 0;

    dev_info(&client->dev, "%s \n", __func__);

    if (!pdata) {
        result = -EINVAL;
        dev_err(&client->dev, "%s: platform data required.\n",
                __func__);
        goto err_no_platform_data;
    }
    mag = kzalloc(sizeof(*mag), GFP_KERNEL);
    if (NULL == mag) {
        result = -ENOMEM;
        goto err_alloc_data_failed;
    }
    mag->client = client;
    mag->poll_interval_ms = pdata->poll_interval_ms;
    mag->range = pdata->range;
    dev_info(&client->dev, "%s:pdata->range:%d\n", __func__, pdata->range);
    i2c_set_clientdata(client, mag);
    if (pdata->power_on)
        mag->power_on = pdata->power_on;
    else
        mag->power_on = lsm303dlhc_mag_power_stub;
    if (pdata->power_off)
        mag->power_off = pdata->power_off;
    else
        mag->power_off = lsm303dlhc_mag_power_stub;
    mag->power_on();
    lsm303dlhc_mag_config_regulator( mag , true);
    msleep(500);
    if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) {
        result = -EIO;
        goto err_check_functionality;
    }
    result = i2c_smbus_write_byte_data(client, MR_REG_M, IDLE_MODE);
    mag->power_off();
    lsm303dlhc_mag_config_regulator( mag , false);
    if (result) {
        dev_err(&client->dev, "%s: Device not responding.\n",
                __func__);
        goto err_not_responding;
    }
    INIT_DELAYED_WORK(&mag->work, lsm303dlhc_mag_poll_func);
    mutex_init(&mag->lock);

    mag->dev = sensors_classdev_register("magnetometer");

    result = create_sysfs_interfaces(mag->dev);
    if (result)
        goto err_sys_attr;
    dev_set_drvdata(mag->dev, mag);
    mag->input_dev = input_allocate_device();
    if (!mag->input_dev) {
        dev_err(&client->dev, "%s: input_allocate_device failed\n",
                __func__);
        result = -ENOMEM;
        goto err_allocate_device;
    }
    input_set_drvdata(mag->input_dev, mag);

    mag->input_dev->name = "magnetometer";
    set_bit(EV_ABS, mag->input_dev->evbit);
    set_bit(ABS_X, mag->input_dev->absbit);
    set_bit(ABS_Y, mag->input_dev->absbit);
    set_bit(ABS_Z, mag->input_dev->absbit);
    input_set_abs_params(mag->input_dev, ABS_X, -MAG_RANGE_MG,
                         MAG_RANGE_MG - 1, 0, 0);
    input_set_abs_params(mag->input_dev, ABS_Y, -MAG_RANGE_MG,
                         MAG_RANGE_MG - 1, 0, 0);
    input_set_abs_params(mag->input_dev, ABS_Z, -MAG_RANGE_MG,
                         MAG_RANGE_MG - 1, 0, 0);

    result = input_register_device(mag->input_dev);
    if (result) {
        dev_err(&client->dev, "%s: input_register_device failed!",
                __func__);
        goto err_register_device;
    }
    dev_set_drvdata(&mag->input_dev->dev, mag);

    if (device_create_file(&mag->input_dev->dev,
                           &dev_attr_enable) < 0) {
        pr_err("%s: Failed to create device file(%s)!\n", __func__,
               dev_attr_enable.attr.name);
        goto err_check_functionality;
    }

    mag->irq_m = pdata->irq_m;
    if (mag->irq_m > 0) { /* interrupt */

        mag->interruptible = true;
        result = request_threaded_irq(gpio_to_irq(mag->irq_m), NULL,
                                      lsm303dlhc_m_gpio_irq,
                                      IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "lsm303dlhc_m",
                                      mag);
        if (result) {
            dev_err(&client->dev, "request irq EGPIO_PIN_1 failed\n");
            goto err_check_functionality;
        }

        disable_irq(gpio_to_irq(mag->irq_m));
    }
    mag->interruptible = false;
    dev_info(&client->dev, "%s mag->interruptible=%d completed.\n", __func__, mag->interruptible);
    return 0;

err_register_device:
    input_free_device(mag->input_dev);
err_allocate_device:
    remove_sysfs_interfaces(mag->dev);
err_sys_attr:
err_not_responding:
    kfree(mag);
err_alloc_data_failed:
err_no_platform_data:
err_check_functionality:
    dev_err(&client->dev, "%s failed.\n", __func__);
    return result;
}
static int __devinit mpu_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct mpu_data *mpu;
	int ret;

	dev_info(&client->dev, "probe start. - new\n");

	mpu = kzalloc(sizeof(struct mpu_data), GFP_KERNEL);
	if (!mpu) {
		ret = -ENOMEM;
		dev_err(&client->dev, "failed to alloc memory: %d\n", ret);
		goto exit_alloc_failed;
	}
	mutex_init(&mpu->lock);
	mpu->client = client;
	i2c_set_clientdata(client, mpu);
	mpu->poll_interval = DEFAULT_POLL_INTERVAL;
	mpu->gpio = client->irq;

	ret = mpu_input_init(mpu);
	if (ret < 0) {
		dev_err(&client->dev, "input init failed\n");
		goto err_input_init_fail;
	}

	ret = mpu_reset(mpu);
	if (ret < 0) {
		dev_err(&client->dev, "reset failed\n");
		goto err_reset;
	}

	ret = mpu_hw_init(mpu);
	if (ret < 0) {
		dev_err(&client->dev, "hw init failed\n");
		goto err_hw_init;
	}

	ret = mpu_setup_irq(mpu);
	if (ret < 0) {
		dev_err(&client->dev,
			"fail to setup irq for gpio %d\n", mpu->gpio);
		goto err_setup_irq;
	}

	mpu->enabled = 0;
	mpu_disable(mpu);

	dev_info(&client->dev, "probed\n");
	return 0;

err_setup_irq:
err_hw_init:
	mpu_disable(mpu);
err_reset:
	input_unregister_device(mpu->input_dev);
	remove_sysfs_interfaces(&client->dev);
err_input_init_fail:
	kfree(mpu);
exit_alloc_failed:
	dev_err(&client->dev, "Driver Init failed\n");
	return ret;
}
static int  mma8452_probe(struct i2c_client *client ,
                                  const struct i2c_device_id *id)
{
    int err=-1,client_id;
    struct i2c_adapter *adapter;
    struct gs_mma8452_data *mma;
    struct mma8452_acc_platform_data *devpd =client->dev.platform_data;
    pr_info("%s: probe start.\n", MMA8452_ACC_DEV_NAME);

    if (!devpd)
    {
        dev_err(&client->dev, "No platfrom data!\n");
        err=-ENODEV;
        goto err_get_power_fail;
    }
    /*get power*/
    if(devpd->power_on)
    {
        err = devpd->power_on(&client->dev);
        if(err < 0)
        {
            dev_err(&client->dev, "mma8452_acc_probe: get power fail! result=%d\n", err);
            goto err_get_power_fail;
        }
        dev_dbg(&client->dev,"mma8452_acc_probe: get power success! \n");
    }
    dev_info(&client->dev, "mma8452_acc_probe: get power success! result=%d\n", err);

    /*check functionality*/
    adapter = to_i2c_adapter(client->dev.parent);
    err = i2c_check_functionality(adapter,
                     I2C_FUNC_SMBUS_BYTE |
                     I2C_FUNC_SMBUS_BYTE_DATA);
    if (!err)
    {
        dev_err(&client->dev, "client not i2c capable\n");
        err=-ENODEV;
        goto err_out;
    }

    msleep(5);

    client_id = i2c_smbus_read_byte_data(client, MMA8452_WHO_AM_I);     // MMA8452_WHO_AM_I=3A
    if (client_id != MMA8452_ID)
    {
        dev_err(&client->dev,
            "read chip ID 0x%x is not equal to 0x%x or 0x%x!\n",
            err, MMA8452_ID, MMA8452_ID);
        err = -EINVAL;
        goto err_out;
    }
	dev_info(&client->dev, "Read mma8452 chip ok, ID is 0x%x\n", client_id);
	err = set_sensor_chip_info(ACC, "FREESCALE MMA8452");
	if (err) {
		dev_err(&client->dev, "set_sensor_chip_info error \n");
	}
    /*allocate memory*/
    mma=kzalloc(sizeof(struct gs_mma8452_data), GFP_KERNEL);
    if (!mma)
    {
        err = -ENOMEM;
        dev_err(&client->dev,
                "failed to allocate memory for module data: "
                    "%d\n",err);
        goto err_out;
    }
	err =  i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG3, 0x2);
	if (err < 0) {
		dev_err(&client->dev, "%s: failed to selects the polarity of the interrupt signal\n", __func__);
		goto err_out;
	}
    mutex_init(&mma->lock);
    mma->client=client;
    i2c_set_clientdata(client,mma);
    /* Initialize the MMA8452 chip */
    err = mma8452_hw_init(mma);      // MOD_2G     0
    if (err<0)
    {
        dev_err(&client->dev,
            "error mma8452_hw_init init chip failed:(%d)\n", err);
        goto err_init;
    }

    /*Initialize the input device */
    err=mma8452_input_init(mma);
    if(err<0)
    {
        dev_err(&client->dev,"input init failed \n");
        goto err_init;
    }

    err = create_sysfs_interfaces(&client->dev);
    if (err < 0)
    {
        dev_err(&client->dev, "device MMA8452_ACC_DEV_NAME sysfs register failed\n");
        goto err_create_sysfs;
    }
    dev_info(&client->dev, "create_sysfs_interfaces: create interfaces success! ");
    mma->mma_status.position = devpd->config_mxc_mma_position;

    #ifdef CONFIG_HAS_EARLYSUSPEND
    mma->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
    mma->early_suspend.suspend = mma8452_early_suspend;
    mma->early_suspend.resume = mma8452_early_resume;
    register_early_suspend(&mma->early_suspend);
    #endif
#ifdef CONFIG_HUAWEI_HW_DEV_DCT
        /* detect current device successful, set the flag as present */
    set_hw_dev_flag(DEV_I2C_G_SENSOR);
#endif
    pr_info("%s: probe success.\n", MMA8452_ACC_DEV_NAME);
    return 0;

err_create_sysfs:
       remove_sysfs_interfaces(&client->dev);
       input_unregister_device(mma->input_dev);
       input_free_device(mma->input_dev);
err_init:
    kfree(mma);
err_out:
    if(devpd->power_off)
          devpd->power_off();
err_get_power_fail:
    return err;
}