Received: by 10.223.176.5 with SMTP id f5csp1073912wra; Fri, 2 Feb 2018 10:43:05 -0800 (PST) X-Google-Smtp-Source: AH8x227MOz1Y9Toqxw/xkgAjpzhm0JMTCb7WNhBhLOcLCcjaJFzdzxKRUY72BJuT5+2U0QmOZ8zz X-Received: by 10.98.98.1 with SMTP id w1mr33644334pfb.9.1517596985408; Fri, 02 Feb 2018 10:43:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517596985; cv=none; d=google.com; s=arc-20160816; b=pP7/pyxvOEzCuvQGQBg6fylVzg4NGZyssCvKvszWOJaMRavtG60VMvRk4aBIxcruL9 gW4duHVlD8qF7GFHeyZYjr0uiSpmJ+3raXQ4lbfC6BH+TJUB944Qecgz9T7ov7ydnRC1 aVVUceonzX32jigajormU3xn1Dy8S9SBw+y1VYoXlmXmxX8Lbhwxb0bhC3yvlVmHX+oV fMhGGitqGmCxSmCA0yQyBb0HZfdDzPh0x2niEef1OL3NAIO6iZ3XVBhRdpzBYTPeE6B6 G4AjMSbSkTvRCE4ZonnWSdXXFwVfzRqkrp2+xZY0xuRukyUbsfQk21nJOpeNEDbHhfLy rJpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=cz1a06Za0aGRYupcCtos7B4BQzQclteamudNm/a9nG8=; b=03EXUba1WOATJsv8CJxKoT38zebt4vSOLl/Mwqfbz7PUb/XCf2uOcBpqfgpQlBMB/S cWj1MVLZrrS0kXVElF3sIlUxzLDWtJDEY/F9AIJqPwQfqMzXVqKrgjpd0EI+s1wZ5UvL 1/fowKRzuKErBqa4nJKT7YTVN8PpiRzjL9OtNxzegSXNuvAXYS35myiwXEpdTy/ozODL kWRpAdAx9q713YT80j1c81CLwXVfAuOdmNgR6K3968+Ex3umdCvkh7VXXLJAYaBYPrwN gr8xkJGI9SCQ/JrTlJP46KtOWFbee6F8C/Vbf2LJTtR37ByYnGEbXRBgBAaMhTQ9HOrC AdIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z90si2273868pfl.204.2018.02.02.10.42.51; Fri, 02 Feb 2018 10:43:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755185AbeBBSk5 (ORCPT + 99 others); Fri, 2 Feb 2018 13:40:57 -0500 Received: from mga07.intel.com ([134.134.136.100]:52245 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755014AbeBBSkA (ORCPT ); Fri, 2 Feb 2018 13:40:00 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Feb 2018 10:39:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,450,1511856000"; d="scan'208";a="24456002" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 02 Feb 2018 10:39:57 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7CD321AC; Fri, 2 Feb 2018 20:39:56 +0200 (EET) From: Andy Shevchenko To: Sudip Mukherjee , linux-kernel@vger.kernel.org, Nikola Ciprich Cc: Andy Shevchenko Subject: [PATCH v1 3/8] parport: Convert to use managed functions pcim_* and devm_* Date: Fri, 2 Feb 2018 20:39:50 +0200 Message-Id: <20180202183955.85453-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180202183955.85453-1-andriy.shevchenko@linux.intel.com> References: <20180202183955.85453-1-andriy.shevchenko@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This makes the error handling much more simpler than open-coding everything and in addition makes the probe function smaller an tidier. Signed-off-by: Andy Shevchenko --- drivers/parport/parport_serial.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c index 9689503641dc..ac72ad1cabf5 100644 --- a/drivers/parport/parport_serial.c +++ b/drivers/parport/parport_serial.c @@ -617,27 +617,23 @@ static int parport_serial_pci_probe(struct pci_dev *dev, struct parport_serial_private *priv; int err; - priv = kzalloc (sizeof *priv, GFP_KERNEL); + priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; + pci_set_drvdata (dev, priv); - err = pci_enable_device (dev); - if (err) { - kfree (priv); + err = pcim_enable_device(dev); + if (err) return err; - } - if (parport_register (dev, id)) { - kfree (priv); + if (parport_register(dev, id)) return -ENODEV; - } if (serial_register (dev, id)) { int i; for (i = 0; i < priv->num_par; i++) parport_pc_unregister_port (priv->port[i]); - kfree (priv); return -ENODEV; } @@ -657,7 +653,6 @@ static void parport_serial_pci_remove(struct pci_dev *dev) for (i = 0; i < priv->num_par; i++) parport_pc_unregister_port (priv->port[i]); - kfree (priv); return; } -- 2.15.1