From patchwork Fri Feb 13 13:52:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 439507 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3B0031402EC for ; Sat, 14 Feb 2015 00:53:30 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752689AbbBMNx3 (ORCPT ); Fri, 13 Feb 2015 08:53:29 -0500 Received: from mga02.intel.com ([134.134.136.20]:44734 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752608AbbBMNx3 (ORCPT ); Fri, 13 Feb 2015 08:53:29 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 13 Feb 2015 05:53:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,571,1418112000"; d="scan'208";a="685303514" Received: from mylly.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.55]) by orsmga002.jf.intel.com with ESMTP; 13 Feb 2015 05:53:27 -0800 From: Jarkko Nikula To: linux-i2c@vger.kernel.org Cc: Jean Delvare , Wolfram Sang , Jarkko Nikula Subject: [PATCHv3 3/5] i2c: i801: Use managed devm_* memory and irq allocation Date: Fri, 13 Feb 2015 15:52:23 +0200 Message-Id: <1423835545-17991-3-git-send-email-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1423835545-17991-1-git-send-email-jarkko.nikula@linux.intel.com> References: <1423835545-17991-1-git-send-email-jarkko.nikula@linux.intel.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org This simplifies the error and remove paths. Signed-off-by: Jarkko Nikula Reviewed-by: Jean Delvare --- drivers/i2c/busses/i2c-i801.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 5f827dfc671a..b1d725d758bb 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1138,7 +1138,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) int err, i; struct i801_priv *priv; - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -1253,8 +1253,9 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) if (priv->features & FEATURE_IRQ) { init_waitqueue_head(&priv->waitq); - err = request_irq(dev->irq, i801_isr, IRQF_SHARED, - dev_driver_string(&dev->dev), priv); + err = devm_request_irq(&dev->dev, dev->irq, i801_isr, + IRQF_SHARED, + dev_driver_string(&dev->dev), priv); if (err) { dev_err(&dev->dev, "Failed to allocate irq %d: %d\n", dev->irq, err); @@ -1275,7 +1276,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) err = i2c_add_adapter(&priv->adapter); if (err) { dev_err(&dev->dev, "Failed to add SMBus adapter\n"); - goto exit_free_irq; + goto exit_release; } i801_probe_optional_slaves(priv); @@ -1286,12 +1287,9 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) return 0; -exit_free_irq: - if (priv->features & FEATURE_IRQ) - free_irq(dev->irq, priv); +exit_release: pci_release_region(dev, SMBBAR); exit: - kfree(priv); return err; } @@ -1303,11 +1301,8 @@ static void i801_remove(struct pci_dev *dev) i2c_del_adapter(&priv->adapter); pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg); - if (priv->features & FEATURE_IRQ) - free_irq(dev->irq, priv); pci_release_region(dev, SMBBAR); - kfree(priv); /* * do not call pci_disable_device(dev) since it can cause hard hangs on * some systems during power-off (eg. Fujitsu-Siemens Lifebook E8010)