From patchwork Tue Aug 28 09:33:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10578087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C10EE17DB for ; Tue, 28 Aug 2018 09:34:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B217E28869 for ; Tue, 28 Aug 2018 09:34:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5DDA28ABE; Tue, 28 Aug 2018 09:34:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F66B28869 for ; Tue, 28 Aug 2018 09:34:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EF606B456A; Tue, 28 Aug 2018 05:34:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8C5876B456B; Tue, 28 Aug 2018 05:34:08 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 767356B456C; Tue, 28 Aug 2018 05:34:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id 1A82B6B456A for ; Tue, 28 Aug 2018 05:34:08 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id v24-v6so882223wmh.5 for ; Tue, 28 Aug 2018 02:34:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=SVWcFbk/dVzlsS+UwHvhPxvTnIJPJG8C6MWyhlzaJP4=; b=rpv8fnMn39+teDnTLiqIr7FtifCazkcDYrsPXb6Uz8NpOd+e8MBnIojNH5TPZQXKZJ Ah27Mrs8Aa60JuNEa0Bqa5LJ94YkCbCgSMqZKm/6c3hVQOV57TFTbMULV3ELZhqS9nbs d6L+iS7wS+v8oSyKBuI+wVnj+F8EBW99OL5Djrosy48hLi+5hFnQBQinDMd9bsUqEjvR 8eW/flfm3wkPgMW5o8OVbQiGZ3YyP9rUHqomuLKZA90RIf5aJyQJlyrAZOEkVSC9PE3/ cGxhWANkYOcDPRWe77YbOYxDlA/obcTaeolLZeX4fkHcjP+sMtwD1zinIbEcKOxNR/yH KfkA== X-Gm-Message-State: APzg51AHbSmtPD89rR0l2wR3tMQeEvYQG3T3oDEeV3IMcGeoHP+n+l4V pxqg+gx9Ge9FaeCtk0I7tkVvAMQ0+0vJan1o/+659ariMjmQ91nJeBj3lauS72q1gYrzdXtfqaM Vvg94TlzpEJc17gv9yUTgwbyMpRRy2Pu5RIwkVCWQK160XlSunhwt1aaGx5MuFehN/VmV0FnohY wn8Q/zmCxKudkvGLG0Ha3nspqn2c/wp4Ipb7E/DC/+EDBU2hPB0I3ifcCJOlFjdpJc+J6o3fAO1 ZnTPaqqu/QdHgSkESckfpfoGQ3V8k87WXN2I958mos+JvSPbB51NkQPXLLKgRZ4FJQUp2pj9P0C BPcMBhWgLpKw4MVK8Sw+g8uQu9TmCJAAPSjFmshQyGVPBsMoxdjlPFCwZDe+Z+5hQPDvdkxvdGi 2 X-Received: by 2002:a1c:5f85:: with SMTP id t127-v6mr804219wmb.16.1535448847559; Tue, 28 Aug 2018 02:34:07 -0700 (PDT) X-Received: by 2002:a1c:5f85:: with SMTP id t127-v6mr804189wmb.16.1535448846796; Tue, 28 Aug 2018 02:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535448846; cv=none; d=google.com; s=arc-20160816; b=sgBAOuxfkpYWfAwuCaHbpnE0IpEpDHg/uBKXa5vFnnwzO7xHB7+5Z3Ko6C4P2i8BVT CaT3lOvE+ZVcCzxM2UVZXzL99ezNiA+EswOSr/8MY3TocKu9+JGKKeExUbPkJy4w4xcN mKqkcuzEYg7a0UDYHFXZyy9KFg1eG9gXdVEHzS7sCfi42Q9TrdKHWRfRgY5c/FSKwobF q1Jf4l4idfnugZut99DpUQDelz1ofRVyeJafCih1h1+6+Z2+bCuPfj7EvelpsI2Boi+0 +DybBl3rb4Gf4HJzKqYc4S0xlKMOlVhCJEalocX+G7UT93brwA/WI9U4aEtgEkfXn7HD x/jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=SVWcFbk/dVzlsS+UwHvhPxvTnIJPJG8C6MWyhlzaJP4=; b=zNvWQYzU7lsbtcc1p6SWsDQfFoATE/UOD1L1LBbwVSLibHUUYIUk8Jn0a/Wg8nNSJN rzLZuE8X+9VQyPY5cELngsbXEMUO2AnM1zRF6D4EQgFP0IwRTHHZpaxMcUbEQ+X6gdcf 6K3C0BRXLfiB2LLtZqEELr8nlJRzM2wZ9616dgO052tjH0uFFLGTMFE7m2sS/t81oL25 2Znit1/Fe345s4bwTGtgjYd/jF8uXOZ8YMazG7BrJPZJxGwNpCOqipEmOtRzfGpFClXQ aV72/PbRTKP0rxA+ilIia48MBkQqNvN2Q9H+D4mcqmt0ID7hFd8n64iFrZ5dcPuWVdLX zGHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=TjY7XD59; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) smtp.mailfrom=brgl@bgdev.pl Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c71-v6sor225839wmc.45.2018.08.28.02.34.06 for (Google Transport Security); Tue, 28 Aug 2018 02:34:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=TjY7XD59; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) smtp.mailfrom=brgl@bgdev.pl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SVWcFbk/dVzlsS+UwHvhPxvTnIJPJG8C6MWyhlzaJP4=; b=TjY7XD59PXtSvVirztIUG/IzfuDVWIiYSDoXxS4NQ4F2s7v5QZzehTI9rlcKQKQmHC S7Wfo/sISESMCfGCmTz8pBDEpoKRlEvMSySpNcKszz/mSeCD6r3ZYQqh7NS42cCUrTUl ohCflbE1aFg6Cg8i4w7T4tUE1hRO4ML0HDDYDXlYX3s/sM/60rqYtpraEcXbn7VFpFsI Rf13u+/Ix6L/8VCcE26REBhIMzh4gODasHflNG5XY4jsGkCfFaneUEaxxPeL1JAmVr33 4agPt2IlxFibmgO36O4hLogKoEqwoSfDEogM+joTQ4uEDhYEWBHeY58XBOHgpQLO+h8I Ngjw== X-Google-Smtp-Source: ANB0VdaV9Pzpww2Wl5G6NP9NsWTUDI9DTePHGQQs1BV4TSeNoZ3PsHOAKQ3DK7ioV0EeP/SgV6txyQ== X-Received: by 2002:a1c:b213:: with SMTP id b19-v6mr759080wmf.141.1535448846439; Tue, 28 Aug 2018 02:34:06 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id l18-v6sm952276wru.75.2018.08.28.02.34.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Aug 2018 02:34:05 -0700 (PDT) From: Bartosz Golaszewski To: Michael Turquette , Stephen Boyd , Greg Kroah-Hartman , "Rafael J . Wysocki" , Arend van Spriel , Ulf Hansson , Bjorn Helgaas , Vivek Gautam , Robin Murphy , Joe Perches , Heikki Krogerus , Andrew Morton , Mike Rapoport , Michal Hocko , Al Viro , Jonathan Corbet , Roman Gushchin , Huang Ying , Kees Cook , Bjorn Andersson , Arnd Bergmann Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Bartosz Golaszewski Subject: [PATCH v2 1/4] devres: constify p in devm_kfree() Date: Tue, 28 Aug 2018 11:33:29 +0200 Message-Id: <20180828093332.20674-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180828093332.20674-1-brgl@bgdev.pl> References: <20180828093332.20674-1-brgl@bgdev.pl> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Make devm_kfree() signature uniform with that of kfree(). To avoid compiler warnings: cast p to (void *) when calling devres_destroy(). Signed-off-by: Bartosz Golaszewski Reviewed-by: Bjorn Andersson --- drivers/base/devres.c | 5 +++-- include/linux/device.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index f98a097e73f2..438c91a43508 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -885,11 +885,12 @@ EXPORT_SYMBOL_GPL(devm_kasprintf); * * Free memory allocated with devm_kmalloc(). */ -void devm_kfree(struct device *dev, void *p) +void devm_kfree(struct device *dev, const void *p) { int rc; - rc = devres_destroy(dev, devm_kmalloc_release, devm_kmalloc_match, p); + rc = devres_destroy(dev, devm_kmalloc_release, + devm_kmalloc_match, (void *)p); WARN_ON(rc); } EXPORT_SYMBOL_GPL(devm_kfree); diff --git a/include/linux/device.h b/include/linux/device.h index 8f882549edee..33f7cb271fbb 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -692,7 +692,7 @@ static inline void *devm_kcalloc(struct device *dev, { return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO); } -extern void devm_kfree(struct device *dev, void *p); +extern void devm_kfree(struct device *dev, const void *p); extern char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc; extern void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp); From patchwork Tue Aug 28 09:33:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10578089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6F9617DB for ; Tue, 28 Aug 2018 09:34:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7B3928869 for ; Tue, 28 Aug 2018 09:34:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C0EC28ABE; Tue, 28 Aug 2018 09:34:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A55728869 for ; Tue, 28 Aug 2018 09:34:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 290D16B456C; Tue, 28 Aug 2018 05:34:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 127B66B456D; Tue, 28 Aug 2018 05:34:10 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 013F56B456E; Tue, 28 Aug 2018 05:34:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by kanga.kvack.org (Postfix) with ESMTP id 996096B456C for ; Tue, 28 Aug 2018 05:34:09 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id p105-v6so839187wrc.11 for ; Tue, 28 Aug 2018 02:34:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=wc9ZRwnUmb5rXGt9YW/Z3OT0r34lfcDOfLS8ZydfUMY=; b=HuKv3i8MwI5p101tSmBaSKEj8M8fZWx8Dx0VCma3dMTyIQYFYgkvR/B8tLIDTKF+my RoHBTskgQEHnqcfzFClWaHnUpurOUQm7gXrbSTfWteEFP7uSuw93XuJP+vODJ6nWsXgV IK8l5qpZZ3vRsqtfutlltmcuXUs+IIAynkCRGarzUsJvW/q5O5Z7lY/mYyvADSE0P8ti 4GiUSgQeKrR5h9tril7CaqJLlWvObvX4QoFL9POgbGd7KUFTZpRq+derty63gaePxXMO FAGB4UsXvK58XFhcrp5z4rO6CF7wdSjIZHKRtfju/LZhQzk9MSpGe/FZUR/mMaw4r9R1 px9A== X-Gm-Message-State: APzg51CKR1OY2WtqmiIfbpJsv9ZUGLqiED7BBE8SXRUQU6xNeGLYC56N WDRqV6w0AyKHUaGvysdStrYxSmd3sUT3uaQepO5y0bXqlF7Vu6yQ9CUckYL/aP26f47gMrwFVea FsvM6Z9vPD6Q5PuUFA7s0aztHOKZbY+jjaFrzCBS+2PvhYi3so79sXYlYkEIZ0RnX9XYf+liuHb 1nz4mv1D+ifz5zojj2gOn8m3fRfMCqN+/gxJEcJd3AdCdvmoSDHL85nlvlWH5RW1D6wPrnGlLMo aTD85IlYrzk4Aw1SHIe9akJHU3XlQ7Mt1CAIk4wJPEcYAAqnXpXN39EjAb+5TcqRZMPGs8fILdm 0d1yTsUaOgwzilURaFrHarIqxqGcSIiC8vCAgdT2l5dbi+ebrq0I/XPzvOQHtDadWrIIO0M5YwN S X-Received: by 2002:adf:ed04:: with SMTP id a4-v6mr573346wro.262.1535448849157; Tue, 28 Aug 2018 02:34:09 -0700 (PDT) X-Received: by 2002:adf:ed04:: with SMTP id a4-v6mr573307wro.262.1535448848350; Tue, 28 Aug 2018 02:34:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535448848; cv=none; d=google.com; s=arc-20160816; b=WfFCVjDlMVp+WQdTJJyiG7hg7hlq1qaSb7iEwb6vJ46z/frPcDYO/4xZpICycVMaij dFe6QhOsu0CcLh6410O7MCgcFkq/VQiZs8AA57YVvLtmWggE0OkELuCwaAryPK9HcYNS cGJyXAYhhBcyE12lS64/MgOU+PxF7G8MpAW/ms5XKShjqLJpfNg8FN83aUsMSqTcIWk2 zVrzXfPdjswir+ohj2wwg6QByhyRSwboIYOZz6oON9TBz+EVICh1rgc+4OBh/OlpLCsS MEfoaxGqQEGKuL3OJpZajD+34ih/xd1LQ3+RaS0QotAtHriLxhwkOq/R7rAIjj3Nm8X6 jbfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=wc9ZRwnUmb5rXGt9YW/Z3OT0r34lfcDOfLS8ZydfUMY=; b=UBfblBqq70NmlgqjwiNuTuZfOTaiOqYIuPZ1ibWgSO+ELCpy3+k2Wmjdb3hZnxbSJ2 bJlJAafVJTjvyRpk0mOepzH5UuPfxFZzFJCq85palrRthIFyoxrEaCRL787zHkEwkDWs xaRDRO9dZowTTtIVIL8SYFl9EfMpjP5UVecUZzoYJaUKY8YDOL56kUfE5l240yey7t5x mUx/aAyyTbjUQWnS67RD2AXXZwMWevUDGxAmVf/H3lzeKa2KO5FU8vB3Kp5Bp7kXTg7G hPtZNuyAjSHOYhQbMTd30UTbaEDUG+QWt75PEy36QTjuS4v7n0WzhPpT2DhVNG2K0RQv nzyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=MME6CIbn; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) smtp.mailfrom=brgl@bgdev.pl Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h18-v6sor237298wrt.57.2018.08.28.02.34.08 for (Google Transport Security); Tue, 28 Aug 2018 02:34:08 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=MME6CIbn; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) smtp.mailfrom=brgl@bgdev.pl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wc9ZRwnUmb5rXGt9YW/Z3OT0r34lfcDOfLS8ZydfUMY=; b=MME6CIbn6ztirIfcMA3UHlZmo1USCfNk6oYrqrfS2kcBjaNSlBGu0Xt3IwJZJhOBa4 zRIVln4bKyOO9n7wPDACSj85rW1EivMdt4i794d5x79jKqT8lqvxRhLlvILxHCDAOGbD seIfVj33o/l6LK9f+eDElZyrX6Z+uhE83lFQTN98edjMRs5CpMwoYxwH6rks8zSFzkdp q+1pL9rlXPsXqmQHC/m1wvlrWWZCscU6mCX/Ru8R5B1aMJxPj1b2QDe4SUWDRE0ncTg7 r1hGif/HO0HXvVRQzxgJOlmQeSasPabVm9nYQ529cNM+/kyaUmuiTT+l8ZFQ9UGnEErd C9yg== X-Google-Smtp-Source: ANB0VdYZg1uzJ+5+eFWd2GzaecxTUS0AzdL/Zfb2QSzLa7FMQgAFFXWWu6LyRuwDUGxRbdwq6jNxzw== X-Received: by 2002:adf:f8ca:: with SMTP id f10-v6mr568901wrq.237.1535448848093; Tue, 28 Aug 2018 02:34:08 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id l18-v6sm952276wru.75.2018.08.28.02.34.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Aug 2018 02:34:07 -0700 (PDT) From: Bartosz Golaszewski To: Michael Turquette , Stephen Boyd , Greg Kroah-Hartman , "Rafael J . Wysocki" , Arend van Spriel , Ulf Hansson , Bjorn Helgaas , Vivek Gautam , Robin Murphy , Joe Perches , Heikki Krogerus , Andrew Morton , Mike Rapoport , Michal Hocko , Al Viro , Jonathan Corbet , Roman Gushchin , Huang Ying , Kees Cook , Bjorn Andersson , Arnd Bergmann Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Bartosz Golaszewski Subject: [PATCH v2 2/4] mm: move is_kernel_rodata() to asm-generic/sections.h Date: Tue, 28 Aug 2018 11:33:30 +0200 Message-Id: <20180828093332.20674-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180828093332.20674-1-brgl@bgdev.pl> References: <20180828093332.20674-1-brgl@bgdev.pl> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Export this routine so that we can use it later in devm_kstrdup_const() and devm_kfree_const(). Signed-off-by: Bartosz Golaszewski Reviewed-by: Bjorn Andersson --- include/asm-generic/sections.h | 14 ++++++++++++++ mm/util.c | 7 ------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index 849cd8eb5ca0..d79abca81a52 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -141,4 +141,18 @@ static inline bool init_section_intersects(void *virt, size_t size) return memory_intersects(__init_begin, __init_end, virt, size); } +/** + * is_kernel_rodata - checks if the pointer address is located in the + * .rodata section + * + * @addr: address to check + * + * Returns: true if the address is located in .rodata, false otherwise. + */ +static inline bool is_kernel_rodata(unsigned long addr) +{ + return addr >= (unsigned long)__start_rodata && + addr < (unsigned long)__end_rodata; +} + #endif /* _ASM_GENERIC_SECTIONS_H_ */ diff --git a/mm/util.c b/mm/util.c index d2890a407332..41e9892a50ce 100644 --- a/mm/util.c +++ b/mm/util.c @@ -15,17 +15,10 @@ #include #include -#include #include #include "internal.h" -static inline int is_kernel_rodata(unsigned long addr) -{ - return addr >= (unsigned long)__start_rodata && - addr < (unsigned long)__end_rodata; -} - /** * kfree_const - conditionally free memory * @x: pointer to the memory From patchwork Tue Aug 28 09:33:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10578091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B745F920 for ; Tue, 28 Aug 2018 09:34:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7BC628869 for ; Tue, 28 Aug 2018 09:34:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C07B28ABE; Tue, 28 Aug 2018 09:34:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C9B228869 for ; Tue, 28 Aug 2018 09:34:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 103BF6B456E; Tue, 28 Aug 2018 05:34:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 05F686B456F; Tue, 28 Aug 2018 05:34:11 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF6436B4570; Tue, 28 Aug 2018 05:34:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by kanga.kvack.org (Postfix) with ESMTP id 80C366B456E for ; Tue, 28 Aug 2018 05:34:11 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id s205-v6so877504wmf.7 for ; Tue, 28 Aug 2018 02:34:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=ZhPS8aKWZHYYGJDbC8vwHCt0WY7YA5vftpevadBx97w=; b=MOxFi5x0gaRUAr7ynNi/qs2LId/XOGRW/1tFKvJmdFSXhPc+tShAIaCbwifVVqzGt/ 9i14ljAHZfHOdckIsGQV7VQhH2N91WOa5ZexK83BfjLT8/jj/+DE2fqUO4cQMhKIgx2u 99naoqgRiJZ7NV9IPmJ9+88nbUSa6Vu1DdTTZLQBibxfTMyw3MAYIGSIEO8gfjgfAPjz L6RnwDFONVylhf7QoQl9i3cll63iFLlX16zTI2Qutv/W3ZuxbRcyhmegbz/K9JJOMFlv xkf7jvJV5d+hxqg2swOmnoZ9TTf7Y+65RHQTWDqsa0zQAXOq/TomfqmT6y+vcNsO94OG m/7Q== X-Gm-Message-State: APzg51Bu+n6kZLpOV/wCFiSDKfaUwXCihRSh94DDKnTt81NT5jq9yEul 3K7/JmQHQ/uS+pJl/xosn27PcTIHct14QMeid8qaY2xfiqvYub+ONO8sNAgxkqjeyET0ZZ5rmAT 6i5F2FrdQQynrGhXfGnN6+O5vRdnhALSNr7IViAfYb/gzFacWi8aeAtYVUrpjh1e9+BFUfdED1s 7u5AUAbeV/by7Etp90HF5oAj3n+zuF9bhZyFXX9UFUCkJMcynpKXQYn0Rntj6vmJF/z6l2lBboa tyUvwyzX/YWUKUl+IuUt0pmRnJdEWFDO45nT6ONDUL3wFXxbU8CA+YZc93qywpaN1sOkHT7cwrO KuW8KOfym7dGOjF+plxruM9uqJCjIzybBaE/HpCUgZE9QRzExrxO1ERnqVUFnkwbC8LAI2LHZEf / X-Received: by 2002:a1c:da51:: with SMTP id r78-v6mr816510wmg.153.1535448850969; Tue, 28 Aug 2018 02:34:10 -0700 (PDT) X-Received: by 2002:a1c:da51:: with SMTP id r78-v6mr816470wmg.153.1535448850032; Tue, 28 Aug 2018 02:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535448850; cv=none; d=google.com; s=arc-20160816; b=o3d7XyGEWn1aHSnmCnmAFaPQa6ipPOYkDGBPbUS0UdXCAPUXLaUzudYr3GtPgN/6QI fO/pwpMgigZMHYT2DXmMq4AT93GGgsHnZRSqwWCCIOC4ChoroNxgwGJjOarZ4tavD3Z6 0MebXGqVGlb+Hj5yE3utCGHlnQ+AuvXVT3Qr0atzWK0k459ltfd6Vs4M/Yfa2yVqk7aB Mpe8RpU5CM579D4WIjo9Zyx5fjc43P1pSrfunqIGYvduOxbVpoZpdIMkWAZA+aeTjSSR BEz4iBVCuMlV0keOIomwPWMywpeZA1M3wUXh+gCmk2A01fpyMjCS/sJiTxZVapRceKZJ SOHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ZhPS8aKWZHYYGJDbC8vwHCt0WY7YA5vftpevadBx97w=; b=0SyQ8PXOYZOHhlM8XF9O3Y7cD0pzfHCjt/PmNbJCIF74GAzBz4AnIfw5gRIJIiRF1f Uy/ZxMReAKBxFGEZvs6wbEBKd7/5WXxTfPXb3B3AXota+Dr/Vu13/A5Fx+j6Hf60ZkiE /DkRboSMtlqnxBwnhstnHT/MpLrhpjej/zPwl1WJftZBSqOIQWUqYjTqarddaPBJIp77 PBpQ3D4jUDzlShGAejcchL2r3bxEbiqO1okgUqP96FzVn7opfDVHmWqSpMvohVptvSpJ uyuVD8oANoCoIjd9qN7wKp59IUz4ULkMxJaHREXyRoCMkOk8L5TZs+NLW40e8Axbeqbe KNkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=K7DgoVj8; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) smtp.mailfrom=brgl@bgdev.pl Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q11-v6sor241007wrp.1.2018.08.28.02.34.09 for (Google Transport Security); Tue, 28 Aug 2018 02:34:10 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=K7DgoVj8; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) smtp.mailfrom=brgl@bgdev.pl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZhPS8aKWZHYYGJDbC8vwHCt0WY7YA5vftpevadBx97w=; b=K7DgoVj8B2c94KzxsFLciUUUVbJs9GG+54y9l44xJv0cIGKEsWtmJ6asfgtAuJRNWG 3YWTqiKNWfRuzi4MGrLExpWGQh33pnpPC31fZLOE1iAYaZnvNBt/3EJXVAqNj7ZSE+GI BMJhuQNbkhunybgsu80wI2MVHZF+0+S2fKypURC6G8Pc77I+SuMexD717Ca3+aF+LLbe UzJnEY249o+9lwmLaJUX6IZQ3YbgBPFpZpqVHYRbpKuZno3BH9GupI4N9Roz4FVRGDCH 96bpEf6CsVsmyV6piYYOMmj0WwEH7xTECiwsKNNBE6PoyKyKGeFQ9Ba7YdipTSodR1f+ fs9w== X-Google-Smtp-Source: ANB0VdazQ1b4GJa2MqkcHdXAY4E48XRwkQi/Vh5haOo3iQRppCTAdopcVEtiX1xS13EEr5bEkgPC0A== X-Received: by 2002:adf:e8c1:: with SMTP id k1-v6mr539276wrn.43.1535448849697; Tue, 28 Aug 2018 02:34:09 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id l18-v6sm952276wru.75.2018.08.28.02.34.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Aug 2018 02:34:09 -0700 (PDT) From: Bartosz Golaszewski To: Michael Turquette , Stephen Boyd , Greg Kroah-Hartman , "Rafael J . Wysocki" , Arend van Spriel , Ulf Hansson , Bjorn Helgaas , Vivek Gautam , Robin Murphy , Joe Perches , Heikki Krogerus , Andrew Morton , Mike Rapoport , Michal Hocko , Al Viro , Jonathan Corbet , Roman Gushchin , Huang Ying , Kees Cook , Bjorn Andersson , Arnd Bergmann Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Bartosz Golaszewski Subject: [PATCH v2 3/4] devres: provide devm_kstrdup_const() Date: Tue, 28 Aug 2018 11:33:31 +0200 Message-Id: <20180828093332.20674-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180828093332.20674-1-brgl@bgdev.pl> References: <20180828093332.20674-1-brgl@bgdev.pl> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Provide a resource managed version of kstrdup_const(). This variant internally calls devm_kstrdup() on pointers that are outside of .rodata section and returns the string as is otherwise. Also provide a corresponding version of devm_kfree(). Signed-off-by: Bartosz Golaszewski Reviewed-by: Bjorn Andersson --- drivers/base/devres.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/device.h | 3 +++ 2 files changed, 41 insertions(+) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index 438c91a43508..48185d57bc5b 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -11,6 +11,8 @@ #include #include +#include + #include "base.h" struct devres_node { @@ -822,6 +824,28 @@ char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) } EXPORT_SYMBOL_GPL(devm_kstrdup); +/** + * devm_kstrdup_const - resource managed conditional string duplication + * @dev: device for which to duplicate the string + * @s: the string to duplicate + * @gfp: the GFP mask used in the kmalloc() call when allocating memory + * + * Strings allocated by devm_kstrdup_const will be automatically freed when + * the associated device is detached. + * + * RETURNS: + * Source string if it is in .rodata section otherwise it falls back to + * devm_kstrdup. + */ +const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gfp) +{ + if (is_kernel_rodata((unsigned long)s)) + return s; + + return devm_kstrdup(dev, s, gfp); +} +EXPORT_SYMBOL(devm_kstrdup_const); + /** * devm_kvasprintf - Allocate resource managed space and format a string * into that. @@ -895,6 +919,20 @@ void devm_kfree(struct device *dev, const void *p) } EXPORT_SYMBOL_GPL(devm_kfree); +/** + * devm_kfree_const - Resource managed conditional kfree + * @dev: device this memory belongs to + * @p: memory to free + * + * Function calls devm_kfree only if @p is not in .rodata section. + */ +void devm_kfree_const(struct device *dev, const void *p) +{ + if (!is_kernel_rodata((unsigned long)p)) + devm_kfree(dev, p); +} +EXPORT_SYMBOL(devm_kfree_const); + /** * devm_kmemdup - Resource-managed kmemdup * @dev: Device this memory belongs to diff --git a/include/linux/device.h b/include/linux/device.h index 33f7cb271fbb..79ccc6eb0975 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -693,7 +693,10 @@ static inline void *devm_kcalloc(struct device *dev, return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO); } extern void devm_kfree(struct device *dev, const void *p); +extern void devm_kfree_const(struct device *dev, const void *p); extern char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc; +extern const char *devm_kstrdup_const(struct device *dev, + const char *s, gfp_t gfp); extern void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp); From patchwork Tue Aug 28 09:33:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10578093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4571217DB for ; Tue, 28 Aug 2018 09:34:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35BF128869 for ; Tue, 28 Aug 2018 09:34:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27E6828ABE; Tue, 28 Aug 2018 09:34:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFDCE28869 for ; Tue, 28 Aug 2018 09:34:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C0936B456F; Tue, 28 Aug 2018 05:34:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 718DD6B4570; Tue, 28 Aug 2018 05:34:13 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 607A66B4571; Tue, 28 Aug 2018 05:34:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 018FD6B456F for ; Tue, 28 Aug 2018 05:34:13 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id w6-v6so831305wrc.22 for ; Tue, 28 Aug 2018 02:34:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=1rAADFiEcrgAP/MWUhEq9f5JToaQRAnXC+gfalAjE3k=; b=nuJmewImrHt22JCr5WFVtK/0Z5uzHdYVmSHR3LH7Ob8EBT5nTGFHZnAQa41jSZ2v9i qt61BjuOPO6+DoSTt8z5B+vER6j3uM3NmcUimD5q1bfxbZGUiZVA45fcB7hXMZdvilrf MfAx90QZpxCFHcunBqUUa5kFjEwjuF0u6Gtq8ON9y2WdhNxyiUZxoUtZU8Pl//g6QleM SR9nyf8oV7nE1WEPeedHOcgPIt/pS4cj+65JE7hvGDbTs74tJihlj9Pc/a+lXG1AX3hv Yl5pjb+Rv4+4iXgCwbFMvXf7yUOPjHclUpvBm1EZ5XV9ooa7JJxRomUEAGWmrmN3inhP 9l3Q== X-Gm-Message-State: APzg51AqhthWj8GZ/ZWgLPG8iZS27JXm1N8Q0BLaEb4xb/bp7y2r1vxj NWlWToaAR22oUPQ/0uzZgW3ILQY/5mkMW3EJqgot+LKWny80+0YUqYGefMpLxm1/TOkYLUDP7r9 XcPdx3N+8ehW2X+UKerjqOCrcOGyEEhwlh1lj/yxoMxwDLV/rkxQ4eTUdQUYwLFRWFf6aYrVhhI QC0xd/f0pQGbYkzcLq57vZbTfaa5KJlIsHjwafUqSFP1pNFzJezemQTvug2Y0rAVdjuv+X6+fqU 0xrV7K37PmMEqUBTMnNvgsGVqE3EyKfOhVUv08w6UnA41CXN4mcPZ+ZWqnWkTUfFgmcZMJUpIyX n8ar/+9VEoWN4yCugcyR5z8sW85qxl4X0Nod6jw4QE0RymRuOo0NZjBOmS59cIL8xLh4XW05CL2 1 X-Received: by 2002:a1c:2108:: with SMTP id h8-v6mr783462wmh.108.1535448852445; Tue, 28 Aug 2018 02:34:12 -0700 (PDT) X-Received: by 2002:a1c:2108:: with SMTP id h8-v6mr783441wmh.108.1535448851707; Tue, 28 Aug 2018 02:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535448851; cv=none; d=google.com; s=arc-20160816; b=EwjsgKsEABP7ZPiA5etOFRvHe0msLoWx77LLfVb0qFhInzkXFVsfkSTgZihdoodA8N Pjyk5YszuRTMMuAIx5qf15hSbMAiRRISbuzTdxQRnWoEEJXj8hSBXW5cbexp0VskL+XI eVF/noAIIAsOL6SrEb3GcL0b8UpNgj47PjabeedfTMF/g6NKOfGdhNCnN47P/xWQRGOd XRZ5zhdlZzv5YP23n88ER1q7HDxyJ9jNterKe7zhLNMMkY1CRBscFmveUqcs794HelHY PtBYmiZip/SQotZJXd4qySirSfmSBr3tyxbxEFl6NZKtFv+3rm1YEenV3SQzB2PUTDOM DVtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=1rAADFiEcrgAP/MWUhEq9f5JToaQRAnXC+gfalAjE3k=; b=ZTt8NUYejgL8zVf2IqkghsxMDPf3KCc2XOZmd1CznE1CLroZaoh4kghRc7ucl2u8tp HqGPIu6U+QzlzTCVt6DDCCnDSjbyIxxCIA2OfEyk4s+xpJVglA7VRE0iZaVUl88UDYdx 9yaBJmzv4q70DyaVCaE35hXAH+5G9aHkkTmEwOR2jQT8MzH43VSEB/tHODKGglcL1xKZ R3AXa8QdRCCC9MX//EovfTGAEAs6AZzL4CujJthpoM/5eMuh1lE6PVkBA0eMu9c5UhY+ 4DBiQy5E0mODz/di54eXPrfpbNNmpvC4Q0RiZWbmGApCcRLokX2LkWf+uYa3+SA2jhwO BcLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b="p//iCCA1"; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) smtp.mailfrom=brgl@bgdev.pl Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x18-v6sor234709wrt.8.2018.08.28.02.34.11 for (Google Transport Security); Tue, 28 Aug 2018 02:34:11 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b="p//iCCA1"; spf=neutral (google.com: 209.85.220.65 is neither permitted nor denied by best guess record for domain of brgl@bgdev.pl) smtp.mailfrom=brgl@bgdev.pl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1rAADFiEcrgAP/MWUhEq9f5JToaQRAnXC+gfalAjE3k=; b=p//iCCA1MuEaI2HpuhoGbJeHcq2jmfgPJ3XDrG/O5LZF3RXf2wsubecp6Goz7f0o79 LzT65i1lmWoaar1tB5UxTxjHYLeLVHrvQscb6ydeLJHCsQEC69i39aaxHAOKVE1CKahY 0m9Ms8Rx7z5+D6L0OSVn9vhev1b0VzkzfM2hrtrjE+pygIscDuYgdSobWncG3TQ7++De sD6EF5qddYdMx2C+2m+idpSPuNykz0yd5T2H8HNxVmT7wG1hwYOhg8Dyg+E1NitcTEm1 xEWToxnbd0MTBOykkCMbKgEEowFIq/mwptYz6+dx0HFbepSNxia95yLEO1YoSRRJiJ0/ KiIg== X-Google-Smtp-Source: ANB0Vdb1z1itApQb6iLVseTRPyo4shStOLvpCOq0LLmwi14Xk+YVt9l+6hKfzi1quea3dB05Pl4LFQ== X-Received: by 2002:adf:9d1c:: with SMTP id k28-v6mr604790wre.104.1535448851396; Tue, 28 Aug 2018 02:34:11 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id l18-v6sm952276wru.75.2018.08.28.02.34.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Aug 2018 02:34:10 -0700 (PDT) From: Bartosz Golaszewski To: Michael Turquette , Stephen Boyd , Greg Kroah-Hartman , "Rafael J . Wysocki" , Arend van Spriel , Ulf Hansson , Bjorn Helgaas , Vivek Gautam , Robin Murphy , Joe Perches , Heikki Krogerus , Andrew Morton , Mike Rapoport , Michal Hocko , Al Viro , Jonathan Corbet , Roman Gushchin , Huang Ying , Kees Cook , Bjorn Andersson , Arnd Bergmann Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Bartosz Golaszewski Subject: [PATCH v2 4/4] clk: pmc-atom: use devm_kstrdup_const() Date: Tue, 28 Aug 2018 11:33:32 +0200 Message-Id: <20180828093332.20674-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180828093332.20674-1-brgl@bgdev.pl> References: <20180828093332.20674-1-brgl@bgdev.pl> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Use devm_kstrdup_const() in the pmc-atom driver. This mostly serves as an example of how to use this new routine to shrink driver code. While we're at it: replace a call to kcalloc() with devm_kcalloc(). Signed-off-by: Bartosz Golaszewski Reviewed-by: Stephen Boyd Reviewed-by: Bjorn Andersson --- drivers/clk/x86/clk-pmc-atom.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/clk/x86/clk-pmc-atom.c b/drivers/clk/x86/clk-pmc-atom.c index 08ef69945ffb..daa2192e6568 100644 --- a/drivers/clk/x86/clk-pmc-atom.c +++ b/drivers/clk/x86/clk-pmc-atom.c @@ -253,14 +253,6 @@ static void plt_clk_unregister_fixed_rate_loop(struct clk_plt_data *data, plt_clk_unregister_fixed_rate(data->parents[i]); } -static void plt_clk_free_parent_names_loop(const char **parent_names, - unsigned int i) -{ - while (i--) - kfree_const(parent_names[i]); - kfree(parent_names); -} - static void plt_clk_unregister_loop(struct clk_plt_data *data, unsigned int i) { @@ -286,8 +278,8 @@ static const char **plt_clk_register_parents(struct platform_device *pdev, if (!data->parents) return ERR_PTR(-ENOMEM); - parent_names = kcalloc(nparents, sizeof(*parent_names), - GFP_KERNEL); + parent_names = devm_kcalloc(&pdev->dev, nparents, + sizeof(*parent_names), GFP_KERNEL); if (!parent_names) return ERR_PTR(-ENOMEM); @@ -300,7 +292,8 @@ static const char **plt_clk_register_parents(struct platform_device *pdev, err = PTR_ERR(data->parents[i]); goto err_unreg; } - parent_names[i] = kstrdup_const(clks[i].name, GFP_KERNEL); + parent_names[i] = devm_kstrdup_const(&pdev->dev, + clks[i].name, GFP_KERNEL); } data->nparents = nparents; @@ -308,7 +301,6 @@ static const char **plt_clk_register_parents(struct platform_device *pdev, err_unreg: plt_clk_unregister_fixed_rate_loop(data, i); - plt_clk_free_parent_names_loop(parent_names, i); return ERR_PTR(err); } @@ -351,15 +343,12 @@ static int plt_clk_probe(struct platform_device *pdev) goto err_unreg_clk_plt; } - plt_clk_free_parent_names_loop(parent_names, data->nparents); - platform_set_drvdata(pdev, data); return 0; err_unreg_clk_plt: plt_clk_unregister_loop(data, i); plt_clk_unregister_parents(data); - plt_clk_free_parent_names_loop(parent_names, data->nparents); return err; }