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:Do you mean the IS_ERR_OR_NULL? I included that to get rid of the
+#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.
"debugfs directory already exists" message when using multiple sensors.