From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754991AbcI2Bvq convert rfc822-to-8bit (ORCPT ); Wed, 28 Sep 2016 21:51:46 -0400 Received: from mga05.intel.com ([192.55.52.43]:63508 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750738AbcI2Bvm (ORCPT ); Wed, 28 Sep 2016 21:51:42 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,412,1470726000"; d="scan'208";a="174367462" From: "Zha, Qipeng" To: Darren Hart , Axel Lin CC: Aubrey Li , "platform-driver-x86@vger.kernel.org" , Linux Kernel Mailing List Subject: RE: [PATCH RFT] platform/x86: intel_pmc_ipc: Convert to use platform_device_register_full Thread-Topic: [PATCH RFT] platform/x86: intel_pmc_ipc: Convert to use platform_device_register_full Thread-Index: AQHSFhdV9SPXpnNtcUeOLRVfKN4W7qCPEAwAgACre2A= Date: Thu, 29 Sep 2016 01:51:37 +0000 Message-ID: References: <1474689248-5925-1-git-send-email-axel.lin@ingics.com> <20160928233644.GC7630@f23x64.localdomain> In-Reply-To: <20160928233644.GC7630@f23x64.localdomain> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDgyZjIyZDctZTc0YS00NGM3LWE4ZWUtZmJiZjBhOWE4MDY1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IiswNGY2WFU5bm1NZENVWTh6R2VNSXJzVGxVVm02alc2aFNGSWRkSFBcL2dZPSJ9 x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's good to me, thanks. >+LKML > >Axel, please always include LKML on any patch. > >Qipeng, any concerns? On Sat, Sep 24, 2016 at 11:54:08AM +0800, Axel Lin wrote: > Use platform_device_register_full() instead of open-coded. > > Signed-off-by: Axel Lin > --- > drivers/platform/x86/intel_pmc_ipc.c | 110 > +++++++++++------------------------ > 1 file changed, 33 insertions(+), 77 deletions(-) > > diff --git a/drivers/platform/x86/intel_pmc_ipc.c > b/drivers/platform/x86/intel_pmc_ipc.c > index b86e1bc..665a9a1 100644 > --- a/drivers/platform/x86/intel_pmc_ipc.c > +++ b/drivers/platform/x86/intel_pmc_ipc.c > @@ -522,48 +522,36 @@ static struct resource telemetry_res[] = { > static int ipc_create_punit_device(void) { > struct platform_device *pdev; > - int ret; > - > - pdev = platform_device_alloc(PUNIT_DEVICE_NAME, -1); > - if (!pdev) { > - dev_err(ipcdev.dev, "Failed to alloc punit platform device\n"); > - return -ENOMEM; > - } > - > - pdev->dev.parent = ipcdev.dev; > - ret = platform_device_add_resources(pdev, punit_res_array, > - ARRAY_SIZE(punit_res_array)); > - if (ret) { > - dev_err(ipcdev.dev, "Failed to add platform punit resources\n"); > - goto err; > - } > + const struct platform_device_info pdevinfo = { > + .parent = ipcdev.dev, > + .name = PUNIT_DEVICE_NAME, > + .id = -1, > + .res = punit_res_array, > + .num_res = ARRAY_SIZE(punit_res_array), > + }; > + > + pdev = platform_device_register_full(&pdevinfo); > + if (IS_ERR(pdev)) > + return PTR_ERR(pdev); > > - ret = platform_device_add(pdev); > - if (ret) { > - dev_err(ipcdev.dev, "Failed to add punit platform device\n"); > - goto err; > - } > ipcdev.punit_dev = pdev; > > return 0; > -err: > - platform_device_put(pdev); > - return ret; > } > > static int ipc_create_tco_device(void) { > struct platform_device *pdev; > struct resource *res; > - int ret; > - > - pdev = platform_device_alloc(TCO_DEVICE_NAME, -1); > - if (!pdev) { > - dev_err(ipcdev.dev, "Failed to alloc tco platform device\n"); > - return -ENOMEM; > - } > - > - pdev->dev.parent = ipcdev.dev; > + const struct platform_device_info pdevinfo = { > + .parent = ipcdev.dev, > + .name = TCO_DEVICE_NAME, > + .id = -1, > + .res = tco_res, > + .num_res = ARRAY_SIZE(tco_res), > + .data = &tco_info, > + .size_data = sizeof(tco_info), > + }; > > res = tco_res + TCO_RESOURCE_ACPI_IO; > res->start = ipcdev.acpi_io_base + TCO_BASE_OFFSET; @@ -577,45 > +565,26 @@ static int ipc_create_tco_device(void) > res->start = ipcdev.gcr_base + TCO_PMC_OFFSET; > res->end = res->start + TCO_PMC_SIZE - 1; > > - ret = platform_device_add_resources(pdev, tco_res, ARRAY_SIZE(tco_res)); > - if (ret) { > - dev_err(ipcdev.dev, "Failed to add tco platform resources\n"); > - goto err; > - } > - > - ret = platform_device_add_data(pdev, &tco_info, sizeof(tco_info)); > - if (ret) { > - dev_err(ipcdev.dev, "Failed to add tco platform data\n"); > - goto err; > - } > + pdev = platform_device_register_full(&pdevinfo); > + if (IS_ERR(pdev)) > + return PTR_ERR(pdev); > > - ret = platform_device_add(pdev); > - if (ret) { > - dev_err(ipcdev.dev, "Failed to add tco platform device\n"); > - goto err; > - } > ipcdev.tco_dev = pdev; > > return 0; > -err: > - platform_device_put(pdev); > - return ret; > } > > static int ipc_create_telemetry_device(void) { > struct platform_device *pdev; > struct resource *res; > - int ret; > - > - pdev = platform_device_alloc(TELEMETRY_DEVICE_NAME, -1); > - if (!pdev) { > - dev_err(ipcdev.dev, > - "Failed to allocate telemetry platform device\n"); > - return -ENOMEM; > - } > - > - pdev->dev.parent = ipcdev.dev; > + const struct platform_device_info pdevinfo = { > + .parent = ipcdev.dev, > + .name = TELEMETRY_DEVICE_NAME, > + .id = -1, > + .res = telemetry_res, > + .num_res = ARRAY_SIZE(telemetry_res), > + }; > > res = telemetry_res + TELEMETRY_RESOURCE_PUNIT_SSRAM; > res->start = ipcdev.telem_punit_ssram_base; @@ -625,26 +594,13 @@ > static int ipc_create_telemetry_device(void) > res->start = ipcdev.telem_pmc_ssram_base; > res->end = res->start + ipcdev.telem_pmc_ssram_size - 1; > > - ret = platform_device_add_resources(pdev, telemetry_res, > - ARRAY_SIZE(telemetry_res)); > - if (ret) { > - dev_err(ipcdev.dev, > - "Failed to add telemetry platform resources\n"); > - goto err; > - } > + pdev = platform_device_register_full(&pdevinfo); > + if (IS_ERR(pdev)) > + return PTR_ERR(pdev); > > - ret = platform_device_add(pdev); > - if (ret) { > - dev_err(ipcdev.dev, > - "Failed to add telemetry platform device\n"); > - goto err; > - } > ipcdev.telemetry_dev = pdev; > > return 0; > -err: > - platform_device_put(pdev); > - return ret; > } > > static int ipc_create_pmc_devices(void) > -- > 2.7.4 > > -- Darren Hart Intel Open Source Technology Center