Skip to content

Commit 03c3bde

Browse files
krzkbroonie
authored andcommitted
regulator: pca9450: Constify pointers to 'regulator_desc' wrap struct
Pointer to 'struct regulator_desc' is a pointer to const and the wrapping structure (container) is not being modified, thus entire syntax can be replaced to preferred and safer container_of_const(). Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20251126-container-of-const-regulator-v1-7-eeec378144d4@oss.qualcomm.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 438e90a commit 03c3bde

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/regulator/pca9450-regulator.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static int buck_set_dvs(const struct regulator_desc *desc,
249249
}
250250

251251
if (ret == 0) {
252-
struct pca9450_regulator_desc *regulator = container_of(desc,
252+
const struct pca9450_regulator_desc *regulator = container_of_const(desc,
253253
struct pca9450_regulator_desc, desc);
254254

255255
/* Enable DVS control through PMIC_STBY_REQ for this BUCK */
@@ -263,7 +263,7 @@ static int pca9450_set_dvs_levels(struct device_node *np,
263263
const struct regulator_desc *desc,
264264
struct regulator_config *cfg)
265265
{
266-
struct pca9450_regulator_desc *data = container_of(desc,
266+
const struct pca9450_regulator_desc *data = container_of_const(desc,
267267
struct pca9450_regulator_desc, desc);
268268
const struct pc9450_dvs_config *dvs = &data->dvs;
269269
unsigned int reg, mask;
@@ -308,7 +308,7 @@ static inline unsigned int pca9450_map_mode(unsigned int mode)
308308

309309
static int pca9450_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
310310
{
311-
struct pca9450_regulator_desc *desc = container_of(rdev->desc,
311+
const struct pca9450_regulator_desc *desc = container_of_const(rdev->desc,
312312
struct pca9450_regulator_desc, desc);
313313
const struct pc9450_dvs_config *dvs = &desc->dvs;
314314
int val;
@@ -333,7 +333,7 @@ static int pca9450_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
333333

334334
static unsigned int pca9450_buck_get_mode(struct regulator_dev *rdev)
335335
{
336-
struct pca9450_regulator_desc *desc = container_of(rdev->desc,
336+
const struct pca9450_regulator_desc *desc = container_of_const(rdev->desc,
337337
struct pca9450_regulator_desc, desc);
338338
const struct pc9450_dvs_config *dvs = &desc->dvs;
339339
int ret = 0, regval;

0 commit comments

Comments
 (0)