From patchwork Wed May 20 08:18:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taku Izumi X-Patchwork-Id: 474211 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E865614027F for ; Wed, 20 May 2015 18:18:58 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750934AbbETISz (ORCPT ); Wed, 20 May 2015 04:18:55 -0400 Received: from mgwkm03.jp.fujitsu.com ([202.219.69.170]:53813 "EHLO mgwkm03.jp.fujitsu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751095AbbETISx (ORCPT ); Wed, 20 May 2015 04:18:53 -0400 Received: from kw-mxoi1.gw.nic.fujitsu.com (unknown [192.168.231.131]) by mgwkm03.jp.fujitsu.com with smtp id 031f_7b6f_ba867af4_91e3_4397_8f00_2121a22ad2b7; Wed, 20 May 2015 17:18:50 +0900 Received: from g01jpfmpwyt01.exch.g01.fujitsu.local (g01jpfmpwyt01.exch.g01.fujitsu.local [10.128.193.38]) by kw-mxoi1.gw.nic.fujitsu.com (Postfix) with ESMTP id C12E7AC00E3; Wed, 20 May 2015 17:18:50 +0900 (JST) Received: from G01JPEXCHYT14.g01.fujitsu.local (G01JPEXCHYT14.g01.fujitsu.local [10.128.194.53]) by g01jpfmpwyt01.exch.g01.fujitsu.local (Postfix) with ESMTP id E2E926D680F; Wed, 20 May 2015 17:18:49 +0900 (JST) Received: from G01JPEXMBYT01.g01.fujitsu.local ([10.128.194.65]) by G01JPEXCHYT14 ([10.128.194.53]) with mapi id 14.03.0224.002; Wed, 20 May 2015 17:18:50 +0900 From: "Izumi, Taku" To: "platform-driver-x86@vger.kernel.org" CC: "Hart, Darren" , "rkhan@redhat.com" , "alexander.h.duyck@redhat.com" , "netdev@vger.kernel.org" , "linux-acpi@vger.kernel.org" Subject: [PATCH 3/7] fjes: Implement platform_driver functionality Thread-Topic: [PATCH 3/7] fjes: Implement platform_driver functionality Thread-Index: AdCS1ZF+X3aI1WjjTnSTqTeTL8YLbA== Date: Wed, 20 May 2015 08:18:48 +0000 Message-ID: Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-securitypolicycheck: OK by SHieldMailChecker v1.7.4 x-originating-ip: [10.124.102.50] MIME-Version: 1.0 X-SecurityPolicyCheck-GC: OK by FENCE-Mail X-TM-AS-MML: disable Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch adds implementation of platform_device driver to FUJITSU Extended Socket Network Device driver. When "PNP0C02" is found and ACPI resource can be retrieved successfuly, this driver creates platform_device. platform_driver.probe and .remove routine are mock code. Signed-off-by: Taku Izumi --- drivers/platform/x86/fjes/fjes_main.c | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/platform/x86/fjes/fjes_main.c b/drivers/platform/x86/fjes/fjes_main.c index 3454098..87057b8 100644 --- a/drivers/platform/x86/fjes/fjes_main.c +++ b/drivers/platform/x86/fjes/fjes_main.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "fjes.h" @@ -47,6 +48,9 @@ static int fjes_acpi_add(struct acpi_device *); static int fjes_acpi_remove(struct acpi_device *); static acpi_status fjes_get_acpi_resource(struct acpi_resource *, void*); +static int fjes_probe(struct platform_device *); +static int fjes_remove(struct platform_device *); + static const struct acpi_device_id fjes_acpi_ids[] = { {"PNP0C02", 0}, @@ -65,6 +69,15 @@ static struct acpi_driver fjes_acpi_driver = { }, }; +static struct platform_driver fjes_driver = { + .driver = { + .name = DRV_NAME, + .owner = THIS_MODULE, + }, + .probe = fjes_probe, + .remove = fjes_remove, +}; + static struct resource fjes_resource[] = { { .flags = IORESOURCE_MEM, @@ -93,6 +106,10 @@ static int __init fjes_init_module(void) fjes_driver_string, fjes_driver_version); pr_info("%s\n", fjes_copyright); + result = platform_driver_register(&fjes_driver); + if (result < 0) + return result; + result = acpi_bus_register_driver(&fjes_acpi_driver); if (result < 0) goto fail_acpi_driver; @@ -100,6 +117,7 @@ static int __init fjes_init_module(void) return 0; fail_acpi_driver: + platform_driver_unregister(&fjes_driver); return result; } @@ -114,6 +132,7 @@ module_init(fjes_init_module); static void __exit fjes_exit_module(void) { acpi_bus_unregister_driver(&fjes_acpi_driver); + platform_driver_unregister(&fjes_driver); } module_exit(fjes_exit_module); @@ -126,6 +145,7 @@ static int fjes_acpi_add(struct acpi_device *device) union acpi_object *str; char str_buf[sizeof(FJES_ACPI_SYMBOL) + 1]; int result; + struct platform_device *plat_dev; status = acpi_evaluate_object(device->handle, "_STR", NULL, &buffer); if (ACPI_FAILURE(status)) @@ -148,11 +168,21 @@ static int fjes_acpi_add(struct acpi_device *device) if (ACPI_FAILURE(status)) return -ENODEV; + /* create platform_device */ + plat_dev = platform_device_register_simple(DRV_NAME, 0, + fjes_resource, ARRAY_SIZE(fjes_resource)); + device->driver_data = plat_dev; + return 0; } static int fjes_acpi_remove(struct acpi_device *device) { + struct platform_device *plat_dev; + + plat_dev = (struct platform_device *)acpi_driver_data(device); + platform_device_unregister(plat_dev); + return 0; } @@ -186,5 +216,22 @@ static acpi_status fjes_get_acpi_resource(struct acpi_resource *acpi_res, return AE_OK; } +/* + * fjes_probe - Device Initialization Routine + * + * Returns 0 on success, negative on failure + */ +static int fjes_probe(struct platform_device *plat_dev) +{ + return 0; +} + +/* + * fjes_remove - Device Removal Routine + */ +static int fjes_remove(struct platform_device *plat_dev) +{ + return 0; +}