From patchwork Fri Apr 29 23:31:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 12832989 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 434963D60 for ; Fri, 29 Apr 2022 23:31:17 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id g8so5701984pfh.5 for ; Fri, 29 Apr 2022 16:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kWF9sCGDLZUK2sgoEIyeIZNot5TI6mJu4iu2/5YFEbs=; b=I4ZrQ02qj5Y2kq+RsM7F/x4rltUPs85PI2jsCeDO07YWMOe6ICw4kN17iLW+muuqND 2bWJtIApxcoKrH7Rg0IB1waVaa3UXApFafxIED0m+uPDHTF/qJAhg5tYHoAsW/JXVomS IxQh1fKEWGgxxaxu1B9nw7vg8ahhN4fv107mQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kWF9sCGDLZUK2sgoEIyeIZNot5TI6mJu4iu2/5YFEbs=; b=KOZi1InuMmTk4qJPPNrPfV3TfFpKfPcbZpN4uTBIoLGL80DzGonap35DRA1qxlLJgX uzlp/QrUJ3obHKlzUi0V/jJYg++BTt1E13dVG8rl/iXOPxMzctxq6QJ5kts5odH+dzXO hBLFCwb8x/vjYToWVXO8zpr9uuHIpF6Y9HQ6mOzaLNgz5ktFhi2LoCcjAYxY7YBJ7lv/ gcMr/Av3WFzJ8k3fL59/eKC9wTkObb5vuXel3UuX2RGisIVT6AfE6mG34arPPLUOACqd YjTgsmKGTR1k/+gcgM6pdOM8zGkP7HINjs77f3ckrcPZDUlKiXuTSEjqTJ9DB8ulNQFs metA== X-Gm-Message-State: AOAM530LipZcT5B9KalYvl1vCOOmaVGlYyyyzzJDv+k8VgTvejG20cAD SWMdTPCgUEn174vqQ3Op8QCywg== X-Google-Smtp-Source: ABdhPJxVK4eELgvKjci8XyIkVF5wrZqTYg/voZE1BMP5wikFWF4v/Rp0TQ1AOSdMffDPdkjReT+NiA== X-Received: by 2002:a05:6a00:24ce:b0:50d:c14b:b655 with SMTP id d14-20020a056a0024ce00b0050dc14bb655mr1240258pfv.57.1651275076720; Fri, 29 Apr 2022 16:31:16 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:201:5172:14b3:3687:1fb0]) by smtp.gmail.com with ESMTPSA id i24-20020aa78b58000000b0050dc762818esm223037pfd.104.2022.04.29.16.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 16:31:16 -0700 (PDT) From: Stephen Boyd To: Dmitry Torokhov Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, chrome-platform@lists.linux.dev, Krzysztof Kozlowski , Rob Herring , devicetree@vger.kernel.org, Benson Leung , Guenter Roeck , Douglas Anderson , Hsin-Yi Wang , "Joseph S. Barrera III" Subject: [PATCH v2 2/2] Input: cros-ec-keyb - skip keyboard registration for switches compatible Date: Fri, 29 Apr 2022 16:31:12 -0700 Message-Id: <20220429233112.2851665-3-swboyd@chromium.org> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog In-Reply-To: <20220429233112.2851665-1-swboyd@chromium.org> References: <20220429233112.2851665-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In commit 4352e23a7ff2 ("Input: cros-ec-keyb - only register keyboard if rows/columns exist") we skipped registration of the keyboard if the row/columns property didn't exist, but that has a slight problem for existing DTBs. The DTBs have the rows/columns properties, so removing the properties to indicate only switches exist makes this keyboard driver fail to probe, resulting in broken power and volume buttons. Ease the migration of existing DTBs by skipping keyboard registration if the google,cros-ec-keyb-switches compatible exists. The end result is that new DTBs can either choose to remove the matrix keymap properties or leave them in place and add this new compatible indicating the matrix keyboard properties should be ignored. Existing DTBs will continue to work, but they will keep registering the keyboard that does nothing. To fix that problem we can add this extra compatible to existing DTBs and the keyboard will stop being registered. Finally, if google,cros-ec-keyb is missing then this driver won't even attempt to register the matrix keyboard. Cc: Krzysztof Kozlowski Cc: Rob Herring Cc: Cc: Benson Leung Cc: Guenter Roeck Cc: Douglas Anderson Cc: Hsin-Yi Wang Cc: "Joseph S. Barrera III" Fixes: 4352e23a7ff2 ("Input: cros-ec-keyb - only register keyboard if rows/columns exist") Signed-off-by: Stephen Boyd --- drivers/input/keyboard/cros_ec_keyb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c index eef909e52e23..1bbe2987bf52 100644 --- a/drivers/input/keyboard/cros_ec_keyb.c +++ b/drivers/input/keyboard/cros_ec_keyb.c @@ -536,6 +536,12 @@ static int cros_ec_keyb_register_matrix(struct cros_ec_keyb *ckdev) u32 *physmap; u32 key_pos; unsigned int row, col, scancode, n_physmap; + bool register_keyboard; + + /* Skip matrix registration if no keyboard */ + register_keyboard = device_get_match_data(dev); + if (!register_keyboard) + return 0; /* * No rows and columns? There isn't a matrix but maybe there are @@ -718,8 +724,13 @@ static int cros_ec_keyb_remove(struct platform_device *pdev) #ifdef CONFIG_OF static const struct of_device_id cros_ec_keyb_of_match[] = { - { .compatible = "google,cros-ec-keyb" }, - {}, + { + /* Must be first */ + .compatible = "google,cros-ec-keyb", + .data = (void *)true + }, + { .compatible = "google,cros-ec-keyb-switches" }, + {} }; MODULE_DEVICE_TABLE(of, cros_ec_keyb_of_match); #endif