static void mtd_notify_add(struct mtd_info* mtd)
{
	if (!mtd)
		return;

#ifdef CONFIG_ARCH_MV88DE3010
	if (mtd->name && (strcmp(mtd->name, "mv_nand") == 0)) {
		device_create_drvdata(mtd_class, NULL,
			      MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
			      NULL, "mtd_mv");

		device_create_drvdata(mtd_class, NULL,
			      MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
			      NULL, "mtdro_mv");
		return;
	}
#endif

	device_create_drvdata(mtd_class, NULL,
			      MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
			      NULL, "mtd%d", mtd->index);

	device_create_drvdata(mtd_class, NULL,
			      MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
			      NULL, "mtd%dro", mtd->index);
}
Exemple #2
0
int power_supply_register(struct device *parent, struct power_supply *psy)
{
	int rc = 0;

	psy->dev = device_create_drvdata(power_supply_class, parent, 0,
					 psy, "%s", psy->name);
	if (IS_ERR(psy->dev)) {
		rc = PTR_ERR(psy->dev);
		goto dev_create_failed;
	}

	INIT_WORK(&psy->changed_work, power_supply_changed_work);

	rc = power_supply_create_attrs(psy);
	if (rc)
		goto create_attrs_failed;

	rc = power_supply_create_triggers(psy);
	if (rc)
		goto create_triggers_failed;

	power_supply_changed(psy);

	goto success;

create_triggers_failed:
	power_supply_remove_attrs(psy);
create_attrs_failed:
	device_unregister(psy->dev);
dev_create_failed:
success:
	return rc;
}
/**
 * hwmon_device_register - register w/ hwmon
 * @dev: the device to register
 *
 * hwmon_device_unregister() must be called when the device is no
 * longer needed.
 *
 * Returns the pointer to the new device.
 */
struct device *hwmon_device_register(struct device *dev)
{
	struct device *hwdev;
	int id, err;

again:
	if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0))
		return ERR_PTR(-ENOMEM);

	spin_lock(&idr_lock);
	err = idr_get_new(&hwmon_idr, NULL, &id);
	spin_unlock(&idr_lock);

	if (unlikely(err == -EAGAIN))
		goto again;
	else if (unlikely(err))
		return ERR_PTR(err);

	id = id & MAX_ID_MASK;
	hwdev = device_create_drvdata(hwmon_class, dev, MKDEV(0, 0), NULL,
				      HWMON_ID_FORMAT, id);

	if (IS_ERR(hwdev)) {
		spin_lock(&idr_lock);
		idr_remove(&hwmon_idr, id);
		spin_unlock(&idr_lock);
	}

	return hwdev;
}
Exemple #4
0
struct display_device *display_device_register(struct display_driver *driver,
						struct device *parent, void *devdata)
{
	struct display_device *new_dev = NULL;
	int ret = -EINVAL;

	if (unlikely(!driver))
		return ERR_PTR(ret);

	mutex_lock(&allocated_dsp_lock);
	ret = idr_pre_get(&allocated_dsp, GFP_KERNEL);
	mutex_unlock(&allocated_dsp_lock);
	if (!ret)
		return ERR_PTR(ret);

	new_dev = kzalloc(sizeof(struct display_device), GFP_KERNEL);
	if (!new_dev)
		return ERR_PTR(-ENOMEM);
	
	ret = driver->probe(new_dev, devdata);
	if (ret < 0)
		goto out;
	
	/* Reserve the index for this display */
	mutex_lock(&allocated_dsp_lock);
	ret = idr_get_new(&allocated_dsp, new_dev, &new_dev->idx);
	mutex_unlock(&allocated_dsp_lock);

	if (ret)
		goto out;
	
	new_dev->dev = device_create_drvdata(display_class, parent,
			MKDEV(0,0), new_dev, "display%d", new_dev->idx);

	if (IS_ERR(new_dev->dev)) {
		mutex_lock(&allocated_dsp_lock);
		idr_remove(&allocated_dsp, new_dev->idx);
		mutex_unlock(&allocated_dsp_lock);
		ret = -EINVAL;
		goto out;
	}

	new_dev->parent = parent;
	new_dev->driver = driver;
	new_dev->priv_data = devdata;
	mutex_init(&new_dev->lock);
	return new_dev;

 out:
	kfree(new_dev);
	return ERR_PTR(ret);
}
/**
 * led_classdev_register - register a new object of led_classdev class.
 * @dev: The device to register.
 * @led_cdev: the led_classdev structure for this device.
 */
int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
{
	int rc;

	led_cdev->dev = device_create_drvdata(leds_class, parent, 0, led_cdev,
					      "%s", led_cdev->name);
	if (IS_ERR(led_cdev->dev))
		return PTR_ERR(led_cdev->dev);

	/* register the attributes */
	rc = device_create_file(led_cdev->dev, &dev_attr_brightness);
	if (rc)
		goto err_out;

	/* add to the list of leds */
	down_write(&leds_list_lock);
	list_add_tail(&led_cdev->node, &leds_list);
	up_write(&leds_list_lock);

	led_update_brightness(led_cdev);

#ifdef CONFIG_LEDS_TRIGGERS
	init_rwsem(&led_cdev->trigger_lock);

	rc = device_create_file(led_cdev->dev, &dev_attr_trigger);
	if (rc)
		goto err_out_led_list;

	led_trigger_set_default(led_cdev);
#endif

	printk(KERN_INFO "Registered led device: %s\n",
			led_cdev->name);

	return 0;

#ifdef CONFIG_LEDS_TRIGGERS
err_out_led_list:
	device_remove_file(led_cdev->dev, &dev_attr_brightness);
	list_del(&led_cdev->node);
#endif
err_out:
	device_unregister(led_cdev->dev);
	return rc;
}
/**
 * snd_register_device_for_dev - Register the ALSA device file for the card
 * @type: the device type, SNDRV_DEVICE_TYPE_XXX
 * @card: the card instance
 * @dev: the device index
 * @f_ops: the file operations
 * @private_data: user pointer for f_ops->open()
 * @name: the device file name
 * @device: the &struct device to link this new device to
 *
 * Registers an ALSA device file for the given card.
 * The operators have to be set in reg parameter.
 *
 * Returns zero if successful, or a negative error code on failure.
 */
int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
				const struct file_operations *f_ops,
				void *private_data,
				const char *name, struct device *device)
{
	int minor;
	struct snd_minor *preg;

	snd_assert(name, return -EINVAL);
	preg = kmalloc(sizeof *preg, GFP_KERNEL);
	if (preg == NULL)
		return -ENOMEM;
	preg->type = type;
	preg->card = card ? card->number : -1;
	preg->device = dev;
	preg->f_ops = f_ops;
	preg->private_data = private_data;
	mutex_lock(&sound_mutex);
#ifdef CONFIG_SND_DYNAMIC_MINORS
	minor = snd_find_free_minor();
#else
	minor = snd_kernel_minor(type, card, dev);
	if (minor >= 0 && snd_minors[minor])
		minor = -EBUSY;
#endif
	if (minor < 0) {
		mutex_unlock(&sound_mutex);
		kfree(preg);
		return minor;
	}
	snd_minors[minor] = preg;
	preg->dev = device_create_drvdata(sound_class, device,
					  MKDEV(major, minor),
					  private_data, "%s", name);
	if (IS_ERR(preg->dev)) {
		snd_minors[minor] = NULL;
		mutex_unlock(&sound_mutex);
		minor = PTR_ERR(preg->dev);
		kfree(preg);
		return minor;
	}

	mutex_unlock(&sound_mutex);
	return 0;
}
struct display_device *display_device_register(struct display_driver *driver,
						struct device *parent, void *devdata)
{
	struct display_device *new_dev = NULL;
	int ret = -EINVAL;

	if (unlikely(!driver))
		return ERR_PTR(ret);

	mutex_lock(&allocated_dsp_lock);
	ret = idr_pre_get(&allocated_dsp, GFP_KERNEL);
	mutex_unlock(&allocated_dsp_lock);
	if (!ret)
		return ERR_PTR(ret);

	new_dev = kzalloc(sizeof(struct display_device), GFP_KERNEL);
	if (likely(new_dev) && unlikely(driver->probe(new_dev, devdata))) {
		// Reserve the index for this display
		mutex_lock(&allocated_dsp_lock);
		ret = idr_get_new(&allocated_dsp, new_dev, &new_dev->idx);
		mutex_unlock(&allocated_dsp_lock);

		if (!ret) {
			new_dev->dev = device_create_drvdata(display_class,
							     parent,
							     MKDEV(0,0),
							     new_dev,
							     "display%d",
							     new_dev->idx);
			if (!IS_ERR(new_dev->dev)) {
				new_dev->parent = parent;
				new_dev->driver = driver;
				mutex_init(&new_dev->lock);
				return new_dev;
			}
			mutex_lock(&allocated_dsp_lock);
			idr_remove(&allocated_dsp, new_dev->idx);
			mutex_unlock(&allocated_dsp_lock);
			ret = -EINVAL;
		}
	}
	kfree(new_dev);
	return ERR_PTR(ret);
}
static int __init s3c_keypad_init(void)
{
	int ret;

	kpd_dev = device_create_drvdata(sec_class, NULL, 0, NULL, "keypad");
	if (IS_ERR(kpd_dev))
		pr_err("Failed to create device(keypad)!\n");
	if (device_create_file(kpd_dev, &dev_attr_talk) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_talk.attr.name);
	if (device_create_file(kpd_dev, &dev_attr_slide) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_slide.attr.name);

	ret = platform_driver_register(&s3c_keypad_driver);
	
	if(!ret)
	   printk(KERN_INFO "S3C Keypad Driver\n");

	return ret;
}
Exemple #9
0
/**
 * omap_previewer_init - Initialization of Preview Wrapper
 *
 * Returns 0 if successful, -ENOMEM if could not allocate memory, -ENODEV if
 * could not register the wrapper as a character device, or other errors if the
 * device or driver can't register.
 **/
static int __init omap_previewer_init(void)
{
	int ret;
	struct prev_device *device;

	device = kzalloc(sizeof(struct prev_device), GFP_KERNEL);
	if (!device) {
		dev_err(prev_dev, OMAP_PREV_NAME ": could not allocate"
								" memory\n");
		return -ENOMEM;
	}
	prev_major = register_chrdev(0, OMAP_PREV_NAME, &prev_fops);

	if (prev_major < 0) {
		dev_err(prev_dev, OMAP_PREV_NAME ": initialization "
				"failed. could not register character "
				"device\n");
		return -ENODEV;
	}

	ret = platform_driver_register(&omap_previewer_driver);
	if (ret) {
		dev_err(prev_dev, OMAP_PREV_NAME
			": failed to register platform driver!\n");
		goto fail2;
	}
	ret = platform_device_register(&omap_previewer_device);
	if (ret) {
		dev_err(prev_dev, OMAP_PREV_NAME
			": failed to register platform device!\n");
		goto fail3;
	}

	prev_class = class_create(THIS_MODULE, OMAP_PREV_NAME);
	if (!prev_class)
		goto fail4;

	prev_dev = device_create_drvdata(prev_class, prev_dev,
						MKDEV(prev_major, 0), NULL,
						OMAP_PREV_NAME);
	dev_dbg(prev_dev, OMAP_PREV_NAME ": Registered Previewer Wrapper\n");
	device->opened = 0;

	device->vbq_ops.buf_setup = previewer_vbq_setup;
	device->vbq_ops.buf_prepare = previewer_vbq_prepare;
	device->vbq_ops.buf_release = previewer_vbq_release;
	device->vbq_ops.buf_queue = previewer_vbq_queue;
	spin_lock_init(&device->inout_vbq_lock);
	spin_lock_init(&device->lsc_vbq_lock);
	prevdevice = device;
	return 0;

fail4:
	platform_device_unregister(&omap_previewer_device);
fail3:
	platform_driver_unregister(&omap_previewer_driver);
fail2:
	unregister_chrdev(prev_major, OMAP_PREV_NAME);

	return ret;
}
Exemple #10
0
int ndas_ctrldev_init(void)
{
	int ret = 0;

#ifdef NDAS_DEVFS
        // Create control device file
	devfs_control_handle = devfs_register(NULL, "ndas",
		DEVFS_FL_DEFAULT, NDAS_CHR_DEV_MAJOR, 0,
		S_IFCHR | S_IRUGO | S_IWUGO,
		&ndasctrl_fops, NULL);

	if (!devfs_control_handle) {
		printk(KERN_ERR "Failed to register control device file\n");
		return -EBUSY;
	}
#else
    ret = register_chrdev(NDAS_CHR_DEV_MAJOR, "ndas", &ndasctrl_fops);
    if (ret < 0) { 
        printk(KERN_ERR "ndas: can't register char device\n");
        return ret;
    }
#endif

#if LINUX_VERSION_25_ABOVE 
#if LINUX_VERSION_HAS_CLASS_CREATE 
    ndas_ctrldev_class = class_create(THIS_MODULE, "ndas");
    if (IS_ERR(ndas_ctrldev_class)) {
#ifdef NDAS_DEVFS
		devfs_unregister(devfs_control_handle);
#else
		unregister_chrdev(NDAS_CHR_DEV_MAJOR, "ndas");
#endif
        return PTR_ERR(ndas_ctrldev_class);
    }

#if LINUX_VERSION_HAS_DEVICE_CREATE
#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) )
	device_create(
#else
    device_create_drvdata(
#endif // Linux 2.6.28 (device_create_drvdata deprecated, now removed)
		ndas_ctrldev_class, NULL,
        MKDEV(NDAS_CHR_DEV_MAJOR, NDAS_CHR_DEV_MINOR),
        NULL, "ndas");
#else
    class_device_create(ndas_ctrldev_class, NULL,
        MKDEV(NDAS_CHR_DEV_MAJOR, NDAS_CHR_DEV_MINOR),
        NULL, "ndas");
#endif //#if LINUX_VERSION_HAS_DEVICE_CREATE

#else 
    ndas_ctrldev_class = class_simple_create(THIS_MODULE, "ndas");
    if (IS_ERR(ndas_ctrldev_class)) {
#ifdef NDAS_DEVFS
		devfs_unregister(devfs_control_handle);
#else
		unregister_chrdev(NDAS_CHR_DEV_MAJOR, "ndas");
#endif
        return PTR_ERR(ndas_ctrldev_class);
    }
    class_simple_device_add(ndas_ctrldev_class,
        MKDEV(NDAS_CHR_DEV_MAJOR, NDAS_CHR_DEV_MINOR),
        NULL, "ndas");
#endif  /* LINUX_VERSION_HAS_CLASS_CREATE */
#endif /* LINUX_VERSION_25_ABOVE  */

    return ret;
}
Exemple #11
0
static int __devinit elmo_probe(struct platform_device *pdev)
{
	int ret = -1;
	int error = 0;

	log_debug("elmo_probe::Probing elmo device\n");
	/* set up the PMIC event configuration for the "ON2B" line */
	error = pmic_power_set_conf_button(BT_ON2B, 0, 0);
	if (error < 0) {
		log_err("pmic_err:err=%d:could not set bt_on2b\n",error);
		goto exit0;
	}
	error = pmic_power_event_sub(PWR_IT_ONOFD2I, wan_tph_notify);
	if (error < 0) {
		log_err("pmic_err:err=%d:could not subscribe WAN TPH event\n",error);
		goto exit0;
	}

	init_waitqueue_head(&elmo_wait_q);
	error = request_irq(gpio_wan_fw_ready_irq(),elmo_fw_ready_handler,IRQF_TRIGGER_RISING,"ELMO_fw_ready",NULL);
	if (error < 0) {
		log_err("elmo_fw_irq_err:irq=%d:Could not request IRQ\n", gpio_wan_fw_ready_irq());
		goto exit1;
	}

	error = request_irq(gpio_wan_mhi_irq(),elmo_usb_wake_handler,IRQF_TRIGGER_RISING,"ELMO_usb_wake",NULL);
	
		if (error < 0) {
		log_err("elmo_usb_irq_err:irq=%d:Could not request IRQ\n", gpio_wan_mhi_irq());
		goto exit_fw_irq;
	}
	/* disable usb wake irq until WAN is powered up */
	disable_irq(gpio_wan_mhi_irq());

	wan_major = register_chrdev(0, WAN_STRING_DEV, &mwan_ops);
	if (wan_major < 0) {
		ret = wan_major;
		log_err("dev_err:device=" WAN_STRING_DEV ",err=%d:could not register device\n", ret);
		goto exit_usb_irq;
	}

	wan_class = class_create(THIS_MODULE, WAN_STRING_CLASS);
	if (IS_ERR(wan_class)) {
		ret = PTR_ERR(wan_class);
		log_err("class_err:err=%d:could not create class\n", ret);
		goto exit2;
	}

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
	wan_dev = device_create(wan_class, NULL, MKDEV(wan_major, 0), NULL, WAN_STRING_DEV);
#else
	wan_dev = device_create_drvdata(wan_class, NULL, MKDEV(wan_major, 0), NULL, WAN_STRING_DEV);
#endif
	if (IS_ERR(wan_dev)) {
		ret = PTR_ERR(wan_dev);
		log_err("dev_err:err=%d:could not create class device\n", ret);
		goto exit3;
	}

	wan_set_power_status(WAN_OFF);

	ret = 0;
	goto exit0;

exit3:
	class_destroy(wan_class);
	wan_class = NULL;

exit2:
	unregister_chrdev(wan_major, WAN_STRING_DEV);

exit_usb_irq:
	free_irq(gpio_wan_mhi_irq(),NULL);

exit_fw_irq:
	free_irq(gpio_wan_fw_ready_irq(),NULL);
exit1:
	/* clear the PMIC event handler */
	pmic_power_event_unsub(PWR_IT_ONOFD2I, wan_tph_notify);

exit0:
	return ret;

}
static int __init init_mac80211_hwsim(void)
{
	int i, err = 0;
	u8 addr[ETH_ALEN];
	struct mac80211_hwsim_data *data;
	struct ieee80211_hw *hw;
	DECLARE_MAC_BUF(mac);

	if (radios < 1 || radios > 65535)
		return -EINVAL;

	hwsim_radio_count = radios;
	hwsim_radios = kcalloc(hwsim_radio_count,
			       sizeof(struct ieee80211_hw *), GFP_KERNEL);
	if (hwsim_radios == NULL)
		return -ENOMEM;

	hwsim_class = class_create(THIS_MODULE, "mac80211_hwsim");
	if (IS_ERR(hwsim_class)) {
		kfree(hwsim_radios);
		return PTR_ERR(hwsim_class);
	}

	memset(addr, 0, ETH_ALEN);
	addr[0] = 0x02;

	for (i = 0; i < hwsim_radio_count; i++) {
		printk(KERN_DEBUG "mac80211_hwsim: Initializing radio %d\n",
		       i);
		hw = ieee80211_alloc_hw(sizeof(*data), &mac80211_hwsim_ops);
		if (hw == NULL) {
			printk(KERN_DEBUG "mac80211_hwsim: ieee80211_alloc_hw "
			       "failed\n");
			err = -ENOMEM;
			goto failed;
		}
		hwsim_radios[i] = hw;

		data = hw->priv;
		data->dev = device_create_drvdata(hwsim_class, NULL, 0, hw,
						"hwsim%d", i);
		if (IS_ERR(data->dev)) {
			printk(KERN_DEBUG
			       "mac80211_hwsim: device_create_drvdata "
			       "failed (%ld)\n", PTR_ERR(data->dev));
			err = -ENOMEM;
			goto failed_drvdata;
		}
		data->dev->driver = &mac80211_hwsim_driver;

		SET_IEEE80211_DEV(hw, data->dev);
		addr[3] = i >> 8;
		addr[4] = i;
		SET_IEEE80211_PERM_ADDR(hw, addr);

		hw->channel_change_time = 1;
		hw->queues = 1;

		memcpy(data->channels, hwsim_channels, sizeof(hwsim_channels));
		memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates));
		data->band.channels = data->channels;
		data->band.n_channels = ARRAY_SIZE(hwsim_channels);
		data->band.bitrates = data->rates;
		data->band.n_bitrates = ARRAY_SIZE(hwsim_rates);
		hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &data->band;

		err = ieee80211_register_hw(hw);
		if (err < 0) {
			printk(KERN_DEBUG "mac80211_hwsim: "
			       "ieee80211_register_hw failed (%d)\n", err);
			goto failed_hw;
		}

		printk(KERN_DEBUG "%s: hwaddr %s registered\n",
		       wiphy_name(hw->wiphy),
		       print_mac(mac, hw->wiphy->perm_addr));

		setup_timer(&data->beacon_timer, mac80211_hwsim_beacon,
			    (unsigned long) hw);
	}

	hwsim_mon = alloc_netdev(0, "hwsim%d", hwsim_mon_setup);
	if (hwsim_mon == NULL)
		goto failed;

	rtnl_lock();

	err = dev_alloc_name(hwsim_mon, hwsim_mon->name);
	if (err < 0)
		goto failed_mon;


	err = register_netdevice(hwsim_mon);
	if (err < 0)
		goto failed_mon;

	rtnl_unlock();

	return 0;

failed_mon:
	rtnl_unlock();
	free_netdev(hwsim_mon);
	mac80211_hwsim_free();
	return err;

failed_hw:
	device_unregister(data->dev);
failed_drvdata:
	ieee80211_free_hw(hw);
	hwsim_radios[i] = NULL;
failed:
	mac80211_hwsim_free();
	return err;
}
static int gp2a_opt_probe( struct platform_device* pdev )
{
	
	struct gp2a_data *gp2a;
	int irq;
	int i;
	int ret;

	/* allocate driver_data */
	gp2a = kzalloc(sizeof(struct gp2a_data),GFP_KERNEL);
	if(!gp2a)
	{
		pr_err("kzalloc error\n");
		return -ENOMEM;

	}


	gprintk("in %s \n",__func__);
	
	/* init i2c */
	opt_i2c_init();

	if(opt_i2c_client == NULL)
	{
		pr_err("opt_probe failed : i2c_client is NULL\n"); 
		return -ENODEV;
	}

	/* hrtimer Settings */

	hrtimer_init(&gp2a->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	gp2a->timer.function = gp2a_timer_func;

	/* Input device Settings */
	if(USE_INPUT_DEVICE)
	{
		gp2a->input_dev = input_allocate_device();
		if (gp2a->input_dev == NULL) 
		{
			pr_err("Failed to allocate input device\n");
			return -ENOMEM;
		}
		gp2a->input_dev->name = "proximity";
	
		set_bit(EV_SYN,gp2a->input_dev->evbit);
		set_bit(EV_ABS,gp2a->input_dev->evbit);
		
        input_set_abs_params(gp2a->input_dev, ABS_DISTANCE, 0, 1, 0, 0);
		
	
		ret = input_register_device(gp2a->input_dev);
		if (ret) 
		{
			pr_err("Unable to register %s input device\n", gp2a->input_dev->name);
			input_free_device(gp2a->input_dev);
			kfree(gp2a);
			return -1;
		}

	}
	/* WORK QUEUE Settings */


    gp2a_wq = create_singlethread_workqueue("gp2a_wq");
    if (!gp2a_wq)
	    return -ENOMEM;
    INIT_WORK(&gp2a->work_prox, gp2a_work_func_prox);
    INIT_WORK(&gp2a->work_light, gp2a_work_func_light);
	
	gprintk("Workqueue Settings complete\n");

	/* misc device Settings */
	ret = misc_register(&proximity_device);
	if(ret) {
		pr_err(KERN_ERR "misc_register failed \n");
	}


	/* wake lock init */
	wake_lock_init(&prx_wake_lock, WAKE_LOCK_SUSPEND, "prx_wake_lock");


	/* set platdata */
	platform_set_drvdata(pdev, gp2a);

	/* set sysfs for light sensor */

	lightsensor_class = class_create(THIS_MODULE, "lightsensor");
	if (IS_ERR(lightsensor_class))
		pr_err("Failed to create class(lightsensor)!\n");

	switch_cmd_dev = device_create_drvdata(lightsensor_class, NULL, 0, NULL, "switch_cmd");
	if (IS_ERR(switch_cmd_dev))
		pr_err("Failed to create device(switch_cmd_dev)!\n");

	if (device_create_file(switch_cmd_dev, &dev_attr_lightsensor_file_cmd) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_lightsensor_file_cmd.attr.name);

	if (device_create_file(switch_cmd_dev, &dev_attr_lightsensor_file_state) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_lightsensor_file_state.attr.name);
	dev_set_drvdata(switch_cmd_dev,gp2a);

	/* ktime init */

	timeA = ktime_set(0,0);
	timeB = ktime_set(0,0);
	
	/* POWER On */

	gpio_set_value(GPIO_LUM_PWM,GPIO_LEVEL_HIGH);

	mdelay(100);

	/* GP2A Regs INIT SETTINGS */
	

	for(i=1;i<5;i++)
	{
		opt_i2c_write((u8)(i),&gp2a_original_image[i]);
	}

	mdelay(2);


	/* INT Settings */	

	irq = IRQ_GP2A_INT;
	gp2a->irq = -1;
	ret = request_irq(irq, gp2a_irq_handler, 0, "gp2a_int", gp2a);
	if (ret) {
		pr_err("unable to request irq %d\n", irq);
		return ret;
	}       
	gp2a->irq = irq;

	gprintk("INT Settings complete\n");


	/* maintain power-down mode before using sensor */

	gp2a_off(gp2a,ALL);
	
	return 0;
}