Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp473340imu; Tue, 22 Jan 2019 23:26:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN6YknvrcL5Nl4xPIFYGIyA7uIGvIF12aBhrZsBr8mPDUspsZWRdR+zNgmQrpr0bbheXz2ob X-Received: by 2002:a62:c613:: with SMTP id m19mr1091206pfg.207.1548228378140; Tue, 22 Jan 2019 23:26:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548228378; cv=none; d=google.com; s=arc-20160816; b=ErJHtLhVIRamKqJDEmzvhAJ1fSG89DEv9etBw62FqkOxK1tbAUMbIEdwxbGELxMZhH yg8xYbzYym5APdy4BgNbgdEF3ms5RINJAPfpZ4WvFsu/kw77CTHatSyRLm9wcXNI7ImK 7T4rfYoKU8zv6+uyeCgIs7exqC0fSdsaUrKl/yl0bvn1RAECSUVRRQaAPmBxM5c5MVy1 GcVqSTQgepfbqXm7Q+k9IpOBcMM/T7s9/kGW+/0Vdnmt6Mghu4UFtu2OisdwCyNRd25/ uUjReTOWdinQlSOMSjGz8eY7m4XVO8ngDhEi0/MUbTK/wGBHj8NFeFOyf9ams+OHuUWm ucAQ== 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; bh=2oEEo0SpkthW/JzN/AyJRWKAmMm/5YX85Fcew7nlKNk=; b=dx1+mwxiU8dlygrUGXVXx5+I7Ij7Hr19HwCUdivB36umcIAKIqmSBOJ1BC+BJfjcod gXdCmJuXmP1zbfEiDCQSnxyO45iW8uot4KTImbp4qgHLYPdzMdaPpZTIRC+p5KWqVcyo nsFuszboBW7lsvlUmuuwJU/t1vwav1zmtllzJSwywYE0ZtULcuypddTjqpCglRhr+2de 0k7Eg2gsQVg+ZLgTl1RFIEp42sfVRppbPvpYgVuz5dIcOGfB5PSaPJctNQzSCGdn093w 9VHgMRI45rV3BcTWnajBspvuFY4WX27+yUuSHLRLyU61K1jiTQgmdUAPlVIcRvwfzobw rlpw== ARC-Authentication-Results: i=1; mx.google.com; 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 t3si17907213plo.69.2019.01.22.23.26.03; Tue, 22 Jan 2019 23:26:18 -0800 (PST) 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; 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 S1726926AbfAWHYi (ORCPT + 99 others); Wed, 23 Jan 2019 02:24:38 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:16536 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725973AbfAWHYg (ORCPT ); Wed, 23 Jan 2019 02:24:36 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 529F466200670903FACD; Wed, 23 Jan 2019 15:24:34 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x0N7OPjN027469; Wed, 23 Jan 2019 15:24:25 +0800 (GMT-8) (envelope-from peng.hao2@zte.com.cn) Received: from localhost.localdomain.localdomain ([10.74.120.59]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019012315244759-23701699 ; Wed, 23 Jan 2019 15:24:47 +0800 From: Peng Hao To: gregkh@linuxfoundation.org, arnd@arndb.de, andy.shevchenko@gmail.com Cc: linux-kernel@vger.kernel.org, Peng Hao Subject: [PATCH V3 3/6] misc/pvpanic: add API for pvpanic driver framework Date: Wed, 23 Jan 2019 23:47:25 +0800 Message-Id: <1548258448-62013-4-git-send-email-peng.hao2@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1548258448-62013-1-git-send-email-peng.hao2@zte.com.cn> References: <1548258448-62013-1-git-send-email-peng.hao2@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-01-23 15:24:47, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-01-23 15:24:18, Serialize complete at 2019-01-23 15:24:18 X-MAIL: mse01.zte.com.cn x0N7OPjN027469 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add pvpanic_add/remove_device API. Follow-up patches will use them to add/remove specific drivers into framework. Signed-off-by: Peng Hao --- drivers/misc/pvpanic/pvpanic.c | 32 ++++++++++++++++++++++++++++++++ drivers/misc/pvpanic/pvpanic.h | 14 ++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 drivers/misc/pvpanic/pvpanic.h diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c index 227ab4e..f842ee4 100644 --- a/drivers/misc/pvpanic/pvpanic.c +++ b/drivers/misc/pvpanic/pvpanic.c @@ -48,6 +48,38 @@ .priority = 1, /* let this called before broken drm_fb_helper */ }; +int pvpanic_add_device(struct device *dev, struct resource *res) +{ + struct platform_device *pdev; + int ret; + + pdev = platform_device_alloc("pvpanic", -1); + if (!pdev) + return -ENOMEM; + + pdev->dev.parent = dev; + + ret = platform_device_add_resources(pdev, res, 1); + if (ret) + goto err; + + ret = platform_device_add(pdev); + if (ret) + goto err; + pvpanic_data.pdev = pdev; + + return 0; +err: + platform_device_put(pdev); + return -1; +} + +void pvpanic_remove_device(void) +{ + platform_device_unregister(pvpanic_data.pdev); + pvpanic_data.pdev = NULL; +} + static int pvpanic_platform_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; diff --git a/drivers/misc/pvpanic/pvpanic.h b/drivers/misc/pvpanic/pvpanic.h new file mode 100644 index 0000000..a72ca59 --- /dev/null +++ b/drivers/misc/pvpanic/pvpanic.h @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* pvpanic driver framework header file + * + * Copyright (C) 2019 ZTE Ltd. + * Author: Peng Hao + */ + +#ifndef __DRIVERS_MISC_PVPANIC_H +#define __DRIVERS_MISC_PVPANIC_H + +extern int pvpanic_add_device(struct device *dev, struct resource *res); +extern void pvpanic_remove_device(void); + +#endif -- 1.8.3.1