From patchwork Thu Jan 9 12:21:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13932462 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42EE7217712 for ; Thu, 9 Jan 2025 12:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736425285; cv=none; b=szeFyqhb951ioWoYNhfDOncCH6XJtfxjRy1vkf5xlsC0zA1w+8+BxH9r76Cvg+cPr+6UyCRG/4JidqccOMt749oHriyFn+GokK/HowDn5YF6BK9mBJ+ZzGvP4XCslt5ELnn2qe4aoO/LSfjrZjXj5ua5nlzFlpcDIPcfKIoTIYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736425285; c=relaxed/simple; bh=Vl7aEibJYyHLkU899tI+Ja6Fj2+G/QAcR+0T3tzOPX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mjF6Nh8X9JEm8yT9zvoS5jOfuBdaXzxRyj84fKyoogbR60GHxDfJqBVOr7p4+rlE0JtdqI2B1uvgjn6aGG9Jiut2b4Kw5Mn+RqH5o5tcFsPAO3XeMg+4AfDAsDn1stBqfcyVB3LOrsrPIiKN9sKaDR3iPvtbdfQhyiu0xIPXuyg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=E6q4n0IW; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="E6q4n0IW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=454BCUBzqC7PUbBBGcyFvNB53HXu7K7rZZdfoXl0+O8=; b=E6q4n0 IWnculoAFt/x8iGBeWHC/UIcrvh+ohKaFokm/f3iXehbBnFIqhyw+3e3lgFxg4w/ LrvYW/2+mLAKNZY23ro5GBQn/acP9Tp1vKbh2bAmmpx9qXWjcm/nFoRuP7xLXk9K sLnky8bvUF7IEEIAj5j7fwMwesNWYX34h7Ev+AnEs6ekHXM6xCZDFdPvP+DF/SX+ pl0MKK3osrxW1P6EF54AaHQ6vhNRCcW19q2ZZGVBwximetC+vPZflc5a1qICFnHD nRsMP35GMPJf81RlXpsuhcepalwhJnZZEDtbhQ4aS0ipFAbSoWVUurfx3loT/9/B oZLFGbcbViOOD3KA== Received: (qmail 2902248 invoked from network); 9 Jan 2025 13:21:18 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 9 Jan 2025 13:21:18 +0100 X-UD-Smtp-Session: l3s3148p1@kuHdA0UrZr0gAwDPXw20AOMQ2KO98fSH From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Guenter Roeck , linux-kernel@vger.kernel.org, Wolfram Sang , linux-i2c@vger.kernel.org Subject: [PATCH 1/2] i2c: add core-managed per-client directory in debugfs Date: Thu, 9 Jan 2025 13:21:10 +0100 Message-ID: <20250109122112.45810-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250109122112.45810-1-wsa+renesas@sang-engineering.com> References: <20250109122112.45810-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 More and more I2C client drivers use debugfs entries and currently they need to manage a subdir for their files on their own. This means inconsistent naming for these subdirs and they are scattered all over the debugfs-tree as well. Not to mention the duplicated code. Let the I2C core provide and maintain a proper directory per client. Note: It was considered to save the additional pointer in 'struct i2c_client' and only provide a subdir when requested via a helper function. When sketching this approach, more and more corner cases appeared, though, so the current solution with its simple and unabiguous code was chosen. Signed-off-by: Wolfram Sang Reviewed-by: Guenter Roeck --- drivers/i2c/i2c-core-base.c | 4 ++++ include/linux/i2c.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index b072030a9105..00f171ebc01f 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1015,6 +1015,8 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf if (status) goto out_remove_swnode; + client->debugfs = debugfs_create_dir(dev_name(&client->dev), adap->debugfs); + dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n", client->name, dev_name(&client->dev)); @@ -1058,6 +1060,8 @@ void i2c_unregister_device(struct i2c_client *client) if (ACPI_COMPANION(&client->dev)) acpi_device_clear_enumerated(ACPI_COMPANION(&client->dev)); + + debugfs_remove_recursive(client->debugfs); device_remove_software_node(&client->dev); device_unregister(&client->dev); } diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 66fb3d6cf686..36de788dc7fe 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -347,6 +347,7 @@ struct i2c_client { i2c_slave_cb_t slave_cb; /* callback for slave mode */ #endif void *devres_group_id; /* ID of probe devres group */ + struct dentry *debugfs; /* per-client debugfs dir */ }; #define to_i2c_client(d) container_of(d, struct i2c_client, dev) From patchwork Thu Jan 9 12:21:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 13932461 X-Patchwork-Delegate: geert@linux-m68k.org Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDA88216E20 for ; Thu, 9 Jan 2025 12:21:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736425284; cv=none; b=Ev1EyDnoJtf6erjP292ITXm93EWQGGPteYXXUYw0UgveAo2jwRBy7GcQ0Xs950DcQalPKY3s6nCxTBX5k1riUSq0JwXe+DEKr5HBKmciWBH5WAcbaHq8mlRj8zARUROn8fWXExc4DgWWQjstnfroJHbfs+UAA5pr9B45NurOhe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736425284; c=relaxed/simple; bh=s6iLSMvwvB1hhEvSbVmgChnOY8FBYiVDdEUfiaRKLus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KCp5gacUHAW9Sc1gOJVt+w6Wcn5IYJM1nEEpNuuBiDL7h1B6Ouwt/gjQUk4V0BYQ3FlizztrheZj1PFWnt3OYiTTsE+BfvYZKgn7GxpN4LRAjfHDgd7Xp81VDNiX25xxZOqAdFF7q/th7XCqGCd/3a8XjriKkDCEcXfW3h4R2SQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=fQJ+UXAk; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="fQJ+UXAk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding; s=k1; bh=Wvj0OmgUBbiythAxDaHZcyRy7Ax S3rfnwX3CjJNEV/c=; b=fQJ+UXAkul0JhNsbZfeiSYTu2E3mPjb4X8LGkNLfC53 QImYkAZoHXjeL4dYRg1TpMEYhS+rHnd4bBFqBhfImp/H2HvJsm1KB8FZYbmqiE/c p36oK62jv9nBnYarowVnITjPkFi+3tJXmV9I3yrKAOZQTaX2ubOl6Ar4rLVVQ2OA nNuprrEZ/VSDyUvqAURfI9ITD21uiw4xu0reMeQjZZjArbhcU4jKXWS8jN6LDvIt 3HkH0ZykU6KSFBhAGmkIZl4HxTeCC1NDpHzvmKVHBd4E3w5RYBcfCytGmWrDe7lG D8KY8wXTDzEpo2wGYxtbkzZebi6/1W5PTy1Ln5LgTwA== Received: (qmail 2902280 invoked from network); 9 Jan 2025 13:21:18 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 9 Jan 2025 13:21:18 +0100 X-UD-Smtp-Session: l3s3148p1@ePvpA0UraL0gAwDPXw20AOMQ2KO98fSH From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Guenter Roeck , linux-kernel@vger.kernel.org, Wolfram Sang , =?utf-8?q?Carsten_Spie?= =?utf-8?q?=C3=9F?= , Jean Delvare , linux-hwmon@vger.kernel.org Subject: [PATCH 2/2] hwmon: (isl28022) Use per-client debugfs entry Date: Thu, 9 Jan 2025 13:21:11 +0100 Message-ID: <20250109122112.45810-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250109122112.45810-1-wsa+renesas@sang-engineering.com> References: <20250109122112.45810-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The I2C core now offers a debugfs-directory per client. Use it and remove the custom handling. Signed-off-by: Wolfram Sang Reviewed-by: Guenter Roeck --- drivers/hwmon/isl28022.c | 44 ++-------------------------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/drivers/hwmon/isl28022.c b/drivers/hwmon/isl28022.c index 3f9b4520b53e..1fb9864635db 100644 --- a/drivers/hwmon/isl28022.c +++ b/drivers/hwmon/isl28022.c @@ -324,26 +324,6 @@ static int shunt_voltage_show(struct seq_file *seqf, void *unused) } DEFINE_SHOW_ATTRIBUTE(shunt_voltage); -static struct dentry *isl28022_debugfs_root; - -static void isl28022_debugfs_remove(void *res) -{ - debugfs_remove_recursive(res); -} - -static void isl28022_debugfs_init(struct i2c_client *client, struct isl28022_data *data) -{ - char name[16]; - struct dentry *debugfs; - - scnprintf(name, sizeof(name), "%d-%04hx", client->adapter->nr, client->addr); - - debugfs = debugfs_create_dir(name, isl28022_debugfs_root); - debugfs_create_file("shunt_voltage", 0444, debugfs, data, &shunt_voltage_fops); - - devm_add_action_or_reset(&client->dev, isl28022_debugfs_remove, debugfs); -} - /* * read property values and make consistency checks. * @@ -475,7 +455,7 @@ static int isl28022_probe(struct i2c_client *client) if (err) return err; - isl28022_debugfs_init(client, data); + debugfs_create_file("shunt_voltage", 0444, client->debugfs, data, &shunt_voltage_fops); hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, data, &isl28022_chip_info, NULL); @@ -505,27 +485,7 @@ static struct i2c_driver isl28022_driver = { .probe = isl28022_probe, .id_table = isl28022_ids, }; - -static int __init isl28022_init(void) -{ - int err; - - isl28022_debugfs_root = debugfs_create_dir("isl28022", NULL); - err = i2c_add_driver(&isl28022_driver); - if (!err) - return 0; - - debugfs_remove_recursive(isl28022_debugfs_root); - return err; -} -module_init(isl28022_init); - -static void __exit isl28022_exit(void) -{ - i2c_del_driver(&isl28022_driver); - debugfs_remove_recursive(isl28022_debugfs_root); -} -module_exit(isl28022_exit); +module_i2c_driver(isl28022_driver); MODULE_AUTHOR("Carsten Spieß "); MODULE_DESCRIPTION("ISL28022 driver");