Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4689571pxk; Wed, 30 Sep 2020 09:11:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgSXMKArjgFJWGFHVRtMwbWizJ1O6JQsgHckZ4Uifbsw0Wm0AsvHfTOzpVWguZ70RRzij7 X-Received: by 2002:a50:d94d:: with SMTP id u13mr3416807edj.365.1601482290794; Wed, 30 Sep 2020 09:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601482290; cv=none; d=google.com; s=arc-20160816; b=04ZGtQCbEAswpzYEGjf++dnhr2nv4tuyIByealPqod+8DYBSS+ugVgO7co/faS+9Ha AE5E/8OVGIT3jgPVtNoWfO9SsO8SgZL2crmBhe/s/iEEGV0zGBRgsQ7DO65hTETzmEtl mDSehMMm5+jaIQ89wbWdvjQzja8gcBaGzxsuy1WpcVP1LcPyVa31LldqdXmQXFgB+WgO HkLVPfrjWK4lNQMxfFcjNgSuZTcxbDqSuwVuvgX3p3PzydXmXNp4hSazv7qVe2Ce975F fjPCTuwT4wKmIbCTEGCDUhzun1Cnd/C4rWzAoGBPYFoxK5wr3tr84LuebnEi7z5Bp5Dl 71Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=4gz7hftu8wVBoM2xjJ8sNgXbJ69uPZrDK6qSgjMFO8I=; b=cgdaoyZCy+4YmwSWk0qq9zGIQnMB0ROcaN7Cyp825JU8dqJKRDLDWnpPS2V4+3uhZD rHgmBo4S0sPAkGhkeXwGi9Lna32nCQic2d1Ovt5nY7RryBVBmyvpdjRdrQB0aYJfE+OJ f6HEHEEP4aNx0EbDhc+o7rPRRAU5rwSjxpl6cJYrN8qh6kIGZJpanRdzykuKzDLO4nQN OXosvzEk32bJpwkA+lRim4Bz8Z2hcRndVouZhSlqVKH4+Irq45v5T5ExF8Hg/whPenRf RGuTBR4bAVNz2+vunjZnvV4/6H/dGpemWMnOmW613vjvO4JYPU5xQ2gWys2zDZhoOtCi MlmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hFSzWCe1; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p13si1307944edx.248.2020.09.30.09.11.06; Wed, 30 Sep 2020 09:11:30 -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=@gmail.com header.s=20161025 header.b=hFSzWCe1; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731252AbgI3QGl (ORCPT + 99 others); Wed, 30 Sep 2020 12:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbgI3QGa (ORCPT ); Wed, 30 Sep 2020 12:06:30 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78FA9C0613D0; Wed, 30 Sep 2020 09:06:30 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id c2so2054280ljj.12; Wed, 30 Sep 2020 09:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=4gz7hftu8wVBoM2xjJ8sNgXbJ69uPZrDK6qSgjMFO8I=; b=hFSzWCe1t/zf7VGo+FfqCZaoM/N2qY5YJVjPZrrragCSJ0GCR0wNhhr5u/xxo/tWTm NcgaqdHrXLERvv4almzK8/pq914nCnSiudPKBqkHHqSe5YmKUiPKLgOEH0UcpRMjCFZb ILpPyXIxobmb6CVlCLhWwB7qqDGBUvb6JmMV9CAfQ8latiICicceLFFrr/LSRbOFnBRz fOEFHGDu8XTrH+lUko8EgIv8aFEW/Me6673r1OR1PgGNtbQm4UguXXS6kdioPrTVUAdf v/OrZzPNbiiJ9bU22qt8XjdjfTed+eqe4P/3N/dqANE+FAYkrC93UjbEOKWIKopWSYXv DOnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4gz7hftu8wVBoM2xjJ8sNgXbJ69uPZrDK6qSgjMFO8I=; b=EKh6H6KYcep+kEOpo+1Kno3IM3FG3SaF9GqwgpihhOkPE/L7DtvhSuFm9skgIULn+P C9vzbMT1943szrYF+f5F5DoH9zDkhH13hDSjbSm/9evKomY8FrjG6wUHZi4RiEkliDyS h55Ha9KfcouRGfpsPeVbrEP3DyHNHpxmg/boWX4AGme4wVq4NrfI+DsTSX6FnzbR97Tk HIKyfREupvsOYrEPNF3lQAppdabsGzyneVdowzEcl+Sc6w4V2TKVkyEDeyMaWNBWaVMS HAG910UEfGcdF9Eg0AeCYdhlygGJZEyFj+f6bMt03jGI2Cck1XVudY3bwzaUHkAXtrVQ NGQw== X-Gm-Message-State: AOAM532Ga+1phTTIqdmZC3nMIZGeNGerzi4wYElVnT5gss/TsbHm1fTv AkpHLNInlBse1vNeB3YmMloIyBoA6Pc= X-Received: by 2002:a2e:3511:: with SMTP id z17mr1000169ljz.58.1601481988722; Wed, 30 Sep 2020 09:06:28 -0700 (PDT) Received: from [192.168.2.145] (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.googlemail.com with ESMTPSA id l4sm236175lfg.296.2020.09.30.09.06.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Sep 2020 09:06:28 -0700 (PDT) Subject: Re: [PATCH v3 1/3] memory: tegra: Add devm_tegra_get_memory_controller() To: Thierry Reding Cc: Nicolin Chen , joro@8bytes.org, krzk@kernel.org, vdumpa@nvidia.com, jonathanh@nvidia.com, linux-tegra@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20200930084258.25493-1-nicoleotsuka@gmail.com> <20200930084258.25493-2-nicoleotsuka@gmail.com> <20200930152320.GA3833404@ulmo> <20200930160355.GC3833404@ulmo> From: Dmitry Osipenko Message-ID: <839df5d6-513f-3d77-ba5f-a1afe5d0883a@gmail.com> Date: Wed, 30 Sep 2020 19:06:27 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200930160355.GC3833404@ulmo> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 30.09.2020 19:03, Thierry Reding пишет: > On Wed, Sep 30, 2020 at 06:53:06PM +0300, Dmitry Osipenko wrote: >> 30.09.2020 18:23, Thierry Reding пишет: >>> On Wed, Sep 30, 2020 at 01:42:56AM -0700, Nicolin Chen wrote: >>>> From: Dmitry Osipenko >>>> >>>> Multiple Tegra drivers need to retrieve Memory Controller and hence there >>>> is quite some duplication of the retrieval code among the drivers. Let's >>>> add a new common helper for the retrieval of the MC. >>>> >>>> Signed-off-by: Dmitry Osipenko >>>> Signed-off-by: Nicolin Chen >>>> --- >>>> >>>> Changelog >>>> v2->v3: >>>> * Replaced with Dimtry's devm_tegra_get_memory_controller() >>>> v1->v2: >>>> * N/A >>>> >>>> drivers/memory/tegra/mc.c | 39 +++++++++++++++++++++++++++++++++++++++ >>>> include/soc/tegra/mc.h | 17 +++++++++++++++++ >>>> 2 files changed, 56 insertions(+) >>> >>> Let's not add this helper, please. If a device needs a reference to the >>> memory controller, it should have a phandle to the memory controller in >>> device tree so that it can be looked up explicitly. >>> >>> Adding this helper is officially sanctioning that it's okay not to have >>> that reference and that's a bad idea. >> >> And please explain why it's a bad idea, I don't see anything bad here at >> all. > > Well, you said yourself in a recent comment that we should avoid global > variables. devm_tegra_get_memory_controller() is nothing but a glorified > global variable. This is not a variable, but a common helper function which will remove the duplicated code and will help to avoid common mistakes like a missed put_device().