linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH 21/22] Input: tsc2004/5 - use device core to create driver-specific device attributes
Date: Fri, 28 Jul 2023 17:51:30 -0700	[thread overview]
Message-ID: <20230729005133.1095051-21-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20230729005133.1095051-1-dmitry.torokhov@gmail.com>

Instead of creating driver-specific device attributes with
sysfs_create_group() have device core do this by setting up dev_groups
pointer in the driver structure.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/touchscreen/tsc2004.c      |  7 ++++---
 drivers/input/touchscreen/tsc2005.c      |  7 ++++---
 drivers/input/touchscreen/tsc200x-core.c | 18 +++++++-----------
 drivers/input/touchscreen/tsc200x-core.h |  1 +
 4 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/drivers/input/touchscreen/tsc2004.c b/drivers/input/touchscreen/tsc2004.c
index b5e904c5b7c4..89c5248f66f6 100644
--- a/drivers/input/touchscreen/tsc2004.c
+++ b/drivers/input/touchscreen/tsc2004.c
@@ -63,9 +63,10 @@ MODULE_DEVICE_TABLE(of, tsc2004_of_match);
 
 static struct i2c_driver tsc2004_driver = {
 	.driver = {
-		.name   = "tsc2004",
-		.of_match_table = of_match_ptr(tsc2004_of_match),
-		.pm     = pm_sleep_ptr(&tsc200x_pm_ops),
+		.name		= "tsc2004",
+		.dev_groups	= tsc200x_groups,
+		.of_match_table	= of_match_ptr(tsc2004_of_match),
+		.pm		= pm_sleep_ptr(&tsc200x_pm_ops),
 	},
 	.id_table       = tsc2004_idtable,
 	.probe          = tsc2004_probe,
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index b6dfbcfc8c19..1b40ce0ca1b9 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -79,9 +79,10 @@ MODULE_DEVICE_TABLE(of, tsc2005_of_match);
 
 static struct spi_driver tsc2005_driver = {
 	.driver	= {
-		.name	= "tsc2005",
-		.of_match_table = of_match_ptr(tsc2005_of_match),
-		.pm	= pm_sleep_ptr(&tsc200x_pm_ops),
+		.name		= "tsc2005",
+		.dev_groups	= tsc200x_groups,
+		.of_match_table	= of_match_ptr(tsc2005_of_match),
+		.pm		= pm_sleep_ptr(&tsc200x_pm_ops),
 	},
 	.probe	= tsc2005_probe,
 	.remove	= tsc2005_remove,
diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c
index b799f26fcf8f..a4c0e9db9bb9 100644
--- a/drivers/input/touchscreen/tsc200x-core.c
+++ b/drivers/input/touchscreen/tsc200x-core.c
@@ -356,6 +356,12 @@ static const struct attribute_group tsc200x_attr_group = {
 	.attrs		= tsc200x_attrs,
 };
 
+const struct attribute_group *tsc200x_groups[] = {
+	&tsc200x_attr_group,
+	NULL
+};
+EXPORT_SYMBOL_GPL(tsc200x_groups);
+
 static void tsc200x_esd_work(struct work_struct *work)
 {
 	struct tsc200x *ts = container_of(work, struct tsc200x, esd_work.work);
@@ -553,25 +559,17 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
 		return error;
 
 	dev_set_drvdata(dev, ts);
-	error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group);
-	if (error) {
-		dev_err(dev,
-			"Failed to create sysfs attributes, err: %d\n", error);
-		goto disable_regulator;
-	}
 
 	error = input_register_device(ts->idev);
 	if (error) {
 		dev_err(dev,
 			"Failed to register input device, err: %d\n", error);
-		goto err_remove_sysfs;
+		goto disable_regulator;
 	}
 
 	irq_set_irq_wake(irq, 1);
 	return 0;
 
-err_remove_sysfs:
-	sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
 disable_regulator:
 	regulator_disable(ts->vio);
 	return error;
@@ -582,8 +580,6 @@ void tsc200x_remove(struct device *dev)
 {
 	struct tsc200x *ts = dev_get_drvdata(dev);
 
-	sysfs_remove_group(&dev->kobj, &tsc200x_attr_group);
-
 	regulator_disable(ts->vio);
 }
 EXPORT_SYMBOL_GPL(tsc200x_remove);
diff --git a/drivers/input/touchscreen/tsc200x-core.h b/drivers/input/touchscreen/tsc200x-core.h
index 4ded34425b21..37de91efd78e 100644
--- a/drivers/input/touchscreen/tsc200x-core.h
+++ b/drivers/input/touchscreen/tsc200x-core.h
@@ -70,6 +70,7 @@
 
 extern const struct regmap_config tsc200x_regmap_config;
 extern const struct dev_pm_ops tsc200x_pm_ops;
+extern const struct attribute_group *tsc200x_groups[];
 
 int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
 		  struct regmap *regmap,
-- 
2.41.0.487.g6d72f3e995-goog


  parent reply	other threads:[~2023-07-29  0:54 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-29  0:51 [PATCH 01/22] Input: cros_ec_keyb - use device core to create driver-specific device attributes Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 02/22] Input: cyapa " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 03/22] Input: iqs269a " Dmitry Torokhov
2023-07-31 15:41   ` Jeff LaBundy
2023-08-02 13:01   ` Mattijs Korpershoek
2023-07-29  0:51 ` [PATCH 04/22] Input: kxtj9 " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 05/22] Input: ad7877 " Dmitry Torokhov
2023-07-31  5:23   ` Hennerich, Michael
2023-07-29  0:51 ` [PATCH 06/22] Input: ad7879 " Dmitry Torokhov
2023-07-31  5:23   ` Hennerich, Michael
2023-07-29  0:51 ` [PATCH 07/22] Input: ads7846 " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 08/22] Input: edt-ft5x06 " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 09/22] Input: elants_i2c " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 10/22] Input: exc3000 " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 11/22] Input: hideep " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 12/22] Input: hycon-hy46xx " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 13/22] Input: ili210x " Dmitry Torokhov
2023-07-29 15:07   ` Marek Vasut
2023-07-30 11:38     ` Greg Kroah-Hartman
2023-07-30 12:24       ` Marek Vasut
2023-07-29  0:51 ` [PATCH 14/22] Input: ilitek_ts_i2c " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 15/22] Input: iqs5xx " Dmitry Torokhov
2023-07-31 15:43   ` Jeff LaBundy
2023-07-29  0:51 ` [PATCH 16/22] Input: melfas-mip4 " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 17/22] Input: raydium_i2c_ts " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 18/22] Input: rohm_bu21023 " Dmitry Torokhov
2023-07-29  0:51 ` [PATCH 19/22] Input: s6sy761 " Dmitry Torokhov
2023-07-30 13:02   ` Andi Shyti
2023-07-29  0:51 ` [PATCH 20/22] Input: stmfts " Dmitry Torokhov
2023-07-30 13:02   ` Andi Shyti
2023-07-29  0:51 ` Dmitry Torokhov [this message]
2023-07-29  0:51 ` [PATCH 22/22] Input: wdt87xx_i2c " Dmitry Torokhov
2023-07-29  2:40 ` [PATCH 01/22] Input: cros_ec_keyb " Guenter Roeck
2023-07-30 11:39 ` Greg Kroah-Hartman

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=20230729005133.1095051-21-dmitry.torokhov@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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).