#define MAX_KEYPAD_KEYS (MAX_MATRIX_KEY_NUM + MAX_DIRECT_KEY_NUM)
struct pxa27x_keypad {
- struct pxa27x_keypad_platform_data *pdata;
+ const struct pxa27x_keypad_platform_data *pdata;
struct clk *clk;
struct input_dev *input_dev;
};
#ifdef CONFIG_OF
-static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad)
+static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad,
+ struct pxa27x_keypad_platform_data *pdata)
{
struct input_dev *input_dev = keypad->input_dev;
struct device *dev = input_dev->dev.parent;
- struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
u32 rows, cols;
int error;
return 0;
}
-static int pxa27x_keypad_direct_key_parse_dt(struct pxa27x_keypad *keypad)
+static int pxa27x_keypad_direct_key_parse_dt(struct pxa27x_keypad *keypad,
+ struct pxa27x_keypad_platform_data *pdata)
{
struct input_dev *input_dev = keypad->input_dev;
struct device *dev = input_dev->dev.parent;
- struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
struct device_node *np = dev->of_node;
const __be16 *prop;
unsigned short code;
return 0;
}
-static int pxa27x_keypad_rotary_parse_dt(struct pxa27x_keypad *keypad)
+static int pxa27x_keypad_rotary_parse_dt(struct pxa27x_keypad *keypad,
+ struct pxa27x_keypad_platform_data *pdata)
{
const __be32 *prop;
int i, relkey_ret;
const char relkeyname[] = {"marvell,rotary-rel-key"};
struct input_dev *input_dev = keypad->input_dev;
struct device *dev = input_dev->dev.parent;
- struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
struct device_node *np = dev->of_node;
relkey_ret = of_property_read_u32(np, relkeyname, &code);
struct input_dev *input_dev = keypad->input_dev;
struct device *dev = input_dev->dev.parent;
struct device_node *np = dev->of_node;
+ struct pxa27x_keypad_platform_data *pdata;
int error;
- keypad->pdata = devm_kzalloc(dev, sizeof(*keypad->pdata),
- GFP_KERNEL);
- if (!keypad->pdata) {
+ pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+ if (!pdata) {
dev_err(dev, "failed to allocate memory for pdata\n");
return -ENOMEM;
}
- error = pxa27x_keypad_matrix_key_parse_dt(keypad);
+ error = pxa27x_keypad_matrix_key_parse_dt(keypad, pdata);
if (error) {
dev_err(dev, "failed to parse matrix key\n");
return error;
}
- error = pxa27x_keypad_direct_key_parse_dt(keypad);
+ error = pxa27x_keypad_direct_key_parse_dt(keypad, pdata);
if (error) {
dev_err(dev, "failed to parse direct key\n");
return error;
}
- error = pxa27x_keypad_rotary_parse_dt(keypad);
+ error = pxa27x_keypad_rotary_parse_dt(keypad, pdata);
if (error) {
dev_err(dev, "failed to parse rotary key\n");
return error;
}
error = of_property_read_u32(np, "marvell,debounce-interval",
- &keypad->pdata->debounce_interval);
+ &pdata->debounce_interval);
if (error) {
dev_err(dev, "failed to parse debpunce-interval\n");
return error;
*/
input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
+ keypad->pdata = pdata;
return 0;
}
static int pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
{
- struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
+ const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
struct input_dev *input_dev = keypad->input_dev;
const struct matrix_keymap_data *keymap_data =
pdata ? pdata->matrix_keymap_data : NULL;
static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad)
{
- struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
+ const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
struct input_dev *input_dev = keypad->input_dev;
int row, col, num_keys_pressed = 0;
uint32_t new_state[MAX_MATRIX_KEY_COLS];
static void pxa27x_keypad_scan_rotary(struct pxa27x_keypad *keypad)
{
- struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
+ const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
uint32_t kprec;
/* read and reset to default count value */
static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad)
{
- struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
+ const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
struct input_dev *input_dev = keypad->input_dev;
unsigned int new_state;
uint32_t kpdk, bits_changed;
static void clear_wakeup_event(struct pxa27x_keypad *keypad)
{
- struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
+ const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
if (pdata->clear_wakeup_event)
(pdata->clear_wakeup_event)();
static void pxa27x_keypad_config(struct pxa27x_keypad *keypad)
{
- struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
+ const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
unsigned int mask = 0, direct_key_num = 0;
unsigned long kpc = 0;
static int pxa27x_keypad_probe(struct platform_device *pdev)
{
- struct pxa27x_keypad_platform_data *pdata = pdev->dev.platform_data;
+ const struct pxa27x_keypad_platform_data *pdata =
+ dev_get_platdata(&pdev->dev);
struct device_node *np = pdev->dev.of_node;
struct pxa27x_keypad *keypad;
struct input_dev *input_dev;
goto failed_put_clk;
}
- /* If device tree is supported, pdata will be allocated. */
- pdata = keypad->pdata;
-
if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) ||
(pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) {
input_dev->evbit[0] |= BIT_MASK(EV_REL);