From patchwork Wed May 12 15:26:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 12254149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_NONE,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F92BC433B4 for ; Wed, 12 May 2021 15:28:48 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 771786187E for ; Wed, 12 May 2021 15:28:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 771786187E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HW9gMFmQQhrWfTo4YBVQfM8uvws4cVSDxECtah3A+4o=; b=eoRIRU9bGiF+IRgcysXWHJxXb VhrksHm7voFfbdk8htHHgd4V3FhUVKleQgY/Atl9ekkPcWtkAdQs13WXiOBu0V/Aig2QUKaMyA4Zm GCN36fQ3hHs+kM/iaQmPsCHVpel6HqlhYMCeYnEA5hzi6YqItyQlAaECo1BTRUYJXirKjWQYkgn8v RmMuisJ317goH3yg7Csqdjvfl2om4YjFENluqaVhetUzHAJ2lfSsPGaqavMjIv8Q5vH6AvYu3WZyC I/L7gueN9VNE7gGKtsd+7dnmjRCtUz+XkN4vFxYkxe/kDERSFsQUCqX/CWKuiUhkLXEx7tkMtXd3F dxOfLY+oA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgqlg-003Bsz-5U; Wed, 12 May 2021 15:27:24 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgqlG-003Bnb-Ao for linux-arm-kernel@desiato.infradead.org; Wed, 12 May 2021 15:26:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=oW516jzYudrgPpoHV87MKKEstdKadYWrqHFNhZ2YbXA=; b=FV21UBjz5OO0/TZa/fp4+XtCEA G1pL4hTshinDaH9oDj1Bknl0BLyARJDeNVVRWZIVB+tWDdwvF1cBwtbaUJTEpUsnMr1olZTqdGmmy DPt+QnG7OusdBGFoLLJ8Vi8Bu54IvOpco4G0nqRoSkVNWOJLCzda+oMdkm1FHpRhCMve0GIzAYrUM WCqRQpnGAkjpekTuAh0BUsUFv4mtrndcDt81miEpU39XxRWs0sMMXQ9PY5Si9/kuwsLYGLUcFCUAc wDqQX2wvMasU6DnDFxNhYOflbUdUoy0zdQoXKc/tq/3IoVREtNr0J2skgbjVXldI9mZJhDwM60BdO SddO8uqA==; Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgqlD-00AW72-23 for linux-arm-kernel@lists.infradead.org; Wed, 12 May 2021 15:26:57 +0000 Received: by mail-wr1-x433.google.com with SMTP id d11so24033072wrw.8 for ; Wed, 12 May 2021 08:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oW516jzYudrgPpoHV87MKKEstdKadYWrqHFNhZ2YbXA=; b=hXAKLlGslSY+StvaTShozecnK56pNk1iaHsdQQqcO3Oq+6ZookK9e21q3ejNQQvBqq RDhHax1vyl5VTyNgLtRs/87oEJGisOF/zGw7VnU0wP2Xli9Vmw1lNM1DP+o1bIMCNZc2 49Wt8OIXmlP0FCA4GETy37IWb6XzuBEsV1YMjfjvHIqMtfiidrWJPN06kSnNPl8G0El+ ejyDjMoNnCe3HFwf1hjDSq/tkolEptYzQzFsogm86a+12K46WgmdmimS0pkSjJdz7Qs1 rZXRl5tgPlAYFLp0FQpP8s37hueBw3hseo+jn1R8u8CpczgMEdOlTFVKdL5IBJcLVRrv wbcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oW516jzYudrgPpoHV87MKKEstdKadYWrqHFNhZ2YbXA=; b=itzXT6akbeUDxfrXbJxWL233dcKFLmaw26W+aD06q6gm6+KXA1huU94GswdLUKEnNw 0IaB94yZsyOq8kCz1XDkgmY+XzqYrjSOLcF5IsvBTnDSkTXnhxFFi079QPF5kRhUIXzD mNAlsVteW/lGENefmzIaRXDazwqh4QRLVnad6LnrZlKpBlV/wN8Dt87jI1k1K+gaxuOx FUxx4b3TjNLZXbov8TEAIQX3BnrtV3ssiXLzez/eNKn7x2OGGCVpcvEy4mCZcXwhYRnV SJfQtx7jiSCRC0lw92b5Agfnqv2YR0K5oPVUKbJgRhHyuQ3F27gkUTvhERwJ5lUHkctp vpwQ== X-Gm-Message-State: AOAM532Y/joPirx55VBEM8mUSL5qE9TmLyib+HXA+dNgbGmQkYRSWCs8 Tpfj/hhBgJAbFCeWH1q41P3mHw== X-Google-Smtp-Source: ABdhPJypo7Jgc6oAImKUv3gajv3k/NqdipfFKhkHkFZxxCQ1LulKIaO0IIMcNGTIuXb2LioBDAsYuQ== X-Received: by 2002:a05:6000:1549:: with SMTP id 9mr45965246wry.367.1620833213218; Wed, 12 May 2021 08:26:53 -0700 (PDT) Received: from mkorpershoek-XPS-13-9370.home (lfbn-tou-1-1465-169.w90-89.abo.wanadoo.fr. [90.89.34.169]) by smtp.gmail.com with ESMTPSA id b7sm30931256wri.83.2021.05.12.08.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 08:26:52 -0700 (PDT) From: Mattijs Korpershoek To: Dmitry Torokhov , Matthias Brugger Cc: Fabien Parent , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Mattijs Korpershoek Subject: [PATCH v2 1/3] Input: mtk-pmic-keys - use get_irq_byname() instead of index Date: Wed, 12 May 2021 17:26:46 +0200 Message-Id: <20210512152648.39961-2-mkorpershoek@baylibre.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210512152648.39961-1-mkorpershoek@baylibre.com> References: <20210512152648.39961-1-mkorpershoek@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210512_082655_106304_1805C39F X-CRM114-Status: GOOD ( 15.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some pmics of the mt6397 family (such as MT6358), have two IRQs per physical key: one for press event, another for release event. The mtk-pmic-keys driver assumes that each key only has one IRQ. The key index and the RES_IRQ resource index have a 1/1 mapping. This won't work for MT6358, as we have multiple resources (2) for one key. To prepare mtk-pmic-keys to support MT6358, retrieve IRQs by name instead of by index. Signed-off-by: Mattijs Korpershoek --- drivers/input/keyboard/mtk-pmic-keys.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c index 62391d6c7da6..d1abf95d5701 100644 --- a/drivers/input/keyboard/mtk-pmic-keys.c +++ b/drivers/input/keyboard/mtk-pmic-keys.c @@ -241,6 +241,7 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) unsigned int keycount; struct mt6397_chip *pmic_chip = dev_get_drvdata(pdev->dev.parent); struct device_node *node = pdev->dev.of_node, *child; + static const char *const irqnames[] = { "powerkey", "homekey" }; struct mtk_pmic_keys *keys; const struct mtk_pmic_regs *mtk_pmic_regs; struct input_dev *input_dev; @@ -268,7 +269,8 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) input_dev->id.version = 0x0001; keycount = of_get_available_child_count(node); - if (keycount > MTK_PMIC_MAX_KEY_COUNT) { + if (keycount > MTK_PMIC_MAX_KEY_COUNT || + keycount > ARRAY_SIZE(irqnames)) { dev_err(keys->dev, "too many keys defined (%d)\n", keycount); return -EINVAL; } @@ -276,7 +278,8 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev) for_each_child_of_node(node, child) { keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index]; - keys->keys[index].irq = platform_get_irq(pdev, index); + keys->keys[index].irq = + platform_get_irq_byname(pdev, irqnames[index]); if (keys->keys[index].irq < 0) { of_node_put(child); return keys->keys[index].irq;