From patchwork Fri Oct 9 14:11:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 7362041 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 805D79F32B for ; Fri, 9 Oct 2015 14:11:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B09B8207E8 for ; Fri, 9 Oct 2015 14:11:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B529720735 for ; Fri, 9 Oct 2015 14:11:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754032AbbJIOLk (ORCPT ); Fri, 9 Oct 2015 10:11:40 -0400 Received: from mga02.intel.com ([134.134.136.20]:25179 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753797AbbJIOLj (ORCPT ); Fri, 9 Oct 2015 10:11:39 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 09 Oct 2015 07:11:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,658,1437462000"; d="scan'208";a="807289459" Received: from black.fi.intel.com ([10.237.72.93]) by fmsmga001.fm.intel.com with ESMTP; 09 Oct 2015 07:11:37 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id ECCA5122; Fri, 9 Oct 2015 17:11:36 +0300 (EEST) From: Andy Shevchenko To: platform-driver-x86@vger.kernel.org, Darren Hart Cc: Andy Shevchenko Subject: [PATCH 1/5] intel_scu_ipc: fix error path by turning to devm_* / pcim_* Date: Fri, 9 Oct 2015 17:11:32 +0300 Message-Id: <1444399896-78599-1-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.5.3 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The error handling is broken right now since it leaves resources unfreed. Convert the code to use managed resources to fix the error handling. Signed-off-by: Andy Shevchenko --- drivers/platform/x86/intel_scu_ipc.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c index 187d108..7148535 100644 --- a/drivers/platform/x86/intel_scu_ipc.c +++ b/drivers/platform/x86/intel_scu_ipc.c @@ -563,7 +563,6 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) { int err; struct intel_scu_ipc_pdata_t *pdata; - resource_size_t base; if (ipcdev.pdev) /* We support only one SCU */ return -EBUSY; @@ -573,32 +572,26 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) ipcdev.pdev = pci_dev_get(dev); ipcdev.irq_mode = pdata->irq_mode; - err = pci_enable_device(dev); + err = pcim_enable_device(dev); if (err) return err; - err = pci_request_regions(dev, "intel_scu_ipc"); + err = pcim_iomap_regions(dev, 1 << 0, pci_name(dev)); if (err) return err; - base = pci_resource_start(dev, 0); - if (!base) - return -ENOMEM; - init_completion(&ipcdev.cmd_complete); - if (request_irq(dev->irq, ioc, 0, "intel_scu_ipc", &ipcdev)) - return -EBUSY; + err = devm_request_irq(&dev->dev, dev->irq, ioc, 0, "intel_scu_ipc", + &ipcdev); + if (err) + return err; - ipcdev.ipc_base = ioremap_nocache(base, pci_resource_len(dev, 0)); - if (!ipcdev.ipc_base) - return -ENOMEM; + ipcdev.ipc_base = pcim_iomap_table(dev)[0]; ipcdev.i2c_base = ioremap_nocache(pdata->i2c_base, pdata->i2c_len); - if (!ipcdev.i2c_base) { - iounmap(ipcdev.ipc_base); + if (!ipcdev.i2c_base) return -ENOMEM; - } intel_scu_devices_create(); @@ -617,10 +610,7 @@ static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id) */ static void ipc_remove(struct pci_dev *pdev) { - free_irq(pdev->irq, &ipcdev); - pci_release_regions(pdev); pci_dev_put(ipcdev.pdev); - iounmap(ipcdev.ipc_base); iounmap(ipcdev.i2c_base); ipcdev.pdev = NULL; intel_scu_devices_destroy();