Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Stefan Gloor <code@stefan-gloor.ch>
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: Tue, 2 Jan 2024 08:39:32 -0800	[thread overview]
Message-ID: <0946e7cc-e054-4e94-85e6-1db88ea925dd@roeck-us.net> (raw)
In-Reply-To: <20240101221448.wtwn23vgeptgs36v@thinkpad>

On Mon, Jan 01, 2024 at 11:18:21PM +0100, Stefan Gloor wrote:
> 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.
> 

This is correct. I personally would prefer the use of devm_add_action_or_reset()
instead of a remove function, but the above works as well. Make sure though
that debugfs_remove_recursive() is also called if hwmon registration fails.

Thanks,
Guenter

      reply	other threads:[~2024-01-02 16:39 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
2024-01-02 16:39       ` Guenter Roeck [this message]

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=0946e7cc-e054-4e94-85e6-1db88ea925dd@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=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 \
    /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