本文整理汇总了C++中INIT_DELAYED_WORK函数的典型用法代码示例。如果您正苦于以下问题:C++ INIT_DELAYED_WORK函数的具体用法?C++ INIT_DELAYED_WORK怎么用?C++ INIT_DELAYED_WORK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了INIT_DELAYED_WORK函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: tca6416_keypad_probe
static int tca6416_keypad_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct tca6416_keys_platform_data *pdata;
struct tca6416_keypad_chip *chip;
struct input_dev *input;
int error;
int i;
/* Check functionality */
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) {
dev_err(&client->dev, "%s adapter not supported\n",
dev_driver_string(&client->adapter->dev));
return -ENODEV;
}
pdata = dev_get_platdata(&client->dev);
if (!pdata) {
dev_dbg(&client->dev, "no platform data\n");
return -EINVAL;
}
chip = kzalloc(sizeof(struct tca6416_keypad_chip) +
pdata->nbuttons * sizeof(struct tca6416_button),
GFP_KERNEL);
input = input_allocate_device();
if (!chip || !input) {
error = -ENOMEM;
goto fail1;
}
chip->client = client;
chip->input = input;
chip->io_size = id->driver_data;
chip->pinmask = pdata->pinmask;
chip->use_polling = pdata->use_polling;
INIT_DELAYED_WORK(&chip->dwork, tca6416_keys_work_func);
input->phys = "tca6416-keys/input0";
input->name = client->name;
input->dev.parent = &client->dev;
input->open = tca6416_keys_open;
input->close = tca6416_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++) {
unsigned int type;
chip->buttons[i] = pdata->buttons[i];
type = (pdata->buttons[i].type) ?: EV_KEY;
input_set_capability(input, type, pdata->buttons[i].code);
}
input_set_drvdata(input, chip);
/*
* Initialize cached registers from their original values.
* we can't share this chip with another i2c master.
*/
error = tca6416_setup_registers(chip);
if (error)
goto fail1;
if (!chip->use_polling) {
if (pdata->irq_is_gpio)
chip->irqnum = gpio_to_irq(client->irq);
else
chip->irqnum = client->irq;
error = request_threaded_irq(chip->irqnum, NULL,
tca6416_keys_isr,
IRQF_TRIGGER_FALLING |
IRQF_ONESHOT,
"tca6416-keypad", chip);
if (error) {
dev_dbg(&client->dev,
"Unable to claim irq %d; error %d\n",
chip->irqnum, error);
goto fail1;
}
disable_irq(chip->irqnum);
}
error = input_register_device(input);
if (error) {
dev_dbg(&client->dev,
"Unable to register input device, error: %d\n", error);
goto fail2;
}
//.........这里部分代码省略.........
开发者ID:020gzh,项目名称:linux,代码行数:101,代码来源:tca6416-keypad.c
示例2: charlcd_probe
static int __init charlcd_probe(struct platform_device *pdev)
{
int ret;
struct charlcd *lcd;
struct resource *res;
lcd = kzalloc(sizeof(struct charlcd), GFP_KERNEL);
if (!lcd)
return -ENOMEM;
lcd->dev = &pdev->dev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
ret = -ENOENT;
goto out_no_resource;
}
lcd->phybase = res->start;
lcd->physize = resource_size(res);
if (request_mem_region(lcd->phybase, lcd->physize,
DRIVERNAME) == NULL) {
ret = -EBUSY;
goto out_no_memregion;
}
lcd->virtbase = ioremap(lcd->phybase, lcd->physize);
if (!lcd->virtbase) {
ret = -ENOMEM;
goto out_no_remap;
}
lcd->irq = platform_get_irq(pdev, 0);
/* If no IRQ is supplied, we'll survive without it */
if (lcd->irq >= 0) {
if (request_irq(lcd->irq, charlcd_interrupt, IRQF_DISABLED,
DRIVERNAME, lcd)) {
ret = -EIO;
goto out_no_irq;
}
}
platform_set_drvdata(pdev, lcd);
/*
* Initialize the display in a delayed work, because
* it is VERY slow and would slow down the boot of the system.
*/
INIT_DELAYED_WORK(&lcd->init_work, charlcd_init_work);
schedule_delayed_work(&lcd->init_work, 0);
dev_info(&pdev->dev, "initialized ARM character LCD at %08x\n",
lcd->phybase);
return 0;
out_no_irq:
iounmap(lcd->virtbase);
out_no_remap:
platform_set_drvdata(pdev, NULL);
out_no_memregion:
release_mem_region(lcd->phybase, SZ_4K);
out_no_resource:
kfree(lcd);
return ret;
}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:66,代码来源:arm-charlcd.c
示例3: ipheth_probe
static int ipheth_probe (struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(intf);
struct usb_host_interface *hintf;
struct usb_endpoint_descriptor *endp;
struct ipheth_device *dev;
struct net_device *netdev;
int i;
int retval;
/* Ensure we are probing the right interface */
if (intf->cur_altsetting->desc.bInterfaceClass != IPHETH_USBINTF_CLASS ||
intf->cur_altsetting->desc.bInterfaceSubClass != IPHETH_USBINTF_SUBCLASS)
return -ENODEV;
netdev = alloc_etherdev(sizeof(struct ipheth_device));
if (!netdev)
return -ENOMEM;
#ifdef HAVE_NET_DEVICE_OPS
netdev->netdev_ops = &ipheth_netdev_ops;
#else /* CONFIG_COMPAT_NET_DEV_OPS */
netdev->open = &ipheth_open;
netdev->stop = &ipheth_close;
netdev->hard_start_xmit = &ipheth_tx;
netdev->tx_timeout = &ipheth_tx_timeout;
netdev->get_stats = &ipheth_stats;
#endif
netdev->watchdog_timeo = IPHETH_TX_TIMEOUT;
dev = netdev_priv(netdev);
dev->udev = udev;
dev->net = netdev;
dev->intf = intf;
/* Set up endpoints */
hintf = usb_altnum_to_altsetting (intf, IPHETH_ALT_INTFNUM);
if (hintf == NULL) {
retval = -ENODEV;
err("Unable to find alternate settings interface");
goto err_endpoints;
}
for (i = 0; i < hintf->desc.bNumEndpoints; i++) {
endp = &hintf->endpoint[i].desc;
if (usb_endpoint_is_bulk_in(endp))
dev->bulk_in = endp->bEndpointAddress;
else if (usb_endpoint_is_bulk_out(endp))
dev->bulk_out = endp->bEndpointAddress;
}
if (!(dev->bulk_in && dev->bulk_out)) {
retval = -ENODEV;
err("Unable to find endpoints");
goto err_endpoints;
}
dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL);
if (dev->ctrl_buf == NULL) {
retval = -ENOMEM;
goto err_alloc_ctrl_buf;
}
if ((retval = ipheth_get_macaddr(dev)))
goto err_get_macaddr;
INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work);
if ((retval = ipheth_alloc_urbs(dev))) {
err("error allocating urbs: %d", retval);
goto err_alloc_urbs;
}
usb_set_intfdata(intf, dev);
SET_NETDEV_DEV(netdev, &intf->dev);
SET_ETHTOOL_OPS(netdev, &ops);
if ((retval = register_netdev(netdev))) {
err("error registering netdev: %d", retval);
retval = -EIO;
goto err_register_netdev;
}
dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached\n");
return 0;
err_register_netdev:
ipheth_free_urbs(dev);
err_alloc_urbs:
err_get_macaddr:
err_alloc_ctrl_buf:
kfree(dev->ctrl_buf);
err_endpoints:
free_netdev(netdev);
return retval;
}
开发者ID:aircross,项目名称:ray,代码行数:97,代码来源:ipheth.c
示例4: affs_fill_super
static int affs_fill_super(struct super_block *sb, void *data, int silent)
{
struct affs_sb_info *sbi;
struct buffer_head *root_bh = NULL;
struct buffer_head *boot_bh;
struct inode *root_inode = NULL;
s32 root_block;
int size, blocksize;
u32 chksum;
int num_bm;
int i, j;
kuid_t uid;
kgid_t gid;
int reserved;
unsigned long mount_flags;
int tmp_flags; /* fix remount prototype... */
u8 sig[4];
int ret;
save_mount_options(sb, data);
pr_debug("read_super(%s)\n", data ? (const char *)data : "no options");
sb->s_magic = AFFS_SUPER_MAGIC;
sb->s_op = &affs_sops;
sb->s_flags |= MS_NODIRATIME;
sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL);
if (!sbi)
return -ENOMEM;
sb->s_fs_info = sbi;
sbi->sb = sb;
mutex_init(&sbi->s_bmlock);
spin_lock_init(&sbi->symlink_lock);
spin_lock_init(&sbi->work_lock);
INIT_DELAYED_WORK(&sbi->sb_work, flush_superblock);
if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block,
&blocksize,&sbi->s_prefix,
sbi->s_volume, &mount_flags)) {
pr_err("Error parsing options\n");
return -EINVAL;
}
/* N.B. after this point s_prefix must be released */
sbi->s_flags = mount_flags;
sbi->s_mode = i;
sbi->s_uid = uid;
sbi->s_gid = gid;
sbi->s_reserved= reserved;
/* Get the size of the device in 512-byte blocks.
* If we later see that the partition uses bigger
* blocks, we will have to change it.
*/
size = sb->s_bdev->bd_inode->i_size >> 9;
pr_debug("initial blocksize=%d, #blocks=%d\n", 512, size);
affs_set_blocksize(sb, PAGE_SIZE);
/* Try to find root block. Its location depends on the block size. */
i = 512;
j = 4096;
if (blocksize > 0) {
i = j = blocksize;
size = size / (blocksize / 512);
}
for (blocksize = i; blocksize <= j; blocksize <<= 1, size >>= 1) {
sbi->s_root_block = root_block;
if (root_block < 0)
sbi->s_root_block = (reserved + size - 1) / 2;
pr_debug("setting blocksize to %d\n", blocksize);
affs_set_blocksize(sb, blocksize);
sbi->s_partition_size = size;
/* The root block location that was calculated above is not
* correct if the partition size is an odd number of 512-
* byte blocks, which will be rounded down to a number of
* 1024-byte blocks, and if there were an even number of
* reserved blocks. Ideally, all partition checkers should
* report the real number of blocks of the real blocksize,
* but since this just cannot be done, we have to try to
* find the root block anyways. In the above case, it is one
* block behind the calculated one. So we check this one, too.
*/
for (num_bm = 0; num_bm < 2; num_bm++) {
pr_debug("Dev %s, trying root=%u, bs=%d, "
"size=%d, reserved=%d\n",
sb->s_id,
sbi->s_root_block + num_bm,
blocksize, size, reserved);
root_bh = affs_bread(sb, sbi->s_root_block + num_bm);
if (!root_bh)
continue;
if (!affs_checksum_block(sb, root_bh) &&
be32_to_cpu(AFFS_ROOT_HEAD(root_bh)->ptype) == T_SHORT &&
be32_to_cpu(AFFS_ROOT_TAIL(sb, root_bh)->stype) == ST_ROOT) {
sbi->s_hashsize = blocksize / 4 - 56;
//.........这里部分代码省略.........
开发者ID:383530895,项目名称:linux,代码行数:101,代码来源:super.c
示例5: si470x_usb_driver_probe
/*
* si470x_usb_driver_probe - probe for the device
*/
static int si470x_usb_driver_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct si470x_device *radio;
int retval = -ENOMEM;
/* private data allocation */
radio = kzalloc(sizeof(struct si470x_device), GFP_KERNEL);
if (!radio)
goto err_initial;
/* video device allocation */
radio->videodev = video_device_alloc();
if (!radio->videodev)
goto err_radio;
/* initial configuration */
memcpy(radio->videodev, &si470x_viddev_template,
sizeof(si470x_viddev_template));
radio->users = 0;
radio->usbdev = interface_to_usbdev(intf);
radio->intf = intf;
mutex_init(&radio->lock);
video_set_drvdata(radio->videodev, radio);
/* show some infos about the specific device */
retval = -EIO;
if (si470x_get_all_registers(radio) < 0)
goto err_all;
printk(KERN_INFO DRIVER_NAME ": DeviceID=0x%4.4hx ChipID=0x%4.4hx\n",
radio->registers[DEVICEID], radio->registers[CHIPID]);
/* check if firmware is current */
if ((radio->registers[CHIPID] & CHIPID_FIRMWARE)
< RADIO_SW_VERSION_CURRENT) {
printk(KERN_WARNING DRIVER_NAME
": This driver is known to work with "
"firmware version %hu,\n", RADIO_SW_VERSION_CURRENT);
printk(KERN_WARNING DRIVER_NAME
": but the device has firmware version %hu.\n",
radio->registers[CHIPID] & CHIPID_FIRMWARE);
printk(KERN_WARNING DRIVER_NAME
": If you have some trouble using this driver,\n");
printk(KERN_WARNING DRIVER_NAME
": please report to V4L ML at "
"[email protected]\n");
}
/* set initial frequency */
si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */
/* rds buffer allocation */
radio->buf_size = rds_buf * 3;
radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL);
if (!radio->buffer)
goto err_all;
/* rds buffer configuration */
radio->wr_index = 0;
radio->rd_index = 0;
init_waitqueue_head(&radio->read_queue);
/* prepare rds work function */
INIT_DELAYED_WORK(&radio->work, si470x_work);
/* register video device */
if (video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr)) {
printk(KERN_WARNING DRIVER_NAME
": Could not register video device\n");
goto err_all;
}
usb_set_intfdata(intf, radio);
return 0;
err_all:
video_device_release(radio->videodev);
kfree(radio->buffer);
err_radio:
kfree(radio);
err_initial:
return retval;
}
开发者ID:Tigrouzen,项目名称:k1099,代码行数:85,代码来源:radio-si470x.c
示例6: dwc3_probe
//.........这里部分代码省略.........
dwc->dev = dev;
if (!strncmp("super", maximum_speed, 5))
dwc->maximum_speed = DWC3_DCFG_SUPERSPEED;
else if (!strncmp("high", maximum_speed, 4))
dwc->maximum_speed = DWC3_DCFG_HIGHSPEED;
else if (!strncmp("full", maximum_speed, 4))
dwc->maximum_speed = DWC3_DCFG_FULLSPEED1;
else if (!strncmp("low", maximum_speed, 3))
dwc->maximum_speed = DWC3_DCFG_LOWSPEED;
else
dwc->maximum_speed = DWC3_DCFG_SUPERSPEED;
dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize");
host_only_mode = of_property_read_bool(node, "host-only-mode");
pm_runtime_no_callbacks(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
ret = dwc3_core_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize core\n");
return ret;
}
mode = DWC3_MODE(dwc->hwparams.hwparams0);
if (host_only_mode && (mode == DWC3_MODE_DRD)) {
dev_dbg(dev, "host only mode selected\n");
mode = DWC3_MODE_HOST;
}
INIT_DELAYED_WORK(&dwc->chg_stop, usb_chg_stop);
switch (mode) {
case DWC3_MODE_DEVICE:
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
ret = dwc3_gadget_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize gadget\n");
goto err1;
}
break;
case DWC3_MODE_HOST:
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
ret = dwc3_host_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize host\n");
goto err1;
}
break;
case DWC3_MODE_DRD:
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
ret = dwc3_otg_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize otg\n");
goto err1;
}
ret = dwc3_host_init(dwc);
if (ret) {
dev_err(dev, "failed to initialize host\n");
dwc3_otg_exit(dwc);
goto err1;
}
开发者ID:Alex-V2,项目名称:One_M8_4.4.3_kernel,代码行数:67,代码来源:core.c
示例7: s3c_adc_bat_probe
static int s3c_adc_bat_probe(struct platform_device *pdev)
{
struct s3c_adc_client *client;
struct s3c_adc_bat_pdata *pdata = pdev->dev.platform_data;
int ret;
client = s3c_adc_register(pdev, NULL, NULL, 0);
if (IS_ERR(client)) {
dev_err(&pdev->dev, "cannot register adc\n");
return PTR_ERR(client);
}
platform_set_drvdata(pdev, client);
main_bat.client = client;
main_bat.pdata = pdata;
main_bat.volt_value = -1;
main_bat.cur_value = -1;
main_bat.cable_plugged = 0;
main_bat.status = POWER_SUPPLY_STATUS_DISCHARGING;
ret = power_supply_register(&pdev->dev, &main_bat.psy);
if (ret)
goto err_reg_main;
if (pdata->backup_volt_mult) {
backup_bat.client = client;
backup_bat.pdata = pdev->dev.platform_data;
backup_bat.volt_value = -1;
ret = power_supply_register(&pdev->dev, &backup_bat.psy);
if (ret)
goto err_reg_backup;
}
INIT_DELAYED_WORK(&bat_work, s3c_adc_bat_work);
if (pdata->gpio_charge_finished >= 0) {
ret = gpio_request(pdata->gpio_charge_finished, "charged");
if (ret)
goto err_gpio;
ret = request_irq(gpio_to_irq(pdata->gpio_charge_finished),
s3c_adc_bat_charged,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
"battery charged", NULL);
if (ret)
goto err_irq;
}
if (pdata->init) {
ret = pdata->init();
if (ret)
goto err_platform;
}
dev_info(&pdev->dev, "successfully loaded\n");
device_init_wakeup(&pdev->dev, 1);
/* Schedule timer to check current status */
schedule_delayed_work(&bat_work,
msecs_to_jiffies(JITTER_DELAY));
return 0;
err_platform:
if (pdata->gpio_charge_finished >= 0)
free_irq(gpio_to_irq(pdata->gpio_charge_finished), NULL);
err_irq:
if (pdata->gpio_charge_finished >= 0)
gpio_free(pdata->gpio_charge_finished);
err_gpio:
if (pdata->backup_volt_mult)
power_supply_unregister(&backup_bat.psy);
err_reg_backup:
power_supply_unregister(&main_bat.psy);
err_reg_main:
return ret;
}
开发者ID:03199618,项目名称:linux,代码行数:77,代码来源:s3c_adc_battery.c
示例8: snd_compr_open
/*
* a note on stream states used:
* we use following states in the compressed core
* SNDRV_PCM_STATE_OPEN: When stream has been opened.
* SNDRV_PCM_STATE_SETUP: When stream has been initialized. This is done by
* calling SNDRV_COMPRESS_SET_PARAMS. Running streams will come to this
* state at stop by calling SNDRV_COMPRESS_STOP, or at end of drain.
* SNDRV_PCM_STATE_PREPARED: When a stream has been written to (for
* playback only). User after setting up stream writes the data buffer
* before starting the stream.
* SNDRV_PCM_STATE_RUNNING: When stream has been started and is
* decoding/encoding and rendering/capturing data.
* SNDRV_PCM_STATE_DRAINING: When stream is draining current data. This is done
* by calling SNDRV_COMPRESS_DRAIN.
* SNDRV_PCM_STATE_PAUSED: When stream is paused. This is done by calling
* SNDRV_COMPRESS_PAUSE. It can be stopped or resumed by calling
* SNDRV_COMPRESS_STOP or SNDRV_COMPRESS_RESUME respectively.
*/
static int snd_compr_open(struct inode *inode, struct file *f)
{
struct snd_compr *compr;
struct snd_compr_file *data;
struct snd_compr_runtime *runtime;
enum snd_compr_direction dirn;
int maj = imajor(inode);
int ret;
if ((f->f_flags & O_ACCMODE) == O_WRONLY)
dirn = SND_COMPRESS_PLAYBACK;
else if ((f->f_flags & O_ACCMODE) == O_RDONLY)
dirn = SND_COMPRESS_CAPTURE;
else
return -EINVAL;
if (maj == snd_major)
compr = snd_lookup_minor_data(iminor(inode),
SNDRV_DEVICE_TYPE_COMPRESS);
else
return -EBADFD;
if (compr == NULL) {
pr_err("no device data!!!\n");
return -ENODEV;
}
if (dirn != compr->direction) {
pr_err("this device doesn't support this direction\n");
snd_card_unref(compr->card);
return -EINVAL;
}
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) {
snd_card_unref(compr->card);
return -ENOMEM;
}
INIT_DELAYED_WORK(&data->stream.error_work, error_delayed_work);
data->stream.ops = compr->ops;
data->stream.direction = dirn;
data->stream.private_data = compr->private_data;
data->stream.device = compr;
runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
if (!runtime) {
kfree(data);
snd_card_unref(compr->card);
return -ENOMEM;
}
runtime->state = SNDRV_PCM_STATE_OPEN;
init_waitqueue_head(&runtime->sleep);
data->stream.runtime = runtime;
f->private_data = (void *)data;
mutex_lock(&compr->lock);
ret = compr->ops->open(&data->stream);
mutex_unlock(&compr->lock);
if (ret) {
kfree(runtime);
kfree(data);
}
snd_card_unref(compr->card);
return ret;
}
开发者ID:AshishNamdev,项目名称:linux,代码行数:83,代码来源:compress_offload.c
示例9: othc_configure_hsed
static int
othc_configure_hsed(struct pm8058_othc *dd, struct platform_device *pd)
{
int rc;
struct input_dev *ipd;
struct pmic8058_othc_config_pdata *pdata = pd->dev.platform_data;
struct othc_hsed_config *hsed_config = pdata->hsed_config;
dd->othc_sdev.name = "pm8058-h2w";
dd->othc_sdev.print_name = othc_headset_print_name;
rc = switch_dev_register(&dd->othc_sdev);
if (rc) {
pr_err("Unable to register switch device\n");
return rc;
}
ipd = input_allocate_device();
if (ipd == NULL) {
pr_err("Unable to allocate memory\n");
rc = -ENOMEM;
goto fail_input_alloc;
}
/* Get the IRQ for Headset Insert-remove and Switch-press */
dd->othc_irq_sw = platform_get_irq(pd, 0);
dd->othc_irq_ir = platform_get_irq(pd, 1);
if (dd->othc_irq_ir < 0 || dd->othc_irq_sw < 0) {
pr_err("othc resource:IRQs absent\n");
rc = -ENXIO;
goto fail_micbias_config;
}
if (pdata->hsed_name != NULL)
ipd->name = pdata->hsed_name;
else
ipd->name = "pmic8058_othc";
ipd->phys = "pmic8058_othc/input0";
ipd->dev.parent = &pd->dev;
dd->othc_ipd = ipd;
dd->othc_sw_state = false;
dd->switch_debounce_ms = hsed_config->switch_debounce_ms;
dd->othc_support_n_switch = hsed_config->othc_support_n_switch;
dd->accessory_support = pdata->hsed_config->accessories_support;
dd->detection_delay_ms = pdata->hsed_config->detection_delay_ms;
if (dd->othc_support_n_switch == true)
dd->switch_config = hsed_config->switch_config;
if (dd->accessory_support == true) {
dd->accessory_info = pdata->hsed_config->accessories;
dd->num_accessories = pdata->hsed_config->othc_num_accessories;
dd->accessories_adc_support =
pdata->hsed_config->accessories_adc_support;
dd->accessories_adc_channel =
pdata->hsed_config->accessories_adc_channel;
dd->video_out_gpio = pdata->hsed_config->video_out_gpio;
}
/* Configure the MIC_BIAS line for headset detection */
rc = pm8058_configure_micbias(dd);
if (rc < 0)
goto fail_micbias_config;
/* Configure for the switch events */
rc = pm8058_configure_switch(dd);
if (rc < 0)
goto fail_micbias_config;
/* Configure the accessory */
if (dd->accessory_support == true) {
rc = pm8058_configure_accessory(dd);
if (rc < 0)
goto fail_micbias_config;
}
input_set_drvdata(ipd, dd);
spin_lock_init(&dd->lock);
rc = input_register_device(ipd);
if (rc) {
pr_err("Unable to register OTHC device\n");
goto fail_micbias_config;
}
hrtimer_init(&dd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
dd->timer.function = pm8058_othc_timer;
INIT_DELAYED_WORK(&dd->detect_work, detect_work_f);
if (dd->othc_support_n_switch == true)
INIT_WORK(&dd->switch_work, switch_work_f);
/* Request the HEADSET IR interrupt */
rc = request_threaded_irq(dd->othc_irq_ir, NULL, pm8058_nc_ir,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_DISABLED,
"pm8058_othc_ir", dd);
if (rc < 0) {
//.........这里部分代码省略.........
开发者ID:Alex163,项目名称:htc-kernel-pyramid,代码行数:101,代码来源:pmic8058-othc.c
示例10: jump_label_rate_limit
void jump_label_rate_limit(struct static_key_deferred *key,
unsigned long rl)
{
key->timeout = rl;
INIT_DELAYED_WORK(&key->work, jump_label_update_timeout);
}
开发者ID:AeroGirl,项目名称:VAR-SOM-AM33-SDK7-Kernel,代码行数:6,代码来源:jump_label.c
示例11: bma2x2_probe
//.........这里部分代码省略.........
if (bma2x2_set_range(client, BMA2X2_RANGE_SET) < 0)
dev_err(&client->dev, "%s: bma2x2_set_range failed\n",
__func__);
#if defined(BMA2X2_ENABLE_INT1) || defined(BMA2X2_ENABLE_INT2)
#ifdef BMA2X2_ENABLE_INT1
/* maps interrupt to INT1 pin */
#ifdef CONFIG_BMA_ENABLE_NEWDATA_INT
bma2x2_set_newdata(client, BMA2X2_INT1_NDATA, 1);
bma2x2_set_newdata(client, BMA2X2_INT2_NDATA, 0);
#endif
#endif
#ifdef BMA2X2_ENABLE_INT2
/* maps interrupt to INT2 pin */
#ifdef CONFIG_BMA_ENABLE_NEWDATA_INT
bma2x2_set_newdata(client, BMA2X2_INT1_NDATA, 0);
bma2x2_set_newdata(client, BMA2X2_INT2_NDATA, 1);
#endif
#endif
bma2x2_set_Int_Mode(client, 1);/*latch interrupt 250ms*/
data->IRQ = client->irq;
err = request_threaded_irq(data->IRQ, NULL, bma2x2_interrupt_thread,
IRQF_TRIGGER_RISING, "bma_int", data);
if (err)
dev_err(&client->dev, "could not request irq\n");
disable_irq(data->IRQ);
#endif
#ifndef CONFIG_BMA_ENABLE_NEWDATA_INT
INIT_DELAYED_WORK(&data->work, bma2x2_work_func);
#endif
atomic_set(&data->delay, BMA2X2_MAX_DELAY);
atomic_set(&data->enable, 0);
bma2x2_set_mode(client, BMA2X2_MODE_SUSPEND);
dev = input_allocate_device();
if (!dev) {
err = -ENOMEM;
goto kfree_exit;
}
dev->name = SENSOR_NAME;
dev->id.bustype = BUS_I2C;
input_set_capability(dev, EV_MSC, ABS_MISC);
input_set_capability(dev, EV_MSC, MSC_RX);
input_set_capability(dev, EV_MSC, MSC_RY);
input_set_capability(dev, EV_MSC, MSC_RZ);
input_set_drvdata(dev, data);
err = input_register_device(dev);
if (err < 0) {
input_free_device(dev);
goto kfree_exit;
}
data->input = dev;
dev_acc = bst_allocate_device();
if (!dev_acc) {
开发者ID:YuechengLi,项目名称:Kernel-Honami-14.1.N.0.52,代码行数:67,代码来源:bma2x2.c
示例12: soc_new_pcm
/* create a new pcm */
int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
{
struct snd_soc_codec *codec = rtd->codec;
struct snd_soc_platform *platform = rtd->platform;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct snd_pcm *pcm;
char new_name[64];
int ret = 0, playback = 0, capture = 0;
/* check client and interface hw capabilities */
snprintf(new_name, sizeof(new_name), "%s %s-%d",
rtd->dai_link->stream_name, codec_dai->name, num);
if (codec_dai->driver->playback.channels_min)
playback = 1;
if (codec_dai->driver->capture.channels_min)
capture = 1;
dev_dbg(rtd->card->dev, "registered pcm #%d %s\n",num,new_name);
ret = snd_pcm_new(rtd->card->snd_card, new_name,
num, playback, capture, &pcm);
if (ret < 0) {
printk(KERN_ERR "asoc: can't create pcm for codec %s\n", codec->name);
return ret;
}
/* DAPM dai link stream work */
INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work);
rtd->pcm = pcm;
pcm->private_data = rtd;
if (platform->driver->ops) {
soc_pcm_ops.mmap = platform->driver->ops->mmap;
soc_pcm_ops.pointer = platform->driver->ops->pointer;
soc_pcm_ops.ioctl = platform->driver->ops->ioctl;
soc_pcm_ops.copy = platform->driver->ops->copy;
soc_pcm_ops.silence = platform->driver->ops->silence;
soc_pcm_ops.ack = platform->driver->ops->ack;
soc_pcm_ops.page = platform->driver->ops->page;
}
if (playback)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops);
if (capture)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops);
if (platform->driver->pcm_new) {
ret = platform->driver->pcm_new(rtd);
if (ret < 0) {
pr_err("asoc: platform pcm constructor failed\n");
return ret;
}
}
pcm->private_free = platform->driver->pcm_free;
printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name,
cpu_dai->name);
return ret;
}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:62,代码来源:soc-pcm.c
示例13: isl29028_probe
static int __devinit isl29028_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int err = 0;
struct input_dev *input_dev;
PR_DEB("isl29028_probe\n");
data = kzalloc(sizeof(struct isl29028_data), GFP_KERNEL);
if (data == NULL) {
err = -ENOMEM;
goto exit;
}
data->client = client;
i2c_set_clientdata(client, data);
dev_info(&client->dev, "support ver. %s enabled\n", DRIVER_VERSION);
/* allocate proximity input_device */
input_dev = input_allocate_device();
if (input_dev == NULL) {
err = -ENOMEM;
dev_err(&data->client->dev, "proximity input device allocate failed\n");
goto exit0;
}
input_set_drvdata(input_dev, data);
input_dev->name = "proximity";
input_set_capability(input_dev, EV_ABS, ABS_DISTANCE);
input_set_abs_params(input_dev, ABS_DISTANCE, 0, 1, 0, 0);
PR_DEB("registering proximity input device\n");
err = input_register_device(input_dev);
if (err) {
pr_err("%s: could not register input device\n", __func__);
goto exit1;
}
data->proximity_input_dev = input_dev;
/* create proximity sysfs interface */
err = sysfs_create_group(&input_dev->dev.kobj, &proximity_attribute_group);
if (err) {
pr_err("%s: could not create sysfs group\n", __func__);
goto exit2;
}
/* allocate light input_device */
input_dev = input_allocate_device();
if (input_dev == NULL) {
err = -ENOMEM;
dev_err(&data->client->dev, "light input device allocate failed\n");
goto exit2;
}
input_set_drvdata(input_dev, data);
input_dev->name = "light";
input_set_capability(input_dev, EV_ABS, ABS_MISC);
input_set_abs_params(input_dev, ABS_MISC, 0, 1, 0, 0);
PR_DEB("registering light input device\n");
err = input_register_device(input_dev);
if (err) {
pr_err("%s: could not register input device\n", __func__);
goto exit3;
}
data->light_input_dev = input_dev;
/* create proximity sysfs interface */
err = sysfs_create_group(&input_dev->dev.kobj, &light_attribute_group);
if (err) {
pr_err("%s: could not create sysfs group\n", __func__);
goto exit4;
}
wq = create_workqueue("isl29028_workqueue");
if (wq == NULL) {
PR_DEB("can't create a workqueue\n");
err = -1;
goto exit4;
}
INIT_DELAYED_WORK(&data->prox_work, prox_work_func);
INIT_DELAYED_WORK(&data->als_work, als_work_func);
/*isl29028 reset*/
isl29028_reset(client);
/*isl29028 init*/
err = isl29028_init_client(client);
if(err)
goto exit5;
/*init mutex for prox */
mutex_init(&prox_lock);
/*init mutex for als */
mutex_init(&als_lock);
wake_lock_init(&data->prox_wake_lock, WAKE_LOCK_SUSPEND, "prox_wake_lock");
/*set init state to not-working*/
atomic_set(&data->als_working,0);
atomic_set(&data->prox_working,0);
/*set init state to not-locking*/
atomic_set(&data->prox_locking,0);
/*set default interval*/
data->prox_interval = DEFAULT_PROX_INTERVAL;
data->als_interval = DEFAULT_ALS_INTERVAL;
//.........这里部分代码省略.........
开发者ID:weritos666,项目名称:android_kernel_msm,代码行数:101,代码来源:isl29028.c
示例14: i2c_touchkey_probe
static int i2c_touchkey_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
struct input_dev *input_dev;
int err = 0;
int touch_auto_calibration_on_off = 0;
u8 data[6];
printk("[TKEY] melfas i2c_touchkey_probe\n");
touchkey_driver =
kzalloc(sizeof(struct i2c_touchkey_driver), GFP_KERNEL);
if (touchkey_driver == NULL) {
dev_err(dev, "failed to create our state\n");
return -ENOMEM;
}
touchkey_driver->client = client;
touchkey_driver->client->irq = IRQ_TOUCHKEY_INT;
strlcpy(touchkey_driver->client->name, "melfas-touchkey", I2C_NAME_SIZE);
// i2c_set_clientdata(client, state);
input_dev = input_allocate_device();
if (!input_dev)
return -ENOMEM;
touchkey_driver->input_dev = input_dev;
input_dev->name = DEVICE_NAME;
input_dev->phys = "melfas-touchkey/input0";
input_dev->id.bustype = BUS_HOST;
if(get_hw_rev() >= 0x02) {
touchkey_keycode[1] = KEY_MENU;
touchkey_keycode[2] = KEY_BACK;
} else {
touchkey_keycode[1] = KEY_MENU;
touchkey_keycode[2] = KEY_BACK;
}
set_bit(EV_SYN, input_dev->evbit);
set_bit(EV_LED, input_dev->evbit);
set_bit(LED_MISC, input_dev->ledbit);
set_bit(EV_KEY, input_dev->evbit);
set_bit(touchkey_keycode[1], input_dev->keybit);
set_bit(touchkey_keycode[2], input_dev->keybit);
set_bit(touchkey_keycode[3], input_dev->keybit);
set_bit(touchkey_keycode[4], input_dev->keybit);
err = input_register_device(input_dev);
if (err) {
input_free_device(input_dev);
return err;
}
// gpio_pend_mask_mem = ioremap(INT_PEND_BASE, 0x10); //temp ks
INIT_DELAYED_WORK(&touch_resume_work, touchkey_resume_func);
#ifdef CONFIG_HAS_EARLYSUSPEND
// touchkey_driver->early_suspend.level = EARLY_SUSPEND_LEVEL_STOP_DRAWING + 1;
touchkey_driver->early_suspend.suspend = melfas_touchkey_early_suspend;
touchkey_driver->early_suspend.resume = melfas_touchkey_early_resume;
register_early_suspend(&touchkey_driver->early_suspend);
#endif
touchkey_enable = 1;
err= request_threaded_irq( IRQ_TOUCHKEY_INT, NULL, touchkey_interrupt, IRQF_DISABLED , "touchkey_int", NULL);
if (err) {
printk(KERN_ERR "%s Can't allocate irq .. %d\n", __FUNCTION__, err);
return -EBUSY;
}
if (get_hw_rev() >=0x02) {
touchkey_auto_calibration(1/*on*/);
mdelay(30);
i2c_touchkey_read (0x00, data, 6);
touch_auto_calibration_on_off = (data[5] & 0x80)>>7;
printk("[TKEY] after touchkey_auto_calibration result = %d \n",touch_auto_calibration_on_off);
}
开发者ID:CL0SeY,项目名称:kernel_P7320T_ICS,代码行数:82,代码来源:cypress-touchkey_q1_skt.c
示例15: wacom_i2c_probe
//.........这里部分代码省略.........
} else {
input_set_abs_params(input, ABS_X, WACOM_POSX_OFFSET,
wac_i2c->wac_feature->x_max, 4, 0);
input_set_abs_params(input, ABS_Y, WACOM_POSY_OFFSET,
wac_i2c->wac_feature->y_max, 4, 0);
}
input_set_abs_params(input, ABS_PRESSURE, 0,
wac_i2c->wac_feature->pressure_max, 0, 0);
#else
input_set_abs_params(wac_i2c->input_dev, ABS_X, pdata->min_x,
pdata->max_x, 4, 0);
input_set_abs_params(wac_i2c->input_dev, ABS_Y, pdata->min_y,
pdata->max_y, 4, 0);
input_set_abs_params(wac_i2c->input_dev, ABS_PRESSURE,
pdata->min_pressure, pdata->max_pressure, 0, 0);
#endif
input_set_drvdata(input, wac_i2c);
/*Before registering input device, data in each input_dev must be set */
ret = input_register_device(input);
if (ret) {
pr_err("[E-PEN] failed to register input device.\n");
goto err_register_device;
}
/*Change below if irq is needed */
wac_i2c->irq_flag = 1;
/*Set client data */
i2c_set_clientdata(client, wac_i2c);
/*Initializing for semaphor */
mutex_init(&wac_i2c->lock);
INIT_DELAYED_WORK(&wac_i2c->resume_work, wacom_i2c_resume_work);
/*Request IRQ */
if (wac_i2c->irq_flag) {
ret =
request_threaded_irq(wac_i2c->irq, NULL, wacom_interrupt,
IRQF_DISABLED | IRQF_TRIGGER_RISING |
IRQF_ONESHOT, wac_i2c->name, wac_i2c);
if (ret < 0) {
printk(KERN_ERR
"[E-PEN]: failed to request irq(%d) - %d\n",
wac_i2c->irq, ret);
goto err_request_irq;
}
}
#ifdef CONFIG_HAS_EARLYSUSPEND
wac_i2c->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
wac_i2c->early_suspend.suspend = wacom_i2c_early_suspend;
wac_i2c->early_suspend.resume = wacom_i2c_late_resume;
register_early_suspend(&wac_i2c->early_suspend);
#endif
wac_i2c->dev = device_create(sec_class, NULL, 0, NULL, "sec_epen");
if (IS_ERR(wac_i2c->dev))
printk(KERN_ERR "Failed to create device(wac_i2c->dev)!\n");
else {
dev_set_drvdata(wac_i2c->dev, wac_i2c);
ret = sysfs_create_group(&wac_i2c->dev->kobj, &epen_attr_group);
if (ret) {
printk(KERN_ERR
"[E-PEN]: failed to create sysfs group\n");
goto err_sysfs_create_group;
}
开发者ID:FennyFatal,项目名称:FF-i777-Rebase,代码行数:67,代码来源:wacom_i2c.c
示例16: msm_host_notify_init
static int msm_host_notify_init(struct device *dev, struct msm_otg *motg)
{
sec_otg_register_booster(&sec_booster_batt);
INIT_DELAYED_WORK(&motg->late_power_work, msm_otg_late_power_work);
return 0;
}
开发者ID:GalaxyTab4,项目名称:android_kernel_samsung_matissewifi.bak,代码行数:6,代码来源:msm_otg_sec.c
示例17: mma7660_probe
static int mma7660_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
struct mma7660_data *mma7660;
int err;
dprint("l=%d,%s:\n",__LINE__, __func__);
Xaverage = Yaverage = Zaverage = RawDataNum = 0;
mma7660 = kzalloc(sizeof(struct mma7660_data), GFP_KERNEL);
if (!mma7660) {
rk28printk("[mma7660]:alloc data failed.\n");
err = -ENOMEM;
goto exit_alloc_data_failed;
}
INIT_WORK(&mma7660->work, mma7660_work_func);
INIT_DELAYED_WORK(&mma7660->delaywork, mma7660_delaywork_func);
mma7660->client = client;
//mma7660->swap_xy =
i2c_set_clientdata(client, mma7660);
this_client = client;
err = mma7660_init_client(client);
if (err < 0) {
rk28printk(KERN_ERR
"mma7660_probe: mma7660_init_client failed\n");
goto exit_request_gpio_irq_failed;
}
mma7660->input_dev = input_allocate_device();
if (!mma7660->input_dev) {
err = -ENOMEM;
rk28printk(KERN_ERR
"mma7660_probe: Failed to allocate input device\n");
goto exit_input_allocate_device_failed;
}
set_bit(EV_ABS, mma7660->input_dev->evbit);
/* x-axis acceleration */
input_set_abs_params(mma7660->input_dev, ABS_X, -1500, 1500, 0, 0);
/* y-axis acceleration */
input_set_abs_params(mma7660->input_dev, ABS_Y, -1500, 1500, 0, 0);
/* z-axis acceleration */
input_set_abs_params(mma7660->input_dev, ABS_Z, -1500, 1500, 0, 0);
mma7660->input_dev->name = "gsensor";
mma7660->input_dev->dev.parent = &client->dev;
err = input_register_device(mma7660->input_dev);
if (err < 0) {
rk28printk(KERN_ERR
"mma7660_probe: Unable to register input device: %s\n",
mma7660->input_dev->name);
goto exit_input_register_device_failed;
}
mma7660_device.parent = &client->dev;
err = misc_register(&mma7660_device);
if (err < 0) {
rk28printk(KERN_ERR
"mma7660_probe: mmad_device register failed\n");
goto exit_misc_device_register_mma7660_device_failed;
}
err = gsensor_sysfs_init();
if (err < 0) {
rk28printk(KERN_ERR
"mma7660_probe: gsensor sysfs init failed\n");
goto exit_gsensor_sysfs_init_failed;
}
#ifdef CONFIG_ANDROID_POWER
mma7660_early_suspend.suspend = mma7660_suspend;
mma7660_early_suspend.resume = mma7660_resume;
mma7660_early_suspend.level = 0x2;
android_register_early_suspend(&mma7660_early_suspend);
#endif
rk28printk(KERN_INFO "mma7660 probe ok\n");
mma7660->status = -1;
#if 0
mma7660_start(client, MMA7660_RATE_32);
#endif
dprint("l=%d,%s:loaded successfully.\n",__LINE__, __func__);
return 0;
exit_gsensor_sysfs_init_failed:
misc_deregister(&mma7660_device);
exit_misc_device_register_mma7660_device_failed:
input_unregister_device(mma7660->input_dev);
exit_input_register_device_failed:
input_free_device(mma7660->input_dev);
exit_input_allocate_device_failed:
free_irq(client->irq, mma7660);
exit_request_gpio_irq_failed:
kfree(mma7660);
exit_alloc_data_failed:
;
//.........这里部分代码省略.........
开发者ID:smartassfox,项目名称:android_kernel_odys_neox_3.0.8,代码行数:101,代码来源:mma7660.c
示例18: ci13xxx_msm_probe
static int ci13xxx_msm_probe(struct platform_device *pdev)
{
struct resource *res;
int ret;
struct ci13xxx_platform_data *pdata = pdev->dev.platform_data;
bool is_l1_supported = false;
dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n");
if (pdata) {
/* Acceptable values for nz_itc are: 0,1,2,4,8,16,32,64 */
if (pdata->log2_itc > CI13XXX_MSM_MAX_LOG2_ITC ||
pdata->log2_itc <= 0)
ci13xxx_msm_udc_driver.nz_itc = 0;
else
ci13xxx_msm_udc_driver.nz_itc =
1 << (pdata->log2_itc-1);
is_l1_supported = pdata->l1_supported;
/* Set ahb2ahb bypass flag if it is requested. */
if (pdata->enable_ahb2ahb_bypass)
ci13xxx_msm_udc_driver.flags |=
CI13XXX_ENABLE_AHB2AHB_BYPASS;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "failed to get
|
请发表评论