From patchwork Mon Oct 12 11:19:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 7374151 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 B6C229F1D5 for ; Mon, 12 Oct 2015 11:21:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DFAD320735 for ; Mon, 12 Oct 2015 11:21:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D4FC02072B for ; Mon, 12 Oct 2015 11:21:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751460AbbJLLTx (ORCPT ); Mon, 12 Oct 2015 07:19:53 -0400 Received: from mga14.intel.com ([192.55.52.115]:56561 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751067AbbJLLTv (ORCPT ); Mon, 12 Oct 2015 07:19:51 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 12 Oct 2015 04:19:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,672,1437462000"; d="scan'208";a="808954316" Received: from black.fi.intel.com ([10.237.72.93]) by fmsmga001.fm.intel.com with ESMTP; 12 Oct 2015 04:19:50 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2316DD3; Mon, 12 Oct 2015 14:19:49 +0300 (EEST) From: Andy Shevchenko To: platform-driver-x86@vger.kernel.org, Darren Hart , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v2 1/5] intel_scu_ipc: fix error path by turning to devm_* / pcim_* Date: Mon, 12 Oct 2015 14:19:44 +0300 Message-Id: <1444648788-74265-2-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: <1444648788-74265-1-git-send-email-andriy.shevchenko@linux.intel.com> References: <1444648788-74265-1-git-send-email-andriy.shevchenko@linux.intel.com> 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();