From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (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 3EC552F52 for ; Fri, 29 Apr 2022 23:31:17 +0000 (UTC) Received: by mail-pg1-f170.google.com with SMTP id q12so7554953pgj.13 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=KNfvQ8eFDwW8Vu0LA6xVWn9DdeNQ59WCgJpNjwjzYMdmdx1e97y7zQD57lnPPrCJpe 5Y5eVEM1bw49UL22PMvhdF4iiNcf/DS487+YvST4nT7ah4oTW/C1MD9IGO6ZWHI+QA9G 1AYMrYrKiUIGLXYZUcpwIELWMXoD+9KEW11urGrAqsbYl5ONTxxkRBqgs+Svi7xmsr02 8YMO9nsnvL8gkGL0kYtkP8FTevagGVC2SrT8hMJCdqR4lXum+wgBtYMbkHMWu1G0kVrC QdxFRUMyh/zOILeEw628gmg0vPTABF+2b/1sFHpH0xm3t3icdw6w1+OeJdqjfQ2zPJAi o9/g== X-Gm-Message-State: AOAM531zeIH8H65Oykbmf8q0Y24V+NcLnb0voYHzM/KIWZaYuxXFT4uz loVTh11CIdvBSUZ+QEhpw5c+mA== 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: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 -- https://chromeos.dev