Linux Documentation
 help / color / mirror / Atom feed
From: Stefan Gloor <code@stefan-gloor.ch>
To: Guenter Roeck <linux@roeck-us.net>
Cc: jdelvare@suse.com, corbet@lwn.net, linux-hwmon@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/1] hwmon: (sht3x) read out sensor serial number
Date: Mon, 1 Jan 2024 23:18:21 +0100	[thread overview]
Message-ID: <20240101221448.wtwn23vgeptgs36v@thinkpad> (raw)
In-Reply-To: <4389cd48-5d61-49bc-8cb5-b337afe40c23@roeck-us.net>

On Sun, Dec 31, 2023 at 10:32:56AM -0800, Guenter Roeck wrote:
> This creates i2c<bus>-<address>/serial_number when the device is instantiated.
> That debugfs entry is not removed when the device is removed, only when the
> driver is unloaded. This means that de-instantiating the device will leave
> stray debugfs directories and files behind until the driver is unloaded.
> 
> We had this before, and I understand that you claimed that this doesn't happen.
> To get me to believe you, you'll have to provide a log of
> 
> - instantiating the driver 
> - Showing the debufs tree
> - de-instantiating the driver
> - Showing the debugfs tree
> 
> ... but even then I'll want to be able to test it myself. Not sure if I
> have an eval board, but either case that will take some time. Frankly,
> I don't understand why you refuse to remove
> i2c<bus>-<address>/serial_number on device removal.
> 
> Guenter
> 

Hi Guenter,

Thank you for your patience. As this is my first patch set for Linux I still
need to learn a lot.

You are right. I was confused about driver instantiation and driver
loading/unloading. The i2cX-XX directory needs to be removed explicitly.

If I understood correctly, the following changes should achieve this:

+static void sht3x_remove(struct i2c_client *client)
+{
+	struct sht3x_data *data;
+
+	data = dev_get_drvdata(&client->dev);
+	debugfs_remove_recursive(data->sensor_dir);
+}
+
 static struct i2c_driver sht3x_i2c_driver = {
 	.driver.name = "sht3x",
 	.probe       = sht3x_probe,
+	.remove      = sht3x_remove,
 	.id_table    = sht3x_ids,
 };

Of course data->sensor_dir needs to be set to the i2X-XX directory when it is
created.

If there is nothing obviously wrong with it I'll submit v4 shortly.

Best,
Stefan

  reply	other threads:[~2024-01-01 22:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-27 19:00 [PATCH v3 0/1] hwmon: (sht3x) read out sensor serial number Stefan Gloor
2023-12-27 19:00 ` [PATCH v3 1/1] " Stefan Gloor
2023-12-31 18:32   ` Guenter Roeck
2024-01-01 22:18     ` Stefan Gloor [this message]
2024-01-02 16:39       ` Guenter Roeck

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=20240101221448.wtwn23vgeptgs36v@thinkpad \
    --to=code@stefan-gloor.ch \
    --cc=corbet@lwn.net \
    --cc=jdelvare@suse.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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