for (ev = 0; ev < n_events; ev++) { if (events[ev] < kpad->info->key_ev_min ||
events[ev] > kpad->info->key_ev_max) continue;
/* * if the event is to be generated by the keymap, we need to make * sure that the pins are part of it!
*/
row = (events[ev] - 1) / kpad->info->max_cols;
col = (events[ev] - 1) % kpad->info->max_cols;
if (test_bit(row, &kpad->keypad) &&
test_bit(col + kpad->info->max_rows, &kpad->keypad)) continue;
return dev_err_probe(kpad->dev, -EINVAL, "Invalid unlock/reset event(%u) not used in the keypad\n",
events[ev]);
}
return 0;
}
staticint adp5585_keys_check_special_events(conststruct adp5585_dev *adp5585, conststruct adp5585_kpad *kpad)
{ int error;
error = adp5585_keys_validate_events(kpad, adp5585->unlock_keys,
adp5585->nkeys_unlock); if (error) return error;
error = adp5585_keys_validate_events(kpad, adp5585->reset1_keys,
adp5585->nkeys_reset1); if (error) return error;
/* * We do not check for errors (or no value) since the input device is * only added if this property is present in the first place.
*/
n_pins = device_property_count_u32(dev, "adi,keypad-pins"); if (n_pins > adp5585->n_pins) return dev_err_probe(dev, -EINVAL, "Too many keypad pins (%d) defined (max=%d)\n",
n_pins, adp5585->n_pins);
error = device_property_read_u32_array(dev, "adi,keypad-pins",
keypad_pins, n_pins); if (error) return error;
/* * We can add the action here since it makes the code easier and nothing * "bad" will happen out of it. Worst case, it will be a no-op and no * bit will set.
*/
error = devm_add_action_or_reset(dev, adp5585_keys_pins_free, kpad); if (error) return error;
/* * Note that given that we get a mask (and the HW allows it), we * can have holes in our keypad (eg: row0, row1 and row7 enabled). * However, for the matrix parsing functions we need to pass the * number of rows/cols as the maximum row/col used plus 1. This * pretty much means we will also have holes in our SW keypad.
*/
rows = find_last_bit(&kpad->keypad, kpad->info->max_rows) + 1; if (rows == kpad->info->max_rows + 1) return dev_err_probe(dev, -EINVAL, "Now rows defined in the keypad!\n");
cols = find_last_bit(&kpad->keypad, kpad->info->max_cols + kpad->info->max_rows); if (cols < kpad->info->max_rows) return dev_err_probe(dev, -EINVAL, "No columns defined in the keypad!\n");
/* * Take care as the below assumes max_rows is always less or equal than * 8 which is true for the supported devices. If we happen to add * another device we need to make sure this still holds true. Although * adding a new device is very unlikely.
*/ do {
keys_bits = bitmap_read(&kpad->keypad, start, nbits); if (keys_bits) {
error = regmap_write(adp5585->regmap, regs->pin_cfg_a + i,
keys_bits); if (error) return error;
}
/* make sure the event is for us */ if (key < kpad->info->key_ev_min || key > kpad->info->key_ev_max) return NOTIFY_DONE;
/* * Unlikely but lets be on the safe side! We do not return any error * because the event was indeed for us but with some weird value. So, * we still want the caller know that the right handler was called.
*/ if (!key) return NOTIFY_BAD;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.