From mboxrd@z Thu Jan 1 00:00:00 1970 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 D251AC7EE25 for ; Fri, 9 Jun 2023 08:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=82iBjeFQh4PlsJ6Vpfcyzf9OKzGQ81CbX8S1JhvUuMA=; b=jA6g5UYjm1Ja4W j0PNozG9NxBiV959bPWvG0HvuoISVlBy3jsgg/ZgUhmwmSkcur148cjZx5ExEwe2M6SIohqnIIwfQ Dw4lAYxpmCmikyix4PSc0RmBi3yjunaZpfBK7yGCptIAKs/DC6ECJQOLgbPGp5mCtzONJAF/eHTAY upV4HzNJ4s5KIuGexOl5Bj95d3MmfFiaY/QS4X0Hsuq43xzg+1HEUH57+5qO7Ytbhfs08M5dA7o1O mDGM0NiaOqdVakV61Z6VeYcONdvlIv7xJQ+vltqhMJ0/Q4oSowkrtJ7UyxXfYnB3TRi+k8Wex3geM b2qFC1NAcUCOnPD6FDXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7XWO-00CEmp-1h; Fri, 09 Jun 2023 08:31:00 +0000 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7XWG-00CEcv-2O for linux-arm-kernel@lists.infradead.org; Fri, 09 Jun 2023 08:30:54 +0000 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-53f9a376f3eso560158a12.0 for ; Fri, 09 Jun 2023 01:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1686299447; x=1688891447; 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=Y20hfxdBlfIy/ItHN/HqfoEN5rlOgkF1Vq6pZHwBBZQ=; b=b1z1ImptZRD1QiXEaYQtBkKMiaM1FzlNwl9m2l0/VOouTX+wm5uYRm2cqqdIywDi3P wzrJ7EddFJviATlgeX9kWgCVwZciNX1ZoNozWzT9lc9gWLb6dNIASTx2pNtphn3V/ple MVgElzNSNJNs36hcTdccf0alSjZNX1fHWvlzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686299447; x=1688891447; 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=Y20hfxdBlfIy/ItHN/HqfoEN5rlOgkF1Vq6pZHwBBZQ=; b=bx+ruh7bVqq8k7xkNUloK16TkSg1T4uri0TI0SBNDcqNpTSeePMbsUc0qAp0uxeo8G UiSVrB45Ou6B9+eZagkePxfav2uwH2ZL1Uv79TNJt8Zewi84Ug0xvDyGCbulG+8eujhb JrFSxNe1kykGx5AmGAhEJ0oWqdoeeaLqbU3gBtXsj5mJoFsa8ErQTSJAZAkbGc0jGSG4 U0A+6XEFGn2CjceSja3bsWgVKWtNsafAHvzpO+v9u3PPkg92IaPB1gkqxez51i0FN/Rf RbMMhKAZgvLcTm/Sgj9xorOGSQEGo5y7m1DM2wHjzDmZPaS3DXUuWAnMzNEvvGFqPsO/ ALAg== X-Gm-Message-State: AC+VfDytpWnJgsDL4brvJB4Pe+dN0vYtvuYKkzDeeDtCt129+P9ju79z kvfIlSlV3/YEjfXCcnvscMc6gQ== X-Google-Smtp-Source: ACHHUZ5Put2IsUN+JeMEl0ftnTU8g4YJZw9JRRCey+z+DaRPLycmDKsBgW74WLrRp8KgF+PhgfXgTg== X-Received: by 2002:a05:6a20:1606:b0:10f:708b:bb28 with SMTP id l6-20020a056a20160600b0010f708bbb28mr797120pzj.7.1686299447295; Fri, 09 Jun 2023 01:30:47 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:c2ea:d8e4:1fe8:21f0]) by smtp.gmail.com with ESMTPSA id 23-20020aa79157000000b0063b806b111csm2184327pfi.169.2023.06.09.01.30.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 01:30:46 -0700 (PDT) From: Chen-Yu Tsai To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mark Brown , Liam Girdwood , Matthias Brugger , AngeloGioacchino Del Regno Cc: Chen-Yu Tsai , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] regulator: mt6358: Const-ify mt6358_regulator_info data structures Date: Fri, 9 Jun 2023 16:30:02 +0800 Message-ID: <20230609083009.2822259-6-wenst@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230609083009.2822259-1-wenst@chromium.org> References: <20230609083009.2822259-1-wenst@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230609_013052_810079_42564B3C X-CRM114-Status: GOOD ( 18.24 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In the MT6358 regulator driver, each regulator is described by a |struct regulator_desc| wrapped by a |struct mt6358_regulator_info|. The latter was tied to the regulator device using the config's driver_data field, which meant that the variables could not be constant. Since each regulator device has a pointer to its regulator_desc, and mt6358_regulator_info wraps that, the driver could use container_of() to retrieve it instead. Switch to using container_of(), drop tha driver_data setting, and const-ify all the regulator descriptions. Signed-off-by: Chen-Yu Tsai --- drivers/regulator/mt6358-regulator.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt6358-regulator.c index 946a251a8b3a..2851ef53ac63 100644 --- a/drivers/regulator/mt6358-regulator.c +++ b/drivers/regulator/mt6358-regulator.c @@ -34,6 +34,8 @@ struct mt6358_regulator_info { u32 modeset_mask; }; +#define to_regulator_info(x) container_of((x), struct mt6358_regulator_info, desc) + #define MT6358_BUCK(match, vreg, min, max, step, \ volt_ranges, vosel_mask, _da_vsel_reg, _da_vsel_mask, \ _modeset_reg, _modeset_shift) \ @@ -342,9 +344,9 @@ static unsigned int mt6358_map_mode(unsigned int mode) static int mt6358_set_voltage_sel(struct regulator_dev *rdev, unsigned int selector) { + const struct mt6358_regulator_info *info = to_regulator_info(rdev->desc); int idx, ret; const u32 *pvol; - struct mt6358_regulator_info *info = rdev_get_drvdata(rdev); pvol = info->index_table; @@ -358,9 +360,9 @@ static int mt6358_set_voltage_sel(struct regulator_dev *rdev, static int mt6358_get_voltage_sel(struct regulator_dev *rdev) { + const struct mt6358_regulator_info *info = to_regulator_info(rdev->desc); int idx, ret; u32 selector; - struct mt6358_regulator_info *info = rdev_get_drvdata(rdev); const u32 *pvol; ret = regmap_read(rdev->regmap, info->desc.vsel_reg, &selector); @@ -384,8 +386,8 @@ static int mt6358_get_voltage_sel(struct regulator_dev *rdev) static int mt6358_get_buck_voltage_sel(struct regulator_dev *rdev) { + const struct mt6358_regulator_info *info = to_regulator_info(rdev->desc); int ret, regval; - struct mt6358_regulator_info *info = rdev_get_drvdata(rdev); ret = regmap_read(rdev->regmap, info->da_vsel_reg, ®val); if (ret != 0) { @@ -402,9 +404,9 @@ static int mt6358_get_buck_voltage_sel(struct regulator_dev *rdev) static int mt6358_get_status(struct regulator_dev *rdev) { + const struct mt6358_regulator_info *info = to_regulator_info(rdev->desc); int ret; u32 regval; - struct mt6358_regulator_info *info = rdev_get_drvdata(rdev); ret = regmap_read(rdev->regmap, info->status_reg, ®val); if (ret != 0) { @@ -418,7 +420,7 @@ static int mt6358_get_status(struct regulator_dev *rdev) static int mt6358_regulator_set_mode(struct regulator_dev *rdev, unsigned int mode) { - struct mt6358_regulator_info *info = rdev_get_drvdata(rdev); + const struct mt6358_regulator_info *info = to_regulator_info(rdev->desc); int val; switch (mode) { @@ -443,7 +445,7 @@ static int mt6358_regulator_set_mode(struct regulator_dev *rdev, static unsigned int mt6358_regulator_get_mode(struct regulator_dev *rdev) { - struct mt6358_regulator_info *info = rdev_get_drvdata(rdev); + const struct mt6358_regulator_info *info = to_regulator_info(rdev->desc); int ret, regval; ret = regmap_read(rdev->regmap, info->modeset_reg, ®val); @@ -498,7 +500,7 @@ static const struct regulator_ops mt6358_volt_fixed_ops = { }; /* The array is indexed by id(MT6358_ID_XXX) */ -static struct mt6358_regulator_info mt6358_regulators[] = { +static const struct mt6358_regulator_info mt6358_regulators[] = { MT6358_BUCK("buck_vdram1", VDRAM1, 500000, 2087500, 12500, buck_volt_range2, 0x7f, MT6358_BUCK_VDRAM1_DBG0, 0x7f, MT6358_VDRAM1_ANA_CON0, 8), @@ -589,7 +591,7 @@ static struct mt6358_regulator_info mt6358_regulators[] = { }; /* The array is indexed by id(MT6366_ID_XXX) */ -static struct mt6358_regulator_info mt6366_regulators[] = { +static const struct mt6358_regulator_info mt6366_regulators[] = { MT6366_BUCK("buck_vdram1", VDRAM1, 500000, 2087500, 12500, buck_volt_range2, 0x7f, MT6358_BUCK_VDRAM1_DBG0, 0x7f, MT6358_VDRAM1_ANA_CON0, 8), @@ -712,7 +714,7 @@ static int mt6358_regulator_probe(struct platform_device *pdev) struct mt6397_chip *mt6397 = dev_get_drvdata(pdev->dev.parent); struct regulator_config config = {}; struct regulator_dev *rdev; - struct mt6358_regulator_info *mt6358_info; + const struct mt6358_regulator_info *mt6358_info; int i, max_regulator, ret; ret = mt6358_sync_vcn33_setting(&pdev->dev); @@ -729,7 +731,6 @@ static int mt6358_regulator_probe(struct platform_device *pdev) for (i = 0; i < max_regulator; i++) { config.dev = &pdev->dev; - config.driver_data = &mt6358_info[i]; config.regmap = mt6397->regmap; rdev = devm_regulator_register(&pdev->dev, -- 2.41.0.162.gfafddb0af9-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel