From patchwork Thu May 6 15:37:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 12242643 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_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 6F10CC433ED for ; Thu, 6 May 2021 16:03:09 +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 0124B610FC for ; Thu, 6 May 2021 16:03:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0124B610FC 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=dpvHlAoh1NlmQ9P4knsN2kP1S Wn0tbeDAzgshp7VvHKSbgqRW3HZ6Gr6FQS8uj/MNCamILNsJ9gQMIdQOx5BgFq7csJiJFDt8zqOyz NfcKQX8kr+mkDlpmUm9332reCxZKAJTjixNC20jCOF0qURBmzch/bpkBBJ+7KqNvrkCjrQvW7Q1aP fKPB2cyQQhhESHS+Gm1Jb1Ob6oj5R9e2lSGE1m0Qj5oeRD/4mqoAHmwZHiEkqK9IqDgCtOBK/AWRh 8minvlM3THfoRV7zYybamE+QJHQKF9ULuASdW56mFSHpov5pkfaf263u8cBL5fgFkV3NkCvygGP4R YFH934x4Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1legNv-004iGx-TH; Thu, 06 May 2021 15:57:56 +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 1leg4C-004beL-Fb for linux-arm-kernel@desiato.infradead.org; Thu, 06 May 2021 15:37:32 +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=Z+6mSPdzFDwsWhJYtyFbcV/qzj THeZxPidfkG3xL3c78Fram+XwOhsWEh8tvGQoOkkr7U0JAa0jmqBsL7C/ajhZa73+Qw++YoqUpAYw jB+S6IxhRaOuAHlesdidXNc4Rf9q7rTdRWB2sHVbnLAD/kH3oC6vR/LpHH2TqSSJ6nBrlF3Iu9niJ qdJD+edx6XRbpvpzpe4yFKXwRrtETwwjveYa4+Sl5OTHKkHl7d6E0rN24Cr/K5fGAR/on4u1C6wK3 ei1fWsZ1iQYHZF7Q062wLD8Zfuqrz/gSlmkbf/IheG9xwbr08E64dA9ZzOtvVsytGoOJALJVTThvn Ghtt4tQQ==; Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leg49-006AKg-Gf for linux-arm-kernel@lists.infradead.org; Thu, 06 May 2021 15:37:31 +0000 Received: by mail-wr1-x429.google.com with SMTP id x5so6091621wrv.13 for ; Thu, 06 May 2021 08:37:28 -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=IXg8o5wjRe5tnEMU6NOudBSTzNqehm2jpqFD2uSexwVdQ672TmU2uAGQncSu7UqNPg CrmtEvYFXjnGmexJXSdcPrvaMYM4qX+uDtCdp+LN273fLznYzyJauDUJs6JdXXOh/A1B D28RQVcG6mYoPM4bd1jPQY/9glaZLpZcZBBzjg3pmhTTpBtX9AnHox6ZmjmMf54Bj0Ii 1UMpTJAw6qlB6BBe1QYcxAT0u6McMDdrxqadMq8o2OgnN47ITYFV31M0a1F8x7Ccr2y5 52CjetHDs27ekPEpbpBuhXlxPLSzp3ER/awpJiJtAlhfBwWO1Hw5Z37t2HvpUc+jhN+i GaIA== 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=HWPzjHArIjPL0zBcjy6wwy5UPz2FNiwiadG0C2PT8P73zsQGq54tsY8Y2R5jotB4lr 6Jj+2uY2Cs6pPapPQ/aFdkYDabvQA1ITA/aoK0pAacMDxIBQWbpuXJX+K/ysLko7RID8 bsOS3nmc+nZOFYNWf9FwB+xeq1RaqnQcKG8bPqidpDjIIPVkBFk6ql0Drm1pTfTID3bV Ejgo1wkbMBLQZo+VEYfXf7lnejMw98WOwvNE9n0Oi63huS51AajcyH5iLx5UcW2xEANC Yv9hUH+STu+MF+YnStIK/6Id+IRwZqaUzX6gzy2vjExRyYQGP8PWaeMceb/e7oXhN1Gp pbVA== X-Gm-Message-State: AOAM5324SdGspTxdCcHgV5/aWViCcJLj4tbzbVU3Gs6kUONLN8LGLXt7 qiuxKwUX9mOUcUDAQ9kK4qeUpA== X-Google-Smtp-Source: ABdhPJyd0JoHB9yNIkDQl4FPDKaa1IAPD7vl4654KnfHoAWsbt2C1ycq3EFe43odqrh+MHp1zRA6hw== X-Received: by 2002:a5d:408f:: with SMTP id o15mr5845999wrp.89.1620315447483; Thu, 06 May 2021 08:37:27 -0700 (PDT) Received: from groot.home ([2a01:cb19:826e:8e00:5fe0:3a70:ad4a:a29b]) by smtp.gmail.com with ESMTPSA id o13sm3788673wmh.34.2021.05.06.08.37.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 08:37:27 -0700 (PDT) From: Mattijs Korpershoek To: Dmitry Torokhov , Matthias Brugger Cc: Fabien Parent , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mattijs Korpershoek , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 1/3] Input: mtk-pmic-keys - use get_irq_byname() instead of index Date: Thu, 6 May 2021 17:37:16 +0200 Message-Id: <20210506153718.256903-2-mkorpershoek@baylibre.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210506153718.256903-1-mkorpershoek@baylibre.com> References: <20210506153718.256903-1-mkorpershoek@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210506_083729_560603_B223DCB6 X-CRM114-Status: GOOD ( 15.01 ) 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;