[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210324125548.45983-2-aardelean@deviqon.com>
Date: Wed, 24 Mar 2021 14:55:39 +0200
From: Alexandru Ardelean <aardelean@...iqon.com>
To: platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org
Cc: coproscefalo@...il.com, hdegoede@...hat.com,
mgross@...ux.intel.com, jic23@...nel.org, linux@...iqon.com,
Alexandru Ardelean <aardelean@...iqon.com>
Subject: [PATCH 01/10] platform/x86: toshiba_acpi: bind life-time of toshiba_acpi_dev to parent
The 'toshiba_acpi_dev' object is allocated first and free'd last. We can
bind it's life-time to the parent ACPI device object. This is a first step
in using more device-managed allocated functions for this.
The main intent is to try to convert the IIO framework to export only
device-managed functions (i.e. devm_iio_device_alloc() and
devm_iio_device_register()). It's still not 100% sure that this is
possible, but for now, this is the process of taking it slowly in that
direction.
Signed-off-by: Alexandru Ardelean <aardelean@...iqon.com>
---
drivers/platform/x86/toshiba_acpi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index fa7232ad8c39..6d298810b7bf 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -2998,8 +2998,6 @@ static int toshiba_acpi_remove(struct acpi_device *acpi_dev)
if (toshiba_acpi)
toshiba_acpi = NULL;
- kfree(dev);
-
return 0;
}
@@ -3016,6 +3014,7 @@ static const char *find_hci_method(acpi_handle handle)
static int toshiba_acpi_add(struct acpi_device *acpi_dev)
{
+ struct device *parent = &acpi_dev->dev;
struct toshiba_acpi_dev *dev;
const char *hci_method;
u32 dummy;
@@ -3033,7 +3032,7 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
return -ENODEV;
}
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ dev = devm_kzalloc(parent, sizeof(*dev), GFP_KERNEL);
if (!dev)
return -ENOMEM;
dev->acpi_dev = acpi_dev;
@@ -3045,7 +3044,6 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
ret = misc_register(&dev->miscdev);
if (ret) {
pr_err("Failed to register miscdevice\n");
- kfree(dev);
return ret;
}
--
2.30.2
Powered by blists - more mailing lists