mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 09:34:12 +08:00
3ea5eb68b9
After commit 0edb555a65
("platform: Make platform_driver::remove()
return void") .remove() is (again) the right callback to implement for
platform drivers.
Convert all platform drivers below drivers/platform/x86/ to use
.remove(), with the eventual goal to drop struct
platform_driver::remove_new(). As .remove() and .remove_new() have the
same prototypes, conversion is done by just changing the structure
member name in the driver initializer.
While touching these files, make indention of the struct initializer
consistent in several files.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20241017073802.53235-2-u.kleine-koenig@baylibre.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
94 lines
2.3 KiB
C
94 lines
2.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Power-button driver for Dollar Cove TI PMIC
|
|
* Copyright (C) 2014 Intel Corp
|
|
* Copyright (c) 2017 Takashi Iwai <tiwai@suse.de>
|
|
*/
|
|
|
|
#include <linux/input.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/device.h>
|
|
#include <linux/mfd/intel_soc_pmic.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/pm_wakeirq.h>
|
|
#include <linux/slab.h>
|
|
|
|
#define CHTDC_TI_SIRQ_REG 0x3
|
|
#define SIRQ_PWRBTN_REL BIT(0)
|
|
|
|
static irqreturn_t chtdc_ti_pwrbtn_interrupt(int irq, void *dev_id)
|
|
{
|
|
struct input_dev *input = dev_id;
|
|
struct device *dev = input->dev.parent;
|
|
struct regmap *regmap = dev_get_drvdata(dev);
|
|
int state;
|
|
|
|
if (!regmap_read(regmap, CHTDC_TI_SIRQ_REG, &state)) {
|
|
dev_dbg(dev, "SIRQ_REG=0x%x\n", state);
|
|
input_report_key(input, KEY_POWER, !(state & SIRQ_PWRBTN_REL));
|
|
input_sync(input);
|
|
}
|
|
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
static int chtdc_ti_pwrbtn_probe(struct platform_device *pdev)
|
|
{
|
|
struct device *dev = &pdev->dev;
|
|
struct intel_soc_pmic *pmic = dev_get_drvdata(dev->parent);
|
|
struct input_dev *input;
|
|
int irq, err;
|
|
|
|
irq = platform_get_irq(pdev, 0);
|
|
if (irq < 0)
|
|
return irq;
|
|
input = devm_input_allocate_device(dev);
|
|
if (!input)
|
|
return -ENOMEM;
|
|
input->name = pdev->name;
|
|
input->phys = "power-button/input0";
|
|
input->id.bustype = BUS_HOST;
|
|
input_set_capability(input, EV_KEY, KEY_POWER);
|
|
err = input_register_device(input);
|
|
if (err)
|
|
return err;
|
|
|
|
dev_set_drvdata(dev, pmic->regmap);
|
|
|
|
err = devm_request_threaded_irq(dev, irq, NULL,
|
|
chtdc_ti_pwrbtn_interrupt,
|
|
IRQF_ONESHOT, KBUILD_MODNAME, input);
|
|
if (err)
|
|
return err;
|
|
|
|
device_init_wakeup(dev, true);
|
|
dev_pm_set_wake_irq(dev, irq);
|
|
return 0;
|
|
}
|
|
|
|
static void chtdc_ti_pwrbtn_remove(struct platform_device *pdev)
|
|
{
|
|
dev_pm_clear_wake_irq(&pdev->dev);
|
|
device_init_wakeup(&pdev->dev, false);
|
|
}
|
|
|
|
static const struct platform_device_id chtdc_ti_pwrbtn_id_table[] = {
|
|
{ .name = "chtdc_ti_pwrbtn" },
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(platform, chtdc_ti_pwrbtn_id_table);
|
|
|
|
static struct platform_driver chtdc_ti_pwrbtn_driver = {
|
|
.driver = {
|
|
.name = KBUILD_MODNAME,
|
|
},
|
|
.probe = chtdc_ti_pwrbtn_probe,
|
|
.remove = chtdc_ti_pwrbtn_remove,
|
|
.id_table = chtdc_ti_pwrbtn_id_table,
|
|
};
|
|
module_platform_driver(chtdc_ti_pwrbtn_driver);
|
|
|
|
MODULE_DESCRIPTION("Power-button driver for Dollar Cove TI PMIC");
|
|
MODULE_LICENSE("GPL v2");
|