本文整理汇总了C++中device_create函数的典型用法代码示例。如果您正苦于以下问题:C++ device_create函数的具体用法?C++ device_create怎么用?C++ device_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了device_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jpeg_probe
static int jpeg_probe(struct platform_device *pdev)
{
struct class_device;
int ret;
struct class_device *class_dev = NULL;
JPEG_MSG("-------------jpeg driver probe-------\n");
ret = alloc_chrdev_region(&jpeg_devno, 0, 1, JPEG_DEVNAME);
if(ret)
{
JPEG_ERR("Error: Can't Get Major number for JPEG Device\n");
}
else
{
JPEG_MSG("Get JPEG Device Major number (%d)\n", jpeg_devno);
}
jpeg_cdev = cdev_alloc();
jpeg_cdev->owner = THIS_MODULE;
jpeg_cdev->ops = &jpeg_fops;
ret = cdev_add(jpeg_cdev, jpeg_devno, 1);
jpeg_class = class_create(THIS_MODULE, JPEG_DEVNAME);
class_dev = (struct class_device *)device_create(jpeg_class, NULL, jpeg_devno, NULL, JPEG_DEVNAME);
spin_lock_init(&jpeg_dec_lock);
spin_lock_init(&jpeg_enc_lock);
// initial codec, register codec ISR
dec_status = 0;
enc_status = 0;
_jpeg_dec_int_status = 0;
_jpeg_enc_int_status = 0;
_jpeg_dec_mode = 0;
#ifndef FPGA_VERSION
init_waitqueue_head(&dec_wait_queue);
init_waitqueue_head(&enc_wait_queue);
//mt6575_irq_set_sens(MT6575_JPEG_CODEC_IRQ_ID, MT65xx_LEVEL_SENSITIVE);
//mt6575_irq_set_polarity(MT6575_JPEG_CODEC_IRQ_ID, MT65xx_POLARITY_LOW);
//mt6575_irq_unmask(MT6575_JPEG_CODEC_IRQ_ID);
JPEG_MSG("request JPEG Encoder IRQ \n");
enable_irq(MT6589_JPEG_ENC_IRQ_ID);
if(request_irq(MT6589_JPEG_ENC_IRQ_ID, jpeg_drv_enc_isr, IRQF_TRIGGER_LOW, "jpeg_enc_driver" , NULL))
//if(request_irq(MT6589_JPEG_ENC_IRQ_ID, jpeg_drv_enc_isr, /*IRQF_TRIGGER_RISING*/ IRQF_TRIGGER_HIGH, "jpeg_enc_driver" , NULL))
//if(request_irq(MT6589_JPEG_ENC_IRQ_ID, jpeg_drv_enc_isr, IRQF_TRIGGER_RISING , "jpeg_enc_driver" , NULL))
{
JPEG_ERR("JPEG ENC Driver request irq failed\n");
}
enable_irq(MT6589_JPEG_DEC_IRQ_ID);
JPEG_MSG("request JPEG Decoder IRQ \n");
//if(request_irq(MT6589_JPEG_DEC_IRQ_ID, jpeg_drv_dec_isr, IRQF_TRIGGER_LOW, "jpeg_dec_driver" , NULL))
//if(request_irq(MT6589_JPEG_DEC_IRQ_ID, jpeg_drv_dec_isr, /*IRQF_TRIGGER_RISING*/ IRQF_TRIGGER_HIGH, "jpeg_dec_driver" , NULL))
//if(request_irq(MT6589_JPEG_DEC_IRQ_ID, jpeg_drv_dec_isr, IRQF_TRIGGER_RISING , "jpeg_dec_driver" , NULL))
if(request_irq(MT6589_JPEG_DEC_IRQ_ID, jpeg_drv_dec_isr, IRQF_TRIGGER_FALLING , "jpeg_dec_driver" , NULL))
{
JPEG_ERR("JPEG DEC Driver request irq failed\n");
}
#endif
JPEG_MSG("JPEG Probe Done\n");
NOT_REFERENCED(class_dev);
return 0;
}
示例2: gpio_keys_probe
//.........这里部分代码省略.........
input->dev.parent = &pdev->dev;
#ifdef CONFIG_SENSORS_HALL
input->evbit[0] |= BIT_MASK(EV_SW);
input_set_capability(input, EV_SW, SW_FLIP);
#endif
input->open = gpio_keys_open;
input->close = gpio_keys_close;
input->id.bustype = BUS_HOST;
input->id.vendor = 0x0001;
input->id.product = 0x0001;
input->id.version = 0x0100;
/* Enable auto repeat feature of Linux input subsystem */
if (pdata->rep)
__set_bit(EV_REP, input->evbit);
for (i = 0; i < pdata->nbuttons; i++) {
button = &pdata->buttons[i];
bdata = &ddata->data[i];
error = gpio_keys_setup_key(pdev, input, bdata, button);
if (error)
goto fail2;
if (button->wakeup)
wakeup = 1;
}
#ifdef KEY_BOOSTER
error = gpio_key_init_dvfs(bdata);
if (error < 0) {
dev_err(dev, "Fail get dvfs level for touch booster\n");
goto fail2;
}
#endif
error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group);
if (error) {
dev_err(dev, "Unable to export keys/switches, error: %d\n",
error);
goto fail2;
}
error = input_register_device(input);
if (error) {
dev_err(dev, "Unable to register input device, error: %d\n",
error);
goto fail3;
}
/* get current state of buttons that are connected to GPIOs */
for (i = 0; i < pdata->nbuttons; i++) {
struct gpio_button_data *bdata = &ddata->data[i];
if (gpio_is_valid(bdata->button->gpio))
gpio_keys_gpio_report_event(bdata);
}
input_sync(input);
#ifdef CONFIG_SENSORS_HALL
sec_key = device_create(sec_class, NULL, 0, NULL, "sec_key");
if (IS_ERR(sec_key))
pr_err("Failed to create device(sec_key)!\n");
ret = device_create_file(sec_key, &dev_attr_hall_detect);
if (ret < 0) {
pr_err("Failed to create device file(%s)!, error: %d\n",
dev_attr_hall_detect.attr.name, ret);
}
ret = device_create_file(sec_key, &dev_attr_sec_key_pressed);
if (ret) {
pr_err("Failed to create device file in sysfs entries(%s)!\n",
dev_attr_sec_key_pressed.attr.name);
}
ret = device_create_file(sec_key, &dev_attr_wakeup_keys);
if (ret < 0) {
pr_err("Failed to create device file(%s), error: %d\n",
dev_attr_wakeup_keys.attr.name, ret);
}
dev_set_drvdata(sec_key, ddata);
#endif
device_init_wakeup(&pdev->dev, 1);
return 0;
fail3:
sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group);
fail2:
while (--i >= 0)
gpio_remove_key(&ddata->data[i]);
platform_set_drvdata(pdev, NULL);
fail1:
input_free_device(input);
kfree(ddata);
/* If we have no platform_data, we allocated buttons dynamically. */
if (!pdev->dev.platform_data)
kfree(pdata->buttons);
return error;
}
示例3: ktd2026_probe
static int __devinit ktd2026_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct ktd2026_data *data;
int ret, i;
pr_info("%s\n", __func__);
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(&client->dev, "need I2C_FUNC_I2C.\n");
return -ENODEV;
}
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
dev_err(&client->dev, "need I2C_FUNC_SMBUS_BYTE_DATA.\n");
return -EIO;
}
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) {
dev_err(&client->adapter->dev,
"failed to allocate driver data.\n");
return -ENOMEM;
}
i2c_set_clientdata(client, data);
data->client = client;
b_client = client;
mutex_init(&data->mutex);
/* initialize LED */
/* turn off all leds */
ktd2026_leds_on(LED_R, LED_EN_OFF, 0);
ktd2026_leds_on(LED_G, LED_EN_OFF, 0);
ktd2026_leds_on(LED_B, LED_EN_OFF, 0);
ktd2026_set_timerslot_control(0); /* Tslot1 */
ktd2026_set_period(0);
ktd2026_set_pwm_duty(PWM1, 0);
ktd2026_set_pwm_duty(PWM2, 0);
ktd2026_set_trise_tfall(0, 0, 0);
for (i = 0; i < MAX_NUM_LEDS; i++) {
ret = initialize_channel(client, &data->leds[i], i);
if (ret < 0) {
dev_err(&client->adapter->dev, "failure on initialization\n");
goto exit;
}
INIT_WORK(&(data->leds[i].brightness_work),
ktd2026_led_brightness_work);
}
leds_i2c_write_all(client);
#ifdef SEC_LED_SPECIFIC
led_dev = device_create(sec_class, NULL, 0, data, "led");
if (IS_ERR(led_dev)) {
dev_err(&client->dev,
"Failed to create device for samsung specific led\n");
ret = -ENODEV;
goto exit;
}
ret = sysfs_create_group(&led_dev->kobj, &sec_led_attr_group);
if (ret) {
dev_err(&client->dev,
"Failed to create sysfs group for samsung specific led\n");
device_destroy(sec_class, 0);
goto exit;
}
#endif
fading_status = 0;
return ret;
exit:
mutex_destroy(&data->mutex);
kfree(data);
return ret;
}
示例4: exynos_pd_power_on
//.........这里部分代码省略.........
break;
}
while (1) {
ret = __pm_genpd_add_device(&pd_index->genpd, dev, &gpd_td);
if (ret != -EAGAIN)
break;
cond_resched();
}
if (!ret) {
pm_genpd_dev_need_restore(dev, true);
pr_info("PM DOMAIN: %s, Device : %s Registered\n", pd_index->genpd.name, dev_name(dev));
} else
pr_err("PM DOMAIN: %s cannot add device %s\n", pd_index->genpd.name, dev_name(dev));
pr_info("%s: test start.\n", pd_index->genpd.name);
pm_runtime_enable(dev);
for (i=0; i<100; i++) {
pm_runtime_get_sync(dev);
mdelay(50);
pm_runtime_put_sync(dev);
mdelay(50);
}
pr_info("%s: test done.\n", pd_index->genpd.name);
pm_runtime_disable(dev);
while (1) {
ret = pm_genpd_remove_device(&pd_index->genpd, dev);
if (ret != -EAGAIN)
break;
cond_resched();
}
if (ret)
pr_err("PM DOMAIN: %s cannot remove device %s\n", pd_index->name, dev_name(dev));
}
return ret;
}
static ssize_t store_power_domain_test(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
char device_name[32], test_name[32];
sscanf(buf, "%s %s", device_name, test_name);
switch (test_name[0]) {
case '1':
exynos_pd_power_on(dev, device_name);
break;
case '0':
exynos_pd_power_off(dev, device_name);
break;
case 't':
exynos_pd_longrun_test(dev, device_name);
break;
default:
printk("echo \"device\" \"test\" > control\n");
}
return count;
}
static DEVICE_ATTR(control, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, show_power_domain, store_power_domain_test);
static struct attribute *control_device_attrs[] = {
&dev_attr_control.attr,
NULL,
};
static const struct attribute_group control_device_attr_group = {
.attrs = control_device_attrs,
};
static int runtime_pm_test_probe(struct platform_device *pdev)
{
struct class *runtime_pm_class;
struct device *runtime_pm_dev;
int ret;
runtime_pm_class = class_create(THIS_MODULE, "runtime_pm");
runtime_pm_dev = device_create(runtime_pm_class, NULL, 0, NULL, "test");
ret = sysfs_create_group(&runtime_pm_dev->kobj, &control_device_attr_group);
if (ret) {
pr_err("Runtime PM Test : error to create sysfs\n");
return -EINVAL;
}
pm_runtime_enable(&pdev->dev);
return 0;
}
static int runtime_pm_test_runtime_suspend(struct device *dev)
{
pr_info("Runtime PM Test : Runtime_Suspend\n");
return 0;
}
示例5: dock_keyboard_probe
static int __devinit dock_keyboard_probe(struct platform_device *pdev)
{
// struct dock_keyboard_data *data = pdev->dev.platform_data;
struct dock_keyboard_data *data;
struct input_dev *input;
int i, error;
#if defined(ACC_INT_KBD)
int gpio, irq;
#endif
struct device *keyboard_dev;
data = kzalloc(sizeof(struct dock_keyboard_data), GFP_KERNEL);
if(NULL == data)
{
error = -ENOMEM;
goto err_free_mem;
}
INIT_WORK(&data->work_msg, key_event_work);
INIT_WORK(&data->work_led, led_work);
input = input_allocate_device();
if (!input)
{
printk(KERN_ERR "[Keyboard] Fail to allocate input device.\n");
error = -ENOMEM;
goto err_free_mem;
}
data->input_dev = input;
data->kl = UNKOWN_KEYLAYOUT;
input->name = pdev->name;
input->dev.parent = &pdev->dev;
input->id.bustype = BUS_RS232;
set_bit(EV_SYN, input->evbit);
// set_bit(EV_REP, input->evbit);
set_bit(EV_KEY, input->evbit);
for(i = 0; i < KEYBOARD_SIZE; i++)
{
if( KEY_RESERVED != dock_keycodes[i].keycode)
{
input_set_capability(input, EV_KEY, dock_keycodes[i].keycode);
}
}
/* for the UK keyboard */
input_set_capability(input, EV_KEY, KEY_NUMERIC_POUND);
/* for the remaped keys */
input_set_capability(input, EV_KEY, KEY_NEXTSONG);
input_set_capability(input, EV_KEY, KEY_PREVIOUSSONG);
error = input_register_device(data->input_dev);
if(error<0)
{
printk(KERN_ERR "[Keyboard] Fail to register input device.\n");
error = -ENOMEM;
goto err_free_mem;
}
/* Accessory detect pin is used by dock accessory driver. */
#if defined(ACC_INT_KBD)
gpio = GPIO_ACCESSORY_INT;
s3c_gpio_cfgpin(gpio, S3C_GPIO_INPUT);
s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
irq = IRQ_EINT5;
error = request_irq(irq, accessory_interrupt,
IRQF_SAMPLE_RANDOM|IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING,
"p1_keyboard", data);
if(error)
{
printk(KERN_ERR "[Keyboard] Fail to request irq : %d\n", error);
error = -EINTR;
goto err_free_mem;
}
data->gpio = gpio;
#else
data->gpio = GPIO_ACCESSORY_INT;
#endif
g_data = data;
keyboard_dev = device_create(sec_class, NULL, 0, NULL, "keyboard");
if (IS_ERR(keyboard_dev))
pr_err("Failed to create device(ts)!\n");
if (device_create_file(keyboard_dev, &dev_attr_keyboard_led) < 0)
pr_err("Failed to create device file(%s)!\n", dev_attr_keyboard_led.attr.name);
#ifdef CONFIG_HAS_EARLYSUSPEND
data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
data->early_suspend.suspend = keyboard_early_suspend;
data->early_suspend.resume = keyboard_late_resume;
register_early_suspend(&data->early_suspend);
#endif /* CONFIG_HAS_EARLYSUSPEND */
init_timer(&data->timer);
//.........这里部分代码省略.........
示例6: backlight_probe
static int backlight_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct backlight_platform_data *pdata;
struct backlight_info *info;
int error = 0;
#if defined(CONFIG_BLIC_TUNING)
struct class *backlight_class;
struct device *backlight_dev;
#endif
struct samsung_display_driver_data *vdd = samsung_get_vdd();
pr_info("%s", __func__);
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)){
pr_err("[BACKLIGHT] failed to check i2c functionality!\n");
return -EIO;
}
if (client->dev.of_node) {
pdata = devm_kzalloc(&client->dev,
sizeof(struct backlight_platform_data),
GFP_KERNEL);
if (!pdata) {
dev_info(&client->dev, "Failed to allocate memory\n");
return -ENOMEM;
}
error = backlight_parse_dt(&client->dev, pdata);
if (error)
return error;
} else
pdata = client->dev.platform_data;
backlight_request_gpio(pdata);
bl_info = info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) {
dev_info(&client->dev, "%s: fail to memory allocation.\n", __func__);
return -ENOMEM;
}
info->client = client;
info->pdata = pdata;
mdss_samsung_parse_backlight_settings(&client->dev,&info->bl_ic_settings,"backlight-ic-tuning");
mdss_samsung_parse_backlight_settings(&client->dev,&info->bl_ic_outdoor_settings,"backlight-ic-tuning-outdoor");
mdss_samsung_parse_backlight_settings(&client->dev,&info->bl_ic_normal_settings,"backlight-ic-tuning-normal");
mdss_samsung_parse_backlight_settings(&client->dev,&info->bl_control,"backlight-i2c-bl-control");
#if defined(CONFIG_BLIC_TUNING)
backlight_class = class_create(THIS_MODULE, "bl-dbg");
backlight_dev = device_create(backlight_class, NULL, 0, NULL, "ic-tuning");
if (IS_ERR(backlight_dev))
pr_err("Failed to create device(backlight_dev)!\n");
else {
if (device_create_file(backlight_dev, &dev_attr_bl_ic_tune) < 0)
pr_err("Failed to create device file(%s)!\n", dev_attr_bl_ic_tune.attr.name);
if (device_create_file(backlight_dev, &dev_attr_bl_ic_name) < 0)
pr_err("Failed to create device file(%s)!\n", dev_attr_bl_ic_name.attr.name);
}
#endif
i2c_set_clientdata(client, info);
vdd->panel_func.samsung_bl_ic_pwm_en = pwm_backlight_control;
vdd->panel_func.samsung_bl_ic_i2c_ctrl = pwm_backlight_control_i2c;
vdd->panel_func.samsung_bl_ic_outdoor = pwm_backlight_outdoor_control;
return error;
}
示例7: p3_probe
static int p3_probe(struct spi_device *spi)
{
int ret = -1;
//struct p3_spi_platform_data *platform_data = NULL;
//struct p3_spi_platform_data platform_data1;
struct p3_dev *p3_dev = NULL;
P3_DBG_MSG("%s chip select : %d , bus number = %d \n",
__FUNCTION__, spi->chip_select, spi->master->bus_num);
p3_dev = kzalloc(sizeof(*p3_dev), GFP_KERNEL);
if (p3_dev == NULL)
{
P3_ERR_MSG("failed to allocate memory for module data\n");
ret = -ENOMEM;
goto err_exit;
}
ret = p3_regulator_onoff(p3_dev, 1);
if (ret) {
P3_ERR_MSG("%s - Failed to enable regulator\n", __func__);
goto p3_parse_dt_failed;
}
ret = p3_parse_dt(&spi->dev, p3_dev);
if (ret) {
P3_ERR_MSG("%s - Failed to parse DT\n", __func__);
goto p3_parse_dt_failed;
}
P3_DBG_MSG("%s: tz_mode=%d, isGpio_cfgDone:%d\n", __func__,
p3_dev->tz_mode, p3_dev->isGpio_cfgDone);
//P3_DBG_MSG("%s ------\n", __FUNCTION__);
#if 0
ret = p3_hw_setup (platform_data, p3_dev, spi);
if (ret < 0)
{
P3_ERR_MSG("Failed to enable IRQ_ENABLE\n");
goto err_exit0;
}
#endif
//usleep_range(3000,3100);
//gpio_direction_output(p3_dev->cs_gpio, 1);
spi->bits_per_word = 8;
spi->mode = SPI_MODE_3;
spi->max_speed_hz = 1000000L;
ret = spi_setup(spi);
if (ret < 0)
{
P3_ERR_MSG("failed to do spi_setup()\n");
goto p3_spi_setup_failed;
}
p3_dev -> spi = spi;
p3_dev -> p3_device.minor = MISC_DYNAMIC_MINOR;
p3_dev -> p3_device.name = "p3";
p3_dev -> p3_device.fops = &p3_dev_fops;
p3_dev -> p3_device.parent = &spi->dev;
dev_set_drvdata(&spi->dev, p3_dev);
/* init mutex and queues */
init_waitqueue_head(&p3_dev->read_wq);
mutex_init(&p3_dev->buffer_mutex);
spin_lock_init(&p3_dev->ese_spi_lock);
#ifdef FEATURE_ESE_WAKELOCK
wake_lock_init(&p3_dev->ese_lock,
WAKE_LOCK_SUSPEND, "ese_wake_lock");
#endif
#ifdef P3_IRQ_ENABLE
spin_lock_init(&p3_dev->irq_enabled_lock);
#endif
ret = misc_register(&p3_dev->p3_device);
if (ret < 0)
{
P3_ERR_MSG("misc_register failed! %d\n", ret);
goto err_exit0;
}
#if 0 //test
{
struct device *dev;
p3_device_class = class_create(THIS_MODULE, "ese");
if (IS_ERR(p3_device_class)) {
P3_ERR_MSG("%s class_create() is failed:%lu\n",
__func__, PTR_ERR(p3_device_class));
//status = PTR_ERR(p3_device_class);
//goto vfsspi_probe_class_create_failed;
}
dev = device_create(p3_device_class, NULL,
0, p3_dev, "p3");
P3_ERR_MSG("%s device_create() is failed:%lu\n",
__func__, PTR_ERR(dev));
if ((device_create_file(dev, &dev_attr_test)) < 0)
P3_ERR_MSG("%s device_create_file failed !!!\n", __func__);
//.........这里部分代码省略.........
示例8: akm8975_probe
int akm8975_probe(struct i2c_client *client,
const struct i2c_device_id *devid)
{
struct akm8975_data *akm;
int err;
if (client->dev.platform_data == NULL) {
dev_err(&client->dev, "platform data is NULL. exiting.\n");
err = -ENODEV;
goto exit_platform_data_null;
}
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(&client->dev, "I2C check failed, exiting.\n");
err = -ENODEV;
goto exit_check_functionality_failed;
}
akm = kzalloc(sizeof(struct akm8975_data), GFP_KERNEL);
if (!akm) {
dev_err(&client->dev,
"failed to allocate memory for module data\n");
err = -ENOMEM;
goto exit_alloc_data_failed;
}
akm->pdata = client->dev.platform_data;
mutex_init(&akm->lock);
init_completion(&akm->data_ready);
i2c_set_clientdata(client, akm);
akm->this_client = client;
err = akm8975_ecs_set_mode_power_down(akm);
if (err < 0)
goto exit_set_mode_power_down_failed;
akm->irq = client->irq;
err = akm8975_setup_irq(akm);
if (err) {
pr_err("%s: could not setup irq\n", __func__);
goto exit_setup_irq;
}
akm->akmd_device.minor = MISC_DYNAMIC_MINOR;
akm->akmd_device.name = "akm8975";
akm->akmd_device.fops = &akmd_fops;
err = misc_register(&akm->akmd_device);
if (err)
goto exit_akmd_device_register_failed;
init_waitqueue_head(&akm->state_wq);
/* put into fuse access mode to read asa data */
err = i2c_smbus_write_byte_data(client, AK8975_REG_CNTL,
REG_CNTL_MODE_FUSE_ROM);
if (err)
pr_err("%s: unable to enter fuse rom mode\n", __func__);
err = i2c_smbus_read_i2c_block_data(client, AK8975_REG_ASAX,
sizeof(akm->asa), akm->asa);
if (err != sizeof(akm->asa))
pr_err("%s: unable to load factory sensitivity adjust values\n",
__func__);
else
pr_debug("%s: asa_x = %d, asa_y = %d, asa_z = %d\n", __func__,
akm->asa[0], akm->asa[1], akm->asa[2]);
err = i2c_smbus_write_byte_data(client, AK8975_REG_CNTL,
REG_CNTL_MODE_POWER_DOWN);
if (err) {
dev_err(&client->dev, "Error in setting power down mode\n");
goto exit_device_create_file2;
}
#if (defined DEBUG) || (defined FACTORY_TEST)
ak8975c_selftest(akm);
#endif
#ifdef FACTORY_TEST
err = sensors_register(magnetic_sensor_device, akm, magnetic_sensor_attrs, "magnetic_sensor");
if(err) {
printk(KERN_ERR "%s: cound not register magnetic sensor device(%d).\n", __func__, err);
}
sec_ak8975_dev = device_create(sec_class, NULL, 0, akm,
"sec_ak8975");
if (IS_ERR(sec_ak8975_dev))
printk("Failed to create device!");
if (device_create_file(sec_ak8975_dev, &dev_attr_ak8975_asa) < 0) {
printk("Failed to create device file(%s)! \n",
dev_attr_ak8975_asa.attr.name);
goto exit_device_create_file2;
}
if (device_create_file(sec_ak8975_dev, &dev_attr_ak8975_selftest) < 0) {
printk("Failed to create device file(%s)! \n",
dev_attr_ak8975_selftest.attr.name);
device_remove_file(sec_ak8975_dev, &dev_attr_ak8975_asa);
//.........这里部分代码省略.........
示例9: ktd2026_probe
static int __devinit ktd2026_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct ktd2026_data *data;
int ret, i;
pr_info("%s\n", __func__);
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(&client->dev, "need I2C_FUNC_I2C.\n");
return -ENODEV;
}
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
dev_err(&client->dev, "need I2C_FUNC_SMBUS_BYTE_DATA.\n");
return -EIO;
}
if (client->dev.of_node) {
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) {
dev_err(&client->adapter->dev,
"failed to allocate driver data.\n");
return -ENOMEM;
}
} else
data = client->dev.platform_data;
i2c_set_clientdata(client, data);
data->client = client;
b_client = client;
mutex_init(&data->mutex);
/* initialize LED */
/* turn off all leds */
ktd2026_leds_on(LED_R, LED_EN_OFF, 0);
#if defined(CONFIG_SEC_FACTORY)
#if defined (CONFIG_SEC_ATLANTIC_PROJECT)
if(batt_id_value == 0)
ret = 1;
else
ret = 0;
#if defined(CONFIG_FB_MSM8x26_MDSS_CHECK_LCD_CONNECTION)
if(get_lcd_attached() == 0) // When LCD Not connected turning RED LED on
ret++;;
#endif
if(jig_power_on_value == 0)
ret++;
if(ret == 3) // case when LCD not connected,battery power on and jig off
ktd2026_leds_on(LED_R, LED_EN_ON, 30);
#endif //ATLANTIC FLAG
#endif
ktd2026_leds_on(LED_G, LED_EN_OFF, 0);
ktd2026_leds_on(LED_B, LED_EN_OFF, 0);
ktd2026_set_timerslot_control(0); /* Tslot1 */
ktd2026_set_period(0);
ktd2026_set_pwm_duty(PWM1, 0);
ktd2026_set_pwm_duty(PWM2, 0);
ktd2026_set_trise_tfall(0, 0, 0);
for (i = 0; i < MAX_NUM_LEDS; i++) {
ret = initialize_channel(client, &data->leds[i], i);
if (ret < 0) {
dev_err(&client->adapter->dev, "failure on initialization\n");
goto exit;
}
INIT_WORK(&(data->leds[i].brightness_work),
ktd2026_led_brightness_work);
}
leds_i2c_write_all(client);
#ifdef SEC_LED_SPECIFIC
led_dev = device_create(sec_class, NULL, 0, data, "led");
if (IS_ERR(led_dev)) {
dev_err(&client->dev,
"Failed to create device for samsung specific led\n");
ret = -ENODEV;
goto exit;
}
ret = sysfs_create_group(&led_dev->kobj, &sec_led_attr_group);
if (ret) {
dev_err(&client->dev,
"Failed to create sysfs group for samsung specific led\n");
goto exit;
}
#endif
return ret;
exit:
mutex_destroy(&data->mutex);
kfree(data);
return ret;
}
示例10: cabc_tuning_init
void cabc_tuning_init(struct mdss_dsi_ctrl_pdata *dsi_pdata)
{
pr_info("%s : dsi dest = %d\n", __func__,
dsi_pdata->panel_data.panel_info.pdest);
if(dsi_pdata->panel_data.panel_info.pdest == MASTER_DSI_PDEST) {
pr_debug("%s : Master DSI Ctrl Copy \n", __func__);
cabc_master_dsi_ctrl = dsi_pdata;
} else {
pr_debug("%s : Slave DSI Ctrl Copy \n", __func__);
cabc_slave_dsi_ctrl = dsi_pdata;
}
if (!cabc_tun_state.cabc_enable) {
pr_info("%s : First Init \n", __func__);
mutex_init(&cabc_tun_state.cabc_mutex);
cabc_class = class_create(THIS_MODULE, "tcon");
if (IS_ERR(cabc_class))
pr_err("Failed to create class(cabc)!\n");
/* Using for CABC Key String */
mdnie_class = class_create(THIS_MODULE, "mdnie");
if (IS_ERR(mdnie_class))
pr_err("Failed to create class(mdnie)!\n");
tune_cabc_dev = device_create(cabc_class, NULL, 0, NULL,
"tcon");
if (IS_ERR(tune_cabc_dev))
pr_err("Failed to create device(cabc)!\n");
/* Using for CABC Key String */
tune_mdnie_dev = device_create(mdnie_class, NULL, 0, NULL,
"mdnie");
if (IS_ERR(tune_mdnie_dev))
pr_err("Failed to create device(mdnie)!\n");
if (device_create_file
(tune_cabc_dev, &dev_attr_auto_br) < 0)
pr_err("Failed to create device file(%s)!\n",
dev_attr_auto_br.attr.name);
if (device_create_file
(tune_cabc_dev, &dev_attr_lux) < 0)
pr_err("Failed to create device file(%s)!\n",
dev_attr_lux.attr.name);
if (device_create_file
(tune_cabc_dev, &dev_attr_mode) < 0)
pr_err("Failed to create device file(%s)!\n",
dev_attr_mode.attr.name);
if (device_create_file
(tune_cabc_dev,
&dev_attr_cetuning) < 0)
pr_err("Failed to create device file(%s)!\n",
dev_attr_cetuning.attr.name);
if (device_create_file
(tune_cabc_dev, &dev_attr_cabctuning) < 0)
pr_err("Failed to create device file(%s)!\n",
dev_attr_cabctuning.attr.name);
/* Using for CABC Key String */
if (device_create_file
(tune_mdnie_dev, &dev_attr_cabc) < 0)
pr_err("Failed to create device file(%s)!\n",
dev_attr_cabc.attr.name);
if (device_create_file
(tune_mdnie_dev, &dev_attr_accessibility) < 0)
pr_err("Failed to create device file(%s)!\n",
dev_attr_cabc.attr.name);
cabc_tun_state.cabc_enable=1;
}
}
示例11: tty_attach
/*
* Register tty device.
*/
device_t
tty_attach(const char *name, struct tty *tp)
{
return device_create(&tty_io, name, DF_CHR, tp);
}
示例12: create_dev_nodes
/*
* create everything concerning the dev interface
*
*/
static int create_dev_nodes(void)
{
int err;
struct device* device;
dev_t write_num = MKDEV(FIFO_MAJOR, WRITE_END);
dev_t read_num = MKDEV(FIFO_MAJOR, READ_END);
cdev_write = cdev_alloc();
cdev_read = cdev_alloc();
if (0 == cdev_write || 0 == cdev_read)
{
printk(KERN_INFO "--- %s: cdev_alloc failed!\n", mod_name);
return ENOMEM;
}
// get the write dev class
class_write = class_create(THIS_MODULE, WRITE_NAME);
if (IS_ERR(class_write))
{
destroy_dev_nodes(0, 0);
return PTR_ERR(class_write);
}
class_write->dev_uevent = write_permission;
// get the read dev class
class_read = class_create(THIS_MODULE, READ_NAME);
if (IS_ERR(class_read))
{
destroy_dev_nodes(0, 0);
return PTR_ERR(class_write);
}
class_read->dev_uevent = read_permission;
// initialize structs
cdev_init(cdev_write, &fifo_write_fops);
cdev_init(cdev_read, &fifo_read_fops);
// adds dev to system, makes it live
err = cdev_add(cdev_write, write_num, 1);
if (err)
{
destroy_dev_nodes(0, 0);
return err;
}
err = cdev_add(cdev_read, read_num, 1);
if (err)
{
destroy_dev_nodes(0, 1);
return err;
}
// add /dev/fifo0
device = device_create(class_write,
0, // parent device
write_num,
0, // additional data
WRITE_NAME);
if (IS_ERR(device))
{
destroy_dev_nodes(1, 1);
return PTR_ERR(device);
}
// add /dev/fifo1
device = device_create(class_read,
0, // parent device
read_num,
0, // additional data
READ_NAME);
if (IS_ERR(device))
{
destroy_dev_nodes(1, 2);
return PTR_ERR(device);
}
return 0;
}
示例13: adg739_write
static ssize_t adg739_write(struct file *filp, const char __user *buf, size_t count, loff_t *fpos)
{
char buf_term[NUM_MULTIPLEXER]; //буфер, куда копируются сообщения из пользовательского пространства, и где они проходят предварительное форматирование
int status = 0;
int i =0;
struct spi_transfer t = { //формируется передача
.tx_buf = adg739_status->buffer,
.len = NUM_MULTIPLEXER * 2,
};
struct spi_message m; // сообщение
DECLARE_COMPLETION_ONSTACK(done); //объявляется и инициализуется условная переменная
//проверка на достоверность переданного буфера
if (count > NUM_MULTIPLEXER)
return (-EMSGSIZE);
if (copy_from_user(buf_term, buf, count))
return (-EFAULT);
for (i=0; i<count; i++)
{
switch(buf_term[i])
{
case 's':
buf_term[i] = 0x11;
break;
case 'v':
buf_term[i] = 0x82;
break;
case 'g':
buf_term[i] = 0x88;
break;
default:
return (-EINVAL);
}
}
//передача сообщения драйверу контроллера
mutex_lock(&device_lockk);
for (i=0; i<count; i++) {
adg739_status->buffer[i]= buf_term[i];
adg739_status->buffer[i+4]= buf_term[i];
}
spi_message_init(&m); //инициализация сообщения
spi_message_add_tail(&t, &m); //постановка передачи в очередь сообщения
m.complete = adg739_complete;
m.context = &done;
if (adg739_status->spi == NULL)
status = -ESHUTDOWN;
else
{
status = spi_async(adg739_status->spi, &m); //передача сообщения
printk(KERN_INFO "Status function spi_async = %d\n", status);
}
if (status == 0) {
wait_for_completion(&done); //ожидание обработки сообщения контроллером spi
status = m.status;
printk(KERN_INFO "Status message = %d\n", status);
if (status == 0)
status = m.actual_length/2;
}
mutex_unlock(&device_lockk);
return (status);
}
//ФУНКЦИИ СТРУКТУРЫ SPI_DRIVER
static int __devinit adg739_probe(struct spi_device *spi)
{
int status, dev;
//регистрация устройства
dev =device_create(devclass, &spi->dev, dev_adg739, NULL, MULTIPLEXER_NAME); //создание устройства
status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
if(status != 0)
{
printk(KERN_ERR "The device_create function failed\n");
return (status);
}
//инициализация членов структуры состояния драйвера
mutex_lock(&device_lockk);
adg739_status->users = 0;
adg739_status->spi = spi;
spi->bits_per_word = 16;
spi->max_speed_hz = 700000;
spin_lock_init(&adg739_status->spi_lock);
memset(adg739_status->buffer, 0, sizeof(adg739_status->buffer));
spi_set_drvdata(spi, adg739_status); //присваевает указателю spi->dev->driver_data значение adg739_status
mutex_unlock(&device_lockk);
return (0);
}
示例14: goldfish_switch_probe
static int __devinit goldfish_switch_probe(struct platform_device *pdev)
{
int ret;
struct resource *r;
struct goldfish_switch *qs;
uint32_t base;
uint32_t name_len;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if(r == NULL) {
ret = -ENODEV;
goto err_no_io_base;
}
base = IO_ADDRESS(r->start - IO_START);
name_len = readl(base + SW_NAME_LEN);
qs = kzalloc(sizeof(*qs) + name_len + 1, GFP_KERNEL);
if(qs == NULL) {
ret = -ENOMEM;
goto err_qs_alloc_failed;
}
platform_set_drvdata(pdev, qs);
qs->base = base;
r = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if(r == NULL) {
ret = -ENODEV;
goto err_no_irq;
}
qs->irq = r->start;
writel(qs->name, base + SW_NAME_PTR);
qs->name[name_len] = '\0';
writel(0, base + SW_INT_ENABLE);
qs->flags = readl(base + SW_FLAGS);
qs->state = readl(base + SW_STATE);
INIT_WORK(&qs->work, goldfish_switch_work);
qs->cdev = device_create(goldfish_switch_class, &pdev->dev, 0,
NULL, "%s", qs->name);
if(unlikely(IS_ERR(qs->cdev))) {
ret = PTR_ERR(qs->cdev);
goto err_device_create_failed;
}
dev_set_drvdata(qs->cdev, qs);
ret = device_create_file(qs->cdev, &dev_attr_state);
if(ret)
goto err_device_create_file_failed;
ret = device_create_file(qs->cdev, &dev_attr_direction);
if(ret)
goto err_device_create_file_failed;
ret = request_irq(qs->irq, goldfish_switch_interrupt, IRQF_SHARED, "goldfish_switch", qs);
if(ret)
goto err_request_irq_failed;
writel(1, base + SW_INT_ENABLE);
return 0;
// free_irq(qs->irq, qs);
err_request_irq_failed:
err_device_create_file_failed:
device_unregister(qs->cdev);
err_device_create_failed:
err_no_irq:
kfree(qs);
err_qs_alloc_failed:
err_no_io_base:
printk("goldfish_switch_probe failed %d\n", ret);
return ret;
}
示例15: unix98_pty_init
static void __init unix98_pty_init(void)
{
ptm_driver = tty_alloc_driver(NR_UNIX98_PTY_MAX,
TTY_DRIVER_RESET_TERMIOS |
TTY_DRIVER_REAL_RAW |
TTY_DRIVER_DYNAMIC_DEV |
TTY_DRIVER_DEVPTS_MEM |
TTY_DRIVER_DYNAMIC_ALLOC);
if (IS_ERR(ptm_driver))
panic("Couldn't allocate Unix98 ptm driver");
pts_driver = tty_alloc_driver(NR_UNIX98_PTY_MAX,
TTY_DRIVER_RESET_TERMIOS |
TTY_DRIVER_REAL_RAW |
TTY_DRIVER_DYNAMIC_DEV |
TTY_DRIVER_DEVPTS_MEM |
TTY_DRIVER_DYNAMIC_ALLOC);
if (IS_ERR(pts_driver))
panic("Couldn't allocate Unix98 pts driver");
ptm_driver->owner = THIS_MODULE;
ptm_driver->driver_name = "pty_master";
ptm_driver->name = "ptm";
ptm_driver->major = UNIX98_PTY_MASTER_MAJOR;
ptm_driver->minor_start = 0;
ptm_driver->type = TTY_DRIVER_TYPE_PTY;
ptm_driver->subtype = PTY_TYPE_MASTER;
ptm_driver->init_termios = tty_std_termios;
ptm_driver->init_termios.c_iflag = 0;
ptm_driver->init_termios.c_oflag = 0;
ptm_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
ptm_driver->init_termios.c_lflag = 0;
ptm_driver->init_termios.c_ispeed = 38400;
ptm_driver->init_termios.c_ospeed = 38400;
ptm_driver->other = pts_driver;
tty_set_operations(ptm_driver, &ptm_unix98_ops);
pts_driver->owner = THIS_MODULE;
pts_driver->driver_name = "pty_slave";
pts_driver->name = "pts";
pts_driver->major = UNIX98_PTY_SLAVE_MAJOR;
pts_driver->minor_start = 0;
pts_driver->type = TTY_DRIVER_TYPE_PTY;
pts_driver->subtype = PTY_TYPE_SLAVE;
pts_driver->init_termios = tty_std_termios;
pts_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
pts_driver->init_termios.c_ispeed = 38400;
pts_driver->init_termios.c_ospeed = 38400;
pts_driver->other = ptm_driver;
tty_set_operations(pts_driver, &pty_unix98_ops);
if (tty_register_driver(ptm_driver))
panic("Couldn't register Unix98 ptm driver");
if (tty_register_driver(pts_driver))
panic("Couldn't register Unix98 pts driver");
/* Now create the /dev/ptmx special device */
tty_default_fops(&ptmx_fops);
ptmx_fops.open = ptmx_open;
cdev_init(&ptmx_cdev, &ptmx_fops);
if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
panic("Couldn't register /dev/ptmx driver");
device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
}