Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1912480rdb; Sat, 20 Jan 2024 21:32:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFefoUONsXoJ+kjO8y4CbRJJ+Nj6AEQJpREMK3ddyozhGYeF3D1ZFys7qOPX+TIDysA85AN X-Received: by 2002:ad4:5ecd:0:b0:681:7ba3:3649 with SMTP id jm13-20020ad45ecd000000b006817ba33649mr3605672qvb.63.1705815177341; Sat, 20 Jan 2024 21:32:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705815177; cv=pass; d=google.com; s=arc-20160816; b=x8p3bStaROaf2BtIe9jxMItn3T6w1bMa4l+8YPeuj2c3WlNxYEJ6PGIEKmGWzOEmtC ENPup0TpL2AwEyc4U6uNxiH0yXL0+/jEDhW8z+yJ4seOTCa8pEzR8f/XQY/YOTpRRRcC R7rBFVDd+8iHzFDsEaYm7Ar+qCzgQcpA6J5N3bgfZiVpBW3GxjNdYhKo2UgnJbTuaXi9 XOqopin3scr/EDPG9wNV+Kv5RS7eegPMJvIhisOebb6cvAGWx49lfkLRVullx/sny8GR XuZ5/58rkXg9fDH3zDpVpAJwIiu2raRjCwilvwj+0uWU5yavSmnmnWuLb6gzR6IqajDx 05Zg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dBrp1Ps9xzLA8SOiLy9P8sSqne7yU34XilTqawEafXQ=; fh=AkOZQXMPXZupshi6+PqPUxn6AuZkFxvuHfpd3C4uC+M=; b=p5XzLb0uC7IzH+BsFLqzRnDdBdgkmZWzEj8SZNxOBeozpiTSlHD/Ku4CkABWiLKHWD ZmrzdrPqJdJ7S430QsMKXPqWtTJkNxpY5JA//WQ+k8OM+6DDkNXbwqEkm9mHHp9pZnKj ilB2J5/HaKbbhTmP2KjNOiXCFnAGnw6/RRbDI6Q6DtguG7NyuiZpO5MXLiAgTsZIEA2y v2jih80dJo/DF1/Ax+tjjGalHUJkTM28qtAGsw/I5tX0OrrX6MaOmgp4pC/ORaFx4Yp9 0tJLD9GYSBBkQiQdmTdfbd65gGuipHnavhz0ODK++tetKuV/aE0z++zubRZ71T1dgO0t Iobw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cyjKsxio; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-31974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i4-20020a37c204000000b00783909d4b82si2781688qkm.724.2024.01.20.21.32.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 21:32:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cyjKsxio; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-31974-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31974-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0A55D1C220E1 for ; Sun, 21 Jan 2024 05:32:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB949364AE; Sun, 21 Jan 2024 05:32:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cyjKsxio" Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 865ED2EB19; Sun, 21 Jan 2024 05:32:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705815160; cv=none; b=ehajHifneJpG0GO4px9bpcRkCsQNoXtl5XcT0/pegLb2fRT9rpp+RpwU7323CPN5HbXyZaIS6lIAKzd2JzsErvvdLlZ6zNHmqvP9Tw0POGa/j0ItoLES3J/qiK4Q8aPTxaFdIbeL3Keyrx73xAux7sVOxdTSAUYy92MemLWnpgU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705815160; c=relaxed/simple; bh=LHz06Lyhxlmi9enxiiPXvlRXe6QQ2nBa6+/km1b7dcE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZQhLZehuCSo1rUlupa/gRa8nD1ZSLMRwOLNrpbrlQKpcJGo5T3hvXOOa3EPUEUnsGSshuvgW7h+dn604mcOsrITVL7Lb33MV307h3K8uwNpZMLNexjq8/GYSHhAmIfqBmlzQzbvo2U+GfQyeM9pc/XqMFBq+SrGc+4RFbUvozDg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cyjKsxio; arc=none smtp.client-ip=209.85.160.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-204f50f305cso1404138fac.3; Sat, 20 Jan 2024 21:32:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705815157; x=1706419957; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dBrp1Ps9xzLA8SOiLy9P8sSqne7yU34XilTqawEafXQ=; b=cyjKsxioQuWiuuMRSf/B+Il04uPIHZKQrOIF1has5+1IpaUJAt5ZHRUHHLj67IwssQ GI1XoEhiLdw/EhGskliZ1FVKMCokZtcnq/K2FCc/zbnX3zwv/MvaAsG22L6OkzpjIjRh tZFQ2Rs/Z6j9otysz9VwmowdlMlV8NVdrxpVDazA0S9u7iVA7LkmuO5kBZngfCSnE0oE SPUeVChh1Cx6KIvpnYYz0BJrpnc3f23srT25bR3bdSeBXNTf8KDdR3qp1YH3qaj8YRsH Qvs+c7A8z0XvelVCQPgQvVJ50EbU6XTfOGNIe2umKOuDtmYMTttM43n/EfMuiV1slzrL zqcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705815157; x=1706419957; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dBrp1Ps9xzLA8SOiLy9P8sSqne7yU34XilTqawEafXQ=; b=LwUvnGbHgaYvzmr1r4x8YbLDODaMCHzdoxZW3kYe9GuitaWpMR8kIBf7G5/81/IZM0 08nHG7lKyibvijmfAgohoZFhuMwbOFPI3G6O1jYfspAMcx6hkQ8NwMYQIHGNPvKKk+ZK kFuWG+3WhOp2bBqo0dtiEfHA/ihD8MpsFxexdNOsQJoxIQVZG3airbFqT2uk0WkAQi/u R/Xc5FjaIznE5BYud4U2sQGbg8AUwI0E+sPddXSIixMT2g08db/uG8H/JOr2rLBJx/o8 RhbyQ7RcNN47PnbSONV3SSvB82w2rln6GP0GVTSZGfIJPsy56eLk2UvxNdfIOSRnP/9u T/8Q== X-Gm-Message-State: AOJu0YxLcWj4UsIy8YHkcMZOio/MFW7M3mO5/eXVMRUx7W8cUqg1kwb+ aRPEWU55HMqKsneFLeXo73cNjaoOsV/ZhMYHrc6FpfTZOswxYLYM3LaJUwzv X-Received: by 2002:a05:6870:63a9:b0:214:2677:8b08 with SMTP id t41-20020a05687063a900b0021426778b08mr2200285oap.90.1705815157140; Sat, 20 Jan 2024 21:32:37 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:9d:2:b227:ab83:6b35:c967]) by smtp.gmail.com with ESMTPSA id mg7-20020a170903348700b001d69badff91sm5323978plb.148.2024.01.20.21.32.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jan 2024 21:32:36 -0800 (PST) From: Dmitry Torokhov To: linux-input@vger.kernel.org, Dan Carpenter , Bartosz Golaszewski Cc: linux-kernel@vger.kernel.org Subject: [PATCH 2/3] Input: matrix_keypad - consolidate handling of clustered interrupt Date: Sat, 20 Jan 2024 21:32:29 -0800 Message-ID: <20240121053232.276968-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog In-Reply-To: <20240121053232.276968-1-dmitry.torokhov@gmail.com> References: <20240121053232.276968-1-dmitry.torokhov@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Now that the driver stores interrupt numbers corresponding to individual GPIOs in non-clustered mode, it is possible to unify handling of both modes by storing clustered interrupt at position 0 and setting the number of interrupts in this case to 1. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/matrix_keypad.c | 63 ++++++++------------------ 1 file changed, 20 insertions(+), 43 deletions(-) diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c index 1cd1ffb80401..44ef600b8f19 100644 --- a/drivers/input/keyboard/matrix_keypad.c +++ b/drivers/input/keyboard/matrix_keypad.c @@ -27,9 +27,10 @@ struct matrix_keypad { const struct matrix_keypad_platform_data *pdata; struct input_dev *input_dev; unsigned int row_shift; - unsigned int row_irqs[MATRIX_MAX_ROWS]; - DECLARE_BITMAP(disabled_gpios, MATRIX_MAX_ROWS); + unsigned int row_irqs[MATRIX_MAX_ROWS]; + unsigned int num_row_irqs; + DECLARE_BITMAP(wakeup_enabled_irqs, MATRIX_MAX_ROWS); uint32_t last_key_state[MATRIX_MAX_COLS]; struct delayed_work work; @@ -86,28 +87,18 @@ static bool row_asserted(const struct matrix_keypad_platform_data *pdata, static void enable_row_irqs(struct matrix_keypad *keypad) { - const struct matrix_keypad_platform_data *pdata = keypad->pdata; int i; - if (pdata->clustered_irq > 0) - enable_irq(pdata->clustered_irq); - else { - for (i = 0; i < pdata->num_row_gpios; i++) - enable_irq(keypad->row_irqs[i]); - } + for (i = 0; i < keypad->num_row_irqs; i++) + enable_irq(keypad->row_irqs[i]); } static void disable_row_irqs(struct matrix_keypad *keypad) { - const struct matrix_keypad_platform_data *pdata = keypad->pdata; int i; - if (pdata->clustered_irq > 0) - disable_irq_nosync(pdata->clustered_irq); - else { - for (i = 0; i < pdata->num_row_gpios; i++) - disable_irq_nosync(keypad->row_irqs[i]); - } + for (i = 0; i < keypad->num_row_irqs; i++) + disable_irq_nosync(keypad->row_irqs[i]); } /* @@ -233,35 +224,20 @@ static void matrix_keypad_stop(struct input_dev *dev) static void matrix_keypad_enable_wakeup(struct matrix_keypad *keypad) { - const struct matrix_keypad_platform_data *pdata = keypad->pdata; int i; - if (pdata->clustered_irq > 0) { - if (enable_irq_wake(pdata->clustered_irq) == 0) - keypad->gpio_all_disabled = true; - } else { - - for (i = 0; i < pdata->num_row_gpios; i++) - if (!test_bit(i, keypad->disabled_gpios)) - if (enable_irq_wake(keypad->row_irqs[i]) == 0) - __set_bit(i, keypad->disabled_gpios); - } + for_each_clear_bit(i, keypad->wakeup_enabled_irqs, keypad->num_row_irqs) + if (enable_irq_wake(keypad->row_irqs[i]) == 0) + __set_bit(i, keypad->wakeup_enabled_irqs); } static void matrix_keypad_disable_wakeup(struct matrix_keypad *keypad) { - const struct matrix_keypad_platform_data *pdata = keypad->pdata; int i; - if (pdata->clustered_irq > 0) { - if (keypad->gpio_all_disabled) { - disable_irq_wake(pdata->clustered_irq); - keypad->gpio_all_disabled = false; - } - } else { - for (i = 0; i < pdata->num_row_gpios; i++) - if (test_and_clear_bit(i, keypad->disabled_gpios)) - disable_irq_wake(keypad->row_irqs[i]); + for_each_set_bit(i, keypad->wakeup_enabled_irqs, keypad->num_row_irqs) { + disable_irq_wake(keypad->row_irqs[i]); + __clear_bit(i, keypad->wakeup_enabled_irqs); } } @@ -335,6 +311,9 @@ static int matrix_keypad_init_gpio(struct platform_device *pdev, "Unable to acquire clustered interrupt\n"); goto err_free_rows; } + + keypad->row_irqs[0] = pdata->clustered_irq; + keypad->num_row_irqs = 1; } else { for (i = 0; i < pdata->num_row_gpios; i++) { irq = gpio_to_irq(pdata->row_gpios[i]); @@ -360,6 +339,8 @@ static int matrix_keypad_init_gpio(struct platform_device *pdev, keypad->row_irqs[i] = irq; } + + keypad->num_row_irqs = pdata->num_row_gpios; } /* initialized as disabled - enabled by input->open */ @@ -386,12 +367,8 @@ static void matrix_keypad_free_gpio(struct matrix_keypad *keypad) const struct matrix_keypad_platform_data *pdata = keypad->pdata; int i; - if (pdata->clustered_irq > 0) { - free_irq(pdata->clustered_irq, keypad); - } else { - for (i = 0; i < pdata->num_row_gpios; i++) - free_irq(keypad->row_irqs[i], keypad); - } + for (i = 0; i < keypad->num_row_irqs; i++) + free_irq(keypad->row_irqs[i], keypad); for (i = 0; i < pdata->num_row_gpios; i++) gpio_free(pdata->row_gpios[i]); -- 2.43.0.429.g432eaa2c6b-goog