Re: [PATCH 2/2] Input: Add driver for a generic ADC keypad

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 28, 2015 at 7:02 AM, Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
> On 28/03/15 00:43, Andrew Bresticker wrote:
>> Add a polled input driver for a keypad in which the buttons are connected
>> in resistor ladders to an ADC.  The IIO framework is used to claim and
>> read the ADC channels.
>>
>> Signed-off-by: Andrew Bresticker <abrestic@xxxxxxxxxxxx>

>> +static int adc_keypad_probe(struct platform_device *pdev)
>> +{
>> +     struct adc_keypad *keypad;
>> +     struct input_polled_dev *poll_dev;
>> +     struct input_dev *input;
>> +     unsigned int i;
>> +     int ret;
>> +
>> +     keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad), GFP_KERNEL);
>> +     if (!keypad)
>> +             return -ENOMEM;
>> +     keypad->dev = &pdev->dev;
>> +     platform_set_drvdata(pdev, keypad);
>> +
>> +     keypad->iio_chans = iio_channel_get_all(&pdev->dev);
>> +     if (IS_ERR(keypad->iio_chans)) {
>> +             dev_err(&pdev->dev, "Failed to get IIO channels: %ld\n",
>> +                     PTR_ERR(keypad->iio_chans));
>> +             return PTR_ERR(keypad->iio_chans);
>> +     }
>> +
>> +     i = 0;
>> +     while (keypad->iio_chans[i].channel != NULL)
>> +             i++;
>> +     keypad->num_chans = i;
>> +     keypad->chan_map = devm_kcalloc(&pdev->dev, keypad->num_chans,
>> +                                     sizeof(*keypad->chan_map), GFP_KERNEL);
>> +     if (!keypad->chan_map) {
>> +             ret = -ENOMEM;
>> +             goto put_chans;
>> +     }
>> +
>> +     ret = adc_keypad_of_parse(keypad);
>> +     if (ret < 0)
>> +             goto put_chans;
>> +
>> +     poll_dev = devm_input_allocate_polled_device(&pdev->dev);
>> +     if (!poll_dev) {
>> +             ret = -ENOMEM;
>> +             goto put_chans;
>> +     }
>> +     keypad->poll_dev = poll_dev;
>> +
>> +     poll_dev->private = keypad;
>> +     poll_dev->poll = adc_keypad_poll;
>> +     poll_dev->poll_interval = keypad->poll_interval;
>> +
>> +     input = poll_dev->input;
>> +     input->name = pdev->name;
>> +     input->phys = "adc-keys/input0";
>> +
>> +     input->id.bustype = BUS_HOST;
>> +     input->id.vendor = 0x0001;
>> +     input->id.product = 0x0001;
>> +     input->id.version = 0x0100;

> Why these particular values?

I just chose these because these are the values most other platform
input devices use, including gpio_keys and gpio_keys_polled.
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux