From patchwork Sat Feb 17 02:06:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10225925 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 786EF601D4 for ; Sat, 17 Feb 2018 02:07:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63B33296EA for ; Sat, 17 Feb 2018 02:07:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 580BE296EC; Sat, 17 Feb 2018 02:07:13 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CADB2296EA for ; Sat, 17 Feb 2018 02:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=HJj4iVMMs+43Q27AOHYMK7MoDc1KE2fuYA9BDoe7sL8=; b=Q3x 0PwKmDLb/GP+zD1zmrifQ9N2R9C3SaOMmIdz1WyoC/Wemfnrr0JzpzWRcvnxoiKVN/h0gUyrjqrik VSrq5ZpuifRWVHAKpW1+yCYsDZZMJ8OOi4SnZlk1djOIZsqU0s1I64lyqU+UDNFzGj+66d6i3CYVc oKs0Ju+q5PNmY1PBCykuf1W7t+aI17tKs1ZJrgORM5sCy5RM10G+3kDxnhr4dZLECTr0ediDuUpkW +VIPnXYIjlsmraNYK9oeNDa7/YSmmiaA+kQPXhvRxeaxvV+fsxSYhs0KC5FAyrx15YcvmsA8cJa8Z VotXghNU0V4defJy1Dtq1SmBPReB61A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1emru3-00039V-WB; Sat, 17 Feb 2018 02:07:03 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1emrty-00036F-Om for linux-arm-kernel@lists.infradead.org; Sat, 17 Feb 2018 02:07:00 +0000 Received: by mail-wm0-x244.google.com with SMTP id j21so7736976wmh.1 for ; Fri, 16 Feb 2018 18:06:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=f1QjAvCqhZ7q4CxoXxpVNkLYPxDMlbMkSvdzBm2AFW0=; b=LMNUa3+1+Dt/BZCVNxVixJVhQctJI65GCjlx+50K4M6ZV2eeZHhwGo5RXC0sxUf7U5 cqaKVMjOK+leuHwoGaPSV8yjub7rrDdPpTgOnXellphlG+XaqIhJ8IfPPyGLwSD3KWQ6 tw+dflqsmY8NnZ7rzD7u+1AUWoRIbVL42hQAzUFHtEdZCbkHmXwXHCGeIttSYHYfHUZL qaQ3WZFOIk5mK+dHy4c6RulY+GdO/pD9ruThQVnnFPW1NYKIhaSwiZxGn/XcRxpE4Qxn 9J8paH7mNLdad7jD/byBP/8BAMAbWzgm94GKm+c30lNFfVpvR/42HeP99KpI20QPgFyx UcOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=f1QjAvCqhZ7q4CxoXxpVNkLYPxDMlbMkSvdzBm2AFW0=; b=Bkx3MimpMhigFX5XrzDFVRzPBeu/JcXXhOa3ybdz3217DG0jTdnPaYnKdBDHwQEJQE q1qUXeMt+JHE4SNsxOZ8WSMd+BE3iRgoAgJPmLEnQYIlO+afgZtEVqtP2icdrqv8NCVQ El599kxaCxs3hLTMORTznNQUZod5775CnKeRRTqQsFkDHIYRglHh5TWgnl3ysucGjBUT fl0LJBp/iYgQCX1H3q3MGlk4NmLCikZP3SXxWLFy9YOJLBDzEFLVr5KOHbzffzWPgDJS ZlfHWWB4YKb0aVwyF6SaIbamV4HJzlCvbUVLgLKmgElDbgyqAec/CO++VhBATDuCtCoW 2Sfw== X-Gm-Message-State: APf1xPBXK1wv8SX5ROdBT/+LGLGERwGs8IoDpFARlsYEY4g8jXsss0QX 9BlApnXcuIEePfbP9u9yOlo= X-Google-Smtp-Source: AH8x226GyN5VtgWFIpx2fJGJGdZA8hiJTAmUFQNsDTG1d9fxpr4noEmY2VPr7UgcylRg8kEdI4hi2Q== X-Received: by 10.28.136.19 with SMTP id k19mr6801311wmd.111.1518833207041; Fri, 16 Feb 2018 18:06:47 -0800 (PST) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id b65sm33195664wrd.26.2018.02.16.18.06.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Feb 2018 18:06:46 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-renesas-soc@vger.kernel.org Subject: [PATCH 1/2] ARM: shmobile: Factor out complex condition Date: Sat, 17 Feb 2018 03:06:41 +0100 Message-Id: <20180217020642.21375-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.15.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180216_180658_855963_7FDD8C84 X-CRM114-Status: GOOD ( 14.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Geert Uytterhoeven , Kuninori Morimoto , Wolfram Sang , Simon Horman , linux-arm-kernel@lists.infradead.org, Marek Vasut MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Pull the complex condition in regulator_quirk_notify() into regulator_quirk_check(). Moreover, do not hard-code the I2C address, but rather use the one in da9xxx_msgs[]. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Kuninori Morimoto Cc: Simon Horman Cc: Wolfram Sang --- arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c index 27fb3a5ec73e..862f7757ef5d 100644 --- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c +++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c @@ -66,6 +66,13 @@ static struct i2c_msg da9xxx_msgs[3] = { }, }; +static int regulator_quirk_check(struct i2c_client *client, u8 i2c_id, + char *compat_string) +{ + return client->addr == da9xxx_msgs[i2c_id].addr && + !strcmp(client->name, compat_string); +} + static int regulator_quirk_notify(struct notifier_block *nb, unsigned long action, void *data) { @@ -88,9 +95,9 @@ static int regulator_quirk_notify(struct notifier_block *nb, client = to_i2c_client(dev); dev_dbg(dev, "Detected %s\n", client->name); - if ((client->addr == 0x58 && !strcmp(client->name, "da9063")) || - (client->addr == 0x68 && !strcmp(client->name, "da9210")) || - (client->addr == 0x70 && !strcmp(client->name, "da9210"))) { + if (regulator_quirk_check(client, 0, "da9063") || + regulator_quirk_check(client, 1, "da9210") || + regulator_quirk_check(client, 2, "da9210")) { int ret, len; /* There are two DA9210 on Stout, one on the other boards. */