From patchwork Sun Mar 23 22:39:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Draszik?= X-Patchwork-Id: 14026711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F691C28B30 for ; Sun, 23 Mar 2025 23:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=66I6A9BwKPx78r+x2ze+D3BdpB1AaTqz42y1bAQYxGU=; b=Duwv7HZ3xOb0VnzceYtp2ot+YL /jKq7nKx5JXe3+ZMqDvq3wu1A+OVWOUq7gYHyhWS4Skw+u5lEjxAL+M2hI8PAMUyJZzKzODIxleQf SSLuM6N0yhFwY+aK4n/xbbt5ANC94cACOuZNQQbwm6MOvrgjUOxet5lqqUSZHYYTleJXjmeX0GSyC fEQYa1H9H8ydocS6CVIVcFruUfvNyknziE58AiPLAUXAnOTiQWW7FAzz7k0pwxzrBU1VGx3itux/Y 1b5/sB6ejygmM/d1MoHrC8izrlqA8aHY0UgnYcshiP0EffRg8h5JrwDeDUGoU1SjZmkXWVdy27CEa rCJp/dBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1twUUf-00000001tGf-0a6V; Sun, 23 Mar 2025 23:12:37 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1twTyi-00000001p9o-3ZrS for linux-arm-kernel@lists.infradead.org; Sun, 23 Mar 2025 22:39:38 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-ac29af3382dso635621766b.2 for ; Sun, 23 Mar 2025 15:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742769575; x=1743374375; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=66I6A9BwKPx78r+x2ze+D3BdpB1AaTqz42y1bAQYxGU=; b=LpPWf5wo1TqPJYZbdPWvURPI66sBI/6yP+96Q1zgWlf3irA8zh4QQs4vrB9T2WECCp RK/I2bdlZmbucU5wP/NXRLYWa3oPQcAmCbGZ2wosrWu76FqzRnu2dXla09Gkb0wcZj4Z aq9IDvJFMaZeJKIPUpnTbJ4k5PA+9rO+d8tmKFABGhB2b/Hud8t7wwq5hAge1NKHfEVH bPmwRhp+iDknqYM76zOgdoE0cPYigJ21ED64ltOCqRmE51JoTI2As2/yKTm/dFLfGF+M StII6oSnR0m7k3MbcSA9cNUoau5f30HYACAtyJ1G4TdRxIdqy+VzIKYEB6P+9usNf56h ccag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742769575; x=1743374375; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=66I6A9BwKPx78r+x2ze+D3BdpB1AaTqz42y1bAQYxGU=; b=KBj3NH1PjFOy8KdF8fKQNuofAJYYtKV4rt2EQB3MDaumadDdA6s+/tPOAdAiiEUioU TRSEnRdRi4+q5AeASyuZrgeETpLO2aR1NRtF44VI6bcXHHyAy3nr0LPyssF0HefP5Cur bPsoY1One3weU1QWR5k60iQ3fNywWKBbA2H2Sm+nw7/TUhn0PqQwwDz3e4flFzOQ7gRq lsgN/QMZsdlE0U02sisFthuiLPrIapNg/QnTp+CiTFDo1ufwkazXS2h4WsUxha8PTQkd hwBZIJxH9MwdnyWUQfDXCCSaLpYahhDco1QuNYl120iqrPWSvWzpMySHCAEqMnkIToZo rzJg== X-Forwarded-Encrypted: i=1; AJvYcCWjJcpmxgn9GYLEGi4hlqnaAooM8RNtIrOSZhGbdCtndM+dNZwL/aKR7nshpbjQvuE/00N/uHVMfZharlLb7ts7@lists.infradead.org X-Gm-Message-State: AOJu0Yysy2AxWyJU5RujmHXgHJpe0JevnNlm3geXNyX0GcVSPJEqJMuH BbO39moL3Rn7xjlT6gj/0O84uvrOL/d+cktbRAy9h1IiD+PtvqK9BLvO2mW+xfE= X-Gm-Gg: ASbGnctpDGVb07U2xR2/MDyJGSAFRHm31OWrjXI/ug4KYu/Z+GYyuoXnXv6RKxmJt8I sl4gmXElx25e+/6gQ+U4JMDObiqP+58apUxLa5szMnLhyT0pSKR8xtWJVZjXERLLZnJAq/JY7j/ Czg6CCgtk4sWfZ5OkcT8957h/HFfLXCDYdzKYwPeJ/EnCFtX6BwZdhk6yOoeAhBlklSfnsKyWT7 XG6Zv5OeyqngbTENosbZxKMi4Zo5znB4CMdZbnqKp6kYj3gnbxggUGvsZgapGljuQ4rYD2qi0lC PbbSToCVsqWiTf0J9Fa8joBrVuX8kS91ZiKpErHVBpm93xfeY58efsCtnnIvMZDUWFPE86cn8QQ Sk2kN7c9zAsNIbWKisjmMkNUH9EfR X-Google-Smtp-Source: AGHT+IFOl2n2dt4259UO9Y2Hc/nB/vtxXxb3XEltGi4hCBG4hgPGKnJT2FEY0IZG076qDEvYKYdc8w== X-Received: by 2002:a17:907:7f0c:b0:ac3:c4a9:7f89 with SMTP id a640c23a62f3a-ac3f251f2a0mr846621366b.54.1742769575429; Sun, 23 Mar 2025 15:39:35 -0700 (PDT) Received: from puffmais.c.googlers.com (8.239.204.35.bc.googleusercontent.com. [35.204.239.8]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac3ef86e44dsm559686666b.31.2025.03.23.15.39.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Mar 2025 15:39:35 -0700 (PDT) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Sun, 23 Mar 2025 22:39:36 +0000 Subject: [PATCH 20/34] mfd: sec: rework platform data and regmap instantiating MIME-Version: 1.0 Message-Id: <20250323-s2mpg10-v1-20-d08943702707@linaro.org> References: <20250323-s2mpg10-v1-0-d08943702707@linaro.org> In-Reply-To: <20250323-s2mpg10-v1-0-d08943702707@linaro.org> To: Krzysztof Kozlowski , Lee Jones , Rob Herring , Conor Dooley , Sylwester Nawrocki , Chanwoo Choi , Alim Akhtar , Michael Turquette , Stephen Boyd , Russell King , Catalin Marinas , Will Deacon , Alexandre Belloni Cc: Peter Griffin , Tudor Ambarus , Will McVicker , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Draszik?= X-Mailer: b4 0.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250323_153936_905929_2AB710AB X-CRM114-Status: GOOD ( 13.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Instead of a large open-coded switch statement, just add both regmap config and device type to the OF match data. This allows us to have all related information in one place, and avoids a long switch() statement. Signed-off-by: André Draszik --- drivers/mfd/sec-i2c.c | 137 +++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 69 deletions(-) diff --git a/drivers/mfd/sec-i2c.c b/drivers/mfd/sec-i2c.c index 1bdd6ea36fcd9f56ea5ec1159a87723f4c09a0bd..9f33d4569cf73461c57d101f6ca1cf2b75f22b4d 100644 --- a/drivers/mfd/sec-i2c.c +++ b/drivers/mfd/sec-i2c.c @@ -20,11 +20,16 @@ #include #include #include -#include #include +#include #include #include "sec-core.h" +struct sec_pmic_i2c_platform_data { + const struct regmap_config *regmap_cfg; + unsigned long device_type; +}; + static bool s2mpa01_volatile(struct device *dev, unsigned int reg) { switch (reg) { @@ -153,55 +158,23 @@ sec_pmic_i2c_parse_dt_pdata(struct device *dev, static int sec_pmic_i2c_probe(struct i2c_client *client) { + const struct sec_pmic_i2c_platform_data *pdata; struct sec_pmic_probe_data probedata; - const struct regmap_config *regmap; - unsigned long device_type; struct regmap *regmap_pmic; - sec_pmic_i2c_parse_dt_pdata(&client->dev, &probedata); - - device_type = (unsigned long)of_device_get_match_data(&client->dev); - - switch (device_type) { - case S2DOS05: - regmap = &s2dos05_regmap_config; - break; - case S2MPA01: - regmap = &s2mpa01_regmap_config; - break; - case S2MPS11X: - regmap = &s2mps11_regmap_config; - break; - case S2MPS13X: - regmap = &s2mps13_regmap_config; - break; - case S2MPS14X: - regmap = &s2mps14_regmap_config; - break; - case S2MPS15X: - regmap = &s2mps15_regmap_config; - break; - case S2MPU02: - regmap = &s2mpu02_regmap_config; - break; - case S2MPU05: - regmap = &s2mpu05_regmap_config; - break; - case S5M8767X: - regmap = &s5m8767_regmap_config; - break; - default: + pdata = device_get_match_data(&client->dev); + if (!pdata) return dev_err_probe(&client->dev, -ENODEV, - "Unsupported device type %lu\n", - device_type); - } + "Unsupported device type\n"); - regmap_pmic = devm_regmap_init_i2c(client, regmap); + sec_pmic_i2c_parse_dt_pdata(&client->dev, &probedata); + + regmap_pmic = devm_regmap_init_i2c(client, pdata->regmap_cfg); if (IS_ERR(regmap_pmic)) return dev_err_probe(&client->dev, PTR_ERR(regmap_pmic), "regmap init failed\n"); - return sec_pmic_probe(&client->dev, device_type, client->irq, + return sec_pmic_probe(&client->dev, pdata->device_type, client->irq, regmap_pmic, &probedata, client); } @@ -210,35 +183,61 @@ static void sec_pmic_i2c_shutdown(struct i2c_client *i2c) sec_pmic_shutdown(&i2c->dev); } +static const struct sec_pmic_i2c_platform_data s2dos05_data = { + .regmap_cfg = &s2dos05_regmap_config, + .device_type = S2DOS05 +}; + +static const struct sec_pmic_i2c_platform_data s2mpa01_data = { + .regmap_cfg = &s2mpa01_regmap_config, + .device_type = S2MPA01, +}; + +static const struct sec_pmic_i2c_platform_data s2mps11_data = { + .regmap_cfg = &s2mps11_regmap_config, + .device_type = S2MPS11X, +}; + +static const struct sec_pmic_i2c_platform_data s2mps13_data = { + .regmap_cfg = &s2mps13_regmap_config, + .device_type = S2MPS13X, +}; + +static const struct sec_pmic_i2c_platform_data s2mps14_data = { + .regmap_cfg = &s2mps14_regmap_config, + .device_type = S2MPS14X, +}; + +static const struct sec_pmic_i2c_platform_data s2mps15_data = { + .regmap_cfg = &s2mps15_regmap_config, + .device_type = S2MPS15X, +}; + +static const struct sec_pmic_i2c_platform_data s2mpu02_data = { + .regmap_cfg = &s2mpu02_regmap_config, + .device_type = S2MPU02, +}; + +static const struct sec_pmic_i2c_platform_data s2mpu05_data = { + .regmap_cfg = &s2mpu05_regmap_config, + .device_type = S2MPU05, +}; + +static const struct sec_pmic_i2c_platform_data s5m8767_data = { + .regmap_cfg = &s5m8767_regmap_config, + .device_type = S5M8767X, +}; + static const struct of_device_id sec_pmic_i2c_of_match[] = { - { - .compatible = "samsung,s2dos05", - .data = (void *)S2DOS05, - }, { - .compatible = "samsung,s2mpa01-pmic", - .data = (void *)S2MPA01, - }, { - .compatible = "samsung,s2mps11-pmic", - .data = (void *)S2MPS11X, - }, { - .compatible = "samsung,s2mps13-pmic", - .data = (void *)S2MPS13X, - }, { - .compatible = "samsung,s2mps14-pmic", - .data = (void *)S2MPS14X, - }, { - .compatible = "samsung,s2mps15-pmic", - .data = (void *)S2MPS15X, - }, { - .compatible = "samsung,s2mpu02-pmic", - .data = (void *)S2MPU02, - }, { - .compatible = "samsung,s2mpu05-pmic", - .data = (void *)S2MPU05, - }, { - .compatible = "samsung,s5m8767-pmic", - .data = (void *)S5M8767X, - }, + { .compatible = "samsung,s2dos05", .data = &s2dos05_data, }, + { .compatible = "samsung,s2mpa01-pmic", .data = &s2mpa01_data, }, + { .compatible = "samsung,s2mps11-pmic", .data = &s2mps11_data, }, + { .compatible = "samsung,s2mps13-pmic", .data = &s2mps13_data, }, + { .compatible = "samsung,s2mps14-pmic", .data = &s2mps15_data, }, + { .compatible = "samsung,s2mps15-pmic", .data = &s2mps15_data, }, + { .compatible = "samsung,s2mpu02-pmic", .data = &s2mpu02_data, }, + { .compatible = "samsung,s2mpu05-pmic", .data = &s2mpu05_data, }, + { .compatible = "samsung,s5m8767-pmic", .data = &s5m8767_data, }, { }, }; MODULE_DEVICE_TABLE(of, sec_pmic_i2c_of_match);