lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 11 Dec 2023 07:28:18 -0800
From:   Guenter Roeck <linux@...ck-us.net>
To:     Stefan Gloor <code@...fan-gloor.ch>
Cc:     jdelvare@...e.com, corbet@....net, linux-hwmon@...r.kernel.org,
        linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] hwmon: sht3x: read out sensor serial number

On 12/11/23 07:12, Stefan Gloor wrote:
> On Mon, Dec 11, 2023 at 06:31:27AM -0800, Guenter Roeck wrote:
>> On Mon, Dec 04, 2023 at 05:50:04PM +0100, Stefan Gloor wrote:
>>>   
>>> +#ifdef CONFIG_DEBUG_FS
>>> +
>>> +static void sht3x_debugfs_init(struct sht3x_data *data)
>>> +{
>>> +	char name[32];
>>> +	struct dentry *sensor_dir;
>>> +
>>> +	data->debugfs = debugfs_lookup("sht3x", NULL);
>>> +	if (IS_ERR_OR_NULL(data->debugfs))
>>> +		data->debugfs = debugfs_create_dir("sht3x", NULL);
>>> +
>>> +	snprintf(name, sizeof(name), "i2c%u-%02x",
>>> +		 data->client->adapter->nr, data->client->addr);
>>> +	sensor_dir = debugfs_create_dir(name, data->debugfs);
>>> +	debugfs_create_u32("serial_number", 0444,
>>> +			   sensor_dir, &data->serial_number);
>>> +}
>>> +
>>> +#else
>>> +
>>> +static void sht3x_debugfs_init(struct sht3x_data *data)
>>> +{
>>> +}
>>> +
>>> +#endif
>>
>> debugfs doesn't need if/else or error handling.
>>
> Do you mean the IS_ERR_OR_NULL? I included that to get rid of the
> "debugfs directory already exists" message when using multiple sensors.
> 

A much easier way to do that would be to create the directory in the init function,
and to use a static variable to point to it. Note that you'll also need need an
explicit exit function to remove it when the driver is unloaded.

Thanks,
Guenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ