From patchwork Thu Jun 9 13:35:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-Patchwork-Id: 12875586 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44D23C433EF for ; Thu, 9 Jun 2022 13:37:59 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 75CF41A99; Thu, 9 Jun 2022 15:37:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 75CF41A99 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1654781877; bh=LdtGmqYHx6gWjJZNFLVe4g7UugnDo1JHioUOoTNWkAI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=F7rvcNAVWIxlAZeVbUDY5MuvGTYnRV3798IwbgCBDJH7a5zXAMbw/tuKh0oEd1XQ/ pRTm1eSI5xJsoeB6UxAnowfCUsV2aUHZJ5NIrkq7Fb9RzZ+M1kimuBNkPAujF+Yy8Z PvyWizLiQeYZxpMrKTnYeD9jEnFoAodLfGRdheD8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DBFD1F80538; Thu, 9 Jun 2022 15:35:59 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8510AF80538; Thu, 9 Jun 2022 15:35:56 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2D8B5F8051E for ; Thu, 9 Jun 2022 15:35:49 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2D8B5F8051E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kG9CEOlX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654781751; x=1686317751; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LdtGmqYHx6gWjJZNFLVe4g7UugnDo1JHioUOoTNWkAI=; b=kG9CEOlXCopFOJvHUNpzaISJTQBox0jd3PHhQM48cFE4Iargw4zeezQV 05VTIKlx+2GAUZ7ah3YHevu7Xxbu5WKYgdNpLMa4PArXo3LdVXdrhJsMz CpIiaSe11mTEDqjsCPUzexldGmvrQEz+tSc84zHCInYzi3j+RU/bFb57T rbmZg0qMxG61BSSSefRQ8sJdZ5EaG4q6aD0PZ9H4iqZS3tJyuFluMgGpC AbL8POGo/8euuOkpCuE6canF5b6YfqK/Q3Z6ls7v9aTOgOFCsnUdSgolS L6mYhmM+XiJrWUP5/snxjdekGKUL+vQF8TL6ppT2F5YcJyR20b9+oCkVT g==; X-IronPort-AV: E=McAfee;i="6400,9594,10373"; a="266061396" X-IronPort-AV: E=Sophos;i="5.91,287,1647327600"; d="scan'208";a="266061396" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2022 06:35:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,287,1647327600"; d="scan'208";a="683966156" Received: from dev2 (HELO DEV2.igk.intel.com) ([10.237.148.94]) by fmsmga002.fm.intel.com with ESMTP; 09 Jun 2022 06:35:46 -0700 From: =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= To: Oder Chiou , Mark Brown Subject: [PATCH 04/11] ASoC: codecs: rt274: Move irq registration and cleanup Date: Thu, 9 Jun 2022 15:35:34 +0200 Message-Id: <20220609133541.3984886-5-amadeuszx.slawinski@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609133541.3984886-1-amadeuszx.slawinski@linux.intel.com> References: <20220609133541.3984886-1-amadeuszx.slawinski@linux.intel.com> MIME-Version: 1.0 Cc: Pierre-Louis Bossart , Cezary Rojewski , alsa-devel@alsa-project.org, Takashi Iwai , Liam Girdwood , =?utf-8?q?Amadeusz_S=C5=82awi=C5=84ski?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Currently irq is registered when i2c driver is loaded, it is unnecessary when component is unused. Initialize irq only when we probe ASoC component. Signed-off-by: Amadeusz Sławiński Reviewed-by: Cezary Rojewski --- sound/soc/codecs/rt274.c | 44 ++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c index a5615e94ec7d..144a6f775c21 100644 --- a/sound/soc/codecs/rt274.c +++ b/sound/soc/codecs/rt274.c @@ -978,13 +978,22 @@ static irqreturn_t rt274_irq(int irq, void *data) static int rt274_probe(struct snd_soc_component *component) { struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); + int ret; rt274->component = component; INIT_DELAYED_WORK(&rt274->jack_detect_work, rt274_jack_detect_work); - if (rt274->i2c->irq) - schedule_delayed_work(&rt274->jack_detect_work, - msecs_to_jiffies(1250)); + if (rt274->i2c->irq) { + ret = request_threaded_irq(rt274->i2c->irq, NULL, rt274_irq, + IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt274", rt274); + if (ret) { + dev_err(&rt274->i2c->dev, "Failed to reguest IRQ: %d\n", ret); + return ret; + } + + schedule_delayed_work(&rt274->jack_detect_work, msecs_to_jiffies(1250)); + } + return 0; } @@ -992,7 +1001,12 @@ static void rt274_remove(struct snd_soc_component *component) { struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); - cancel_delayed_work_sync(&rt274->jack_detect_work); + if (rt274->i2c->irq) { + cancel_delayed_work_sync(&rt274->jack_detect_work); + + disable_irq(rt274->i2c->irq); + free_irq(rt274->i2c->irq, rt274); + } } #ifdef CONFIG_PM @@ -1187,16 +1201,6 @@ static int rt274_i2c_probe(struct i2c_client *i2c) regmap_write(rt274->regmap, RT274_UNSOLICITED_HP_OUT, 0x81); regmap_write(rt274->regmap, RT274_UNSOLICITED_MIC, 0x82); - if (rt274->i2c->irq) { - ret = request_threaded_irq(rt274->i2c->irq, NULL, rt274_irq, - IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt274", rt274); - if (ret != 0) { - dev_err(&i2c->dev, - "Failed to reguest IRQ: %d\n", ret); - return ret; - } - } - ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt274, rt274_dai, ARRAY_SIZE(rt274_dai)); @@ -1204,17 +1208,6 @@ static int rt274_i2c_probe(struct i2c_client *i2c) return ret; } -static int rt274_i2c_remove(struct i2c_client *i2c) -{ - struct rt274_priv *rt274 = i2c_get_clientdata(i2c); - - if (i2c->irq) - free_irq(i2c->irq, rt274); - - return 0; -} - - static struct i2c_driver rt274_i2c_driver = { .driver = { .name = "rt274", @@ -1224,7 +1217,6 @@ static struct i2c_driver rt274_i2c_driver = { #endif }, .probe_new = rt274_i2c_probe, - .remove = rt274_i2c_remove, .id_table = rt274_i2c_id, };