From patchwork Thu Nov 30 20:13:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 748505 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1099360wrn; Thu, 30 Nov 2023 12:14:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFptlWlvstQJjrCc0hMIxHZ/KWxICQ7oElZOTgBUzTDudTPQUtP9LcijwegwseGO05/X9WW X-Received: by 2002:aa7:98dd:0:b0:6cd:e189:c0f4 with SMTP id e29-20020aa798dd000000b006cde189c0f4mr4537014pfm.12.1701375272563; Thu, 30 Nov 2023 12:14:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375272; cv=none; d=google.com; s=arc-20160816; b=l7vOHsX8d/NydoffG5OFX+WvBYERb42xFMuSpwsJZNfqNVuRPYmTsjfLdc+JCj5Xo+ XXCDmztFTg+d7N8wJeoFKXf/hnIy1ZDJdWf3iGEc3wIuF5TpWrNk3/u/CrvG29/dn2ZD sDtzw6ptYqhNElexUDhevYm/gbibgnHxitFbFYWbW0Zc3Srcq3/H6iOTq9B07w6JP/Ni DBFS7pL4bMBR0U6SkqbBJZ4NayltUsQjnulDlTh4CSBqMEx+56aSvWDFIynT6AmGLm4k Ib4DBV8LxJBEIg1DK9v64TINC3pZcAoRMFjXx9fKXOQG3LJtxbwGDIfXAScEpA1lkXvo 6lxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=24twM8Gopj8Bt8YRkSH7X4CY1ye6W4+acyuqiKl0gnE=; fh=249O9ROWnprHO+UayzBfuXR6OIgDvHdlAHTtO8OnZEM=; b=slE/HQUK3nTSG6vOWTfN0rcArGu4dmBunu7vWLjFPrNds9KFc9gotPrlmd8Ti1VVNY /qcjUq8fHZSjD9Fz9GTMObiiwaMw5Awh4CokgxGl0VHpIf2sJlJ8yL8kjYwvHuEs0eD9 fzmt0keJBtpXueQUY9Ke7VhQlnE1ZWHFYC3Q7UAOvOmKkZHls2BbfG9GrJ0MDWxx4NY+ 3454pIDlKJBGcLY6hHOUdsMEcYXNM2+NDfatQpPSTY6a6sH81JghVAthUV91StUSshSx fjIma7hU882BjATaaSohPLLG8yw518ILg/XQgLo5EH9K2SDU4JrPKdA0w69viwPs52w6 w0fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PoejjSav; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id h14-20020a63e14e000000b005bdfda8e044si1934586pgk.775.2023.11.30.12.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:14:32 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PoejjSav; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 47288876C6; Thu, 30 Nov 2023 21:14:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="PoejjSav"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6106487646; Thu, 30 Nov 2023 21:13:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2D7F387646 for ; Thu, 30 Nov 2023 21:13:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-58cf894544cso768634eaf.3 for ; Thu, 30 Nov 2023 12:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375235; x=1701980035; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=24twM8Gopj8Bt8YRkSH7X4CY1ye6W4+acyuqiKl0gnE=; b=PoejjSavwRrX7lRy3k26625fGSYxftVsxf+PGTzQuwTMx1QrHhSiTQkF4qFBZAE+zw Th8PunUoTSX37sFOOMe+KzRvn4ISR3/ll2bItchh9ZOgNbhe8oGWEqn8pirmjTMO3NKD wDPAews7l7Tp8f6v4abJMxdQ+SZMSkMTVvesJkilLVUzz2R7z/3dQ17pqae79QeItok6 RZPxtyUfB10LjTHc//Iu2+22tVZWYylTIhvmDLu1nqrhstmBLoY3WY655wwNTyTOSezF ilgQg8whxTtl7S2BtVl1f5Hhd0Hm0WeUZrs8ndgnQnvQb+TGdlHgV37QamnQab1qzcuJ 6VRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375235; x=1701980035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=24twM8Gopj8Bt8YRkSH7X4CY1ye6W4+acyuqiKl0gnE=; b=QMQBSJPh+UZ6HMI5r7pxBJtUgzUhYUqoVxzxrTJoTpTqov1ThaP22UMevLbRFVYXhN QCxJZnuzKou3tHQ0JpR/z/NshfInSYLgM36LZSRruXMi9kF0H2ZBo79NbILaOvt7IPTv aSea7FDhCInNAiC+mknV2oJ7lopBPz+/9DHXWcm4ZsJCKtTcHC9reAqKjIK6yoK7Un7h k1tbJHgTsjbbpeKunFWMt1D8LfgLkJMvkIQuEC+Jr2Eq/4w/zndGckhxNZilIp3UXg7m Y3MIPJvMd8TW4t5hMHw9KFF0n1yrDUwwc05+c2Oq2EAfOeIdX+fWYOt8CGohzulbQQnB rtZg== X-Gm-Message-State: AOJu0Yw2zqjFRwTY2EehjGb6aAuevNhegbbOoEeCB2vEgr3jO2JtZmoP xB3qnQhTUhcACaiwRXVTnTGOqQ== X-Received: by 2002:a05:6870:524c:b0:1fa:3014:ada9 with SMTP id o12-20020a056870524c00b001fa3014ada9mr22293906oai.54.1701375234450; Thu, 30 Nov 2023 12:13:54 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id la2-20020a056871410200b001f5d2d47439sm428404oab.32.2023.11.30.12.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:13:54 -0800 (PST) From: Sam Protsenko To: Minkyu Kang , Tom Rini Cc: Andre Przywara , Simon Glass , u-boot@lists.denx.de Subject: [PATCH 2/7] pinctrl: exynos: Extract pin parsing code into a separate function Date: Thu, 30 Nov 2023 14:13:47 -0600 Message-Id: <20231130201352.6379-3-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231130201352.6379-1-semen.protsenko@linaro.org> References: <20231130201352.6379-1-semen.protsenko@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Next commits are going to re-design the pin_to_bank_base() function and its usage in a way that the pin parsing code will be called separately. Extract it into a separate function first, as a refactoring commit. No functional change. Signed-off-by: Sam Protsenko --- drivers/pinctrl/exynos/pinctrl-exynos.c | 27 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/exynos/pinctrl-exynos.c b/drivers/pinctrl/exynos/pinctrl-exynos.c index 995a3a0ee5fd..2d194ba0a4b5 100644 --- a/drivers/pinctrl/exynos/pinctrl-exynos.c +++ b/drivers/pinctrl/exynos/pinctrl-exynos.c @@ -34,6 +34,22 @@ void exynos_pinctrl_setup_peri(struct exynos_pinctrl_config_data *conf, } } +static void parse_pin(const char *pin_name, u32 *pin, char *bank_name) +{ + u32 idx = 0; + + /* + * The format of the pin name is -. + * Example: gpa0-4 (gpa0 is the bank_name name and 4 is the pin number. + */ + while (pin_name[idx] != '-') { + bank_name[idx] = pin_name[idx]; + idx++; + } + bank_name[idx] = '\0'; + *pin = pin_name[++idx] - '0'; +} + /* given a pin-name, return the address of pin config registers */ static unsigned long pin_to_bank_base(struct udevice *dev, const char *pin_name, u32 *pin) @@ -44,16 +60,7 @@ static unsigned long pin_to_bank_base(struct udevice *dev, const char *pin_name, u32 nr_banks, pin_ctrl_idx = 0, idx = 0, bank_base; char bank[10]; - /* - * The format of the pin name is -. - * Example: gpa0-4 (gpa0 is the bank name and 4 is the pin number. - */ - while (pin_name[idx] != '-') { - bank[idx] = pin_name[idx]; - idx++; - } - bank[idx] = '\0'; - *pin = pin_name[++idx] - '0'; + parse_pin(pin_name, pin, bank); /* lookup the pin bank data using the pin bank name */ while (true) {