Path: blob/master/arch/mips/ath79/dev-gpio-buttons.c
10817 views
/*1* Atheros AR71XX/AR724X/AR913X GPIO button support2*3* Copyright (C) 2008-2010 Gabor Juhos <[email protected]>4* Copyright (C) 2008 Imre Kaloz <[email protected]>5*6* This program is free software; you can redistribute it and/or modify it7* under the terms of the GNU General Public License version 2 as published8* by the Free Software Foundation.9*/1011#include "linux/init.h"12#include "linux/slab.h"13#include <linux/platform_device.h>1415#include "dev-gpio-buttons.h"1617void __init ath79_register_gpio_keys_polled(int id,18unsigned poll_interval,19unsigned nbuttons,20struct gpio_keys_button *buttons)21{22struct platform_device *pdev;23struct gpio_keys_platform_data pdata;24struct gpio_keys_button *p;25int err;2627p = kmalloc(nbuttons * sizeof(*p), GFP_KERNEL);28if (!p)29return;3031memcpy(p, buttons, nbuttons * sizeof(*p));3233pdev = platform_device_alloc("gpio-keys-polled", id);34if (!pdev)35goto err_free_buttons;3637memset(&pdata, 0, sizeof(pdata));38pdata.poll_interval = poll_interval;39pdata.nbuttons = nbuttons;40pdata.buttons = p;4142err = platform_device_add_data(pdev, &pdata, sizeof(pdata));43if (err)44goto err_put_pdev;4546err = platform_device_add(pdev);47if (err)48goto err_put_pdev;4950return;5152err_put_pdev:53platform_device_put(pdev);5455err_free_buttons:56kfree(p);57}585960