From patchwork Fri May 11 16:20:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10394687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 653F160236 for ; Fri, 11 May 2018 16:26:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECED228F37 for ; Fri, 11 May 2018 16:26:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E11FA28F4F; Fri, 11 May 2018 16:26:15 +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 autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3D3A328F37 for ; Fri, 11 May 2018 16:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=SUrPCU16EF3CfQrR/ZvhIUJKDf08z2W8BBLNowjXOHM=; b=KhiIYuu8iiCtYdGoo2YdFRHU8l yQjgFnWB/E2jN+AL6KIUH97zum86GCVsP4KBY7xZT4PGIHsEWZr3EjtH+W9RIOUYdF0DH1gfHAusN 3GvGaah1D6tpByO7qOgdAomQelWHEdqKVWDiY1dn/rS2pzY0cdcLAFytVBiCdrqdurHpxsMlQn6qj 6fLCsLy59RXbzsOB8Azaty07RMCpyLywOmi7D7Cvb63TQvMXpMFM243a5E/g9St4q9nnqjiKldkke 1RX2/uwNPP2RFvLQigMM5TljnGHHzumAIWA2qTFR+KNqjWqTFg5PEEGXbN3EqOhy5PIDAR2erBlYd kGMlab3w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fHArz-0005wM-AJ; Fri, 11 May 2018 16:26:11 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fHAnf-0002g4-Rg for linux-arm-kernel@lists.infradead.org; Fri, 11 May 2018 16:21:45 +0000 Received: by mail-wr0-x241.google.com with SMTP id v15-v6so5894732wrm.10 for ; Fri, 11 May 2018 09:21:33 -0700 (PDT) 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=5iLiFd+aaRP1gYeDp+N2C4rkJvtBC9/Cf4Bv8Vp8wZk=; b=MFdxN+SrTxDMyqTs/gFMyuXBx4VWHEzANRjJZVkjDWAVAueb+qAKs7uXl7ifEi+fyE XsVujbnTo/xj9Y/znwCU5nXXfKq2Wn5Q3O0fsQbBl4VnjLX+BvZnULsn1JvYjWdV+4hs KQCGQecv05T7ylxmrYTKTS4srLyehrmdHHiLLWJQOSKgncNOKtPPkg+ZWJCES3V63t2R a7KnAI+pDWqO+jc4MlewhDPbscvXAvo4aAjxzOu/cK/HB3h+jluI5GXKlT/KKytpRwZ3 tpkXdc0VJudgTxmkx1FSU3gQHwuCZBIcqHbh/EA//FmIUYCTzMIe0+3b1BwJ9OCThzvV rHWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5iLiFd+aaRP1gYeDp+N2C4rkJvtBC9/Cf4Bv8Vp8wZk=; b=qzmH/BcaMCqEQ4A569k7HKqwv/S7/h03BSLv5xrBiIEJShcJ7p8MTNa2uR3lRdTZBq 6+MGLwUxM7dI4tRR9ZYKXemCqo69WnOvbC3CzdgVgM7ZxajKQVE3ewWxzhy1HhdUqe3K Wp6vEQuMfORB1Pt3kv19B0C8cLogDhXnvt+9aw+x/hOZivgj84CBEcY8KES1wOfMY318 k+gMTxiZjD7Ey5FnIt/FRGwnDZSDcKB7A3On5sHC/oXoCiliX78CirgTvQ92A6zpu60d lbrObzb0KwIc9FK6PI8RzDBYPQD3Zfho1u6UO0Knor6g/eMwmEuwo7XwgVWAmp+IRCh/ QqUQ== X-Gm-Message-State: ALKqPwdXVjDt8z1D40V4o10kL7zSKfGh8w/sy9XWbJ5eEOXHTL78iC2g 4u/LpSFuodJ7/j4KdoO+7IdzNg== X-Google-Smtp-Source: AB8JxZrYeTBwPLqP8KW9XfkVUTQ+AdzA8AivDmNSMMvzNiE4x2G+qo9aefrt2AdPWVhxUpmSAVDCYw== X-Received: by 2002:adf:df02:: with SMTP id y2-v6mr5251530wrl.92.1526055691961; Fri, 11 May 2018 09:21:31 -0700 (PDT) Received: from brgl-bgdev.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id q17-v6sm1429523wmf.3.2018.05.11.09.21.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 May 2018 09:21:31 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , David Lechner , Michael Turquette , Stephen Boyd , Arnd Bergmann , Greg Kroah-Hartman , Mark Rutland , Yoshinori Sato , Rich Felker , Andy Shevchenko , Marc Zyngier , "Rafael J . Wysocki" , Peter Rosin , Jiri Slaby , Thomas Gleixner , Daniel Lezcano , Geert Uytterhoeven , Magnus Damm , Johan Hovold , Rob Herring , Frank Rowand Subject: [PATCH 04/12] platform: provide a separate function for initializing platform devices Date: Fri, 11 May 2018 18:20:20 +0200 Message-Id: <20180511162028.20616-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180511162028.20616-1-brgl@bgdev.pl> References: <20180511162028.20616-1-brgl@bgdev.pl> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180511_092143_940433_2A313A3E X-CRM114-Status: GOOD ( 15.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski The early platform driver framework will allocate platform devices using its own internal mechanisms. Provide a function that allows to initialize a platform device object without allocating it. Signed-off-by: Bartosz Golaszewski Reviewed-by: Geert Uytterhoeven --- drivers/base/platform.c | 24 ++++++++++++++++++++---- include/linux/platform_device.h | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 0c53e3e3e5aa..0ba4effb9618 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -252,6 +252,25 @@ static void platform_device_release(struct device *dev) kfree(pa); } +/** + * platform_device_init - initialize a platform device + * @pdev: platform device to initialize + * @name: base name of the device we're adding, NOTE: it's not copied + * @id: instance id + * + * Initiate an already allocated platform device. This routine does not set + * the release device callback. + */ +void platform_device_init(struct platform_device *pdev, + const char *name, int id) +{ + pdev->name = name; + pdev->id = id; + device_initialize(&pdev->dev); + arch_setup_pdev_archdata(pdev); +} +EXPORT_SYMBOL_GPL(platform_device_init); + /** * platform_device_alloc - create a platform device * @name: base name of the device we're adding @@ -267,11 +286,8 @@ struct platform_device *platform_device_alloc(const char *name, int id) pa = kzalloc(sizeof(*pa) + strlen(name) + 1, GFP_KERNEL); if (pa) { strcpy(pa->name, name); - pa->pdev.name = pa->name; - pa->pdev.id = id; - device_initialize(&pa->pdev.dev); + platform_device_init(&pa->pdev, pa->name, id); pa->pdev.dev.release = platform_device_release; - arch_setup_pdev_archdata(&pa->pdev); } return pa ? &pa->pdev : NULL; diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 099aaf804b50..46bfd5ff666f 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -165,6 +165,8 @@ static inline struct platform_device *platform_device_register_data( NULL, 0, data, size); } +extern void platform_device_init(struct platform_device *pdev, + const char *name, int id); extern struct platform_device *platform_device_alloc(const char *name, int id); extern int platform_device_add_resources(struct platform_device *pdev, const struct resource *res,