Beispiel #1
0
static int
isl29023_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	int res;
	int err;
	int mode_check;

	struct isl29023_data *isl29023;
	pr_info("isl29023 probe begin...\n");

	isl29023 = kzalloc(sizeof(struct isl29023_data), GFP_KERNEL);
	if (!isl29023) {
		return -EINVAL;
	}

	err = isl29023_input_init(isl29023);
	if (err < 0) {
		goto err_exit;
	}

	err = sysfs_create_group(&client->dev.kobj, &m_isl_gr);
	if (err < 0) {
		goto err_exit;
	}

	res = isl_set_default_config(client);
	if (res < 0) {
		pr_warn("isl29023: set default config failed!!\n");
		is_device = 0;
		goto err_exit;
	}

	i2c_set_clientdata(client, isl29023);
	isl29023->client = client;

  /* setup driver interfaces */
	INIT_DELAYED_WORK(&isl29023->work, isl29023_work_func);


	last_mod = 0;
	mode_check = isl_set_mod(client, ISL_MOD_ALS_CONT);
	if (mode_check)
		schedule_delayed_work(&isl29023->work, delay_to_jiffies(1000) + 1);
	else
		cancel_delayed_work_sync(&isl29023->work);

#if DEBUG
	dev_dbg(&client->dev, "isl29023 probe succeed!\n");
#endif

	return res;

err_exit:
	kfree(isl29023);
	return -EINVAL;
}
Beispiel #2
0
static ssize_t
isl_enable_store(struct device *dev,
		      struct device_attribute *attr,
		      const char *buf, size_t count)
{
	struct isl29023_data *isl29023 = dev_get_drvdata(dev);
	int ret_val;
	unsigned long val;

	if (strict_strtoul(buf, 10, &val))
		return -EINVAL;

    //printk("[LIGHT]isl_enable_store val = %ld  \n",val);
    if(!is_device)
    {
        printk("[LIGHT] NO DEVICE is_device = %d  \n",is_device);
        return;
    }

    if(val == 1)
	    val = 5;  //ISL_MOD_ALS_CONT
    mutex_lock(&mutex);
	ret_val = isl_set_mod(isl29023->client, val);
	mutex_unlock(&mutex);

	if (ret_val < 0)
		return ret_val;

   if(val){
    schedule_delayed_work(&isl29023->work, delay_to_jiffies(3000) + 1);
#ifdef FEATURE_BACKLIGHT_ONOFF_LOG
    printk("[LIGHT] Power-Up \n");
#endif
   }
  else{
    cancel_delayed_work_sync(&isl29023->work);
#ifdef FEATURE_BACKLIGHT_ONOFF_LOG
    printk("[LIGHT] Power-Down \n");
#endif
   }

    return count;
}
static ssize_t isl_lmod_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
    struct i2c_client *client = isl29030_i2c_client;
    int ret_val;
    unsigned long val;

    if (strict_strtoul(buf, 10, &val))
        return -EINVAL;
    if (val > 2)
        return -EINVAL;

    mutex_lock(&mutex);
    //pm_runtime_get_sync(dev);
    ret_val = isl_set_mod(client, ISL_FUNC_ALS, val);
    //pm_runtime_put_sync(dev);
    mutex_unlock(&mutex);

    if (ret_val < 0)
        return ret_val;
    return count;
}
Beispiel #4
0
static int
isl29023_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	int res;
	int err;
	int mode_check;
  
	struct isl29023_data *isl29023;
	printk("[LIGHT] Isl29023 Probe \n");

	isl29023 = kzalloc(sizeof(struct isl29023_data), GFP_KERNEL);
	if (!isl29023) {
		return -EINVAL;
	}

    //printk(KERN_INFO MODULE_NAME ": %s isl29023 probe call, ID= %s\n", __func__, id->name);
#if 1
	err = isl29023_input_init(isl29023);
	if (err < 0) {
		return -EINVAL;
	}
 	err = sysfs_create_group(&isl29023->input->dev.kobj, &m_isl_gr);
	if (err < 0) {
		return -EINVAL;
	}
#endif
	res = isl_set_default_config(client);
	if (res < 0) {
		//pr_warn("isl29023: set default config failed!!\n");
     printk(KERN_INFO MODULE_NAME ": %s isl29023 set default config failed\n", __func__);

     is_device = 0;
     //
		return -EINVAL;
	}

  i2c_set_clientdata(client, isl29023);
  isl29023->client = client;
  
  /* setup driver interfaces */
    INIT_DELAYED_WORK(&isl29023->work, isl29023_work_func);


  last_mod = 0;
  mode_check = isl_set_mod(client, ISL_MOD_ALS_CONT);
  if (mode_check)
    schedule_delayed_work(&isl29023->work, delay_to_jiffies(3000) + 1);
  else
    cancel_delayed_work_sync(&isl29023->work);

  
#if 0 //Ĩ�� �ҷ����� ���� Ÿ ������ �������� ���� ���� �۾�.
	err = isl29023_input_init(isl29023);
	if (err < 0) {
		return -EINVAL;
	}
  
	err = sysfs_create_group(&isl29023->input->dev.kobj, &m_isl_gr);
	if (err < 0) {
		return -EINVAL;
	}
#endif
  
//  pm_runtime_enable(&client->dev);

#if DEBUG
	dev_dbg(&client->dev, "isl29023 probe succeed!\n");
#endif

	return res;
}