From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>, Mark Brown <broonie@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>
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 [thread overview]
Message-ID: <20240819045813.2154642-13-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com>
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 <dmitry.torokhov@gmail.com>
---
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 <linux/delay.h>
#include <linux/err.h>
#include <linux/input.h>
+#include <linux/input/matrix_keypad.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
@@ -21,7 +22,9 @@
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/sched.h>
-#include <linux/input/samsung-keypad.h>
+
+#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 <jy0922.shim@samsung.com>
- */
-
-#ifndef __SAMSUNG_KEYPAD_H
-#define __SAMSUNG_KEYPAD_H
-
-#include <linux/input/matrix_keypad.h>
-
-#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 */
--
2.46.0.184.g6999bdac58-goog
next prev parent reply other threads:[~2024-08-19 4:58 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 4:57 [PATCH 00/14] Remove support for platform data from samsung keypad Dmitry Torokhov
2024-08-19 4:57 ` [PATCH 01/14] Input: samsung-keypad - switch to using devm_clk_get_prepared() Dmitry Torokhov
2024-08-19 12:51 ` Krzysztof Kozlowski
2024-08-19 14:46 ` Dmitry Torokhov
2024-08-19 4:57 ` [PATCH 02/14] Input: samsung-keypad - do not set input device's parent explicitly Dmitry Torokhov
2024-08-19 12:51 ` Krzysztof Kozlowski
2024-08-19 4:58 ` [PATCH 03/14] Input: samsung-keypad - do not combine memory allocation checks Dmitry Torokhov
2024-08-19 12:52 ` Krzysztof Kozlowski
2024-08-19 4:58 ` [PATCH 04/14] Input: samsung-keypad - use struct_size() helper Dmitry Torokhov
2024-08-19 12:52 ` Krzysztof Kozlowski
2024-08-19 4:58 ` [PATCH 05/14] Input: samsung-keypad - use devm to disable runtime PM Dmitry Torokhov
2024-08-19 12:54 ` Krzysztof Kozlowski
2024-08-19 14:47 ` Dmitry Torokhov
2024-08-19 4:58 ` [PATCH 06/14] Input: samsung-keypad - use guard notation to acquire mutex Dmitry Torokhov
2024-08-22 15:48 ` Krzysztof Kozlowski
2024-08-22 18:07 ` Dmitry Torokhov
2024-08-23 6:06 ` Krzysztof Kozlowski
2024-08-23 8:32 ` Dmitry Torokhov
2024-08-23 8:52 ` Krzysztof Kozlowski
2024-08-23 15:41 ` Dmitry Torokhov
2024-08-19 4:58 ` [PATCH 07/14] Input: samsung-keypad - use per-chip parameters Dmitry Torokhov
2024-08-19 12:57 ` Krzysztof Kozlowski
2024-08-19 4:58 ` [PATCH 08/14] Input: samsung-keypad - use BIT() and GENMASK() where appropriate Dmitry Torokhov
2024-08-19 4:58 ` [PATCH 09/14] dt-bindings: input: samsung,s3c6410-keypad: introduce compact binding Dmitry Torokhov
2024-08-19 13:02 ` Krzysztof Kozlowski
2024-08-19 15:49 ` Dmitry Torokhov
2024-08-19 16:48 ` Conor Dooley
2024-08-19 17:14 ` Dmitry Torokhov
2024-08-19 4:58 ` [PATCH 10/14] Input: samsung-keypad - handle " Dmitry Torokhov
2024-08-19 4:58 ` [PATCH 11/14] ARM: s3c: crag6410: switch keypad device to software properties Dmitry Torokhov
2024-08-22 15:41 ` Krzysztof Kozlowski
2024-08-19 4:58 ` Dmitry Torokhov [this message]
2024-08-19 4:58 ` [PATCH 13/14] ARM: s3c: crag6410: use software nodes/properties to set up GPIO keys Dmitry Torokhov
2024-08-22 15:50 ` Krzysztof Kozlowski
2024-08-19 4:58 ` [PATCH 14/14] ARM: s3c: crag6410 - convert GPIO lookup tables to property entries Dmitry Torokhov
2024-08-22 15:49 ` Krzysztof Kozlowski
2024-08-19 9:40 ` [PATCH 00/14] Remove support for platform data from samsung keypad Arnd Bergmann
2024-10-04 13:38 ` Dmitry Torokhov
2024-10-04 14:58 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240819045813.2154642-13-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).