int mcp_get_pgd(int fd) { unsigned char pgd; mcp_get(fd, MCP_IN, &pgd); return pgd & MCP_PGDI; }
static int __init ucb1x00_init(void) { struct mcp *mcp; unsigned int id; int ret = -ENODEV; mcp = mcp_get(); if (!mcp) goto no_mcp; mcp_enable(mcp); id = mcp_reg_read(mcp, UCB_ID); if (id != UCB_ID_1200 && id != UCB_ID_1300) { printk(KERN_WARNING "UCB1x00 ID not found: %04x\n", id); goto out; } my_ucb = kmalloc(sizeof(struct ucb1x00), GFP_KERNEL); ret = -ENOMEM; if (!my_ucb) goto out; if (machine_is_shannon()) { /* reset the codec */ GPDR |= SHANNON_GPIO_CODEC_RESET; GPCR = SHANNON_GPIO_CODEC_RESET; GPSR = SHANNON_GPIO_CODEC_RESET; } memset(my_ucb, 0, sizeof(struct ucb1x00)); spin_lock_init(&my_ucb->lock); spin_lock_init(&my_ucb->io_lock); sema_init(&my_ucb->adc_sem, 1); my_ucb->id = id; my_ucb->mcp = mcp; ret = ucb1x00_configure(my_ucb); if (ret) goto out; ret = request_irq(my_ucb->irq, ucb1x00_irq, 0, "UCB1x00", my_ucb); if (ret) { printk(KERN_ERR "ucb1x00: unable to grab irq%d: %d\n", my_ucb->irq, ret); kfree(my_ucb); my_ucb = NULL; goto out; } #ifdef CONFIG_PM my_ucb->pmdev = pm_register(PM_SYS_DEV, PM_SYS_UNKNOWN, ucb1x00_pm); if (my_ucb->pmdev == NULL) printk("ucb1x00: unable to register in PM.\n"); else my_ucb->pmdev->data = my_ucb; #endif out: mcp_disable(mcp); no_mcp: return ret; }