From patchwork Sat Sep 24 03:54:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 9349019 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 45568607F0 for ; Sat, 24 Sep 2016 03:54:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DC172A127 for ; Sat, 24 Sep 2016 03:54:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 205932A149; Sat, 24 Sep 2016 03:54:22 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 584122A127 for ; Sat, 24 Sep 2016 03:54:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753791AbcIXDyT (ORCPT ); Fri, 23 Sep 2016 23:54:19 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33113 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753757AbcIXDyT (ORCPT ); Fri, 23 Sep 2016 23:54:19 -0400 Received: by mail-pf0-f193.google.com with SMTP id q2so6047811pfj.0 for ; Fri, 23 Sep 2016 20:54:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ingics-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=LTEm/M7KOKpI3qay3ae///rtLuERyk6KpIDNi8Q7qY4=; b=Vpzz53QNjdtpwNCbVaQB3aKYPUB42v/Wzo4EQ4cnv2XC1QpeNmxwB2h4SiPi2Bnt1q L8cMyJ42dM2Mg5q2FKYzEwelQFC+nYrRuJa5CQdJRbbWEuIiqf+BtUiiE/+rpH7htxE1 9/kVn+VRmw7+hu7tz21kiuLoRl0ZfE5/GFflHTC/o9QY2iomW/9FA4/yH98bNfvBHcIl 394RYwhhFmloFTncc0V9gEA1uBJVnKHHOCOPJwWD/Qx660Fdcxw9kzxxudoVEoRAKXdT +njAjmDZIlN+qwzxmrgq34s/RuXZeizbMeYNa0rxvADMV4TG94VQjvr9dJ0oFPbLX+dg 2yYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LTEm/M7KOKpI3qay3ae///rtLuERyk6KpIDNi8Q7qY4=; b=FxkxdfRNbxRwHgp0JaOE3FiT6s8u5wHPVpbgiqIlsOs+TT03xWhvqGreLB5U4kW1Vg qWsnyc2PUtbySmgwrFu6tewbF6ZsGTloX9rR8v0s5TW7wuUcNV2DF0HemMWhTWCBh6WY VSZgxMvlHANnU21899B7AbLul79FDyTzcURUidPzoL0TAXvNf4QJHFGpkHkPqzYiCFQp ASE4r43JJuHoMGywltj744k4z87ApKzbwZobYZ8k1RVTUam2x6rKtcOUxR5x6N1yxDY8 UCr/FNBULIoLObX0VZ/mCRQy5cRVWKds9GjtDQ3ucWk7nUo15GhHhDcWi7DV9QZTgeuo 9jYA== X-Gm-Message-State: AE9vXwOQ/mUbzqUC02L6NSlXFyR6DYa4d8Qc5OfYS1bzLGsk7qF6v12lg9bsDIxiMWwaOw== X-Received: by 10.98.80.136 with SMTP id g8mr18408579pfj.185.1474689258183; Fri, 23 Sep 2016 20:54:18 -0700 (PDT) Received: from localhost.localdomain (223-137-0-10.EMOME-IP.hinet.net. [223.137.0.10]) by smtp.gmail.com with ESMTPSA id o5sm14611898pfb.9.2016.09.23.20.54.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Sep 2016 20:54:17 -0700 (PDT) From: Axel Lin To: Darren Hart Cc: Zha Qipeng , Aubrey Li , platform-driver-x86@vger.kernel.org, Axel Lin Subject: [PATCH RFT] platform/x86: intel_pmc_ipc: Convert to use platform_device_register_full Date: Sat, 24 Sep 2016 11:54:08 +0800 Message-Id: <1474689248-5925-1-git-send-email-axel.lin@ingics.com> X-Mailer: git-send-email 2.7.4 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)