mfd: Use threaded irq for pcf50633
Use threaded oneshot irq handler instead of normal irq handler and a workqueue. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
6438a694b6
commit
f7b2a77fe6
@@ -57,7 +57,7 @@ obj-$(CONFIG_PMIC_DA903X) += da903x.o
|
|||||||
max8925-objs := max8925-core.o max8925-i2c.o
|
max8925-objs := max8925-core.o max8925-i2c.o
|
||||||
obj-$(CONFIG_MFD_MAX8925) += max8925.o
|
obj-$(CONFIG_MFD_MAX8925) += max8925.o
|
||||||
|
|
||||||
obj-$(CONFIG_MFD_PCF50633) += pcf50633-core.o
|
obj-$(CONFIG_MFD_PCF50633) += pcf50633-core.o pcf50633-irq.o
|
||||||
obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o
|
obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o
|
||||||
obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o
|
obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o
|
||||||
obj-$(CONFIG_ABX500_CORE) += abx500-core.o
|
obj-$(CONFIG_ABX500_CORE) += abx500-core.o
|
||||||
|
@@ -325,14 +325,12 @@ static void pcf50633_irq_call_handler(struct pcf50633 *pcf, int irq)
|
|||||||
/* Maximum amount of time ONKEY is held before emergency action is taken */
|
/* Maximum amount of time ONKEY is held before emergency action is taken */
|
||||||
#define PCF50633_ONKEY1S_TIMEOUT 8
|
#define PCF50633_ONKEY1S_TIMEOUT 8
|
||||||
|
|
||||||
static void pcf50633_irq_worker(struct work_struct *work)
|
static irqreturn_t pcf50633_irq(int irq, void *data)
|
||||||
{
|
{
|
||||||
struct pcf50633 *pcf;
|
struct pcf50633 *pcf = data;
|
||||||
int ret, i, j;
|
int ret, i, j;
|
||||||
u8 pcf_int[5], chgstat;
|
u8 pcf_int[5], chgstat;
|
||||||
|
|
||||||
pcf = container_of(work, struct pcf50633, irq_work);
|
|
||||||
|
|
||||||
/* Read the 5 INT regs in one transaction */
|
/* Read the 5 INT regs in one transaction */
|
||||||
ret = pcf50633_read_block(pcf, PCF50633_REG_INT1,
|
ret = pcf50633_read_block(pcf, PCF50633_REG_INT1,
|
||||||
ARRAY_SIZE(pcf_int), pcf_int);
|
ARRAY_SIZE(pcf_int), pcf_int);
|
||||||
@@ -436,21 +434,7 @@ static void pcf50633_irq_worker(struct work_struct *work)
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
put_device(pcf->dev);
|
return IRQ_HANDLED
|
||||||
enable_irq(pcf->irq);
|
|
||||||
}
|
|
||||||
|
|
||||||
static irqreturn_t pcf50633_irq(int irq, void *data)
|
|
||||||
{
|
|
||||||
struct pcf50633 *pcf = data;
|
|
||||||
|
|
||||||
dev_dbg(pcf->dev, "pcf50633_irq\n");
|
|
||||||
|
|
||||||
get_device(pcf->dev);
|
|
||||||
disable_irq_nosync(pcf->irq);
|
|
||||||
queue_work(pcf->work_queue, &pcf->irq_work);
|
|
||||||
|
|
||||||
return IRQ_HANDLED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -488,9 +472,6 @@ static int pcf50633_suspend(struct i2c_client *client, pm_message_t state)
|
|||||||
* henceforth */
|
* henceforth */
|
||||||
disable_irq(pcf->irq);
|
disable_irq(pcf->irq);
|
||||||
|
|
||||||
/* Make sure that any running IRQ worker has quit */
|
|
||||||
cancel_work_sync(&pcf->irq_work);
|
|
||||||
|
|
||||||
/* Save the masks */
|
/* Save the masks */
|
||||||
ret = pcf50633_read_block(pcf, PCF50633_REG_INT1M,
|
ret = pcf50633_read_block(pcf, PCF50633_REG_INT1M,
|
||||||
ARRAY_SIZE(pcf->suspend_irq_masks),
|
ARRAY_SIZE(pcf->suspend_irq_masks),
|
||||||
@@ -531,16 +512,7 @@ static int pcf50633_resume(struct i2c_client *client)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(pcf->dev, "Error restoring saved suspend masks\n");
|
dev_err(pcf->dev, "Error restoring saved suspend masks\n");
|
||||||
|
|
||||||
/* Restore regulators' state */
|
enable_irq(pcf->irq);
|
||||||
|
|
||||||
|
|
||||||
get_device(pcf->dev);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clear any pending interrupts and set resume reason if any.
|
|
||||||
* This will leave with enable_irq()
|
|
||||||
*/
|
|
||||||
pcf50633_irq_worker(&pcf->irq_work);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -574,22 +546,13 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
|
|||||||
pcf->dev = &client->dev;
|
pcf->dev = &client->dev;
|
||||||
pcf->i2c_client = client;
|
pcf->i2c_client = client;
|
||||||
pcf->irq = client->irq;
|
pcf->irq = client->irq;
|
||||||
pcf->work_queue = create_singlethread_workqueue("pcf50633");
|
|
||||||
|
|
||||||
if (!pcf->work_queue) {
|
|
||||||
dev_err(&client->dev, "Failed to alloc workqueue\n");
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto err_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
INIT_WORK(&pcf->irq_work, pcf50633_irq_worker);
|
|
||||||
|
|
||||||
version = pcf50633_reg_read(pcf, 0);
|
version = pcf50633_reg_read(pcf, 0);
|
||||||
variant = pcf50633_reg_read(pcf, 1);
|
variant = pcf50633_reg_read(pcf, 1);
|
||||||
if (version < 0 || variant < 0) {
|
if (version < 0 || variant < 0) {
|
||||||
dev_err(pcf->dev, "Unable to probe pcf50633\n");
|
dev_err(pcf->dev, "Unable to probe pcf50633\n");
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto err_destroy_workqueue;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev_info(pcf->dev, "Probed device version %d variant %d\n",
|
dev_info(pcf->dev, "Probed device version %d variant %d\n",
|
||||||
@@ -603,12 +566,13 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
|
|||||||
pcf50633_reg_write(pcf, PCF50633_REG_INT4M, 0x00);
|
pcf50633_reg_write(pcf, PCF50633_REG_INT4M, 0x00);
|
||||||
pcf50633_reg_write(pcf, PCF50633_REG_INT5M, 0x00);
|
pcf50633_reg_write(pcf, PCF50633_REG_INT5M, 0x00);
|
||||||
|
|
||||||
ret = request_irq(client->irq, pcf50633_irq,
|
ret = request_threaded_irq(client->irq, NULL, pcf50633_irq,
|
||||||
IRQF_TRIGGER_LOW, "pcf50633", pcf);
|
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
|
||||||
|
"pcf50633", pcf);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(pcf->dev, "Failed to request IRQ %d\n", ret);
|
dev_err(pcf->dev, "Failed to request IRQ %d\n", ret);
|
||||||
goto err_destroy_workqueue;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create sub devices */
|
/* Create sub devices */
|
||||||
@@ -654,8 +618,6 @@ static int __devinit pcf50633_probe(struct i2c_client *client,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_destroy_workqueue:
|
|
||||||
destroy_workqueue(pcf->work_queue);
|
|
||||||
err_free:
|
err_free:
|
||||||
i2c_set_clientdata(client, NULL);
|
i2c_set_clientdata(client, NULL);
|
||||||
kfree(pcf);
|
kfree(pcf);
|
||||||
@@ -669,7 +631,6 @@ static int __devexit pcf50633_remove(struct i2c_client *client)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
free_irq(pcf->irq, pcf);
|
free_irq(pcf->irq, pcf);
|
||||||
destroy_workqueue(pcf->work_queue);
|
|
||||||
|
|
||||||
platform_device_unregister(pcf->input_pdev);
|
platform_device_unregister(pcf->input_pdev);
|
||||||
platform_device_unregister(pcf->rtc_pdev);
|
platform_device_unregister(pcf->rtc_pdev);
|
||||||
|
Reference in New Issue
Block a user