@@ -34,6 +34,8 @@ struct mt6358_regulator_info {
34
34
u32 modeset_mask ;
35
35
};
36
36
37
+ #define to_regulator_info (x ) container_of((x), struct mt6358_regulator_info, desc)
38
+
37
39
#define MT6358_BUCK (match , vreg , min , max , step , \
38
40
volt_ranges , vosel_mask , _da_vsel_reg , _da_vsel_mask , \
39
41
_modeset_reg , _modeset_shift ) \
@@ -342,9 +344,9 @@ static unsigned int mt6358_map_mode(unsigned int mode)
342
344
static int mt6358_set_voltage_sel (struct regulator_dev * rdev ,
343
345
unsigned int selector )
344
346
{
347
+ const struct mt6358_regulator_info * info = to_regulator_info (rdev -> desc );
345
348
int idx , ret ;
346
349
const u32 * pvol ;
347
- struct mt6358_regulator_info * info = rdev_get_drvdata (rdev );
348
350
349
351
pvol = info -> index_table ;
350
352
@@ -358,9 +360,9 @@ static int mt6358_set_voltage_sel(struct regulator_dev *rdev,
358
360
359
361
static int mt6358_get_voltage_sel (struct regulator_dev * rdev )
360
362
{
363
+ const struct mt6358_regulator_info * info = to_regulator_info (rdev -> desc );
361
364
int idx , ret ;
362
365
u32 selector ;
363
- struct mt6358_regulator_info * info = rdev_get_drvdata (rdev );
364
366
const u32 * pvol ;
365
367
366
368
ret = regmap_read (rdev -> regmap , info -> desc .vsel_reg , & selector );
@@ -384,8 +386,8 @@ static int mt6358_get_voltage_sel(struct regulator_dev *rdev)
384
386
385
387
static int mt6358_get_buck_voltage_sel (struct regulator_dev * rdev )
386
388
{
389
+ const struct mt6358_regulator_info * info = to_regulator_info (rdev -> desc );
387
390
int ret , regval ;
388
- struct mt6358_regulator_info * info = rdev_get_drvdata (rdev );
389
391
390
392
ret = regmap_read (rdev -> regmap , info -> da_vsel_reg , & regval );
391
393
if (ret != 0 ) {
@@ -402,9 +404,9 @@ static int mt6358_get_buck_voltage_sel(struct regulator_dev *rdev)
402
404
403
405
static int mt6358_get_status (struct regulator_dev * rdev )
404
406
{
407
+ const struct mt6358_regulator_info * info = to_regulator_info (rdev -> desc );
405
408
int ret ;
406
409
u32 regval ;
407
- struct mt6358_regulator_info * info = rdev_get_drvdata (rdev );
408
410
409
411
ret = regmap_read (rdev -> regmap , info -> status_reg , & regval );
410
412
if (ret != 0 ) {
@@ -418,7 +420,7 @@ static int mt6358_get_status(struct regulator_dev *rdev)
418
420
static int mt6358_regulator_set_mode (struct regulator_dev * rdev ,
419
421
unsigned int mode )
420
422
{
421
- struct mt6358_regulator_info * info = rdev_get_drvdata (rdev );
423
+ const struct mt6358_regulator_info * info = to_regulator_info (rdev -> desc );
422
424
int val ;
423
425
424
426
switch (mode ) {
@@ -443,7 +445,7 @@ static int mt6358_regulator_set_mode(struct regulator_dev *rdev,
443
445
444
446
static unsigned int mt6358_regulator_get_mode (struct regulator_dev * rdev )
445
447
{
446
- struct mt6358_regulator_info * info = rdev_get_drvdata (rdev );
448
+ const struct mt6358_regulator_info * info = to_regulator_info (rdev -> desc );
447
449
int ret , regval ;
448
450
449
451
ret = regmap_read (rdev -> regmap , info -> modeset_reg , & regval );
@@ -498,7 +500,7 @@ static const struct regulator_ops mt6358_volt_fixed_ops = {
498
500
};
499
501
500
502
/* The array is indexed by id(MT6358_ID_XXX) */
501
- static struct mt6358_regulator_info mt6358_regulators [] = {
503
+ static const struct mt6358_regulator_info mt6358_regulators [] = {
502
504
MT6358_BUCK ("buck_vdram1" , VDRAM1 , 500000 , 2087500 , 12500 ,
503
505
buck_volt_range2 , 0x7f , MT6358_BUCK_VDRAM1_DBG0 , 0x7f ,
504
506
MT6358_VDRAM1_ANA_CON0 , 8 ),
@@ -589,7 +591,7 @@ static struct mt6358_regulator_info mt6358_regulators[] = {
589
591
};
590
592
591
593
/* The array is indexed by id(MT6366_ID_XXX) */
592
- static struct mt6358_regulator_info mt6366_regulators [] = {
594
+ static const struct mt6358_regulator_info mt6366_regulators [] = {
593
595
MT6366_BUCK ("buck_vdram1" , VDRAM1 , 500000 , 2087500 , 12500 ,
594
596
buck_volt_range2 , 0x7f , MT6358_BUCK_VDRAM1_DBG0 , 0x7f ,
595
597
MT6358_VDRAM1_ANA_CON0 , 8 ),
@@ -712,7 +714,7 @@ static int mt6358_regulator_probe(struct platform_device *pdev)
712
714
struct mt6397_chip * mt6397 = dev_get_drvdata (pdev -> dev .parent );
713
715
struct regulator_config config = {};
714
716
struct regulator_dev * rdev ;
715
- struct mt6358_regulator_info * mt6358_info ;
717
+ const struct mt6358_regulator_info * mt6358_info ;
716
718
int i , max_regulator , ret ;
717
719
718
720
ret = mt6358_sync_vcn33_setting (& pdev -> dev );
@@ -729,7 +731,6 @@ static int mt6358_regulator_probe(struct platform_device *pdev)
729
731
730
732
for (i = 0 ; i < max_regulator ; i ++ ) {
731
733
config .dev = & pdev -> dev ;
732
- config .driver_data = & mt6358_info [i ];
733
734
config .regmap = mt6397 -> regmap ;
734
735
735
736
rdev = devm_regulator_register (& pdev -> dev ,
0 commit comments