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; } i2c_set_clientdata(client, chip); device_init_wakeup(&client->dev, 1); return 0; fail2: if (!chip->use_polling) { free_irq(chip->irqnum, chip); enable_irq(chip->irqnum); } fail1: input_free_device(input); kfree(chip); return error; }
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; }
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; }
static int s6evr02_probe(struct device *dev) { int ret = 0, i; struct lcd_info *lcd; #ifdef SMART_DIMMING u8 mtp_data[LDI_MTP_LENGTH] = {0,}; #endif lcd = kzalloc(sizeof(struct lcd_info), GFP_KERNEL); if (!lcd) { pr_err("failed to allocate for lcd\n"); ret = -ENOMEM; goto err_alloc; } g_lcd = lcd; lcd->ld = lcd_device_register("panel", dev, lcd, &s6evr02_lcd_ops); if (IS_ERR(lcd->ld)) { pr_err("failed to register lcd device\n"); ret = PTR_ERR(lcd->ld); goto out_free_lcd; } lcd->bd = backlight_device_register("panel", dev, lcd, &s6evr02_backlight_ops, NULL); if (IS_ERR(lcd->bd)) { pr_err("failed to register backlight device\n"); ret = PTR_ERR(lcd->bd); goto out_free_backlight; } lcd->dev = dev; lcd->dsim = (struct dsim_global *)dev_get_drvdata(dev->parent); lcd->bd->props.max_brightness = MAX_BRIGHTNESS; lcd->bd->props.brightness = DEFAULT_BRIGHTNESS; lcd->bl = DEFAULT_GAMMA_LEVEL; lcd->current_bl = lcd->bl; lcd->acl_enable = 0; lcd->current_acl = 0; lcd->power = FB_BLANK_UNBLANK; lcd->ldi_enable = 1; lcd->connected = 1; lcd->auto_brightness = 0; ret = device_create_file(&lcd->ld->dev, &dev_attr_power_reduce); if (ret < 0) dev_err(&lcd->ld->dev, "failed to add sysfs entries, %d\n", __LINE__); ret = device_create_file(&lcd->ld->dev, &dev_attr_lcd_type); if (ret < 0) dev_err(&lcd->ld->dev, "failed to add sysfs entries, %d\n", __LINE__); ret = device_create_file(&lcd->ld->dev, &dev_attr_window_type); if (ret < 0) dev_err(&lcd->ld->dev, "failed to add sysfs entries, %d\n", __LINE__); ret = device_create_file(&lcd->ld->dev, &dev_attr_gamma_table); if (ret < 0) dev_err(&lcd->ld->dev, "failed to add sysfs entries, %d\n", __LINE__); ret = device_create_file(&lcd->bd->dev, &dev_attr_auto_brightness); if (ret < 0) dev_err(&lcd->ld->dev, "failed to add sysfs entries, %d\n", __LINE__); dev_set_drvdata(dev, lcd); mutex_init(&lcd->lock); mutex_init(&lcd->bl_lock); s6evr02_read_id(lcd, lcd->id); dev_info(&lcd->ld->dev, "ID: %x, %x, %x\n", lcd->id[0], lcd->id[1], lcd->id[2]); dev_info(&lcd->ld->dev, "%s lcd panel driver has been probed.\n", dev_name(dev)); #ifdef SMART_DIMMING for (i = 0; i < LDI_ID_LEN; i++) { lcd->smart.panelid[i] = lcd->id[i]; } init_table_info(&lcd->smart); ret = s6evr02_read_mtp(lcd, mtp_data); /* for (i = 0; i < LDI_MTP_LENGTH ; i++) printk(" %dth mtp value is %x\n", i, mtp_data[i]); */ if (!ret) { printk(KERN_ERR "[LCD:ERROR] : %s read mtp failed\n", __func__); /*return -EPERM;*/ } calc_voltage_table(&lcd->smart, mtp_data); ret = init_elvss_table(lcd); ret += init_gamma_table(lcd, mtp_data); ret += init_aid_dimming_table(lcd); if (ret) printk(KERN_ERR "gamma table generation is failed\n"); update_brightness(lcd, 1); #endif #if defined(GPIO_ERR_FG) if (lcd->connected) { INIT_DELAYED_WORK(&lcd->err_fg_detection, err_fg_detection_work); lcd->irq = gpio_to_irq(GPIO_ERR_FG); irq_set_irq_type(lcd->irq, IRQ_TYPE_EDGE_RISING); s3c_gpio_cfgpin(GPIO_ERR_FG, S3C_GPIO_SFN(0xf)); s3c_gpio_setpull(GPIO_ERR_FG, S3C_GPIO_PULL_NONE); if (request_irq(lcd->irq, err_fg_detection_int, IRQF_TRIGGER_RISING, "err_fg_detection", lcd)) pr_err("failed to reqeust irq. %d\n", lcd->irq); } #endif #if defined(GPIO_OLED_DET) if (lcd->connected) { INIT_DELAYED_WORK(&lcd->oled_detection, oled_detection_work); s3c_gpio_cfgpin(GPIO_OLED_DET, S3C_GPIO_SFN(0xf)); s3c_gpio_setpull(GPIO_OLED_DET, S3C_GPIO_PULL_NONE); if (request_irq(gpio_to_irq(GPIO_OLED_DET), oled_detection_int, IRQF_TRIGGER_FALLING, "oled_detection", lcd)) pr_err("failed to reqeust irq. %d\n", gpio_to_irq(GPIO_OLED_DET)); } #endif lcd_early_suspend = s6evr02_early_suspend; lcd_late_resume = s6evr02_late_resume; return 0; out_free_backlight: lcd_device_unregister(lcd->ld); kfree(lcd); return ret; out_free_lcd: kfree(lcd); return ret; err_alloc: return ret; }
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; sbi->s_root_block += num_bm; goto got_root; } affs_brelse(root_bh); root_bh = NULL; } } if (!silent) pr_err("No valid root block on device %s\n", sb->s_id); return -EINVAL; /* N.B. after this point bh must be released */ got_root: /* Keep super block in cache */ sbi->s_root_bh = root_bh; root_block = sbi->s_root_block; /* Find out which kind of FS we have */ boot_bh = sb_bread(sb, 0); if (!boot_bh) { pr_err("Cannot read boot block\n"); return -EINVAL; } memcpy(sig, boot_bh->b_data, 4); brelse(boot_bh); chksum = be32_to_cpu(*(__be32 *)sig); /* Dircache filesystems are compatible with non-dircache ones * when reading. As long as they aren't supported, writing is * not recommended. */ if ((chksum == FS_DCFFS || chksum == MUFS_DCFFS || chksum == FS_DCOFS || chksum == MUFS_DCOFS) && !(sb->s_flags & MS_RDONLY)) { pr_notice("Dircache FS - mounting %s read only\n", sb->s_id); sb->s_flags |= MS_RDONLY; } switch (chksum) { case MUFS_FS: case MUFS_INTLFFS: case MUFS_DCFFS: sbi->s_flags |= SF_MUFS; /* fall thru */ case FS_INTLFFS: case FS_DCFFS: sbi->s_flags |= SF_INTL; break; case MUFS_FFS: sbi->s_flags |= SF_MUFS; break; case FS_FFS: break; case MUFS_OFS: sbi->s_flags |= SF_MUFS; /* fall thru */ case FS_OFS: sbi->s_flags |= SF_OFS; sb->s_flags |= MS_NOEXEC; break; case MUFS_DCOFS: case MUFS_INTLOFS: sbi->s_flags |= SF_MUFS; case FS_DCOFS: case FS_INTLOFS: sbi->s_flags |= SF_INTL | SF_OFS; sb->s_flags |= MS_NOEXEC; break; default: pr_err("Unknown filesystem on device %s: %08X\n", sb->s_id, chksum); return -EINVAL; } if (mount_flags & SF_VERBOSE) { u8 len = AFFS_ROOT_TAIL(sb, root_bh)->disk_name[0]; pr_notice("Mounting volume \"%.*s\": Type=%.3s\\%c, Blocksize=%d\n", len > 31 ? 31 : len, AFFS_ROOT_TAIL(sb, root_bh)->disk_name + 1, sig, sig[3] + '0', blocksize); } sb->s_flags |= MS_NODEV | MS_NOSUID; sbi->s_data_blksize = sb->s_blocksize; if (sbi->s_flags & SF_OFS) sbi->s_data_blksize -= 24; tmp_flags = sb->s_flags; ret = affs_init_bitmap(sb, &tmp_flags); if (ret) return ret; sb->s_flags = tmp_flags; /* set up enough so that it can read an inode */ root_inode = affs_iget(sb, root_block); if (IS_ERR(root_inode)) return PTR_ERR(root_inode); if (AFFS_SB(sb)->s_flags & SF_INTL) sb->s_d_op = &affs_intl_dentry_operations; else sb->s_d_op = &affs_dentry_operations; sb->s_root = d_make_root(root_inode); if (!sb->s_root) { pr_err("AFFS: Get root inode failed\n"); return -ENOMEM; } pr_debug("s_flags=%lX\n", sb->s_flags); return 0; }
/* * 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; }
static int __devinit dwc3_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; struct resource *res; struct dwc3 *dwc; struct device *dev = &pdev->dev; int ret = -ENOMEM; void __iomem *regs; void *mem; u8 mode; bool host_only_mode; mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); if (!mem) { dev_err(dev, "not enough memory\n"); return -ENOMEM; } dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); dwc->mem = mem; if (!dev->dma_mask) dev->dma_mask = &dwc3_dma_mask; if (!dev->coherent_dma_mask) dev->coherent_dma_mask = DMA_BIT_MASK(64); dwc->notify_event = notify_event; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { dev_err(dev, "missing IRQ\n"); return -ENODEV; } dwc->xhci_resources[1].start = res->start; dwc->xhci_resources[1].end = res->end; dwc->xhci_resources[1].flags = res->flags; dwc->xhci_resources[1].name = res->name; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "missing memory resource\n"); return -ENODEV; } dwc->xhci_resources[0].start = res->start; dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + DWC3_XHCI_REGS_END; dwc->xhci_resources[0].flags = res->flags; dwc->xhci_resources[0].name = res->name; res = devm_request_mem_region(dev, res->start + DWC3_GLOBALS_REGS_START, resource_size(res) - DWC3_GLOBALS_REGS_START, dev_name(dev)); if (!res) { dev_err(dev, "can't request mem region\n"); return -ENOMEM; } regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); if (!regs) { dev_err(dev, "ioremap failed\n"); return -ENOMEM; } spin_lock_init(&dwc->lock); platform_set_drvdata(pdev, dwc); dwc->regs = regs; dwc->regs_size = resource_size(res); 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; } ret = dwc3_gadget_init(dwc); if (ret) { dev_err(dev, "failed to initialize gadget\n"); dwc3_host_exit(dwc); dwc3_otg_exit(dwc); goto err1; } break; default: dev_err(dev, "Unsupported mode of operation %d\n", mode); goto err1; } dwc->mode = mode; ret = dwc3_debugfs_init(dwc); if (ret) { dev_err(dev, "failed to initialize debugfs\n"); goto err2; } dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_INITIALIZATION_EVENT); return 0; err2: switch (mode) { case DWC3_MODE_DEVICE: dwc3_gadget_exit(dwc); break; case DWC3_MODE_HOST: dwc3_host_exit(dwc); break; case DWC3_MODE_DRD: dwc3_gadget_exit(dwc); dwc3_host_exit(dwc); dwc3_otg_exit(dwc); break; default: break; } err1: dwc3_core_exit(dwc); return ret; }
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; }
/* * 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; }
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) { pr_err("Unable to request pm8058_othc_ir IRQ\n"); goto fail_ir_irq; } /* Request the SWITCH press/release interrupt */ rc = request_threaded_irq(dd->othc_irq_sw, NULL, pm8058_no_sw, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_DISABLED, "pm8058_othc_sw", dd); if (rc < 0) { pr_err("Unable to request pm8058_othc_sw IRQ\n"); goto fail_sw_irq; } /* Check if the accessory is already inserted during boot up */ rc = pm8058_irq_get_rt_status(dd->pm_chip, dd->othc_irq_ir); if (rc < 0) { pr_err("Unable to get accessory status at boot\n"); goto fail_ir_irq; } if (rc) { pr_debug("Accessory inserted during boot up\n"); /* process the data and report the inserted accessory */ rc = pm8058_accessory_report(dd, 1); if (rc) pr_debug("Unabele to detect accessory at boot up\n"); } device_init_wakeup(&pd->dev, hsed_config->hsed_bias_config->othc_wakeup); return 0; fail_sw_irq: free_irq(dd->othc_irq_ir, dd); fail_ir_irq: input_unregister_device(ipd); dd->othc_ipd = NULL; fail_micbias_config: input_free_device(ipd); fail_input_alloc: switch_dev_unregister(&dd->othc_sdev); return rc; }
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); }
static int bma2x2_probe(struct i2c_client *client, const struct i2c_device_id *id) { int err = 0; int tempvalue; unsigned char tmp_chip_id; #if defined(BMA2X2_ENABLE_INT1) || defined(BMA2X2_ENABLE_INT2) unsigned int irq_gpio_flags; #endif struct bma2x2_data *data; struct input_dev *dev; struct bst_dev *dev_acc; struct bma2x2_regulator_data *regdata = &bma2x2_regu_data; dev_info(&client->dev, "%s: BMA2x2 start probing.\n", __func__); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_info(&client->dev, "i2c_check_functionality error\n"); goto exit; } data = kzalloc(sizeof(struct bma2x2_data), GFP_KERNEL); if (!data) { err = -ENOMEM; goto exit; } #if defined(BMA2X2_ENABLE_INT1) || defined(BMA2X2_ENABLE_INT2) data->irq_gpio = of_get_named_gpio_flags(client->dev.of_node, "bma2x2,irq_gpio", 0, &irq_gpio_flags); if (data->irq_gpio < 0) { dev_err(&client->dev, "%s: negative gpio number ", __func__); err = -EIO; goto kfree_exit; } err = gpio_request(data->irq_gpio, SENSOR_NAME); if (err) { dev_err(&client->dev, "%s: gpio_request failed, err=%d\n", __func__, err); goto kfree_exit; } #endif /* init regulator */ regdata->reg_vdd = NULL; regdata->reg_vio = NULL; regdata->id_vdd = "bma2x2_vdd"; regdata->id_vio = "bma2x2_vio"; bma2x2_regulator_init(&client->dev); /* power on */ bma2x2_regulator_control(1, &client->dev); /* read chip id */ tempvalue = i2c_smbus_read_word_data(client, BMA2X2_CHIP_ID_REG); tmp_chip_id = tempvalue&0x00ff; switch (tmp_chip_id) { case BMA255_CHIP_ID: data->sensor_type = BMA255_TYPE; break; case BMA250E_CHIP_ID: data->sensor_type = BMA250E_TYPE; break; case BMA222E_CHIP_ID: data->sensor_type = BMA222E_TYPE; break; case BMA280_CHIP_ID: data->sensor_type = BMA280_TYPE; break; default: data->sensor_type = -1; } if (data->sensor_type != -1) { data->chip_id = tmp_chip_id; dev_info(&client->dev, "Bosch Sensortec Device detected!\n" \ "%s registered I2C driver!\n", \ sensor_name[data->sensor_type]); } else{ dev_info(&client->dev, "Bosch Sensortec Device not found" \ "i2c error %d\n", tempvalue); err = -ENODEV; goto kfree_exit; } i2c_set_clientdata(client, data); data->bma2x2_client = client; mutex_init(&data->value_mutex); mutex_init(&data->mode_mutex); mutex_init(&data->enable_mutex); bma2x2_set_bandwidth(client, BMA2X2_BW_SET); 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) { err = -ENOMEM; goto error_sysfs; } dev_acc->name = ACC_NAME; bst_set_drvdata(dev_acc, data); err = bst_register_device(dev_acc); if (err < 0) goto bst_free_acc_exit; data->bst_acc = dev_acc; err = sysfs_create_group(&data->bst_acc->dev.kobj, &bma2x2_attribute_group); if (err < 0) goto bst_free_exit; return 0; bst_free_exit: (void)bst_unregister_device(dev_acc); bst_free_acc_exit: bst_free_device(dev_acc); error_sysfs: input_unregister_device(data->input); kfree_exit: #if defined(BMA2X2_ENABLE_INT1) || defined(BMA2X2_ENABLE_INT2) if (NULL != data) gpio_free(data->irq_gpio); #endif if ((NULL != data) && (NULL != data->bst_pd)) { kfree(data->bst_pd); data->bst_pd = NULL; } kfree(data); exit: return err; }
/* 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; }
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; dev_info(&client->dev, "sensor driver probe successful\n"); goto exit; exit5: destroy_workqueue(wq); exit4: sysfs_remove_group(&data->light_input_dev->dev.kobj, &light_attribute_group); exit3: input_unregister_device(data->light_input_dev); input_free_device(data->light_input_dev); exit2: sysfs_remove_group(&data->proximity_input_dev->dev.kobj, &proximity_attribute_group); exit1: input_unregister_device(data->proximity_input_dev); input_free_device(data->proximity_input_dev); exit0: kfree(data); exit: return err; }
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); }
static int wacom_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct wacom_g5_platform_data *pdata = client->dev.platform_data; struct wacom_i2c *wac_i2c; struct input_dev *input; int ret = 0; if (pdata == NULL) { printk(KERN_ERR "%s: no pdata\n", __func__); ret = -ENODEV; goto err_i2c_fail; } /*Check I2C functionality */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { printk(KERN_ERR "[E-PEN] No I2C functionality found\n"); ret = -ENODEV; goto err_i2c_fail; } /*Obtain kernel memory space for wacom i2c */ wac_i2c = kzalloc(sizeof(struct wacom_i2c), GFP_KERNEL); if (NULL == wac_i2c) { printk(KERN_ERR "[E-PEN] failed to allocate wac_i2c.\n"); ret = -ENOMEM; goto err_freemem; } input = input_allocate_device(); if (NULL == input) { printk(KERN_ERR "[E-PEN] failed to allocate input device.\n"); ret = -ENOMEM; goto err_input_allocate_device; } else wacom_i2c_set_input_values(client, wac_i2c, input); wac_i2c->wac_feature = &wacom_feature_EMR; wac_i2c->wac_pdata = pdata; wac_i2c->input_dev = input; wac_i2c->client = client; wac_i2c->irq = client->irq; /*Change below if irq is needed */ wac_i2c->irq_flag = 1; /*Register callbacks */ wac_i2c->callbacks.check_prox = wacom_check_emr_prox; if (wac_i2c->wac_pdata->register_cb) wac_i2c->wac_pdata->register_cb(&wac_i2c->callbacks); /* Firmware Feature */ wacom_i2c_init_firm_data(); #if defined(CONFIG_MACH_Q1_BD) /* Change Origin offset by rev */ if (system_rev < 6) { origin_offset[0] = origin_offset_48[0]; origin_offset[1] = origin_offset_48[1]; } /* Reset IC */ wacom_i2c_reset_hw(wac_i2c->wac_pdata); #endif ret = wacom_i2c_query(wac_i2c); if (ret < 0) epen_reset_result = false; else epen_reset_result = true; INIT_WORK(&wac_i2c->update_work, update_work_func); #if defined(CONFIG_MACH_P4) if (pdata->xy_switch) { input_set_abs_params(input, ABS_X, WACOM_POSY_OFFSET, wac_i2c->wac_feature->y_max, 4, 0); input_set_abs_params(input, ABS_Y, WACOM_POSX_OFFSET, wac_i2c->wac_feature->x_max, 4, 0); } 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; } } #if defined(CONFIG_MACH_P4) if (Firmware_version_of_file > wac_i2c->wac_feature->fw_version) { /* the firmware should be updated only 4.8pitch panel */ if (0x107 != wac_i2c->wac_feature->fw_version) schedule_work(&wac_i2c->update_work); } #elif defined(CONFIG_MACH_Q1_BD) /* firmware info */ printk(KERN_NOTICE "[E-PEN] wacom fw ver : 0x%x, new fw ver : 0x%x\n", wac_i2c->wac_feature->fw_version, Firmware_version_of_file); #endif #ifdef CONFIG_SEC_TOUCHSCREEN_DVFS_LOCK INIT_DELAYED_WORK(&wac_i2c->dvfs_work, free_dvfs_lock); if (exynos_cpufreq_get_level(800000, &wac_i2c->cpufreq_level)) printk(KERN_ERR "[E-PEN] exynos_cpufreq_get_level Error\n"); #ifdef SEC_BUS_LOCK wac_i2c->bus_dev = dev_get("exynos-busfreq"); #endif #endif return 0; err_sysfs_create_group: free_irq(wac_i2c->irq, wac_i2c); err_request_irq: err_register_device: input_unregister_device(input); input = NULL; err_input_allocate_device: input_free_device(input); err_freemem: kfree(wac_i2c); err_i2c_fail: return ret; }
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; }
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: ; return err; }
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 platform resource mem\n"); return -ENXIO; } _udc_ctxt.regs = ioremap(res->start, resource_size(res)); if (!_udc_ctxt.regs) { dev_err(&pdev->dev, "ioremap failed\n"); return -ENOMEM; } ret = udc_probe(&ci13xxx_msm_udc_driver, &pdev->dev, _udc_ctxt.regs); if (ret < 0) { dev_err(&pdev->dev, "udc_probe failed\n"); goto iounmap; } _udc->gadget.l1_supported = is_l1_supported; _udc_ctxt.irq = platform_get_irq(pdev, 0); if (_udc_ctxt.irq < 0) { dev_err(&pdev->dev, "IRQ not found\n"); ret = -ENXIO; goto udc_remove; } res = platform_get_resource_byname(pdev, IORESOURCE_IO, "USB_RESUME"); if (res) { ret = ci13xxx_msm_install_wake_gpio(pdev, res); if (ret < 0) { dev_err(&pdev->dev, "gpio irq install failed\n"); goto udc_remove; } } ret = request_irq(_udc_ctxt.irq, msm_udc_irq, IRQF_SHARED, pdev->name, pdev); if (ret < 0) { dev_err(&pdev->dev, "request_irq failed\n"); goto gpio_uninstall; } #ifdef CONFIG_USB_G_LGE_ANDROID wake_lock_init(&_udc_ctxt.wlock, WAKE_LOCK_SUSPEND, "usb_bus_active"); INIT_DELAYED_WORK(&_udc_ctxt.wunlock_w, wunlock_w); #endif #ifdef CONFIG_LGE_PM_VZW_FAST_CHG INIT_DELAYED_WORK(&usb_detect_w, usb_detect_work); #endif pm_runtime_no_callbacks(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; gpio_uninstall: ci13xxx_msm_uninstall_wake_gpio(pdev); udc_remove: udc_remove(); iounmap: iounmap(_udc_ctxt.regs); return ret; }
int __init rpi_power_switch_init(void) { int ret = 0; old_pm_power_off = pm_power_off; pm_power_off = rpi_power_switch_power_off; pr_info("Adafruit Industries' power switch driver v%s\n", RPI_POWER_SWITCH_VERSION); INIT_DELAYED_WORK(&initiate_shutdown_work, initiate_shutdown); /* Register our own class for the power switch */ ret = class_register(&power_switch_class); if (ret < 0) { pr_err("%s: Unable to register class\n", power_switch_class.name); goto out0; } /* Create devices for each PWM present */ switch_dev = device_create(&power_switch_class, &platform_bus, MKDEV(0, 0), NULL, "pswitch%u", 0); if (IS_ERR(switch_dev)) { pr_err("%s: device_create failed\n", power_switch_class.name); ret = PTR_ERR(switch_dev); goto out1; } ret = sysfs_create_group(&switch_dev->kobj, &rpi_power_switch_attribute_group); if (ret < 0) { pr_err("%s: create_group failed\n", power_switch_class.name); goto out2; } /* GPIO register memory must be mapped before doing any direct * accesses such as changing GPIO alt functions or changing GPIO * pull ups or pull downs. */ gpio_reg = ioremap(GPIO_BASE, 1024); /* Set the specified pin as a GPIO input */ SET_GPIO_INPUT(gpio_pin); /* Set the pin as a pulldown. Most pins should default to having * pulldowns, and this seems most intuitive. */ set_gpio_pull(gpio_pin, GPIO_PULL_UP); gpio_request(gpio_pin, "Power switch"); gpio_direction_input(gpio_pin); /* The targeted polarity should be the opposite of the current value. * I.e. we want the pin to transition to this state in order to * initiate a shutdown. */ gpio_pol = !gpio_get_value(gpio_pin); /* Request an interrupt to fire when the pin transitions to our * desired state. */ ret = request_irq(__gpio_to_irq(gpio_pin), power_isr, gpio_pol?IRQF_TRIGGER_RISING:IRQF_TRIGGER_FALLING, "Power button", NULL); if (ret) { pr_err("Unable to request IRQ\n"); goto out3; } return 0; /* Error handling */ out3: sysfs_remove_group(&switch_dev->kobj,&rpi_power_switch_attribute_group); out2: device_unregister(switch_dev); out1: class_unregister(&power_switch_class); out0: iounmap(gpio_reg); pm_power_off = old_pm_power_off; return ret; }
static int ssp_probe(struct spi_device *spi_dev) { int iRet = 0; struct ssp_data *data; struct ssp_platform_data *pdata; if (poweroff_charging == 1 || recovery_mode == 1) { pr_err("[SSP] probe exit : lpm %d recovery %d \n", poweroff_charging, recovery_mode); return -ENODEV; } data = kzalloc(sizeof(*data), GFP_KERNEL); if (data == NULL) { pr_err("[SSP]: %s - failed to allocate memory for data\n", __func__); iRet = -ENOMEM; goto exit; } #if defined (CONFIG_SEC_MONTBLANC_PROJECT) proximity_ldo_enable(1); #endif if (spi_dev->dev.of_node) { iRet = ssp_parse_dt(&spi_dev->dev, data); if (iRet) { pr_err("[SSP]: %s - Failed to parse DT\n", __func__); goto err_setup; } data->ssp_changes = SSP_MCU_L5; /* K330, MPU L5*/ } else { pdata = spi_dev->dev.platform_data; if (pdata == NULL) { pr_err("[SSP]: %s - platform_data is null\n", __func__); iRet = -ENOMEM; goto err_setup; } data->wakeup_mcu = pdata->wakeup_mcu; data->check_mcu_ready = pdata->check_mcu_ready; data->check_mcu_busy = pdata->check_mcu_busy; data->set_mcu_reset = pdata->set_mcu_reset; data->read_chg = pdata->read_chg; /* AP system_rev */ if (pdata->check_ap_rev) data->ap_rev = pdata->check_ap_rev(); else data->ap_rev = 0; /* For changed devices */ if (pdata->check_changes) data->ssp_changes = pdata->check_changes(); else data->ssp_changes = SSP_MCU_L5; /* K330, MPU L5*/ /* Get sensor positions */ if (pdata->get_positions) pdata->get_positions(&data->accel_position, &data->mag_position); else if (spi_dev->dev.of_node == NULL) { data->accel_position = 0; data->mag_position = 0; } } spi_dev->mode = SPI_MODE_1; if (spi_setup(spi_dev)) { pr_err("failed to setup spi for ssp_spi\n"); goto err_setup; } data->bProbeIsDone = false; data->fw_dl_state = FW_DL_STATE_NONE; data->spi = spi_dev; spi_set_drvdata(spi_dev, data); #ifdef CONFIG_SENSORS_SSP_SHTC1 mutex_init(&data->cp_temp_adc_lock); mutex_init(&data->bulk_temp_read_lock); #endif #if defined(CONFIG_SENSORS_SSP_STM) || defined(CONFIG_SENSORS_SSP_STM_MONTBLANC) mutex_init(&data->comm_mutex); mutex_init(&data->pending_mutex); #endif if (((data->wakeup_mcu == NULL) || (data->check_mcu_ready == NULL) || (data->check_mcu_busy == NULL) || (data->set_mcu_reset == NULL) || (data->read_chg == NULL)) && (spi_dev->dev.of_node == NULL)) { pr_err("[SSP]: %s - function callback is null\n", __func__); iRet = -EIO; goto err_reset_null; } pr_info("\n#####################################################\n"); INIT_DELAYED_WORK(&data->work_firmware, work_function_firmware_update); wake_lock_init(&data->ssp_wake_lock, WAKE_LOCK_SUSPEND, "ssp_wake_lock"); iRet = initialize_input_dev(data); if (iRet < 0) { pr_err("[SSP]: %s - could not create input device\n", __func__); goto err_input_register_device; } iRet = initialize_debug_timer(data); if (iRet < 0) { pr_err("[SSP]: %s - could not create workqueue\n", __func__); goto err_create_workqueue; } iRet = initialize_irq(data); if (iRet < 0) { pr_err("[SSP]: %s - could not create irq\n", __func__); goto err_setup_irq; } iRet = initialize_sysfs(data); if (iRet < 0) { pr_err("[SSP]: %s - could not create sysfs\n", __func__); goto err_sysfs_create; } iRet = initialize_event_symlink(data); if (iRet < 0) { pr_err("[SSP]: %s - could not create symlink\n", __func__); goto err_symlink_create; } initialize_variable(data); ssp_enable(data, true); /* check boot loader binary */ data->fw_dl_state = check_fwbl(data); if (data->fw_dl_state == FW_DL_STATE_NONE) { iRet = initialize_mcu(data); if (iRet == ERROR) { data->uResetCnt++; toggle_mcu_reset(data); msleep(SSP_SW_RESET_TIME); initialize_mcu(data); } else if (iRet < ERROR) { pr_err("[SSP]: %s - initialize_mcu failed\n", __func__); goto err_read_reg; } } #ifdef CONFIG_HAS_EARLYSUSPEND data->early_suspend.suspend = ssp_early_suspend; data->early_suspend.resume = ssp_late_resume; register_early_suspend(&data->early_suspend); #endif #ifdef CONFIG_SENSORS_SSP_SENSORHUB /* init sensorhub device */ iRet = ssp_sensorhub_initialize(data); if (iRet < 0) { pr_err("%s: ssp_sensorhub_initialize err(%d)", __func__, iRet); ssp_sensorhub_remove(data); } #endif pr_info("[SSP]: %s - probe success!\n", __func__); enable_debug_timer(data); iRet = 0; if (data->fw_dl_state == FW_DL_STATE_NEED_TO_SCHEDULE) { pr_info("[SSP]: Firmware update is scheduled\n"); schedule_delayed_work(&data->work_firmware, msecs_to_jiffies(1000)); data->fw_dl_state = FW_DL_STATE_SCHEDULED; } else if (data->fw_dl_state == FW_DL_STATE_FAIL) data->bSspShutdown = true; data->bProbeIsDone = true; goto exit; err_read_reg: err_symlink_create: remove_sysfs(data); err_sysfs_create: free_irq(data->iIrq, data); gpio_free(data->mcu_int1); err_setup_irq: destroy_workqueue(data->debug_wq); err_create_workqueue: remove_input_dev(data); err_input_register_device: wake_lock_destroy(&data->ssp_wake_lock); err_reset_null: #ifdef CONFIG_SENSORS_SSP_SHTC1 mutex_destroy(&data->cp_temp_adc_lock); mutex_destroy(&data->bulk_temp_read_lock); #endif #if defined(CONFIG_SENSORS_SSP_STM) || defined(CONFIG_SENSORS_SSP_STM_MONTBLANC) mutex_destroy(&data->comm_mutex); mutex_destroy(&data->pending_mutex); #endif err_setup: kfree(data); pr_err("[SSP]: %s - probe failed!\n", __func__); exit: pr_info("#####################################################\n\n"); return iRet; }
static int yas_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct yas_state *st; struct iio_dev *indio_dev; int ret, i; this_client = i2c; printk("[CCI]%s: yas_bosch_accel_probe start ---\n", __FUNCTION__); indio_dev = iio_device_alloc(sizeof(*st)); if (!indio_dev) { ret = -ENOMEM; goto error_ret; } i2c_set_clientdata(i2c, indio_dev); indio_dev->name = id->name; indio_dev->dev.parent = &i2c->dev; indio_dev->info = &yas_info; indio_dev->channels = yas_channels; indio_dev->num_channels = ARRAY_SIZE(yas_channels); indio_dev->modes = INDIO_DIRECT_MODE; st = iio_priv(indio_dev); st->client = i2c; st->sampling_frequency = 20; st->acc.callback.device_open = yas_device_open; st->acc.callback.device_close = yas_device_close; st->acc.callback.device_read = yas_device_read; st->acc.callback.device_write = yas_device_write; st->acc.callback.usleep = yas_usleep; st->acc.callback.current_time = yas_current_time; INIT_DELAYED_WORK(&st->work, yas_work_func); mutex_init(&st->lock); #ifdef CONFIG_HAS_EARLYSUSPEND st->sus.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; st->sus.suspend = yas_early_suspend; st->sus.resume = yas_late_resume; register_early_suspend(&st->sus); #endif for (i = 0; i < 3; i++) { st->compass_data[i] = 0; st->calib_bias[i] = 0; } ret = yas_probe_buffer(indio_dev); if (ret) goto error_free_dev; ret = yas_probe_trigger(indio_dev); if (ret) goto error_remove_buffer; ret = iio_device_register(indio_dev); if (ret) goto error_remove_trigger; ret = yas_acc_driver_init(&st->acc); if (ret < 0) { ret = -EFAULT; goto error_unregister_iio; } ret = st->acc.init(); if (ret < 0) { ret = -EFAULT; goto error_unregister_iio; } ret = st->acc.set_enable(1); if (ret < 0) { ret = -EFAULT; goto error_driver_term; } printk("[CCI]%s: yas_bosch_accel_probe end ---\n", __FUNCTION__); return 0; error_driver_term: st->acc.term(); error_unregister_iio: iio_device_unregister(indio_dev); error_remove_trigger: yas_remove_trigger(indio_dev); error_remove_buffer: yas_remove_buffer(indio_dev); error_free_dev: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&st->sus); #endif iio_device_free(indio_dev); error_ret: i2c_set_clientdata(i2c, NULL); this_client = NULL; return ret; }
static int appledisplay_probe(struct usb_interface *iface, const struct usb_device_id *id) { struct backlight_properties props; struct appledisplay *pdata; struct usb_device *udev = interface_to_usbdev(iface); struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int int_in_endpointAddr = 0; int i, retval = -ENOMEM, brightness; char bl_name[20]; /* set up the endpoint information */ /* use only the first interrupt-in endpoint */ iface_desc = iface->cur_altsetting; for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { endpoint = &iface_desc->endpoint[i].desc; if (!int_in_endpointAddr && usb_endpoint_is_int_in(endpoint)) { /* we found an interrupt in endpoint */ int_in_endpointAddr = endpoint->bEndpointAddress; break; } } if (!int_in_endpointAddr) { dev_err(&iface->dev, "Could not find int-in endpoint\n"); return -EIO; } /* allocate memory for our device state and initialize it */ pdata = kzalloc(sizeof(struct appledisplay), GFP_KERNEL); if (!pdata) { retval = -ENOMEM; dev_err(&iface->dev, "Out of memory\n"); goto error; } pdata->udev = udev; spin_lock_init(&pdata->lock); INIT_DELAYED_WORK(&pdata->work, appledisplay_work); /* Allocate buffer for control messages */ pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); if (!pdata->msgdata) { retval = -ENOMEM; dev_err(&iface->dev, "Allocating buffer for control messages failed\n"); goto error; } /* Allocate interrupt URB */ pdata->urb = usb_alloc_urb(0, GFP_KERNEL); if (!pdata->urb) { retval = -ENOMEM; dev_err(&iface->dev, "Allocating URB failed\n"); goto error; } /* Allocate buffer for interrupt data */ pdata->urbdata = usb_alloc_coherent(pdata->udev, ACD_URB_BUFFER_LEN, GFP_KERNEL, &pdata->urb->transfer_dma); if (!pdata->urbdata) { retval = -ENOMEM; dev_err(&iface->dev, "Allocating URB buffer failed\n"); goto error; } /* Configure interrupt URB */ usb_fill_int_urb(pdata->urb, udev, usb_rcvintpipe(udev, int_in_endpointAddr), pdata->urbdata, ACD_URB_BUFFER_LEN, appledisplay_complete, pdata, 1); if (usb_submit_urb(pdata->urb, GFP_KERNEL)) { retval = -EIO; dev_err(&iface->dev, "Submitting URB failed\n"); goto error; } /* Register backlight device */ snprintf(bl_name, sizeof(bl_name), "appledisplay%d", atomic_inc_return_unchecked(&count_displays) - 1); memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = 0xff; pdata->bd = backlight_device_register(bl_name, NULL, pdata, &appledisplay_bl_data, &props); if (IS_ERR(pdata->bd)) { dev_err(&iface->dev, "Backlight registration failed\n"); retval = PTR_ERR(pdata->bd); goto error; } /* Try to get brightness */ brightness = appledisplay_bl_get_brightness(pdata->bd); if (brightness < 0) { retval = brightness; dev_err(&iface->dev, "Error while getting initial brightness: %d\n", retval); goto error; } /* Set brightness in backlight device */ pdata->bd->props.brightness = brightness; /* save our data pointer in the interface device */ usb_set_intfdata(iface, pdata); printk(KERN_INFO "appledisplay: Apple Cinema Display connected\n"); return 0; error: if (pdata) { if (pdata->urb) { usb_kill_urb(pdata->urb); if (pdata->urbdata) usb_free_coherent(pdata->udev, ACD_URB_BUFFER_LEN, pdata->urbdata, pdata->urb->transfer_dma); usb_free_urb(pdata->urb); } if (pdata->bd && !IS_ERR(pdata->bd)) backlight_device_unregister(pdata->bd); kfree(pdata->msgdata); } usb_set_intfdata(iface, NULL); kfree(pdata); return retval; }
static int __devinit mipi_orise_lcd_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct mipi_panel_info *mipi; struct platform_device *current_pdev; static struct mipi_dsi_phy_ctrl *phy_settings; int rc = 0; if (pdev->id == 0) { mipi_orise_pdata = pdev->dev.platform_data; if (mipi_orise_pdata && mipi_orise_pdata->phy_ctrl_settings) { phy_settings = (mipi_orise_pdata->phy_ctrl_settings); } return 0; } current_pdev = msm_fb_add_device(pdev); if (current_pdev) { mfd = platform_get_drvdata(current_pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; mipi = &mfd->panel_info.mipi; if (phy_settings != NULL) mipi->dsi_phy_db = phy_settings; } rc = gpio_request(LCD_TE_GPIO, "LCD_TE_GPIO#"); if (rc < 0) { pr_err("MIPI GPIO LCD_TE_GPIO request failed: %d\n", rc); return -ENODEV; } rc = gpio_direction_input(LCD_TE_GPIO); if (rc < 0) { pr_err("MIPI GPIO LCD_TE_GPIO set failed: %d\n", rc); return -ENODEV; } irq = gpio_to_irq(LCD_TE_GPIO); rc = request_threaded_irq(irq, NULL, TE_irq_thread_fn, IRQF_TRIGGER_RISING, "LCD_TE",NULL); if (rc < 0) { pr_err("Unable to register IRQ handler\n"); return -ENODEV; } INIT_DELAYED_WORK(&techeck_work, techeck_work_func ); schedule_delayed_work(&techeck_work, msecs_to_jiffies(20000)); init_suspend(); /* ATTR node: root@android:/sys/devices/virtual/graphics/fb0/orise_bkl */ mfd = platform_get_drvdata(current_pdev); rc = sysfs_create_group(&mfd->fbi->dev->kobj, &fs_attr_bkl_ctrl); if (rc) { pr_err("%s: fs_attr_bkl_ctrl sysfs group creation failed, rc=%d\n", __func__, rc); return rc; } /* OPPO 2013-03-07 zhengzk Add begin for reason */ display_switch.name = "dispswitch"; rc = switch_dev_register(&display_switch); if (rc) { pr_err("Unable to register display switch device\n"); return rc; } /* OPPO 2013-03-07 zhengzk Add end */ return 0; }
static int cxacru_bind(struct usbatm_data *usbatm_instance, struct usb_interface *intf, const struct usb_device_id *id) { struct cxacru_data *instance; struct usb_device *usb_dev = interface_to_usbdev(intf); struct usb_host_endpoint *cmd_ep = usb_dev->ep_in[CXACRU_EP_CMD]; int ret; /* instance init */ instance = kzalloc(sizeof(*instance), GFP_KERNEL); if (!instance) { usb_dbg(usbatm_instance, "cxacru_bind: no memory for instance data\n"); return -ENOMEM; } instance->usbatm = usbatm_instance; instance->modem_type = (struct cxacru_modem_type *) id->driver_info; mutex_init(&instance->poll_state_serialize); instance->poll_state = CXPOLL_STOPPED; instance->line_status = -1; instance->adsl_status = -1; mutex_init(&instance->adsl_state_serialize); instance->rcv_buf = (u8 *) __get_free_page(GFP_KERNEL); if (!instance->rcv_buf) { usb_dbg(usbatm_instance, "cxacru_bind: no memory for rcv_buf\n"); ret = -ENOMEM; goto fail; } instance->snd_buf = (u8 *) __get_free_page(GFP_KERNEL); if (!instance->snd_buf) { usb_dbg(usbatm_instance, "cxacru_bind: no memory for snd_buf\n"); ret = -ENOMEM; goto fail; } instance->rcv_urb = usb_alloc_urb(0, GFP_KERNEL); if (!instance->rcv_urb) { usb_dbg(usbatm_instance, "cxacru_bind: no memory for rcv_urb\n"); ret = -ENOMEM; goto fail; } instance->snd_urb = usb_alloc_urb(0, GFP_KERNEL); if (!instance->snd_urb) { usb_dbg(usbatm_instance, "cxacru_bind: no memory for snd_urb\n"); ret = -ENOMEM; goto fail; } if (!cmd_ep) { usb_dbg(usbatm_instance, "cxacru_bind: no command endpoint\n"); ret = -ENODEV; goto fail; } if ((cmd_ep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT) { usb_fill_int_urb(instance->rcv_urb, usb_dev, usb_rcvintpipe(usb_dev, CXACRU_EP_CMD), instance->rcv_buf, PAGE_SIZE, cxacru_blocking_completion, &instance->rcv_done, 1); usb_fill_int_urb(instance->snd_urb, usb_dev, usb_sndintpipe(usb_dev, CXACRU_EP_CMD), instance->snd_buf, PAGE_SIZE, cxacru_blocking_completion, &instance->snd_done, 4); } else { usb_fill_bulk_urb(instance->rcv_urb, usb_dev, usb_rcvbulkpipe(usb_dev, CXACRU_EP_CMD), instance->rcv_buf, PAGE_SIZE, cxacru_blocking_completion, &instance->rcv_done); usb_fill_bulk_urb(instance->snd_urb, usb_dev, usb_sndbulkpipe(usb_dev, CXACRU_EP_CMD), instance->snd_buf, PAGE_SIZE, cxacru_blocking_completion, &instance->snd_done); } mutex_init(&instance->cm_serialize); INIT_DELAYED_WORK(&instance->poll_work, cxacru_poll_status); usbatm_instance->driver_data = instance; usbatm_instance->flags = (cxacru_card_status(instance) ? 0 : UDSL_SKIP_HEAVY_INIT); return 0; fail: free_page((unsigned long) instance->snd_buf); free_page((unsigned long) instance->rcv_buf); usb_free_urb(instance->snd_urb); usb_free_urb(instance->rcv_urb); kfree(instance); return ret; }
static int gdlm_mount(struct gfs2_sbd *sdp, const char *table) { struct lm_lockstruct *ls = &sdp->sd_lockstruct; char cluster[GFS2_LOCKNAME_LEN]; const char *fsname; uint32_t flags; int error, ops_result; /* * initialize everything */ INIT_DELAYED_WORK(&sdp->sd_control_work, gfs2_control_func); spin_lock_init(&ls->ls_recover_spin); ls->ls_recover_flags = 0; ls->ls_recover_mount = 0; ls->ls_recover_start = 0; ls->ls_recover_block = 0; ls->ls_recover_size = 0; ls->ls_recover_submit = NULL; ls->ls_recover_result = NULL; ls->ls_lvb_bits = NULL; error = set_recover_size(sdp, NULL, 0); if (error) goto fail; /* * prepare dlm_new_lockspace args */ fsname = strchr(table, ':'); if (!fsname) { fs_info(sdp, "no fsname found\n"); error = -EINVAL; goto fail_free; } memset(cluster, 0, sizeof(cluster)); memcpy(cluster, table, strlen(table) - strlen(fsname)); fsname++; flags = DLM_LSFL_FS | DLM_LSFL_NEWEXCL; /* * create/join lockspace */ error = dlm_new_lockspace(fsname, cluster, flags, GDLM_LVB_SIZE, &gdlm_lockspace_ops, sdp, &ops_result, &ls->ls_dlm); if (error) { fs_err(sdp, "dlm_new_lockspace error %d\n", error); goto fail_free; } if (ops_result < 0) { /* * dlm does not support ops callbacks, * old dlm_controld/gfs_controld are used, try without ops. */ fs_info(sdp, "dlm lockspace ops not used\n"); free_recover_size(ls); set_bit(DFL_NO_DLM_OPS, &ls->ls_recover_flags); return 0; } if (!test_bit(SDF_NOJOURNALID, &sdp->sd_flags)) { fs_err(sdp, "dlm lockspace ops disallow jid preset\n"); error = -EINVAL; goto fail_release; } /* * control_mount() uses control_lock to determine first mounter, * and for later mounts, waits for any recoveries to be cleared. */ error = control_mount(sdp); if (error) { fs_err(sdp, "mount control error %d\n", error); goto fail_release; } ls->ls_first = !!test_bit(DFL_FIRST_MOUNT, &ls->ls_recover_flags); clear_bit(SDF_NOJOURNALID, &sdp->sd_flags); smp_mb__after_atomic(); wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID); return 0; fail_release: dlm_release_lockspace(ls->ls_dlm, 2); fail_free: free_recover_size(ls); fail: return error; }
/** * mei_probe - Device Initialization Routine * * @pdev: PCI device structure * @ent: entry in kcs_pci_tbl * * returns 0 on success, <0 on failure. */ static int __devinit mei_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct mei_device *dev; int err; mutex_lock(&mei_mutex); if (mei_device) { err = -EEXIST; goto end; } /* enable pci dev */ err = pci_enable_device(pdev); if (err) { ; goto end; } /* set PCI host mastering */ pci_set_master(pdev); /* pci request regions for mei driver */ err = pci_request_regions(pdev, mei_driver_name); if (err) { ; goto disable_device; } /* allocates and initializes the mei dev structure */ dev = init_mei_device(pdev); if (!dev) { err = -ENOMEM; goto release_regions; } /* mapping IO device memory */ dev->mem_addr = pci_iomap(pdev, 0, 0); if (!dev->mem_addr) { ; err = -ENOMEM; goto free_device; } /* request and enable interrupt */ err = request_threaded_irq(pdev->irq, mei_interrupt_quick_handler, mei_interrupt_thread_handler, IRQF_SHARED, mei_driver_name, dev); if (err) { // printk(KERN_ERR "mei: request_threaded_irq failure. irq = %d\n", ; goto unmap_memory; } INIT_DELAYED_WORK(&dev->wd_work, mei_wd_timer); if (mei_hw_init(dev)) { ; err = -ENODEV; goto release_irq; } mei_device = pdev; pci_set_drvdata(pdev, dev); schedule_delayed_work(&dev->wd_work, HZ); mutex_unlock(&mei_mutex); pr_debug("mei: Driver initialization successful.\n"); return 0; release_irq: /* disable interrupts */ dev->host_hw_state = mei_hcsr_read(dev); mei_disable_interrupts(dev); flush_scheduled_work(); free_irq(pdev->irq, dev); unmap_memory: pci_iounmap(pdev, dev->mem_addr); free_device: kfree(dev); release_regions: pci_release_regions(pdev); disable_device: pci_disable_device(pdev); end: mutex_unlock(&mei_mutex); ; return err; }
static ssize_t pm8941_set_mode(struct device *ldev, struct device_attribute *attr, const char *buf, size_t size) { struct pm8941_flash_data *data = dev_get_drvdata(ldev); unsigned long mode; int rc = 0; if (kstrtoul(buf, 10, &mode)) return -EINVAL; if (mode >= FLASH_MODE_MAX) return -EINVAL; mutex_lock(&data->lock); if (data->scheduled) { mutex_unlock(&data->lock); flush_delayed_work_sync(&data->dwork); mutex_lock(&data->lock); } else { rc = pm_reg_masked_write(data, STROBE_CONTROL, ENABLE_CURRENT_OUT, DISABLE_CURRENT_OUT); if (rc) goto error; rc = pm_reg_write(data, ENABLE_CONTROL, MODULE_DISABLE | CURR_MAX_200mA); if (rc) goto error; rc = pm8941_regulator_disable(&data->spmi_dev->dev, &data->boost_for_torch); rc = rc ? rc : pm8941_regulator_disable(&data->spmi_dev->dev, &data->boost_for_flash); if (rc) goto exit; } switch (mode) { case FLASH_MODE_FLASH: rc = rc ? rc : pm8941_regulator_enable(&data->spmi_dev->dev, &data->boost_for_flash); rc = rc ? rc : pm_reg_write(data, TMR_CONTROL, ENABLE_FLASH_TIMER); rc = rc ? rc : pm_reg_write(data, VREG_OK_FORCE, 0x40); rc = rc ? rc : pm_reg_write(data, FAULT_DETECT, ENABLE_SELF_CHECK); rc = rc ? rc : pm_reg_write(data, MAX_CURRENT, 0x4F); rc = rc ? rc : pm_reg_write(data, ENABLE_CONTROL, MODULE_ENABLE | CURR_MAX_1A); rc = rc ? rc : pm_reg_masked_write(data, STROBE_CONTROL, ENABLE_CURRENT_OUT, ENABLE_CURRENT_OUT); if (!is_hw_strobe(data)) { data->scheduled = true; INIT_DELAYED_WORK(&data->dwork, flash_turn_off_delayed); schedule_delayed_work(&data->dwork, msecs_to_jiffies(data->turn_off_delay_ms)); } break; case FLASH_MODE_TORCH: rc = rc ? rc : pm_reg_masked_write(data, STROBE_CONTROL, STROBE_SELECT_HW, STROBE_SELECT_SW); rc = rc ? rc : pm8941_regulator_enable(&data->spmi_dev->dev, &data->boost_for_torch); rc = rc ? rc : pm_reg_write(data, MAX_CURRENT, 0xF); rc = rc ? rc : pm_reg_write(data, TMR_CONTROL, ENABLE_WATCHDOG_TIMER); rc = rc ? rc : pm_reg_write(data, ENABLE_CONTROL, MODULE_ENABLE | CURR_MAX_200mA); rc = rc ? rc : pm_reg_masked_write(data, STROBE_CONTROL, ENABLE_CURRENT_OUT, ENABLE_CURRENT_OUT); break; case FLASH_MODE_NONE: default: break; } error: if (rc) pm8941_dev_err(data, "reg write failed(%d)\n", rc); exit: mutex_unlock(&data->lock); return rc ? rc : size; }
static int sta32x_probe(struct snd_soc_codec *codec) { struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); struct sta32x_platform_data *pdata = sta32x->pdata; int i, ret = 0, thermal = 0; ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); if (ret != 0) { dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); return ret; } ret = sta32x_startup_sequence(sta32x); if (ret < 0) { dev_err(codec->dev, "Failed to startup device\n"); return ret; } /* CONFA */ if (!pdata->thermal_warning_recovery) thermal |= STA32X_CONFA_TWAB; if (!pdata->thermal_warning_adjustment) thermal |= STA32X_CONFA_TWRB; if (!pdata->fault_detect_recovery) thermal |= STA32X_CONFA_FDRB; regmap_update_bits(sta32x->regmap, STA32X_CONFA, STA32X_CONFA_TWAB | STA32X_CONFA_TWRB | STA32X_CONFA_FDRB, thermal); /* CONFC */ regmap_update_bits(sta32x->regmap, STA32X_CONFC, STA32X_CONFC_CSZ_MASK, pdata->drop_compensation_ns << STA32X_CONFC_CSZ_SHIFT); /* CONFE */ regmap_update_bits(sta32x->regmap, STA32X_CONFE, STA32X_CONFE_MPCV, pdata->max_power_use_mpcc ? STA32X_CONFE_MPCV : 0); regmap_update_bits(sta32x->regmap, STA32X_CONFE, STA32X_CONFE_MPC, pdata->max_power_correction ? STA32X_CONFE_MPC : 0); regmap_update_bits(sta32x->regmap, STA32X_CONFE, STA32X_CONFE_AME, pdata->am_reduction_mode ? STA32X_CONFE_AME : 0); regmap_update_bits(sta32x->regmap, STA32X_CONFE, STA32X_CONFE_PWMS, pdata->odd_pwm_speed_mode ? STA32X_CONFE_PWMS : 0); /* CONFF */ regmap_update_bits(sta32x->regmap, STA32X_CONFF, STA32X_CONFF_IDE, pdata->invalid_input_detect_mute ? STA32X_CONFF_IDE : 0); /* select output configuration */ regmap_update_bits(sta32x->regmap, STA32X_CONFF, STA32X_CONFF_OCFG_MASK, pdata->output_conf << STA32X_CONFF_OCFG_SHIFT); /* channel to output mapping */ regmap_update_bits(sta32x->regmap, STA32X_C1CFG, STA32X_CxCFG_OM_MASK, pdata->ch1_output_mapping << STA32X_CxCFG_OM_SHIFT); regmap_update_bits(sta32x->regmap, STA32X_C2CFG, STA32X_CxCFG_OM_MASK, pdata->ch2_output_mapping << STA32X_CxCFG_OM_SHIFT); regmap_update_bits(sta32x->regmap, STA32X_C3CFG, STA32X_CxCFG_OM_MASK, pdata->ch3_output_mapping << STA32X_CxCFG_OM_SHIFT); /* initialize coefficient shadow RAM with reset values */ for (i = 4; i <= 49; i += 5) sta32x->coef_shadow[i] = 0x400000; for (i = 50; i <= 54; i++) sta32x->coef_shadow[i] = 0x7fffff; sta32x->coef_shadow[55] = 0x5a9df7; sta32x->coef_shadow[56] = 0x7fffff; sta32x->coef_shadow[59] = 0x7fffff; sta32x->coef_shadow[60] = 0x400000; sta32x->coef_shadow[61] = 0x400000; if (sta32x->pdata->needs_esd_watchdog) INIT_DELAYED_WORK(&sta32x->watchdog_work, sta32x_watchdog); snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); return 0; }
static int bq24297_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct bq24297_chip *chip; struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct device_node *np = client->dev.of_node; struct pinctrl *pinctrl; int ret = 0; dev_info(&client->dev, "%s: addr=0x%x @ IIC%d, irq=%d\n", client->name,client->addr,client->adapter->nr,client->irq); if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))//I2C_FUNC_SMBUS_BYTE return -EIO; chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (!chip) return -ENOMEM; this_chip = chip; chip->client = client; i2c_set_clientdata(client, chip); of_property_read_u32(np, "debug", &bq24297_dbg); ret = bq24297_hw_init(); if (ret < 0) { goto err_hw_init; } bq24297_read_version(); chip->usb.name = "usb"; chip->usb.type = POWER_SUPPLY_TYPE_USB; chip->usb.supplied_to = supply_to_list; chip->usb.num_supplicants = ARRAY_SIZE(supply_to_list); chip->usb.get_property = bq24297_power_get_property; chip->usb.properties = bq24297_power_props; chip->usb.num_properties = ARRAY_SIZE(bq24297_power_props); chip->ac.name = "ac"; chip->ac.type = POWER_SUPPLY_TYPE_MAINS; chip->ac.supplied_to = supply_to_list; chip->ac.num_supplicants = ARRAY_SIZE(supply_to_list); chip->ac.get_property = bq24297_power_get_property; chip->ac.properties = bq24297_power_props; chip->ac.num_properties = ARRAY_SIZE(bq24297_power_props); power_supply_register(&client->dev, &chip->usb); power_supply_register(&client->dev, &chip->ac); chip->battery = power_supply_get_by_name("battery"); ret = sysfs_create_group(&client->dev.kobj, &bq24297_attr_group); if (ret) { dev_err(&client->dev, "create sysfs error\n"); goto err_create_sysfs; } pinctrl = devm_pinctrl_get_select_default(&client->dev); if (IS_ERR(pinctrl)) { dev_err(&client->dev, "pinctrl error\n"); goto err_pinctrl; } INIT_DELAYED_WORK(&chip->work_status, bq24297_status_func); chip->chg_int_gpio = of_get_named_gpio(np, "bq24297,chg_int", 0); chip->chg_int_irq = gpio_to_irq(chip->chg_int_gpio); //gpio_set_debounce(chip->chg_int_gpio, 1);// TODO ret = request_irq(chip->chg_int_irq, chg_int_func, IRQF_TRIGGER_RISING, "chg_int", NULL); if (ret) { dev_err(&client->dev, "request_irq error\n"); goto err_request_irq; } return 0; err_request_irq: err_pinctrl: sysfs_remove_group(&client->dev.kobj, &bq24297_attr_group); err_create_sysfs: power_supply_unregister(&chip->usb); power_supply_unregister(&chip->ac); err_hw_init: kfree(chip); return ret; }