本文整理汇总了C++中device_set_wakeup_capable函数的典型用法代码示例。如果您正苦于以下问题:C++ device_set_wakeup_capable函数的具体用法?C++ device_set_wakeup_capable怎么用?C++ device_set_wakeup_capable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了device_set_wakeup_capable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ambarella_init_filbert
/* ==========================================================================*/
static void __init ambarella_init_filbert(void)
{
int i;
ambarella_init_machine("Filbert");
platform_add_devices(ambarella_devices, ARRAY_SIZE(ambarella_devices));
for (i = 0; i < ARRAY_SIZE(ambarella_devices); i++) {
device_set_wakeup_capable(&ambarella_devices[i]->dev, 1);
device_set_wakeup_enable(&ambarella_devices[i]->dev, 0);
}
/* Config Eth0*/
ambarella_eth0_platform_info.mii_reset.gpio_id = GPIO(124);
ambarella_eth0_platform_info.mii_reset.active_level = GPIO_LOW;
ambarella_eth0_platform_info.mii_reset.active_delay = 20;
/* Config Eth1*/
ambarella_eth1_platform_info.mii_reset.gpio_id = GPIO(125);
ambarella_eth1_platform_info.mii_reset.active_level = GPIO_LOW;
ambarella_eth1_platform_info.mii_reset.active_delay = 20;
/* Config SD*/
fio_default_owner = SELECT_FIO_SDIO;
ambarella_platform_sd_controller0.clk_limit = 48000000;
ambarella_platform_sd_controller0.slot[0].cd_delay = HZ;
ambarella_platform_sd_controller0.slot[0].use_bounce_buffer = 1;
ambarella_platform_sd_controller0.slot[0].max_blk_sz = SD_BLK_SZ_128KB;
ambarella_platform_sd_controller0.slot[1].cd_delay = HZ;
ambarella_platform_sd_controller0.slot[1].gpio_cd.irq_gpio = GPIO(75);
ambarella_platform_sd_controller0.slot[1].gpio_cd.irq_line = gpio_to_irq(75);
ambarella_platform_sd_controller0.slot[1].gpio_cd.irq_type = IRQ_TYPE_EDGE_BOTH;
ambarella_platform_sd_controller0.slot[1].gpio_wp.gpio_id = GPIO(76);
}
示例2: zynq_gpio_remove
/**
* zynq_gpio_remove - Driver removal function
* @pdev: platform device instance
*
* Return: 0 always
*/
static int zynq_gpio_remove(struct platform_device *pdev)
{
struct zynq_gpio *gpio = platform_get_drvdata(pdev);
clk_disable_unprepare(gpio->clk);
device_set_wakeup_capable(&pdev->dev, 0);
return 0;
}
示例3: hym8563_probe
static int hym8563_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct hym8563 *hym8563;
int ret;
hym8563 = devm_kzalloc(&client->dev, sizeof(*hym8563), GFP_KERNEL);
if (!hym8563)
return -ENOMEM;
hym8563->client = client;
i2c_set_clientdata(client, hym8563);
device_set_wakeup_capable(&client->dev, true);
ret = hym8563_init_device(client);
if (ret) {
dev_err(&client->dev, "could not init device, %d\n", ret);
return ret;
}
ret = devm_request_threaded_irq(&client->dev, client->irq,
NULL, hym8563_irq,
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
client->name, hym8563);
if (ret < 0) {
dev_err(&client->dev, "irq %d request failed, %d\n",
client->irq, ret);
return ret;
}
/* check state of calendar information */
ret = i2c_smbus_read_byte_data(client, HYM8563_SEC);
if (ret < 0)
return ret;
hym8563->valid = !(ret & HYM8563_SEC_VL);
dev_dbg(&client->dev, "rtc information is %s\n",
hym8563->valid ? "valid" : "invalid");
hym8563->rtc = devm_rtc_device_register(&client->dev, client->name,
&hym8563_rtc_ops, THIS_MODULE);
if (IS_ERR(hym8563->rtc))
return PTR_ERR(hym8563->rtc);
/* the hym8563 alarm only supports a minute accuracy */
hym8563->rtc->uie_unsupported = 1;
#ifdef CONFIG_COMMON_CLK
hym8563_clkout_register_clk(hym8563);
#endif
return 0;
}
示例4: tegra_pd_add_device
void tegra_pd_add_device(struct device *dev)
{
struct generic_pm_domain *master = tegra_pd_get_domain(dev_name(dev));
if (!master)
return;
device_set_wakeup_capable(dev, 1);
pm_genpd_add_device(master, dev);
pm_genpd_dev_need_save(dev, false);
pm_genpd_add_callbacks(dev, &tegra_pd_ops, NULL);
}
示例5: ds1374_probe
static int ds1374_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct ds1374 *ds1374;
int ret;
ds1374 = kzalloc(sizeof(struct ds1374), GFP_KERNEL);
if (!ds1374)
return -ENOMEM;
ds1374->client = client;
i2c_set_clientdata(client, ds1374);
INIT_WORK(&ds1374->work, ds1374_work);
mutex_init(&ds1374->mutex);
ret = ds1374_check_rtc_status(client);
if (ret)
goto out_free;
if (client->irq > 0) {
ret = request_irq(client->irq, ds1374_irq, 0,
"ds1374", client);
if (ret) {
dev_err(&client->dev, "unable to request IRQ\n");
goto out_free;
}
device_set_wakeup_capable(&client->dev, 1);
}
ds1374->rtc = rtc_device_register(client->name, &client->dev,
&ds1374_rtc_ops, THIS_MODULE);
if (IS_ERR(ds1374->rtc)) {
ret = PTR_ERR(ds1374->rtc);
dev_err(&client->dev, "unable to register the class device\n");
goto out_irq;
}
return 0;
out_irq:
if (client->irq > 0)
free_irq(client->irq, client);
out_free:
i2c_set_clientdata(client, NULL);
kfree(ds1374);
return ret;
}
示例6: hsic_remoteWakeup_store
static ssize_t hsic_remoteWakeup_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
int retval;
int org_req;
if (size > HSIC_ENABLE_SIZE) {
dev_dbg(dev, "Invalid, size = %d\n", size);
return -EINVAL;
}
if (sscanf(buf, "%d", &org_req) != 1) {
dev_dbg(dev, "Invalid, value\n");
return -EINVAL;
}
mutex_lock(&hsic.hsic_mutex);
hsic.remoteWakeup_enable = org_req;
if ((hsic.modem_dev != NULL) &&
(hsic.rh_dev != NULL)) {
if (hsic.remoteWakeup_enable) {
dev_dbg(dev, "Modem dev remote wakeup enabled\n");
device_set_wakeup_capable(&hsic.modem_dev->dev, 1);
device_set_wakeup_capable(&hsic.rh_dev->dev, 1);
} else {
dev_dbg(dev, "Modem dev remote wakeup disabled\n");
device_set_wakeup_capable(&hsic.modem_dev->dev, 0);
device_set_wakeup_capable(&hsic.rh_dev->dev, 0);
}
pm_runtime_get_sync(&hsic.modem_dev->dev);
pm_runtime_put_sync(&hsic.modem_dev->dev);
}
mutex_unlock(&hsic.hsic_mutex);
return size;
}
示例7: ds3232_probe
static int ds3232_probe(struct device *dev, struct regmap *regmap, int irq,
const char *name)
{
struct ds3232 *ds3232;
int ret;
ds3232 = devm_kzalloc(dev, sizeof(*ds3232), GFP_KERNEL);
if (!ds3232)
return -ENOMEM;
ds3232->regmap = regmap;
ds3232->irq = irq;
ds3232->dev = dev;
dev_set_drvdata(dev, ds3232);
ret = ds3232_check_rtc_status(dev);
if (ret)
return ret;
if (ds3232->irq > 0)
device_init_wakeup(dev, 1);
ds3232_hwmon_register(dev, name);
ds3232->rtc = devm_rtc_device_register(dev, name, &ds3232_rtc_ops,
THIS_MODULE);
if (IS_ERR(ds3232->rtc))
return PTR_ERR(ds3232->rtc);
if (ds3232->irq > 0) {
ret = devm_request_threaded_irq(dev, ds3232->irq, NULL,
ds3232_irq,
IRQF_SHARED | IRQF_ONESHOT,
name, dev);
if (ret) {
device_set_wakeup_capable(dev, 0);
ds3232->irq = 0;
dev_err(dev, "unable to request IRQ\n");
}
}
return 0;
}
示例8: uhci_pci_init
static int uhci_pci_init(struct usb_hcd *hcd)
{
struct uhci_hcd *uhci = hcd_to_uhci(hcd);
uhci->io_addr = (unsigned long) hcd->rsrc_start;
uhci->rh_numports = uhci_count_ports(hcd);
/* Intel controllers report the OverCurrent bit active on.
* VIA controllers report it active off, so we'll adjust the
* bit value. (It's not standardized in the UHCI spec.)
*/
if (to_pci_dev(uhci_dev(uhci))->vendor == PCI_VENDOR_ID_VIA)
uhci->oc_low = 1;
/* HP's server management chip requires a longer port reset delay. */
if (to_pci_dev(uhci_dev(uhci))->vendor == PCI_VENDOR_ID_HP)
uhci->wait_for_hp = 1;
/* Intel controllers use non-PME wakeup signalling */
if (to_pci_dev(uhci_dev(uhci))->vendor == PCI_VENDOR_ID_INTEL)
device_set_wakeup_capable(uhci_dev(uhci), true);
/* Set up pointers to PCI-specific functions */
uhci->reset_hc = uhci_pci_reset_hc;
uhci->check_and_reset_hc = uhci_pci_check_and_reset_hc;
uhci->configure_hc = uhci_pci_configure_hc;
uhci->resume_detect_interrupts_are_broken =
uhci_pci_resume_detect_interrupts_are_broken;
uhci->global_suspend_mode_is_broken =
uhci_pci_global_suspend_mode_is_broken;
/* Kick BIOS off this hardware and reset if the controller
* isn't already safely quiescent.
*/
check_and_reset_hc(uhci);
return 0;
}
示例9: usb_register_remote_wakeup
/*!
* Register remote wakeup by this usb controller
*
* @param pdev: platform_device for this usb controller
*
* @return 0 or negative error code in case not supportted.
*/
static int usb_register_remote_wakeup(struct platform_device *pdev)
{
struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
struct resource *res;
int irq;
pr_debug("%s: pdev=0x%p \n", __func__, pdev);
if (!(pdata->wake_up_enable))
return -ECANCELED;
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(&pdev->dev,
"Found HC with no IRQ. Check %s setup!\n",
dev_name(&pdev->dev));
return -ENODEV;
}
irq = res->start;
device_set_wakeup_capable(&pdev->dev, true);
enable_irq_wake(irq);
return 0;
}
示例10: msm_serial_hsl_remove
static int __devexit msm_serial_hsl_remove(struct platform_device *pdev)
{
struct msm_hsl_port *msm_hsl_port = platform_get_drvdata(pdev);
struct uart_port *port;
D("%s (): ir\n", __func__);
port = get_port_from_line(pdev->id);
#ifdef CONFIG_SERIAL_MSM_HSL_CONSOLE
device_remove_file(&pdev->dev, &dev_attr_console);
#endif
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
device_set_wakeup_capable(&pdev->dev, 0);
platform_set_drvdata(pdev, NULL);
uart_remove_one_port(&msm_hsl_uart_driver, port);
clk_put(msm_hsl_port->pclk);
clk_put(msm_hsl_port->clk);
debugfs_remove(msm_hsl_port->loopback_dir);
return 0;
}
示例11: hsic_notify
/* the root hub will call this callback when device added/removed */
void hsic_notify(struct usb_device *udev, unsigned action)
{
int retval;
struct pci_dev *pdev = to_pci_dev(udev->bus->controller);
printk(KERN_ERR "pdev device ID: %d, portnum: %d",
pdev->device, udev->portnum);
/* Ignore and only valid for HSIC. Filter out
* the USB devices added by other USB2 host driver */
if (pdev->device != USH_PCI_ID)
return;
/* Ignore USB devices on external hub */
if (udev->parent && udev->parent->parent)
return;
switch (action) {
case USB_DEVICE_ADD:
pr_debug("Notify HSIC add device\n");
/* Root hub */
if (!udev->parent) {
if (udev->speed == USB_SPEED_HIGH) {
pr_debug("%s rh device set\n", __func__);
hsic.rh_dev = udev;
pr_debug("%s Disable autosuspend\n", __func__);
pm_runtime_set_autosuspend_delay(&udev->dev,
hsic.bus_inactivityDuration);
usb_disable_autosuspend(udev);
}
} else {
if (udev->portnum != HSIC_USH_PORT) {
pr_debug("%s ignore ush ports except port5\n",
__func__);
pr_debug("%s ush ports %d\n", __func__,
udev->portnum);
break;
}
/* Modem devices */
hsic.modem_dev = udev;
pm_runtime_set_autosuspend_delay
(&udev->dev, hsic.port_inactivityDuration);
if (hsic.remoteWakeup_enable) {
pr_debug("%s Modem dev remote wakeup enabled\n",
__func__);
device_set_wakeup_capable
(&hsic.modem_dev->dev, 1);
device_set_wakeup_capable
(&hsic.rh_dev->dev, 1);
} else {
pr_debug("%s Modem dev remote wakeup disabled\n",
__func__);
device_set_wakeup_capable
(&hsic.modem_dev->dev, 0);
device_set_wakeup_capable
(&hsic.rh_dev->dev, 0);
}
usb_disable_autosuspend(hsic.modem_dev);
usb_disable_autosuspend(hsic.rh_dev);
#if 0
if (hsic.autosuspend_enable) {
pr_debug("%s----> enable autosuspend\n",
__func__);
usb_enable_autosuspend(udev->parent);
hsic_wakeup_irq_init();
}
if (hsic.autosuspend_enable == 0) {
pr_debug("%s Modem dev autosuspend disable\n",
__func__);
usb_disable_autosuspend(hsic.modem_dev);
}
#endif
}
break;
case USB_DEVICE_REMOVE:
pr_debug("Notify HSIC delete device\n");
/* Root hub */
if (udev->speed != USB_SPEED_HIGH) {
pr_debug("%s ignore ss port\n", __func__);
break;
}
if (!udev->parent) {
pr_debug("%s rh_dev deleted\n", __func__);
hsic.rh_dev = NULL;
} else {
/* Modem devices */
pr_debug("%s----> modem dev deleted\n", __func__);
hsic.modem_dev = NULL;
usb_disable_autosuspend(hsic.rh_dev);
}
break;
case MODEM_WORK_FLUSH:
if (udev == hsic.modem_dev) {
pr_debug("Notify MODEM work flush\n");
synchronize_irq(gpio_to_irq(hsic.aux_gpio));
flush_work(&hsic.hsic_aux);
//.........这里部分代码省略.........
示例12: ds1305_probe
//.........这里部分代码省略.........
/* maybe enable trickle charge */
if (((ds1305->ctrl[2] & 0xf0) != DS1305_TRICKLE_MAGIC)) {
ds1305->ctrl[2] = DS1305_TRICKLE_MAGIC
| pdata->trickle;
write_ctrl = true;
}
/* on DS1306, configure 1 Hz signal */
if (pdata->is_ds1306) {
if (pdata->en_1hz) {
if (!(ds1305->ctrl[0] & DS1306_1HZ)) {
ds1305->ctrl[0] |= DS1306_1HZ;
write_ctrl = true;
}
} else {
if (ds1305->ctrl[0] & DS1306_1HZ) {
ds1305->ctrl[0] &= ~DS1306_1HZ;
write_ctrl = true;
}
}
}
}
if (write_ctrl) {
u8 buf[4];
buf[0] = DS1305_WRITE | DS1305_CONTROL;
buf[1] = ds1305->ctrl[0];
buf[2] = ds1305->ctrl[1];
buf[3] = ds1305->ctrl[2];
status = spi_write_then_read(spi, buf, sizeof buf, NULL, 0);
if (status < 0) {
dev_dbg(&spi->dev, "can't %s, %d\n",
"write", status);
goto fail0;
}
dev_dbg(&spi->dev, "ctrl %s: %02x %02x %02x\n",
"write", ds1305->ctrl[0],
ds1305->ctrl[1], ds1305->ctrl[2]);
}
/* see if non-Linux software set up AM/PM mode */
addr = DS1305_HOUR;
status = spi_write_then_read(spi, &addr, sizeof addr,
&value, sizeof value);
if (status < 0) {
dev_dbg(&spi->dev, "read HOUR --> %d\n", status);
goto fail0;
}
ds1305->hr12 = (DS1305_HR_12 & value) != 0;
if (ds1305->hr12)
dev_dbg(&spi->dev, "AM/PM\n");
/* register RTC ... from here on, ds1305->ctrl needs locking */
ds1305->rtc = rtc_device_register("ds1305", &spi->dev,
&ds1305_ops, THIS_MODULE);
if (IS_ERR(ds1305->rtc)) {
status = PTR_ERR(ds1305->rtc);
dev_dbg(&spi->dev, "register rtc --> %d\n", status);
goto fail0;
}
/* Maybe set up alarm IRQ; be ready to handle it triggering right
* away. NOTE that we don't share this. The signal is active low,
* and we can't ack it before a SPI message delay. We temporarily
* disable the IRQ until it's acked, which lets us work with more
* IRQ trigger modes (not all IRQ controllers can do falling edge).
*/
if (spi->irq) {
INIT_WORK(&ds1305->work, ds1305_work);
status = request_irq(spi->irq, ds1305_irq,
0, dev_name(&ds1305->rtc->dev), ds1305);
if (status < 0) {
dev_dbg(&spi->dev, "request_irq %d --> %d\n",
spi->irq, status);
goto fail1;
}
device_set_wakeup_capable(&spi->dev, 1);
}
/* export NVRAM */
status = sysfs_create_bin_file(&spi->dev.kobj, &nvram);
if (status < 0) {
dev_dbg(&spi->dev, "register nvram --> %d\n", status);
goto fail2;
}
return 0;
fail2:
free_irq(spi->irq, ds1305);
fail1:
rtc_device_unregister(ds1305->rtc);
fail0:
kfree(ds1305);
return status;
}
示例13: ehci_pci_setup
//.........这里部分代码省略.........
"dummy qh workaround\n");
}
/* data structure init */
retval = ehci_init(hcd);
if (retval)
return retval;
switch (pdev->vendor) {
case PCI_VENDOR_ID_NEC:
ehci->need_io_watchdog = 0;
break;
case PCI_VENDOR_ID_INTEL:
ehci->need_io_watchdog = 0;
ehci->fs_i_thresh = 1;
if (pdev->device == 0x27cc) {
ehci->broken_periodic = 1;
ehci_info(ehci, "using broken periodic workaround\n");
}
if (pdev->device == 0x0806 || pdev->device == 0x0811
|| pdev->device == 0x0829) {
ehci_info(ehci, "disable lpm for langwell/penwell\n");
ehci->has_lpm = 0;
}
if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB) {
hcd->has_tt = 1;
tdi_reset(ehci);
}
if (pdev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK) {
/* EHCI #1 or #2 on 6 Series/C200 Series chipset */
if (pdev->device == 0x1c26 || pdev->device == 0x1c2d) {
ehci_info(ehci, "broken D3 during system sleep on ASUS\n");
hcd->broken_pci_sleep = 1;
device_set_wakeup_capable(&pdev->dev, false);
}
}
break;
case PCI_VENDOR_ID_TDI:
if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) {
hcd->has_tt = 1;
tdi_reset(ehci);
}
break;
case PCI_VENDOR_ID_AMD:
/* AMD PLL quirk */
if (usb_amd_find_chipset_info())
ehci->amd_pll_fix = 1;
/* AMD8111 EHCI doesn't work, according to AMD errata */
if (pdev->device == 0x7463) {
ehci_info(ehci, "ignoring AMD8111 (errata)\n");
retval = -EIO;
goto done;
}
break;
case PCI_VENDOR_ID_NVIDIA:
switch (pdev->device) {
/* Some NForce2 chips have problems with selective suspend;
* fixed in newer silicon.
*/
case 0x0068:
if (pdev->revision < 0xa4)
ehci->no_selective_suspend = 1;
break;
/* MCP89 chips on the MacBookAir3,1 give EPROTO when
* fetching device descriptors unless LPM is disabled.
示例14: msm_serial_hsl_probe
static int __init msm_serial_hsl_probe(struct platform_device *pdev)
{
struct msm_hsl_port *msm_hsl_port;
struct resource *uart_resource;
struct resource *gsbi_resource;
struct uart_port *port;
struct msm_serial_hslite_platform_data *pdata = pdev->dev.platform_data;
int ret;
if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
return -ENXIO;
printk(KERN_INFO "msm_serial_hsl: detected port #%d\n", pdev->id);
port = get_port_from_line(pdev->id);
port->dev = &pdev->dev;
msm_hsl_port = UART_TO_MSM(port);
if (pdata && pdata->config_gpio) {
ret = gpio_request(pdata->uart_tx_gpio, "UART_TX_GPIO");
if (unlikely(ret)) {
printk(KERN_ERR "%s: gpio request failed for:"
"%d\n", __func__, pdata->uart_tx_gpio);
return ret;
}
ret = gpio_request(pdata->uart_rx_gpio, "UART_RX_GPIO");
if (unlikely(ret)) {
printk(KERN_ERR "%s: gpio request failed for:"
"%d\n", __func__, pdata->uart_rx_gpio);
gpio_free(pdata->uart_tx_gpio);
return ret;
}
}
if (msm_serial_hsl_has_gsbi()) {
gsbi_resource =
platform_get_resource_byname(pdev,
IORESOURCE_MEM,
"gsbi_resource");
if (unlikely(!gsbi_resource))
return -ENXIO;
msm_hsl_port->clk = clk_get(&pdev->dev, "gsbi_uart_clk");
msm_hsl_port->pclk = clk_get(&pdev->dev, "gsbi_pclk");
} else {
msm_hsl_port->clk = clk_get(&pdev->dev, "uartdm_clk");
msm_hsl_port->pclk = NULL;
}
if (unlikely(IS_ERR(msm_hsl_port->clk))) {
printk(KERN_ERR "%s: Error getting clk\n", __func__);
return PTR_ERR(msm_hsl_port->clk);
}
if (unlikely(IS_ERR(msm_hsl_port->pclk))) {
printk(KERN_ERR "%s: Error getting pclk\n", __func__);
return PTR_ERR(msm_hsl_port->pclk);
}
/* Set up the MREG/NREG/DREG/MNDREG */
ret = clk_set_rate(msm_hsl_port->clk, 7372800);
if (ret) {
printk(KERN_WARNING "Error setting clock rate on UART\n");
return ret;
}
uart_resource = platform_get_resource_byname(pdev,
IORESOURCE_MEM,
"uartdm_resource");
if (unlikely(!uart_resource)) {
printk(KERN_ERR "getting uartdm_resource failed\n");
return -ENXIO;
}
port->mapbase = uart_resource->start;
port->irq = platform_get_irq(pdev, 0);
if (unlikely(port->irq < 0)) {
printk(KERN_ERR "%s: getting irq failed\n", __func__);
return -ENXIO;
}
device_set_wakeup_capable(&pdev->dev, 1);
platform_set_drvdata(pdev, port);
pm_runtime_enable(port->dev);
ret = uart_add_one_port(&msm_hsl_uart_driver, port);
return ret;
}
示例15: tc3589x_keypad_probe
static int tc3589x_keypad_probe(struct platform_device *pdev)
{
struct tc3589x *tc3589x = dev_get_drvdata(pdev->dev.parent);
struct tc_keypad *keypad;
struct input_dev *input;
const struct tc3589x_keypad_platform_data *plat;
int error, irq;
plat = tc3589x->pdata->keypad;
if (!plat) {
dev_err(&pdev->dev, "invalid keypad platform data\n");
return -EINVAL;
}
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
keypad = kzalloc(sizeof(struct tc_keypad), GFP_KERNEL);
input = input_allocate_device();
if (!keypad || !input) {
dev_err(&pdev->dev, "failed to allocate keypad memory\n");
error = -ENOMEM;
goto err_free_mem;
}
keypad->board = plat;
keypad->input = input;
keypad->tc3589x = tc3589x;
input->id.bustype = BUS_I2C;
input->name = pdev->name;
input->dev.parent = &pdev->dev;
input->open = tc3589x_keypad_open;
input->close = tc3589x_keypad_close;
error = matrix_keypad_build_keymap(plat->keymap_data, NULL,
TC3589x_MAX_KPROW, TC3589x_MAX_KPCOL,
NULL, input);
if (error) {
dev_err(&pdev->dev, "Failed to build keymap\n");
goto err_free_mem;
}
keypad->keymap = input->keycode;
input_set_capability(input, EV_MSC, MSC_SCAN);
if (!plat->no_autorepeat)
__set_bit(EV_REP, input->evbit);
input_set_drvdata(input, keypad);
error = request_threaded_irq(irq, NULL,
tc3589x_keypad_irq, plat->irqtype,
"tc3589x-keypad", keypad);
if (error < 0) {
dev_err(&pdev->dev,
"Could not allocate irq %d,error %d\n",
irq, error);
goto err_free_mem;
}
error = input_register_device(input);
if (error) {
dev_err(&pdev->dev, "Could not register input device\n");
goto err_free_irq;
}
/* let platform decide if keypad is a wakeup source or not */
device_init_wakeup(&pdev->dev, plat->enable_wakeup);
device_set_wakeup_capable(&pdev->dev, plat->enable_wakeup);
platform_set_drvdata(pdev, keypad);
return 0;
err_free_irq:
free_irq(irq, keypad);
err_free_mem:
input_free_device(input);
kfree(keypad);
return error;
}