@@ -627,6 +627,16 @@ static irqreturn_t ccg_irq_handler(int irq, void *data)
return IRQ_HANDLED;
}
+static int ccg_request_irq(struct ucsi_ccg *uc)
+{
+ unsigned long flags = IRQF_ONESHOT;
+
+ if (!has_acpi_companion(uc->dev))
+ flags |= IRQF_TRIGGER_HIGH;
+
+ return request_threaded_irq(uc->irq, NULL, ccg_irq_handler, flags, dev_name(uc->dev), uc);
+}
+
static void ccg_pm_workaround_work(struct work_struct *pm_work)
{
ccg_irq_handler(0, container_of(pm_work, struct ucsi_ccg, pm_work));
@@ -1250,9 +1260,7 @@ static int ccg_restart(struct ucsi_ccg *uc)
return status;
}
- status = request_threaded_irq(uc->irq, NULL, ccg_irq_handler,
- IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
- dev_name(dev), uc);
+ status = ccg_request_irq(uc);
if (status < 0) {
dev_err(dev, "request_threaded_irq failed - %d\n", status);
return status;
@@ -1331,6 +1339,7 @@ static int ucsi_ccg_probe(struct i2c_client *client,
uc->dev = dev;
uc->client = client;
+ uc->irq = client->irq;
mutex_init(&uc->lock);
init_completion(&uc->complete);
INIT_WORK(&uc->work, ccg_update_firmware);
@@ -1366,16 +1375,12 @@ static int ucsi_ccg_probe(struct i2c_client *client,
ucsi_set_drvdata(uc->ucsi, uc);
- status = request_threaded_irq(client->irq, NULL, ccg_irq_handler,
- IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
- dev_name(dev), uc);
+ status = ccg_request_irq(uc);
if (status < 0) {
dev_err(uc->dev, "request_threaded_irq failed - %d\n", status);
goto out_ucsi_destroy;
}
- uc->irq = client->irq;
-
status = ucsi_register(uc->ucsi);
if (status)
goto out_free_irq;
The current implementation supports only Level trigger with ACTIVE HIGH, which is overriding level and polarity set by the ACPI table, hence implement the common utility function to manage irq requests. Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com> --- Changes in v3: - Implemented the new routine ccg_request_irq to handle irq requests including ACPI based device check. Changes in v2: - Implemented the new routine ccg_request_irq to handle irq requests. drivers/usb/typec/ucsi/ucsi_ccg.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)