Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp993941imm; Fri, 11 May 2018 09:25:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoHlX2cPjJjWpc1yOflrp4zmqLbqIGZN/lgs5H62ObwpAaxHn3cATIAKMC9edahm7qq695R X-Received: by 2002:a17:902:988b:: with SMTP id s11-v6mr6106176plp.304.1526055936383; Fri, 11 May 2018 09:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526055936; cv=none; d=google.com; s=arc-20160816; b=AtZotemyZ41JIveXFVo32842dm0zHmVvW4iIyHcRy8k/owU2Jjhqj3lQ4UjDzLW8Ed 139SACcrTCN/9ZL7g4EoOxdzWHaMSIv1oqOuLVYY07aHkLBQ1ai7/6RlbiPIYoGcXIRv RZ5p3PsENx+HGcCG/wy9fEcqmDGmRMyJu7Usc+Vm3JfePnrhPmDlOELiS21tYR2uj8f+ X8yVaw/Hql4CNCFADj7t/1kn1KYbShHV/+TeguidPn+pNLatc0sG78epvjJwK0nemoVg BX5kUBWqeMErpZ6Ferzm+6FLvcLqT8RgmvumWd2JOenpptFivhwJGyMcERoDXBTjWLi6 4k4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=5iLiFd+aaRP1gYeDp+N2C4rkJvtBC9/Cf4Bv8Vp8wZk=; b=MuxDe0mir7mGfTbXQjsgvt8JYpl021vYxYCKcZxWdg44GyhuWGG/FpH/mgg3fX2jPC DGz6gfzlUOIRyxwQ/vdQZgq5k+cafya1y0JFL+nvxbZCLE88CReqHrX7frSRJsl3qGoh SSpNXz06tvRCzqLg3WUC3hBO81rQlj7zbZ10FdX23jsz9jggKlpDid1foy4nWBZCPrBV e5+L2Q+sJlm5UGSUI3Q8AqDc5mJKAWGichdi7lkwcIKEWxbZOtHH8c72xNJAchtE1swT S42RRWAUDJVbkx1wHkBv4SxO7nl8uOmnPwLJOYG/TIKKgUkzZLMugy36X6368JpPzhuw qgZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=MFdxN+Sr; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 68-v6si3673791pfq.172.2018.05.11.09.25.22; Fri, 11 May 2018 09:25:36 -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; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=MFdxN+Sr; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752361AbeEKQY1 (ORCPT + 99 others); Fri, 11 May 2018 12:24:27 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:39546 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752047AbeEKQVd (ORCPT ); Fri, 11 May 2018 12:21:33 -0400 Received: by mail-wr0-f194.google.com with SMTP id q3-v6so5907561wrj.6 for ; Fri, 11 May 2018 09:21:32 -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=uk17l9MgDCmiJMlGcJL6X99CkgeJmo1URPAE6JFt+Uf/HDUqeZCwB6eAWkpnoO53Ld cqGyx3V4sNt+rnIsh+NqZR8KiEmgXaS4cILEudpQreRBZK4/bU+2xdAuRkSiGRgN1bUi f9JXBQMHug9VO+8kKmfB3rhI0GU6GEM/i52ETSooJjBjqWehaF2sp/N1qmJYQ3qSLWdR Gb0/KsDQqaC4iHqBghGzzmNNUUX79xXzuCARBWy3WqLXc7aZIkaQM8Hgx4RGyN1i3B7v tzkgCbXS8y5lsIeG1pbw5qtxw+57VIMsuioLFY+FZjH1E8yH4Ec2MjyNd4c09yiTHkkT CmkA== X-Gm-Message-State: ALKqPwfYYsTF02vxblkbbVqqtZFYEVc5MsMsXKvro8sDgtgA3eLXp/WU mTAXGdSdj3J7NY7QpyXTm+fsTA== 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, Bartosz Golaszewski 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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, -- 2.17.0