mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
![Linus Torvalds](/assets/img/avatar_default.png)
Here's the big staging tree pull request for 3.19-rc1. We continued to delete more lines than were added, always a good thing, but not at a huge rate this release, only about 70k lines removed overall mostly from removing the horrid bcm driver. Lots of normal staging driver cleanups and fixes all over the place, well over a thousand of them, the shortlog shows all the horrid details. The "contentious" thing here is the movement of the Android binder code out of staging into the "real" part of the kernel. This is code that has been stable for a few years now and is working as-is in the tens of millions of devices with no issues. Yes, the code is horrid, and the userspace api leaves a lot to be desired, but it's not going to change due to legacy issues that we have no control over. Because so many devices and companies rely on this, and the code is stable, might as well promote it out of staging. This was all discussed at the Linux Plumbers conference, and everyone participating agreed that this was the best way forward. There is work happening to replace the binder code with something new that is happening right now, but I don't expect to see the results of that work for another year at the earliest. If that ever happens, and Android switches over to it, I'll gladly remove this version. As for maintainers, I'll be glad to maintain this code, I've been doing it for the past few years with no problems. I'll send a MAINTAINERS entry for it before 3.19-final is out, still need to talk to the Google developers about if they are willing to help with it or not, last I checked they were, which was good. All of these patches have been in linux-next for a while with no reported issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEABECAAYFAlSPICkACgkQMUfUDdst+yksdwCfSLE9VUy1o2sAPDRe+J3bQced EWEAoL3RtnejKbo5tHS2IT69pLrwiIDS =YXyM -----END PGP SIGNATURE----- Merge tag 'staging-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging driver updates from Greg KH: "Here's the big staging tree pull request for 3.19-rc1. We continued to delete more lines than were added, always a good thing, but not at a huge rate this release, only about 70k lines removed overall mostly from removing the horrid bcm driver. Lots of normal staging driver cleanups and fixes all over the place, well over a thousand of them, the shortlog shows all the horrid details. The "contentious" thing here is the movement of the Android binder code out of staging into the "real" part of the kernel. This is code that has been stable for a few years now and is working as-is in the tens of millions of devices with no issues. Yes, the code is horrid, and the userspace api leaves a lot to be desired, but it's not going to change due to legacy issues that we have no control over. Because so many devices and companies rely on this, and the code is stable, might as well promote it out of staging. This was all discussed at the Linux Plumbers conference, and everyone participating agreed that this was the best way forward. There is work happening to replace the binder code with something new that is happening right now, but I don't expect to see the results of that work for another year at the earliest. If that ever happens, and Android switches over to it, I'll gladly remove this version. As for maintainers, I'll be glad to maintain this code, I've been doing it for the past few years with no problems. I'll send a MAINTAINERS entry for it before 3.19-final is out, still need to talk to the Google developers about if they are willing to help with it or not, last I checked they were, which was good. All of these patches have been in linux-next for a while with no reported issues" * tag 'staging-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (1382 commits) Staging: slicoss: Fix long line issues in slicoss.c staging: rtl8712: remove unnecessary else after return staging: comedi: change some printk calls to pr_err staging: rtl8723au: hal: Removed the extra semicolon lustre: Deletion of unnecessary checks before three function calls staging: lustre: fix sparse warnings: static function declaration staging: lustre: fixed sparse warnings related to static declarations staging: unisys: remove duplicate header staging: unisys: remove unneeded structure staging: ft1000 : replace __attribute ((__packed__) with __packed drivers: staging: rtl8192e: Include "asm/unaligned.h" instead of "access_ok.h" in "rtl819x_BAProc.c" Drivers:staging:rtl8192e: Fixed checkpatch warning Drivers:staging:clocking-wizard: Added a newline staging: clocking-wizard: check for a valid clk_name pointer staging: rtl8723au: Hal_InitPGData() avoid unnecessary typecasts staging: rtl8723au: _DisableAnalog(): Avoid zero-init variables unnecessarily staging: rtl8723au: Remove unnecessary wrapper _ResetDigitalProcedure1() staging: rtl8723au: _ResetDigitalProcedure1_92C() reduce code obfuscation staging: rtl8723au: Remove unnecessary wrapper _DisableRFAFEAndResetBB() staging: rtl8723au: _DisableRFAFEAndResetBB8192C(): Reduce code obfuscation ...
168 lines
4 KiB
C
168 lines
4 KiB
C
/* drivers/misc/timed_gpio.c
|
|
*
|
|
* Copyright (C) 2008 Google, Inc.
|
|
* Author: Mike Lockwood <lockwood@android.com>
|
|
*
|
|
* This software is licensed under the terms of the GNU General Public
|
|
* License version 2, as published by the Free Software Foundation, and
|
|
* may be copied, distributed, and modified under those terms.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/hrtimer.h>
|
|
#include <linux/err.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/ktime.h>
|
|
|
|
#include "timed_output.h"
|
|
#include "timed_gpio.h"
|
|
|
|
|
|
struct timed_gpio_data {
|
|
struct timed_output_dev dev;
|
|
struct hrtimer timer;
|
|
spinlock_t lock;
|
|
unsigned gpio;
|
|
int max_timeout;
|
|
u8 active_low;
|
|
};
|
|
|
|
static enum hrtimer_restart gpio_timer_func(struct hrtimer *timer)
|
|
{
|
|
struct timed_gpio_data *data =
|
|
container_of(timer, struct timed_gpio_data, timer);
|
|
|
|
gpio_direction_output(data->gpio, data->active_low ? 1 : 0);
|
|
return HRTIMER_NORESTART;
|
|
}
|
|
|
|
static int gpio_get_time(struct timed_output_dev *dev)
|
|
{
|
|
struct timed_gpio_data *data;
|
|
ktime_t t;
|
|
|
|
data = container_of(dev, struct timed_gpio_data, dev);
|
|
|
|
if (!hrtimer_active(&data->timer))
|
|
return 0;
|
|
|
|
t = hrtimer_get_remaining(&data->timer);
|
|
|
|
return ktime_to_ms(t);
|
|
}
|
|
|
|
static void gpio_enable(struct timed_output_dev *dev, int value)
|
|
{
|
|
struct timed_gpio_data *data =
|
|
container_of(dev, struct timed_gpio_data, dev);
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&data->lock, flags);
|
|
|
|
/* cancel previous timer and set GPIO according to value */
|
|
hrtimer_cancel(&data->timer);
|
|
gpio_direction_output(data->gpio, data->active_low ? !value : !!value);
|
|
|
|
if (value > 0) {
|
|
if (value > data->max_timeout)
|
|
value = data->max_timeout;
|
|
|
|
hrtimer_start(&data->timer,
|
|
ktime_set(value / 1000, (value % 1000) * 1000000),
|
|
HRTIMER_MODE_REL);
|
|
}
|
|
|
|
spin_unlock_irqrestore(&data->lock, flags);
|
|
}
|
|
|
|
static int timed_gpio_probe(struct platform_device *pdev)
|
|
{
|
|
struct timed_gpio_platform_data *pdata = pdev->dev.platform_data;
|
|
struct timed_gpio *cur_gpio;
|
|
struct timed_gpio_data *gpio_data, *gpio_dat;
|
|
int i, ret;
|
|
|
|
if (!pdata)
|
|
return -EBUSY;
|
|
|
|
gpio_data = devm_kzalloc(&pdev->dev,
|
|
sizeof(struct timed_gpio_data) * pdata->num_gpios,
|
|
GFP_KERNEL);
|
|
if (!gpio_data)
|
|
return -ENOMEM;
|
|
|
|
for (i = 0; i < pdata->num_gpios; i++) {
|
|
cur_gpio = &pdata->gpios[i];
|
|
gpio_dat = &gpio_data[i];
|
|
|
|
hrtimer_init(&gpio_dat->timer, CLOCK_MONOTONIC,
|
|
HRTIMER_MODE_REL);
|
|
gpio_dat->timer.function = gpio_timer_func;
|
|
spin_lock_init(&gpio_dat->lock);
|
|
|
|
gpio_dat->dev.name = cur_gpio->name;
|
|
gpio_dat->dev.get_time = gpio_get_time;
|
|
gpio_dat->dev.enable = gpio_enable;
|
|
ret = gpio_request(cur_gpio->gpio, cur_gpio->name);
|
|
if (ret < 0)
|
|
goto err_out;
|
|
ret = timed_output_dev_register(&gpio_dat->dev);
|
|
if (ret < 0) {
|
|
gpio_free(cur_gpio->gpio);
|
|
goto err_out;
|
|
}
|
|
|
|
gpio_dat->gpio = cur_gpio->gpio;
|
|
gpio_dat->max_timeout = cur_gpio->max_timeout;
|
|
gpio_dat->active_low = cur_gpio->active_low;
|
|
gpio_direction_output(gpio_dat->gpio, gpio_dat->active_low);
|
|
}
|
|
|
|
platform_set_drvdata(pdev, gpio_data);
|
|
|
|
return 0;
|
|
|
|
err_out:
|
|
while (--i >= 0) {
|
|
timed_output_dev_unregister(&gpio_data[i].dev);
|
|
gpio_free(gpio_data[i].gpio);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int timed_gpio_remove(struct platform_device *pdev)
|
|
{
|
|
struct timed_gpio_platform_data *pdata = pdev->dev.platform_data;
|
|
struct timed_gpio_data *gpio_data = platform_get_drvdata(pdev);
|
|
int i;
|
|
|
|
for (i = 0; i < pdata->num_gpios; i++) {
|
|
timed_output_dev_unregister(&gpio_data[i].dev);
|
|
gpio_free(gpio_data[i].gpio);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct platform_driver timed_gpio_driver = {
|
|
.probe = timed_gpio_probe,
|
|
.remove = timed_gpio_remove,
|
|
.driver = {
|
|
.name = TIMED_GPIO_NAME,
|
|
},
|
|
};
|
|
|
|
module_platform_driver(timed_gpio_driver);
|
|
|
|
MODULE_AUTHOR("Mike Lockwood <lockwood@android.com>");
|
|
MODULE_DESCRIPTION("timed gpio driver");
|
|
MODULE_LICENSE("GPL");
|