Re: [PATCH v2 4/7] i2c: i2c-core-acpi: Add i2c_acpi_dev_name()

From
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date
2021-01-18 13:45:27
Also in
linux-acpi, linux-gpio, lkml, platform-driver-x86
Reply to
Laurent Pinchart, 2021-01-18
On Mon, Jan 18, 2021 at 11:18:55AM +0200, Laurent Pinchart wrote:
On Mon, Jan 18, 2021 at 12:34:25AM +0000, Daniel Scally wrote:
...
quoted
+/**
+ * i2c_acpi_dev_name - Construct i2c device name for devs sourced from ACPI
+ * @adev:     ACPI device to construct the name for
+ *
+ * Constructs the name of an i2c device matching the format used by
+ * i2c_dev_set_name() to allow users to refer to an i2c device by name even
+ * before they have been instantiated.
+ *
+ * The caller is responsible for freeing the returned pointer.
+ */
+char *i2c_acpi_dev_name(struct acpi_device *adev)
+{
+	return kasprintf(GFP_KERNEL, I2C_DEV_NAME_FORMAT, acpi_dev_name(adev));
There's a real danger of a memory leak, as the function name sounds very
similar to dev_name() or acpi_dev_name() and those don't allocate
memory. I'm not sure what a better name would be, but given that this
function is only used in patch 6/7 and not in the I2C subsystem itself,
I wonder if we should inline this kasprintf() call in the caller and
drop this patch.
Dan, I'm fine with either choice.
quoted
+}
-- 
With Best Regards,
Andy Shevchenko

Thread (98 messages) 98 messages, 11 authors, last reply 2021-02-07
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help