Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1685459ybh; Fri, 13 Mar 2020 05:43:05 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvIVBvzpOhHBX8k2mYSaMO5oP+bkVQnewS44IylXgUcx/4CHcMNC7YmbYtVIkjokX8aBpCZ X-Received: by 2002:a05:6830:60e:: with SMTP id w14mr3965098oti.22.1584103385628; Fri, 13 Mar 2020 05:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584103385; cv=none; d=google.com; s=arc-20160816; b=voD8ZIWI3TvKEhD6K4ao30BbQaYZD1lXzbHyBhr/zQwU89FBK1f/OKpCEQnScSIx87 sEOFycokUOMPn/5I3hMG+hhVehBbI+h9vmWt8Se0vh/EYaaVfaRH+xbjC5W4Q0hsUIF8 uWy9qSdKQWc07BHUv4xWF8vLOc6fejj7yOB4h+BfwslgUQncwrQYeN3t+mPp0U1nA+tY 6h73zvHipnRJx/AaaQuexCdxhRpwM1DSkCYI1BUgYuz+0cjQeOoEsmZN+qJBV/RDQFDG ul/sTpnkaYrDa1LcWIw7gGxY05KAHs4YoDloVR/qQ6HSqJmcQBhSuU5wyTewB8rfUJKQ LBbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from; bh=DjcTqtFGBsfB5GR4ct8O5EvuQjS+6RX5PL+arz4vf7M=; b=fqqNsEOTjsCtkMOAKeT+LxMDRAX8R08MCy1A8DIf7/NwtDBZqTEIJzXtHDe03xNFVi 1P7ACwWq+CxerTC2pgVnVfYRm+z01nCbmM018XfnRpYjAyrWZuoe8xrvI5DpBFewLrKM JS5jn12FI3WuM3n6OIJAgHrGiBwAztIfQoRma0CyjNrhwNJL6LWajdIfaybNAVPvxBIZ N33MOfbyEtqDWM+PbN0G5ZOVzRHGKF+BxivOnFIdVomZTlPaY45vWFrVUJLogFjKiCwr EnehIaVr79hH7jF7OcQtrnWvX/b/mWozFfXYDz07Ue5aXTzDG7vi4gQh7AomUaXtSsZW dKmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l15si731074oil.50.2020.03.13.05.42.53; Fri, 13 Mar 2020 05:43:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbgCMMlZ (ORCPT + 99 others); Fri, 13 Mar 2020 08:41:25 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:53264 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbgCMMlZ (ORCPT ); Fri, 13 Mar 2020 08:41:25 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 905C727E99E From: Enric Balletbo i Serra Subject: Re: [PATCH 1/3] platform/chrome: notify: Add driver data struct To: Prashant Malani , linux-kernel@vger.kernel.org Cc: furquan@chromium.org, Benson Leung References: <20200312100809.21153-1-pmalani@chromium.org> <20200312100809.21153-2-pmalani@chromium.org> Message-ID: <06d90fc3-c792-b85f-c4aa-923c5a7f5eea@collabora.com> Date: Fri, 13 Mar 2020 13:41:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200312100809.21153-2-pmalani@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prashant, On 12/3/20 11:08, Prashant Malani wrote: > Introduce a device driver data structure, cros_usbpd_notify_data, in > which we can store the notifier block object and pointers to the struct > cros_ec_device and struct device objects. > > This will make it more convenient to access these pointers when > executing both platform and ACPI callbacks. > > While we are here, also add a dev_info print declaring successful device > registration at the end of the platform probe function. > This info can be obtained by other means, i.e function tracing or initcall_debug. There is no need to repeat the same explicitly in the driver. > Signed-off-by: Prashant Malani > --- > drivers/platform/chrome/cros_usbpd_notify.c | 30 ++++++++++++++------- > 1 file changed, 21 insertions(+), 9 deletions(-) > > diff --git a/drivers/platform/chrome/cros_usbpd_notify.c b/drivers/platform/chrome/cros_usbpd_notify.c > index 3851bbd6e9a39..edcb346024b07 100644 > --- a/drivers/platform/chrome/cros_usbpd_notify.c > +++ b/drivers/platform/chrome/cros_usbpd_notify.c > @@ -16,6 +16,12 @@ > > static BLOCKING_NOTIFIER_HEAD(cros_usbpd_notifier_list); > > +struct cros_usbpd_notify_data { > + struct device *dev; > + struct cros_ec_device *ec; > + struct notifier_block nb; > +}; > + > /** > * cros_usbpd_register_notify - Register a notifier callback for PD events. > * @nb: Notifier block pointer to register > @@ -98,23 +104,28 @@ static int cros_usbpd_notify_probe_plat(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > struct cros_ec_dev *ecdev = dev_get_drvdata(dev->parent); > - struct notifier_block *nb; > + struct cros_usbpd_notify_data *pdnotify; > int ret; > > - nb = devm_kzalloc(dev, sizeof(*nb), GFP_KERNEL); > - if (!nb) > + pdnotify = devm_kzalloc(dev, sizeof(*pdnotify), GFP_KERNEL); > + if (!pdnotify) > return -ENOMEM; > > - nb->notifier_call = cros_usbpd_notify_plat; > - dev_set_drvdata(dev, nb); > + pdnotify->dev = dev; > + pdnotify->ec = ecdev->ec_dev; > + pdnotify->nb.notifier_call = cros_usbpd_notify_plat; > + > + dev_set_drvdata(dev, pdnotify); > > ret = blocking_notifier_chain_register(&ecdev->ec_dev->event_notifier, > - nb); > + &pdnotify->nb); > if (ret < 0) { > dev_err(dev, "Failed to register notifier\n"); > return ret; > } > > + dev_info(dev, "Chrome EC PD notify device registered.\n"); > + This is only noise to the kernel log, remove it. > return 0; > } > > @@ -122,10 +133,11 @@ static int cros_usbpd_notify_remove_plat(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > struct cros_ec_dev *ecdev = dev_get_drvdata(dev->parent); > - struct notifier_block *nb = > - (struct notifier_block *)dev_get_drvdata(dev); > + struct cros_usbpd_notify_data *pdnotify = > + (struct cros_usbpd_notify_data *)dev_get_drvdata(dev); > > - blocking_notifier_chain_unregister(&ecdev->ec_dev->event_notifier, nb); > + blocking_notifier_chain_unregister(&ecdev->ec_dev->event_notifier, > + &pdnotify->nb); > > return 0; > } >