From nobody Sun Feb 8 18:24:31 2026 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 42E1B217709 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=1736425284; cv=none; b=BUa4YxEBrkoYgyl2VF1CWAXqymptj8UV9skGZeWBRVhXDmHkd7eUFlKi5ETEOqI1MquVpxWWcFn6rE2KXyhM1Ps0vd9Fj/0SryPFc5AX6MBRux9C5Gq7gGHu8CdZL8usB5CM3kaKEq2s5Ablfm/t6MFrYXtjAIWqqmkrMcY8YCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736425284; c=relaxed/simple; bh=Vl7aEibJYyHLkU899tI+Ja6Fj2+G/QAcR+0T3tzOPX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nnjO3tMlJv9FV2C8JiptoOHNMaRy4WdgAoIq7qC041voECYjSb70pZl2MrB1MxBi3lwkg70iE23nQBIBdY4M1dBsJyZB6O4S4movFRKiYCRctKI8RQj8fcaKf3xAo21CZsJjMItcDJunQjIHm6d1chJWNl1kJOSGOa2hPMmiQkM= 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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, struc= t i2c_board_info const *inf if (status) goto out_remove_swnode; =20 + client->debugfs =3D debugfs_create_dir(dev_name(&client->dev), adap->debu= gfs); + dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n", client->name, dev_name(&client->dev)); =20 @@ -1058,6 +1060,8 @@ void i2c_unregister_device(struct i2c_client *client) =20 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) =20 --=20 2.45.2 From nobody Sun Feb 8 18:24:31 2026 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 DDAEC217701 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=1736425285; cv=none; b=HxgtXvuk6RDZ0N/bUt9H0QquCbjBzTcy9k9SnA0izm/WfZLrtwwpCioHyPxHT1m9VvKX+RXEttAINCf34fSR8oEJfwix0TtCgrGI90DgpnAj8FsXDSjdKh2y3VvpoSzgGGOfi4whkwkn1AYXaDis74QN9RG5RrePsE0gY1nLI3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736425285; c=relaxed/simple; bh=s6iLSMvwvB1hhEvSbVmgChnOY8FBYiVDdEUfiaRKLus=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZBdPP+Ye2oOEApxMJy7HUOFCmWzu09Im/tWfCvUCyyxLs3xiLazLy3TJqNWEuPq2t0s8fPuw7PGVs4z4YyZGftYoadaX7EO2Y7lLfXtmY/bqcZ4C4KTFJLkArAkj/vMSYIEXHiQbFuVUsjs54x6rScwdEOQhQ3l09IZniATqET4= 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=20Spie=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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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, v= oid *unused) } DEFINE_SHOW_ATTRIBUTE(shunt_voltage); =20 -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 isl280= 22_data *data) -{ - char name[16]; - struct dentry *debugfs; - - scnprintf(name, sizeof(name), "%d-%04hx", client->adapter->nr, client->ad= dr); - - debugfs =3D 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; =20 - isl28022_debugfs_init(client, data); + debugfs_create_file("shunt_voltage", 0444, client->debugfs, data, &shunt_= voltage_fops); =20 hwmon_dev =3D devm_hwmon_device_register_with_info(dev, client->name, data, &isl28022_chip_info, NULL); @@ -505,27 +485,7 @@ static struct i2c_driver isl28022_driver =3D { .probe =3D isl28022_probe, .id_table =3D isl28022_ids, }; - -static int __init isl28022_init(void) -{ - int err; - - isl28022_debugfs_root =3D debugfs_create_dir("isl28022", NULL); - err =3D 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); =20 MODULE_AUTHOR("Carsten Spie=C3=9F "); MODULE_DESCRIPTION("ISL28022 driver"); --=20 2.45.2