From patchwork Wed Feb 1 23:09:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9550771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7569360424 for ; Wed, 1 Feb 2017 23:09:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 645A52844A for ; Wed, 1 Feb 2017 23:09:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5758928458; Wed, 1 Feb 2017 23:09:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F00382844A for ; Wed, 1 Feb 2017 23:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752186AbdBAXJS (ORCPT ); Wed, 1 Feb 2017 18:09:18 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33636 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752089AbdBAXJR (ORCPT ); Wed, 1 Feb 2017 18:09:17 -0500 Received: by mail-pg0-f66.google.com with SMTP id 194so35462091pgd.0; Wed, 01 Feb 2017 15:09:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=jX/9ssCnQJluBxtfmS9kMpIgD4kdjCpI9Hi6pkBakqI=; b=X5iSCSjzEm6LBJezJBzOj15bvolYQ1RPd5KrsuSNdz1XOHfzKTpenCyfkdEIrAwZHl 236kWEEwCLR7RqFbDGAOjFNVsQ4au6ougLT5QMDbsdr/0xZ1aMBuGlK2eceppd5wrrI8 dRp1cgGo7s496vizDjH7tULG281uYW2HTno+kb7vSA51CWYqiEH08S7BZJr9eHl6I6fr g3xhLxegxKN7imMSng2FtTfFA4666MP5HsH1TrgQzi/dH2MYzd2iyqdtPMpVIa56Wh4G s5D/r2sF1LvJvA7aLg4FuahEQ1cn2zH03N0EgwZv848ttbL95qrDXiij99URi5OEXLOi ucng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=jX/9ssCnQJluBxtfmS9kMpIgD4kdjCpI9Hi6pkBakqI=; b=DHJyFO3VZv9R4wQGciaNO0dTAE1TcqOfHcEgUeFjDnA3MgLQutZHrSSF4fpgPl3aAY noyxNivCbn4Ti8d24uYeoQh2CEDcz6AP44Fml8uH/KLyzQl0CRuOxPPCw0nm2qPHgERU wvMWhaC4H1MyAYPV13ufFvyMhIuY5yp8ozy6E4hjoXLV3vvFWn8uqTDNxY1PKZXlk2g7 fJzWunNJJja1mL6ifzeGD6mGasX+pCRH2oP7gzdu8OVy7pQCmwScsGl+LtNo5murbuIv wF0DjcUcXFf9Ts3U8XQDBpGMmV7Y96k+NEIyY+XN9Iyz39y/iTdBEGUMdeq7wuYVz9q+ J91g== X-Gm-Message-State: AIkVDXKOMKH6XjlZEe9p8IM0vwRn1vhNyf48D32liTjn9CTBw2Nk/Exn2OcEPLbGM9ELQA== X-Received: by 10.99.121.195 with SMTP id u186mr6897214pgc.96.1485990556953; Wed, 01 Feb 2017 15:09:16 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1311:4916:fdca:51f:9afb]) by smtp.gmail.com with ESMTPSA id a24sm52367390pfh.33.2017.02.01.15.09.16 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 01 Feb 2017 15:09:16 -0800 (PST) Date: Wed, 1 Feb 2017 15:09:14 -0800 From: Dmitry Torokhov To: Yoshinori Sato Cc: Rich Felker , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] sh: make use of for_each_node_by_type() Message-ID: <20170201230914.GA33322@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of open-coding the loop, let's use canned macro. Also make sure we are not leaking last OF node reference. Signed-off-by: Dmitry Torokhov --- arch/sh/boards/of-generic.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c index 1fb6d5714bae..fc318386d7b0 100644 --- a/arch/sh/boards/of-generic.c +++ b/arch/sh/boards/of-generic.c @@ -56,15 +56,15 @@ const struct of_cpu_method __cpu_method_of_table_sentinel static void sh_of_smp_probe(void) { - struct device_node *np = 0; - const char *method = 0; + struct device_node *np; + const char *method = NULL; const struct of_cpu_method *m = __cpu_method_of_table; pr_info("SH generic board support: scanning for cpus\n"); init_cpu_possible(cpumask_of(0)); - while ((np = of_find_node_by_type(np, "cpu"))) { + for_each_node_by_type(np, "cpu") { const __be32 *cell = of_get_property(np, "reg", NULL); u64 id = -1; if (cell) id = of_read_number(cell, of_n_addr_cells(np)); @@ -80,6 +80,7 @@ static void sh_of_smp_probe(void) if (!method) { np = of_find_node_by_name(NULL, "cpus"); of_property_read_string(np, "enable-method", &method); + of_node_put(np); } pr_info("CPU enable method: %s\n", method);