From patchwork Mon Aug 19 04:58:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8AD82C3DA4A for ; Mon, 19 Aug 2024 05:07:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nUndIWERZKRj9I2TwNCsJPKiHZoV4U6VZkZuTz/CWC4=; b=p644sifmjr2Q5AHDpr/yblyM0Y AaxBHCw6nz62yBz0Qth1e2eo3RqEVncIZisLMWNGt+MqkziIrsGP/h+M2jV7ji4vng9T5m9X4bPDn vSsN5YDBZuKxiaZSng63qhUMAmSi31ZlkqpkIGaEl+SGb0hUYSJgCgS7lb4hnGmis0fI9tQaDgfII 05i5Bp896ClD5TL9OT5S6HszI19RkmSu91FqBV7ubsOekOyYEcnExl8WXoWEz4WgV9YzPtp/B8hT4 9L7AL+tWC+r3Y+KTGbHRL57CklCNXDYpe/oDy/KQC9/UDWLDy6tKwDYlO4PZWvIk5ZXZLYDq264U0 +aZTyZLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfubg-00000000Nig-0LxE; Mon, 19 Aug 2024 05:07:04 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTZ-00000000Lal-0tUy for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:42 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-20230059241so4338035ad.3 for ; Sun, 18 Aug 2024 21:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043520; x=1724648320; darn=lists.infradead.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=nUndIWERZKRj9I2TwNCsJPKiHZoV4U6VZkZuTz/CWC4=; b=kLLDNC7lkyFG5LWNtceHiYGG1P5WM6ReaVeUv8pwE8BrMTe53wb5oPJKoIjVC2rnZ7 my3d2sHWG4J0DwgCy8AZlogp5DhMYypCerhL6lh+tufcCLOSN/1olid5e8mHyO94lnDN oIyfn7jWp1leEUNtdC4RTFqK+qe6VgD2kmBH5HWiCtuMnjaBPthPqlbbsdlN7vbhN2Ls 4kdD9O1QDD3IW7YsYgrqKMoKL5rukT3EBEv4IOBLfz/yeGidgaZt6XGWOBaQ0yYw3ucU ffw4VAhA0WjDn0cqjiKOBzvJ4TCGI7iGOx8yozjkg4RfNU7lw8V5FuecLqYS+gLUyRTi uBCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043520; x=1724648320; 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=nUndIWERZKRj9I2TwNCsJPKiHZoV4U6VZkZuTz/CWC4=; b=A511WuWNPQ3CWOtMBjiir10PcEDwMWCEMZ0GT1QinaUFsWACZaXo862p4Uez57teqp na1Q9dlAYDxwF/OdJrYrRziauYu4rIH42P3pPJb3+c4eAhm2hEdjYOspQQimaeIQsftL Nq9PqKt6yDhJfIV/d6e2rbWuQmaoibc5D332zeYo6m5cB4M+UrEtUVCy/axLDHRd4/gW IyuaWLfGZe7g2lZWHyWqJHNZSge+PElpt+yOAS0JoYeMyCX6XlHQ624HOnvlZG4QoSR1 C3B0cUKlG75UVzg38DOVPdCjPyxDJLEh28ljDeNyqQ7zpdTP8924SLevXAjdGBFYO4K1 Yxfw== X-Forwarded-Encrypted: i=1; AJvYcCWbTBza8QP2R1oAhFk1Auo+Mh+jruYGNZNkslD+fVen/35AxuMJED/bzAmNukI58nJtslUe9+B7cSkFcSz/TrilnOfVsrHTkb22WIz2chPafywsjtU= X-Gm-Message-State: AOJu0YyQNK/E/qNRS5ACLRr9mcUK6QK9mWaKoX/63T9SS5pHkxwwY96u XeIMCf/G/9N7dJiuos6tp62bKmTRNmp70iNG4o9yrjY7KBCgsP75 X-Google-Smtp-Source: AGHT+IE8wP1IODXwo9Jr5pjb8LD7AgNjePF3eWo7XxmUYWOTaK20CLj2D3LT7nPWl3GEhcIqE16bMA== X-Received: by 2002:a17:902:d10b:b0:1fb:6d12:2c1c with SMTP id d9443c01a7336-20203e9b06emr68765385ad.19.1724043520237; Sun, 18 Aug 2024 21:58:40 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:39 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 12/14] Input: samsung-keypad - remove support for platform data Date: Sun, 18 Aug 2024 21:58:09 -0700 Message-ID: <20240819045813.2154642-13-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215841_306249_1634D99F X-CRM114-Status: GOOD ( 30.69 ) 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 Because there are no more users of samsung_keypad_platdata left in the kernel remove support for it from the driver. The driver supports generic device properties so all configuration should be done using them instead of a custom platform data. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/samsung-keypad.c | 190 +++++++++--------------- include/linux/input/samsung-keypad.h | 39 ----- 2 files changed, 70 insertions(+), 159 deletions(-) delete mode 100644 include/linux/input/samsung-keypad.h diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index df2427ac63d7..78fa55498fc3 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -21,7 +22,9 @@ #include #include #include -#include + +#define SAMSUNG_MAX_ROWS 8 +#define SAMSUNG_MAX_COLS 8 #define SAMSUNG_KEYIFCON 0x00 #define SAMSUNG_KEYIFSTSCLR 0x04 @@ -231,84 +234,43 @@ static void samsung_keypad_close(struct input_dev *input_dev) samsung_keypad_stop(keypad); } -static const struct matrix_keymap_data * -samsung_parse_verbose_keymap(struct device *dev) +static int samsung_keypad_parse_keymap(struct samsung_keypad *keypad) { - struct matrix_keymap_data *keymap_data; + struct matrix_keymap_data keymap_data = { 0 }; + struct device *dev = &keypad->pdev->dev; struct fwnode_handle *child; u32 *keymap; unsigned int key_count; - - keymap_data = devm_kzalloc(dev, sizeof(*keymap_data), GFP_KERNEL); - if (!keymap_data) { - dev_err(dev, "could not allocate memory for keymap data\n"); - return ERR_PTR(-ENOMEM); - } + int retval; key_count = device_get_child_node_count(dev); - keymap = devm_kcalloc(dev, key_count, sizeof(*keymap), GFP_KERNEL); - if (!keymap) { - dev_err(dev, "could not allocate memory for keymap\n"); - return ERR_PTR(-ENOMEM); - } - - keymap_data->keymap_size = key_count; - keymap_data->keymap = keymap; - - device_for_each_child_node(dev, child) { - u32 row, col, key_code; - - fwnode_property_read_u32(child, "keypad,row", &row); - fwnode_property_read_u32(child, "keypad,column", &col); - fwnode_property_read_u32(child, "linux,code", &key_code); - - *keymap++ = KEY(row, col, key_code); - } - - return keymap_data; -} - -static const struct samsung_keypad_platdata * -samsung_keypad_parse_properties(struct device *dev) -{ - const struct matrix_keymap_data *keymap_data; - struct samsung_keypad_platdata *pdata; - u32 num_rows = 0, num_cols = 0; - int error; + if (key_count) { + keymap = kcalloc(key_count, sizeof(*keymap), GFP_KERNEL); + if (!keymap) { + dev_err(dev, "could not allocate memory for keymap\n"); + return -ENOMEM; + } - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) { - dev_err(dev, "could not allocate memory for platform data\n"); - return ERR_PTR(-ENOMEM); - } + keymap_data.keymap = keymap; + keymap_data.keymap_size = key_count; - device_property_read_u32(dev, "samsung,keypad-num-rows", &num_rows); - device_property_read_u32(dev, "samsung,keypad-num-columns", &num_cols); + device_for_each_child_node(dev, child) { + u32 row, col, key_code; - error = matrix_keypad_parse_properties(dev, &num_rows, &num_cols); - if (error) - return ERR_PTR(error); + fwnode_property_read_u32(child, "keypad,row", &row); + fwnode_property_read_u32(child, "keypad,column", &col); + fwnode_property_read_u32(child, "linux,code", &key_code); - pdata->rows = num_rows; - pdata->cols = num_cols; - - if (!device_property_present(dev, "linux,keymap")) { - keymap_data = samsung_parse_verbose_keymap(dev); - if (IS_ERR(keymap_data)) - return ERR_CAST(keymap_data); - - pdata->keymap_data = keymap_data; + *keymap++ = KEY(row, col, key_code); + } } - - pdata->no_autorepeat = - device_property_read_bool(dev, "linux,input-no-autorepeat"); - - pdata->wakeup = device_property_read_bool(dev, "wakeup-source") || - /* legacy name */ - device_property_read_bool(dev, "linux,input-wakeup"); - - return pdata; + retval = matrix_keypad_build_keymap(key_count ? &keymap_data : NULL, + NULL, keypad->rows, keypad->cols, + keypad->keycodes, + keypad->input_dev); + kfree(keymap_data.keymap); + return retval; } static void samsung_disable_runtime_pm(void *data) @@ -320,68 +282,39 @@ static void samsung_disable_runtime_pm(void *data) static int samsung_keypad_probe(struct platform_device *pdev) { - const struct samsung_keypad_platdata *pdata; const struct platform_device_id *id; + struct device *dev = &pdev->dev; struct samsung_keypad *keypad; struct resource *res; struct input_dev *input_dev; unsigned int row_shift; + u32 num_rows = 0, num_cols = 0; + bool wakeup; int error; - pdata = dev_get_platdata(&pdev->dev); - if (pdata) { - if (!pdata->keymap_data) { - dev_err(&pdev->dev, "no keymap data defined\n"); - return -EINVAL; - } - } else { - pdata = samsung_keypad_parse_properties(&pdev->dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - } + device_property_read_u32(dev, "samsung,keypad-num-rows", &num_rows); + device_property_read_u32(dev, "samsung,keypad-num-columns", &num_cols); - if (!pdata->rows || pdata->rows > SAMSUNG_MAX_ROWS) - return -EINVAL; + error = matrix_keypad_parse_properties(dev, &num_rows, &num_cols); + if (error) + return error; - if (!pdata->cols || pdata->cols > SAMSUNG_MAX_COLS) + if (num_rows > SAMSUNG_MAX_ROWS || num_cols > SAMSUNG_MAX_COLS) return -EINVAL; - /* initialize the gpio */ - if (pdata->cfg_gpio) - pdata->cfg_gpio(pdata->rows, pdata->cols); - - row_shift = get_count_order(pdata->cols); + row_shift = get_count_order(num_cols); keypad = devm_kzalloc(&pdev->dev, struct_size(keypad, keycodes, - pdata->rows << row_shift), + num_rows << row_shift), GFP_KERNEL); if (!keypad) return -ENOMEM; - input_dev = devm_input_allocate_device(&pdev->dev); - if (!input_dev) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -ENODEV; - - keypad->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); - if (!keypad->base) - return -EBUSY; - - keypad->clk = devm_clk_get_prepared(&pdev->dev, "keypad"); - if (IS_ERR(keypad->clk)) { - dev_err(&pdev->dev, "failed to get keypad clk\n"); - return PTR_ERR(keypad->clk); - } - - keypad->input_dev = input_dev; keypad->pdev = pdev; keypad->row_shift = row_shift; - keypad->rows = pdata->rows; - keypad->cols = pdata->cols; + keypad->rows = num_rows; + keypad->cols = num_cols; keypad->stopped = true; init_waitqueue_head(&keypad->wait); @@ -397,26 +330,45 @@ static int samsung_keypad_probe(struct platform_device *pdev) return -EINVAL; } + input_dev = devm_input_allocate_device(&pdev->dev); + if (!input_dev) + return -ENOMEM; + + keypad->input_dev = input_dev; + input_dev->name = pdev->name; input_dev->id.bustype = BUS_HOST; input_dev->open = samsung_keypad_open; input_dev->close = samsung_keypad_close; - error = matrix_keypad_build_keymap(pdata->keymap_data, NULL, - pdata->rows, pdata->cols, - keypad->keycodes, input_dev); + error = samsung_keypad_parse_keymap(keypad); if (error) { dev_err(&pdev->dev, "failed to build keymap\n"); return error; } input_set_capability(input_dev, EV_MSC, MSC_SCAN); - if (!pdata->no_autorepeat) + + if (!device_property_read_bool(&pdev->dev, "linux,input-no-autorepeat")) __set_bit(EV_REP, input_dev->evbit); input_set_drvdata(input_dev, keypad); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -ENODEV; + + keypad->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (!keypad->base) + return -EBUSY; + + keypad->clk = devm_clk_get_prepared(&pdev->dev, "keypad"); + if (IS_ERR(keypad->clk)) { + dev_err(&pdev->dev, "failed to get keypad clk\n"); + return PTR_ERR(keypad->clk); + } + keypad->irq = platform_get_irq(pdev, 0); if (keypad->irq < 0) { error = keypad->irq; @@ -431,7 +383,11 @@ static int samsung_keypad_probe(struct platform_device *pdev) return error; } - device_init_wakeup(&pdev->dev, pdata->wakeup); + wakeup = device_property_read_bool(dev, "wakeup-source") || + /* legacy name */ + device_property_read_bool(dev, "linux,input-wakeup"); + device_init_wakeup(&pdev->dev, wakeup); + platform_set_drvdata(pdev, keypad); pm_runtime_enable(&pdev->dev); @@ -444,12 +400,6 @@ static int samsung_keypad_probe(struct platform_device *pdev) if (error) return error; - if (!dev_get_platdata(&pdev->dev)) { - devm_kfree(&pdev->dev, (void *)pdata->keymap_data->keymap); - devm_kfree(&pdev->dev, (void *)pdata->keymap_data); - devm_kfree(&pdev->dev, (void *)pdata); - } - return 0; } diff --git a/include/linux/input/samsung-keypad.h b/include/linux/input/samsung-keypad.h deleted file mode 100644 index ab6b97114c08..000000000000 --- a/include/linux/input/samsung-keypad.h +++ /dev/null @@ -1,39 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Samsung Keypad platform data definitions - * - * Copyright (C) 2010 Samsung Electronics Co.Ltd - * Author: Joonyoung Shim - */ - -#ifndef __SAMSUNG_KEYPAD_H -#define __SAMSUNG_KEYPAD_H - -#include - -#define SAMSUNG_MAX_ROWS 8 -#define SAMSUNG_MAX_COLS 8 - -/** - * struct samsung_keypad_platdata - Platform device data for Samsung Keypad. - * @keymap_data: pointer to &matrix_keymap_data. - * @rows: number of keypad row supported. - * @cols: number of keypad col supported. - * @no_autorepeat: disable key autorepeat. - * @wakeup: controls whether the device should be set up as wakeup source. - * @cfg_gpio: configure the GPIO. - * - * Initialisation data specific to either the machine or the platform - * for the device driver to use or call-back when configuring gpio. - */ -struct samsung_keypad_platdata { - const struct matrix_keymap_data *keymap_data; - unsigned int rows; - unsigned int cols; - bool no_autorepeat; - bool wakeup; - - void (*cfg_gpio)(unsigned int rows, unsigned int cols); -}; - -#endif /* __SAMSUNG_KEYPAD_H */