Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4148536pxf; Mon, 29 Mar 2021 23:51:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBvIZHHapnCT162ojRRTgV3E5B7LXMqc5FziQ704dqDJHcKCKaio2gvSLg1PrTgHrJHC/c X-Received: by 2002:aa7:d588:: with SMTP id r8mr31824030edq.88.1617087105208; Mon, 29 Mar 2021 23:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617087105; cv=none; d=google.com; s=arc-20160816; b=IQLTYY4O08j/EiXnZECnE/qvllFbWKZu69IhQWvUyMDXWVYC+UzzIjdQV2gnO2dfXi xQOxneRObDohNInavY6EqbHPhsPEoYr5X2f83QKKcWzDtdHvHoTma1UHXMQHmJCBZPOA NnuTKHnSvheG33FWXRPeMXltcnPxSeu8NcgwdM+dNGu11c4v6m1ztOTbfHYixH5xZ/A+ OMBw4Gi7BM1eDLyu+QlSnYkNJyUXU7bMenBPO4IBZ2GUdzb78jLUfyvxPG0CfUdQtb2c FbCozLMGfb+jqwQAbK389qXT51FhxqS9aauEtwnAs9zZDDJY20nVlP0GITy/u86FJOzP JGpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tf2KzUlyksDFUDRISHkB0sElt3B4+D1u0mtS+5lxeuA=; b=DMpM0fGID2Tsdce41D4Lgs4GOXUw3MJBGUf6RwIiKF8BBxbx3Yh4EX8V7N1nlkxRZN LGE09zNHdpsUC95qgCUAB26Br/ZBwT5D/lcIoD2RoMdnvqGhV9G4kLB44+z0hIqnXqDN DCvCydpdb308DCUm9q9DqujEzX2TWAWltyKXa9szlF+0hvnVZk9ggQayesOuUSxQMZVh y7coRuQLUMayvqykTC+cL3D9H7exQf1pcsJVjOAdIrTn2PwLpdD5MBQG8+Utu7Br3+1F SOiuG8e2uIeL8lMgJZOxpLuTeYgiZyFAmQ5xVUtB1uCtLiwnY8x2+yxblcd6mfLW2aNH qhJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=GjV6UMKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r22si14613246edy.138.2021.03.29.23.51.22; Mon, 29 Mar 2021 23:51:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=GjV6UMKO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbhC3Gty (ORCPT + 99 others); Tue, 30 Mar 2021 02:49:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230501AbhC3Gtq (ORCPT ); Tue, 30 Mar 2021 02:49:46 -0400 Received: from mail-vk1-xa2f.google.com (mail-vk1-xa2f.google.com [IPv6:2607:f8b0:4864:20::a2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8233CC061765 for ; Mon, 29 Mar 2021 23:49:46 -0700 (PDT) Received: by mail-vk1-xa2f.google.com with SMTP id k76so3324886vkk.10 for ; Mon, 29 Mar 2021 23:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tf2KzUlyksDFUDRISHkB0sElt3B4+D1u0mtS+5lxeuA=; b=GjV6UMKOXOseT3Sqr7BuWmhe6oAE3wXsIuhOD1r28O4ehqpMfZsjPzj+pfMJerPAwJ Utw1oegCbKxUG9FHhXr3Uspq2CcUWlU2miMod9GIyh2ep1YtF3oXT4BcUIt82DiPkoKH 0scxjMU6a/OkCtTMhZD4qHWxTTbipBQqwAPaZQTms5et6cTDwoMiJ9SLuHD5U8Fo+pNb 7Did25h38asg5xPJMX4ArFyV1mwqTz4vbVIKCHYaeKuM+lyCa79ck97pLOv9eAtFsGCl AVvRqqb+23eAp2s1VkRMf0CPaEZ0MOPtRZt66QLBdsY4om+r7nyUoiYFwHLEatpRd8hb aotQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tf2KzUlyksDFUDRISHkB0sElt3B4+D1u0mtS+5lxeuA=; b=CXJu0bNwez5isa3IJCfmFXgfdw1v64sn7hhNuc32LUUkUB/ue2rPb3qlbbhjUeldYz ArcYeiJ1fj3fIC10UUmgbuiE5HRmsd6kVUZQmosJnOE7xkbiaX+hBAtIhkon2mu3EuAM dfbikLTLH8YzUqLZF/GCaU9AcPPmHUWFQNGQTgYeMyjEn7FRgM+IKl6VgS6NnZ+wcI0x /6gz5lGcQl5tA1y5yyRYCdglIVn/l3XF9dR3z6I1uN9pdj/L5onEWpnNLYAPebrjcr+0 9vMZxrn/98Y5j4MzBI6aH0Mf/DfP6OshXkuwtvCtV8DajCN6QW5rFSQvawE4iRvsKuWw XeZA== X-Gm-Message-State: AOAM5337cmFWnPP1utPXntNiJmrIeqfXsxSodcoS/1R7i3sLJTylXAUw +yx/XK1nYS2GYPL88J8PlVgowksel1WvkJDBpjDkQQ== X-Received: by 2002:a1f:18c9:: with SMTP id 192mr17037924vky.11.1617086985525; Mon, 29 Mar 2021 23:49:45 -0700 (PDT) MIME-Version: 1.0 References: <20210324125548.45983-1-aardelean@deviqon.com> <20210324125548.45983-2-aardelean@deviqon.com> <20210329153047.57904ab4@jic23-huawei> In-Reply-To: <20210329153047.57904ab4@jic23-huawei> From: Alexandru Ardelean Date: Tue, 30 Mar 2021 09:49:34 +0300 Message-ID: Subject: Re: [PATCH 01/10] platform/x86: toshiba_acpi: bind life-time of toshiba_acpi_dev to parent To: Jonathan Cameron Cc: platform-driver-x86@vger.kernel.org, Linux Kernel Mailing List , linux-iio@vger.kernel.org, coproscefalo@gmail.com, hdegoede@redhat.com, mgross@linux.intel.com, linux@deviqon.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 29 Mar 2021 at 17:30, Jonathan Cameron wrote: > > On Wed, 24 Mar 2021 14:55:39 +0200 > Alexandru Ardelean wrote: > > > 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 > > Might just be me, but naming anything dev that isn't a struct device * > is downright confusing? > I found it a bit odd as well, but I decided to not take it in consideration for now. > > > > > --- > > 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; > > } > > >