From patchwork Mon Jun 3 15:49:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 165603 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4643790ili; Mon, 3 Jun 2019 08:51:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyC+PTYCyF+/UTYaKNIhtUQt/r6rXyJGOAYYv/bBxEStfwo9EqF63/cTBbRYBF1uU1peUM X-Received: by 2002:a62:ed09:: with SMTP id u9mr32012075pfh.23.1559577062075; Mon, 03 Jun 2019 08:51:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559577062; cv=none; d=google.com; s=arc-20160816; b=hPyb5Id8j8+z2qpl13+pqA5gZWqrd/VePyf2PTBSBoY2WMZMbQD6Uxi0iOBRFQixOM 3zKAElFvgjIbpcyV5KJ4oZzdWG0tQF5WhNCcBYFOeULDXKp8QvNz4VO0lyAQ45QVaJwh TOpQ4rCYJyFbL5SvFNuVIsSX59HrPmf5c2Uql4nJ2VdPenFW7ih5Y1g6+uJEzPtUOZ5Z jrZzfxdHVeeATvDc4HZ8dHkoC3T1roiT+i2XBpLateHBQusKCicsg/LtesPAHMe+fAH/ z1Wnlc4eecYzu7P99+n8OKYBoZgX/S6v7/bE1i3WzvbPM4X5+X+vl3rBzXWSMobj4uoP z77Q== 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; bh=7OcctiR3Y5yafVm6MQ9anMwvPpnlhFp0GiQMldlkUH4=; b=OXdo3QcgNqi3TTwC+ysYQxKUhIfb80BbkDCcVokS0W6kpASV8LRT72jfizuq4Vp5aI i1Hsy14d+2f3XAkOvvEZAlQlTblw4oGqBAOl3DClHcfUHEsTZBBRZWcHiqBbYpG1d6MR VI5QRcBdtGRo/YejhYeZVqTm7rx9b+cioYZq6QvPt9Aa8cEZe3wCrhp32BWWQ9j0p884 UZox9eDNFQ4t6bPqVOO4wQLtBuu9ZImK+2KduowPwO5vMp4bDBlGj9pDfpKnJRoHTyAf fksR8SwhMue5TsEx+4ZpKl6hqjgNNxMH556tjQQFFUxc45pWQe8/fSWjrTCa7p3R5R/d HbLg== 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 a8si18108271pgm.592.2019.06.03.08.51.01; Mon, 03 Jun 2019 08:51:02 -0700 (PDT) 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 S1728264AbfFCPvA (ORCPT + 30 others); Mon, 3 Jun 2019 11:51:00 -0400 Received: from foss.arm.com ([217.140.101.70]:53500 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbfFCPvA (ORCPT ); Mon, 3 Jun 2019 11:51:00 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0599515AB; Mon, 3 Jun 2019 08:51:00 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A35A63F246; Mon, 3 Jun 2019 08:50:58 -0700 (PDT) From: Suzuki K Poulose To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, rafael@kernel.org, suzuki.poulose@arm.com, Sebastian Ott , Peter Oberparleiter , Heiko Carstens Subject: [RFC PATCH 01/57] drivers: s390/cio: Use driver_for_each_device Date: Mon, 3 Jun 2019 16:49:27 +0100 Message-Id: <1559577023-558-2-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559577023-558-1-git-send-email-suzuki.poulose@arm.com> References: <1559577023-558-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cio driver use driver_find_device() to find all devices to release them before the driver is unregistered. Instead, it could easily use a lighter driver_for_each_device() helper to iterate over all the devices. Cc: Sebastian Ott Cc: Peter Oberparleiter Cc: Heiko Carstens Signed-off-by: Suzuki K Poulose --- drivers/s390/cio/ccwgroup.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) -- 2.7.4 Reviewed-by: Sebastian Ott diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c index 4ebf6d4..a006945 100644 --- a/drivers/s390/cio/ccwgroup.c +++ b/drivers/s390/cio/ccwgroup.c @@ -581,9 +581,12 @@ int ccwgroup_driver_register(struct ccwgroup_driver *cdriver) } EXPORT_SYMBOL(ccwgroup_driver_register); -static int __ccwgroup_match_all(struct device *dev, void *data) +static int ccwgroup_release_device(struct device *dev, void *unused) { - return 1; + struct ccwgroup_device *gdev = to_ccwgroupdev(dev); + + ccwgroup_ungroup(gdev); + return 0; } /** @@ -594,16 +597,11 @@ static int __ccwgroup_match_all(struct device *dev, void *data) */ void ccwgroup_driver_unregister(struct ccwgroup_driver *cdriver) { - struct device *dev; + int ret; /* We don't want ccwgroup devices to live longer than their driver. */ - while ((dev = driver_find_device(&cdriver->driver, NULL, NULL, - __ccwgroup_match_all))) { - struct ccwgroup_device *gdev = to_ccwgroupdev(dev); - - ccwgroup_ungroup(gdev); - put_device(dev); - } + ret = driver_for_each_device(&cdriver->driver, NULL, NULL, + ccwgroup_release_device); driver_unregister(&cdriver->driver); } EXPORT_SYMBOL(ccwgroup_driver_unregister);