From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x224Enf/6B8ELvvtQuJkf02JJMcdABZdCQaWIl00bioeTRUQ+JzPyGKkdcZYe4AfF/isIiM0X ARC-Seal: i=1; a=rsa-sha256; t=1516704723; cv=none; d=google.com; s=arc-20160816; b=olNCepZtsgxn1f0BaHd1OadCzbdz1Q2doOlTQSFGL7G7PfCkyR7tGlAz2kURqGzFml 95thNjtSKZoXxsx4DjuwfwybkC3wqU3YmJY3l+1yW0Ldj3qraS+cRpyIVQofub+kkS5E d07IwYasaugdlvy64jdyPGOSVkXzNbe5130QnA1c3Y8Q2Jtd6QXssBhXUTxQIyHojakr T5Cm2bao+OaWkwQWfgaFFKbffBiELPCBMoI6iF6d1msbEhrF1iwT0PKCoLqS7w27drKV 5Gh0PWS6c0qAhLw8SsUwxwAt8Lz2c/vJGTprCV2Bn8mQmD67Yfv1Arj40aloNs4RwYG1 sjQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:references:to:subject:arc-authentication-results; bh=8eUcZvuUZUVC1DJSskVnrpCAGqa4YKysg8EjGH1uDzw=; b=mSCtJPchBAduuDGerDKY8VPnXKjCKwxZBFXXSrfPz2CuIqQRM9LPpnlhK7gbUeeerb 7Sdtps4Wa1MP0/+6Vw2X+DKmfZqzJ1cFhcmrmq1ABeCs4JCYx56ufhZ9drbLmbF8hi84 xUG40fy7tq/7RlQxyEZPZQ+Qv/XcCe/ii9l5MQI/1Dh4V18bDKOkv7o/85TBwGgF15+Z jgoiIGXONaFY+ha49bcREsIt7fUO3IVfR+HkqucIB2duOYubN/XsJ0E0ud02x4Njd4RU yCQd5g+yqz+rM/rLOHPCkE34BzCk5NSw57gwYwDt/n9BBq/TYtgCIznqIZqjUyE9sc+o FlpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of xieyisheng1@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=xieyisheng1@huawei.com Authentication-Results: mx.google.com; spf=pass (google.com: domain of xieyisheng1@huawei.com designates 45.249.212.32 as permitted sender) smtp.mailfrom=xieyisheng1@huawei.com Subject: Re: [PATCH v5] devres: combine function devm_ioremap* To: Greg KH References: <1516104221-32710-1-git-send-email-xieyisheng1@huawei.com> <20180123084233.GD21463@kroah.com> CC: , , From: Yisheng Xie Message-ID: <0c667e07-af75-323a-38c3-69e6c8a2819f@huawei.com> Date: Tue, 23 Jan 2018 18:50:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <20180123084233.GD21463@kroah.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1589751067753367425?= X-GMAIL-MSGID: =?utf-8?q?1590380172161753607?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On 2018/1/23 16:42, Greg KH wrote: > On Tue, Jan 16, 2018 at 08:03:41PM +0800, Yisheng Xie wrote: >> When I tried to use devm_ioremap function and review related >> code, I found devm_ioremap_* almost have the similar realize >> with each other, which can be combined. >> >> In the former version, I have tried to kill ioremap_cache to >> reduce the size of devres, which can not work for ioremap is >> not the same as ioremap_nocache in some ARCHs likes ia64. >> Therefore, as the suggestion of Christophe, I introduce a help >> function __devm_ioremap, let devm_ioremap* inline and call >> __devm_ioremap with different devm_ioremap_type. >> >> After apply the patch, the size of devres.o can be reduce from >> 8216 Bytes to 7352Bytes in my compile environment. >> >> Suggested-by: Christophe LEROY >> Signed-off-by: Yisheng Xie >> --- >> v2: >> - use MARCO for ioremap >> v3: >> - kill dev_ioremap_nocache >> v4: >> - combine function devm_ioremap* >> v5: >> - fix code style. >> >> include/linux/io.h | 61 +++++++++++++++++++++++++++++++++++---- >> lib/devres.c | 84 ++++++++++-------------------------------------------- >> 2 files changed, 70 insertions(+), 75 deletions(-) >> >> diff --git a/include/linux/io.h b/include/linux/io.h >> index 32e30e8..4d0a640 100644 >> --- a/include/linux/io.h >> +++ b/include/linux/io.h >> @@ -73,12 +73,61 @@ static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr) >> >> #define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err) >> >> -void __iomem *devm_ioremap(struct device *dev, resource_size_t offset, >> - resource_size_t size); >> -void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset, >> - resource_size_t size); >> -void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset, >> - resource_size_t size); >> +enum devm_ioremap_type { >> + DEVM_IOREMAP = 0, >> + DEVM_IOREMAP_NC, >> + DEVM_IOREMAP_WC, >> +}; > > Why do these types need to be in a public .h file? > > Why not just keep the .h file as-is and then just put the cleanup in the > .c file like you did? > Right. I was just trying to inline these functions. Anyway, I will follow your suggestion. Sorry for sending so many versions. Thanks Yisheng > thanks, > > greg k-h > > . >