pxa27x_keypad.c (1d05726c315c146b2ac0c5e94f01fde0c2b73dc1) | pxa27x_keypad.c (38c3807252085f97e1359400c8bf1312da3168c6) |
---|---|
1/* 2 * linux/drivers/input/keyboard/pxa27x_keypad.c 3 * 4 * Driver for the pxa27x matrix keyboard controller. 5 * 6 * Created: Feb 22, 2007 7 * Author: Rodolfo Giometti <giometti@linux.it> 8 * --- 727 unchanged lines hidden (view full) --- 736 } 737 738 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 739 if (res == NULL) { 740 dev_err(&pdev->dev, "failed to get I/O memory\n"); 741 return -ENXIO; 742 } 743 | 1/* 2 * linux/drivers/input/keyboard/pxa27x_keypad.c 3 * 4 * Driver for the pxa27x matrix keyboard controller. 5 * 6 * Created: Feb 22, 2007 7 * Author: Rodolfo Giometti <giometti@linux.it> 8 * --- 727 unchanged lines hidden (view full) --- 736 } 737 738 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 739 if (res == NULL) { 740 dev_err(&pdev->dev, "failed to get I/O memory\n"); 741 return -ENXIO; 742 } 743 |
744 keypad = kzalloc(sizeof(struct pxa27x_keypad), GFP_KERNEL); 745 input_dev = input_allocate_device(); 746 if (!keypad || !input_dev) { 747 dev_err(&pdev->dev, "failed to allocate memory\n"); 748 error = -ENOMEM; 749 goto failed_free; 750 } | 744 keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad), 745 GFP_KERNEL); 746 if (!keypad) 747 return -ENOMEM; |
751 | 748 |
749 input_dev = devm_input_allocate_device(&pdev->dev); 750 if (!input_dev) 751 return -ENOMEM; 752 |
|
752 keypad->pdata = pdata; 753 keypad->input_dev = input_dev; 754 keypad->irq = irq; 755 | 753 keypad->pdata = pdata; 754 keypad->input_dev = input_dev; 755 keypad->irq = irq; 756 |
756 res = request_mem_region(res->start, resource_size(res), pdev->name); 757 if (res == NULL) { 758 dev_err(&pdev->dev, "failed to request I/O memory\n"); 759 error = -EBUSY; 760 goto failed_free; 761 } | 757 keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res); 758 if (IS_ERR(keypad->mmio_base)) 759 return PTR_ERR(keypad->mmio_base); |
762 | 760 |
763 keypad->mmio_base = ioremap(res->start, resource_size(res)); 764 if (keypad->mmio_base == NULL) { 765 dev_err(&pdev->dev, "failed to remap I/O memory\n"); 766 error = -ENXIO; 767 goto failed_free_mem; 768 } 769 770 keypad->clk = clk_get(&pdev->dev, NULL); | 761 keypad->clk = devm_clk_get(&pdev->dev, NULL); |
771 if (IS_ERR(keypad->clk)) { 772 dev_err(&pdev->dev, "failed to get keypad clock\n"); | 762 if (IS_ERR(keypad->clk)) { 763 dev_err(&pdev->dev, "failed to get keypad clock\n"); |
773 error = PTR_ERR(keypad->clk); 774 goto failed_free_io; | 764 return PTR_ERR(keypad->clk); |
775 } 776 777 input_dev->name = pdev->name; 778 input_dev->id.bustype = BUS_HOST; 779 input_dev->open = pxa27x_keypad_open; 780 input_dev->close = pxa27x_keypad_close; 781 input_dev->dev.parent = &pdev->dev; 782 --- 14 unchanged lines hidden (view full) --- 797 * Data that we get from DT resides in dynamically 798 * allocated memory so we need to update our pdata 799 * pointer. 800 */ 801 pdata = keypad->pdata; 802 } 803 if (error) { 804 dev_err(&pdev->dev, "failed to build keycode\n"); | 765 } 766 767 input_dev->name = pdev->name; 768 input_dev->id.bustype = BUS_HOST; 769 input_dev->open = pxa27x_keypad_open; 770 input_dev->close = pxa27x_keypad_close; 771 input_dev->dev.parent = &pdev->dev; 772 --- 14 unchanged lines hidden (view full) --- 787 * Data that we get from DT resides in dynamically 788 * allocated memory so we need to update our pdata 789 * pointer. 790 */ 791 pdata = keypad->pdata; 792 } 793 if (error) { 794 dev_err(&pdev->dev, "failed to build keycode\n"); |
805 goto failed_put_clk; | 795 return error; |
806 } 807 808 keypad->row_shift = get_count_order(pdata->matrix_key_cols); 809 810 if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) || 811 (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) { 812 input_dev->evbit[0] |= BIT_MASK(EV_REL); 813 } 814 | 796 } 797 798 keypad->row_shift = get_count_order(pdata->matrix_key_cols); 799 800 if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) || 801 (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) { 802 input_dev->evbit[0] |= BIT_MASK(EV_REL); 803 } 804 |
815 error = request_irq(irq, pxa27x_keypad_irq_handler, 0, 816 pdev->name, keypad); | 805 error = devm_request_irq(&pdev->dev, irq, pxa27x_keypad_irq_handler, 806 0, pdev->name, keypad); |
817 if (error) { 818 dev_err(&pdev->dev, "failed to request IRQ\n"); | 807 if (error) { 808 dev_err(&pdev->dev, "failed to request IRQ\n"); |
819 goto failed_put_clk; | 809 return error; |
820 } 821 822 /* Register the input device */ 823 error = input_register_device(input_dev); 824 if (error) { 825 dev_err(&pdev->dev, "failed to register input device\n"); | 810 } 811 812 /* Register the input device */ 813 error = input_register_device(input_dev); 814 if (error) { 815 dev_err(&pdev->dev, "failed to register input device\n"); |
826 goto failed_free_irq; | 816 return error; |
827 } 828 829 platform_set_drvdata(pdev, keypad); 830 device_init_wakeup(&pdev->dev, 1); 831 832 return 0; | 817 } 818 819 platform_set_drvdata(pdev, keypad); 820 device_init_wakeup(&pdev->dev, 1); 821 822 return 0; |
833 834failed_free_irq: 835 free_irq(irq, keypad); 836failed_put_clk: 837 clk_put(keypad->clk); 838failed_free_io: 839 iounmap(keypad->mmio_base); 840failed_free_mem: 841 release_mem_region(res->start, resource_size(res)); 842failed_free: 843 input_free_device(input_dev); 844 kfree(keypad); 845 return error; | |
846} 847 | 823} 824 |
848static int pxa27x_keypad_remove(struct platform_device *pdev) 849{ 850 struct pxa27x_keypad *keypad = platform_get_drvdata(pdev); 851 struct resource *res; 852 853 free_irq(keypad->irq, keypad); 854 clk_put(keypad->clk); 855 856 input_unregister_device(keypad->input_dev); 857 iounmap(keypad->mmio_base); 858 859 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 860 release_mem_region(res->start, resource_size(res)); 861 862 kfree(keypad); 863 864 return 0; 865} 866 867/* work with hotplug and coldplug */ 868MODULE_ALIAS("platform:pxa27x-keypad"); 869 | |
870#ifdef CONFIG_OF 871static const struct of_device_id pxa27x_keypad_dt_match[] = { 872 { .compatible = "marvell,pxa27x-keypad" }, 873 {}, 874}; 875MODULE_DEVICE_TABLE(of, pxa27x_keypad_dt_match); 876#endif 877 878static struct platform_driver pxa27x_keypad_driver = { 879 .probe = pxa27x_keypad_probe, | 825#ifdef CONFIG_OF 826static const struct of_device_id pxa27x_keypad_dt_match[] = { 827 { .compatible = "marvell,pxa27x-keypad" }, 828 {}, 829}; 830MODULE_DEVICE_TABLE(of, pxa27x_keypad_dt_match); 831#endif 832 833static struct platform_driver pxa27x_keypad_driver = { 834 .probe = pxa27x_keypad_probe, |
880 .remove = pxa27x_keypad_remove, | |
881 .driver = { 882 .name = "pxa27x-keypad", 883 .of_match_table = of_match_ptr(pxa27x_keypad_dt_match), | 835 .driver = { 836 .name = "pxa27x-keypad", 837 .of_match_table = of_match_ptr(pxa27x_keypad_dt_match), |
838 .owner = THIS_MODULE, |
|
884 .pm = &pxa27x_keypad_pm_ops, 885 }, 886}; 887module_platform_driver(pxa27x_keypad_driver); 888 889MODULE_DESCRIPTION("PXA27x Keypad Controller Driver"); 890MODULE_LICENSE("GPL"); | 839 .pm = &pxa27x_keypad_pm_ops, 840 }, 841}; 842module_platform_driver(pxa27x_keypad_driver); 843 844MODULE_DESCRIPTION("PXA27x Keypad Controller Driver"); 845MODULE_LICENSE("GPL"); |
846/* work with hotplug and coldplug */ 847MODULE_ALIAS("platform:pxa27x-keypad"); |
|