Skip to content

Commit 10e23f1

Browse files
GoldenBugfacebook-github-bot
authored andcommitted
Refactor plat_sdr to Extract Common Functions.
Summary: plat_get_sdr_size(...) and load_sdr_table(...) were common between all plat_sdr_table configs for the platforms (except Yv3.5 CL). This commit extracts those functions and places them into the common sensor/sdr files. Reviewed By: garnermic Differential Revision: D38228113 fbshipit-source-id: b3e53b83c11480c4faea6babe7047b15f45560a5
1 parent 935a9b0 commit 10e23f1

11 files changed

Lines changed: 24 additions & 79 deletions

File tree

‎common/service/sensor/sdr.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ SDR_INFO sdr_info;
1010
static uint16_t RSV_ID[2] = { 0 };
1111
bool is_sdr_not_init = true;
1212

13+
extern SDR_Full_sensor plat_sdr_table[];
14+
extern const int SDR_TABLE_SIZE;
15+
1316
SDR_Full_sensor *full_sdr_table;
1417

1518
uint8_t sensor_config_size = 0;
@@ -211,3 +214,14 @@ uint8_t sdr_init(void)
211214
is_sdr_not_init = false;
212215
return true;
213216
}
217+
218+
uint8_t plat_get_sdr_size()
219+
{
220+
return SDR_TABLE_SIZE;
221+
}
222+
223+
__weak void load_sdr_table(void)
224+
{
225+
memcpy(full_sdr_table, plat_sdr_table, SDR_TABLE_SIZE);
226+
sdr_count = SDR_TABLE_SIZE;
227+
}

‎common/service/sensor/sdr.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,5 +462,7 @@ bool check_sdr_num_exist(uint8_t sensor_num);
462462
void add_full_sdr_table(SDR_Full_sensor add_item);
463463
void change_sensor_threshold(uint8_t sensor_num, uint8_t threshold_type, uint8_t change_value);
464464
void change_sensor_mbr(uint8_t sensor_num, uint8_t mbr_type, uint16_t change_value);
465+
uint8_t plat_get_sdr_size();
466+
void load_sdr_table(void);
465467

466468
#endif

‎meta-facebook/gt-cc/src/platform/plat_sdr_table.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9100,13 +9100,4 @@ SDR_Full_sensor plat_sdr_table[] = {
91009100

91019101
};
91029102

9103-
uint8_t plat_get_sdr_size()
9104-
{
9105-
return ARRAY_SIZE(plat_sdr_table);
9106-
}
9107-
9108-
void load_sdr_table(void)
9109-
{
9110-
memcpy(full_sdr_table, plat_sdr_table, sizeof(plat_sdr_table));
9111-
sdr_count = ARRAY_SIZE(plat_sdr_table);
9112-
}
9103+
const int SDR_TABLE_SIZE = ARRAY_SIZE(plat_sdr_table);

‎meta-facebook/gt-cc/src/platform/plat_sdr_table.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,4 @@
55

66
#define MAX_SENSOR_SIZE 150
77

8-
uint8_t plat_get_sdr_size();
9-
void load_sdr_table(void);
10-
118
#endif

‎meta-facebook/wc-mb/src/platform/plat_sdr_table.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,13 +2031,4 @@ SDR_Full_sensor plat_sdr_table[] = {
20312031
},
20322032
};
20332033

2034-
uint8_t plat_get_sdr_size()
2035-
{
2036-
return ARRAY_SIZE(plat_sdr_table);
2037-
}
2038-
2039-
void load_sdr_table(void)
2040-
{
2041-
memcpy(full_sdr_table, plat_sdr_table, sizeof(plat_sdr_table));
2042-
sdr_count = ARRAY_SIZE(plat_sdr_table);
2043-
}
2034+
const int SDR_TABLE_SIZE = ARRAY_SIZE(plat_sdr_table);

‎meta-facebook/yv3-dl/src/platform/plat_sdr_table.c‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,15 +3061,4 @@ SDR_Full_sensor plat_sdr_table[] = {
30613061
},
30623062
};
30633063

3064-
uint8_t plat_get_sdr_size()
3065-
{
3066-
return ARRAY_SIZE(plat_sdr_table);
3067-
}
3068-
3069-
uint8_t load_sdr_table(void)
3070-
{
3071-
memcpy(full_sdr_table, plat_sdr_table, sizeof(plat_sdr_table));
3072-
sdr_count = ARRAY_SIZE(plat_sdr_table);
3073-
3074-
return ARRAY_SIZE(plat_sdr_table);
3075-
}
3064+
const int SDR_TABLE_SIZE = ARRAY_SIZE(plat_sdr_table);

‎meta-facebook/yv3-vf/src/platform/plat_sdr_table.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,4 @@
1111

1212
SDR_Full_sensor plat_sdr_table[] = {};
1313

14-
uint8_t plat_get_sdr_size()
15-
{
16-
return ARRAY_SIZE(plat_sdr_table);
17-
}
18-
19-
void load_sdr_table(void)
20-
{
21-
memcpy(full_sdr_table, plat_sdr_table, sizeof(plat_sdr_table));
22-
sdr_count = ARRAY_SIZE(plat_sdr_table);
23-
};
14+
const int SDR_TABLE_SIZE = ARRAY_SIZE(plat_sdr_table);

‎meta-facebook/yv35-bb/src/platform/plat_sdr_table.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,13 +1230,4 @@ SDR_Full_sensor plat_sdr_table[] = {
12301230
},
12311231
};
12321232

1233-
uint8_t plat_get_sdr_size()
1234-
{
1235-
return ARRAY_SIZE(plat_sdr_table);
1236-
}
1237-
1238-
void load_sdr_table(void)
1239-
{
1240-
memcpy(full_sdr_table, plat_sdr_table, sizeof(plat_sdr_table));
1241-
sdr_count = ARRAY_SIZE(plat_sdr_table);
1242-
};
1233+
const int SDR_TABLE_SIZE = ARRAY_SIZE(plat_sdr_table);

‎meta-facebook/yv35-cl/src/platform/plat_sdr_table.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3625,10 +3625,7 @@ SDR_Full_sensor dpv2_sdr_table[] = {
36253625
},
36263626
};
36273627

3628-
uint8_t plat_get_sdr_size()
3629-
{
3630-
return ARRAY_SIZE(plat_sdr_table);
3631-
}
3628+
const int SDR_TABLE_SIZE = ARRAY_SIZE(plat_sdr_table);
36323629

36333630
void load_sdr_table(void)
36343631
{

‎meta-facebook/yv35-hd/src/platform/plat_sdr_table.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,13 +2448,4 @@ SDR_Full_sensor plat_sdr_table[] = {
24482448
},
24492449
};
24502450

2451-
uint8_t plat_get_sdr_size()
2452-
{
2453-
return ARRAY_SIZE(plat_sdr_table);
2454-
}
2455-
2456-
void load_sdr_table(void)
2457-
{
2458-
memcpy(full_sdr_table, plat_sdr_table, sizeof(plat_sdr_table));
2459-
sdr_count = ARRAY_SIZE(plat_sdr_table);
2460-
}
2451+
const int SDR_TABLE_SIZE = ARRAY_SIZE(plat_sdr_table);

0 commit comments

Comments
 (0)