History

mfd: cros_ec: add ec_align macros

To reduce code and improve performance of the embedded controller firmware, pragma __aligned(2) or __aligned(4) are used when alignment to 16 or 32 bit boundary is expected. Define all ec_align to packed when compiling kernel.

Gwendal Grignou committed 7 years ago

Commit 6f72c3f1 parent df95a3b1 file · +238 −204Browse files

Unified · Split

include/linux/mfd/cros_ec_commands.h+238−204
@@ -188,12 +188,46 @@ · 187 unmodified lines
188188 #ifndef __ACPI__
189189
190190 /*
191− * Define __packed if someone hasn't beat us to it. Linux kernel style
192− * checking prefers __packed over __attribute__((packed)).
191+ * Attributes for EC request and response packets. Just defining __packed
192+ * results in inefficient assembly code on ARM, if the structure is actually
193+ * 32-bit aligned, as it should be for all buffers.
194+ *
195+ * Be very careful when adding these to existing structures. They will round
196+ * up the structure size to the specified boundary.
197+ *
198+ * Also be very careful to make that if a structure is included in some other
199+ * parent structure that the alignment will still be true given the packing of
200+ * the parent structure. This is particularly important if the sub-structure
201+ * will be passed as a pointer to another function, since that function will
202+ * not know about the misaligment caused by the parent structure's packing.
203+ *
204+ * Also be very careful using __packed - particularly when nesting non-packed
205+ * structures inside packed ones. In fact, DO NOT use __packed directly;
206+ * always use one of these attributes.
207+ *
208+ * Once everything is annotated properly, the following search strings should
209+ * not return ANY matches in this file other than right here:
210+ *
211+ * "__packed" - generates inefficient code; all sub-structs must also be packed
212+ *
213+ * "struct [^_]" - all structs should be annotated, except for structs that are
214+ * members of other structs/unions (and their original declarations should be
215+ * annotated).
193216 */
194−#ifndef __packed
195−#define __packed __attribute__((packed))
196−#endif
217+
218+/*
219+ * Packed structures make no assumption about alignment, so they do inefficient
220+ * byte-wise reads.
221+ */
222+#define __ec_align1 __packed
223+#define __ec_align2 __packed
224+#define __ec_align4 __packed
225+#define __ec_align_size1 __packed
226+#define __ec_align_offset1 __packed
227+#define __ec_align_offset2 __packed
228+#define __ec_todo_packed __packed
229+#define __ec_todo_unpacked
230+
197231
198232 /* LPC command status byte masks */
199233 /* EC has written a byte in the data register and host hasn't read it yet */
@@ -317,7 +351,7 @@ struct ec_lpc_host_args { · 117 unmodified lines
317351 uint8_t command_version;
318352 uint8_t data_size;
319353 uint8_t checksum;
320−} __packed;
354+} __ec_align4;
321355
322356 /* Flags for ec_lpc_host_args.flags */
323357 /*
@@ -488,7 +522,7 @@ struct ec_host_request { · 164 unmodified lines
488522 uint8_t command_version;
489523 uint8_t reserved;
490524 uint16_t data_len;
491−} __packed;
525+} __ec_align4;
492526
493527 #define EC_HOST_RESPONSE_VERSION 3
494528
@@ -507,7 +541,7 @@ struct ec_host_response { · 12 unmodified lines
507541 uint16_t result;
508542 uint16_t data_len;
509543 uint16_t reserved;
510−} __packed;
544+} __ec_align4;
511545
512546 /*****************************************************************************/
513547 /*
@@ -536,7 +570,7 @@ struct ec_host_response { · 22 unmodified lines
536570 */
537571 struct ec_response_proto_version {
538572 uint32_t version;
539−} __packed;
573+} __ec_align4;
540574
541575 /*
542576 * Hello. This is a simple command to test the EC is responsive to
@@ -550,7 +584,7 @@ struct ec_response_proto_version { · 7 unmodified lines
550584 */
551585 struct ec_params_hello {
552586 uint32_t in_data;
553−} __packed;
587+} __ec_align4;
554588
555589 /**
556590 * struct ec_response_hello - Response to the hello command.
@@ -558,7 +592,7 @@ struct ec_params_hello { · 1 unmodified line
558592 */
559593 struct ec_response_hello {
560594 uint32_t out_data;
561−} __packed;
595+} __ec_align4;
562596
563597 /* Get version number */
564598 #define EC_CMD_GET_VERSION 0x02
@@ -581,7 +615,7 @@ struct ec_response_get_version { · 16 unmodified lines
581615 char version_string_rw[32];
582616 char reserved[32];
583617 uint32_t current_image;
584−} __packed;
618+} __ec_align4;
585619
586620 /* Read test */
587621 #define EC_CMD_READ_TEST 0x03
@@ -594,7 +628,7 @@ struct ec_response_get_version { · 6 unmodified lines
594628 struct ec_params_read_test {
595629 uint32_t offset;
596630 uint32_t size;
597−} __packed;
631+} __ec_align4;
598632
599633 /**
600634 * struct ec_response_read_test - Response to the read test command.
@@ -602,7 +636,7 @@ struct ec_params_read_test { · 1 unmodified line
602636 */
603637 struct ec_response_read_test {
604638 uint32_t data[32];
605−} __packed;
639+} __ec_align4;
606640
607641 /*
608642 * Get build information
@@ -624,7 +658,7 @@ struct ec_response_get_chip_info { · 15 unmodified lines
624658 char vendor[32];
625659 char name[32];
626660 char revision[32];
627−} __packed;
661+} __ec_align4;
628662
629663 /* Get board HW version */
630664 #define EC_CMD_GET_BOARD_VERSION 0x06
@@ -635,7 +669,7 @@ struct ec_response_get_chip_info { · 4 unmodified lines
635669 */
636670 struct ec_response_board_version {
637671 uint16_t board_version;
638−} __packed;
672+} __ec_align2;
639673
640674 /*
641675 * Read memory-mapped data.
@@ -655,7 +689,7 @@ struct ec_response_board_version { · 13 unmodified lines
655689 struct ec_params_read_memmap {
656690 uint8_t offset;
657691 uint8_t size;
658−} __packed;
692+} __ec_align1;
659693
660694 /* Read versions supported for a command */
661695 #define EC_CMD_GET_CMD_VERSIONS 0x08
@@ -666,7 +700,7 @@ struct ec_params_read_memmap { · 4 unmodified lines
666700 */
667701 struct ec_params_get_cmd_versions {
668702 uint8_t cmd;
669−} __packed;
703+} __ec_align1;
670704
671705 /**
672706 * struct ec_params_get_cmd_versions_v1 - Parameters for the get command
@@ -675,7 +709,7 @@ struct ec_params_get_cmd_versions { · 2 unmodified lines
675709 */
676710 struct ec_params_get_cmd_versions_v1 {
677711 uint16_t cmd;
678−} __packed;
712+} __ec_align2;
679713
680714 /**
681715 * struct ec_response_get_cmd_version - Response to the get command versions.
@@ -684,7 +718,7 @@ struct ec_params_get_cmd_versions_v1 { · 2 unmodified lines
684718 */
685719 struct ec_response_get_cmd_versions {
686720 uint32_t version_mask;
687−} __packed;
721+} __ec_align4;
688722
689723 /*
690724 * Check EC communications status (busy). This is needed on i2c/spi but not
@@ -707,7 +741,7 @@ enum ec_comms_status { · 16 unmodified lines
707741 */
708742 struct ec_response_get_comms_status {
709743 uint32_t flags; /* Mask of enum ec_comms_status */
710−} __packed;
744+} __ec_align4;
711745
712746 /* Fake a variety of responses, purely for testing purposes. */
713747 #define EC_CMD_TEST_PROTOCOL 0x0a
@@ -717,12 +751,12 @@ struct ec_params_test_protocol { · 3 unmodified lines
717751 uint32_t ec_result;
718752 uint32_t ret_len;
719753 uint8_t buf[32];
720−} __packed;
754+} __ec_align4;
721755
722756 /* Here it comes... */
723757 struct ec_response_test_protocol {
724758 uint8_t buf[32];
725−} __packed;
759+} __ec_align4;
726760
727761 /* Get protocol information */
728762 #define EC_CMD_GET_PROTOCOL_INFO 0x0b
@@ -745,7 +779,7 @@ struct ec_response_get_protocol_info { · 16 unmodified lines
745779 uint16_t max_request_packet_size;
746780 uint16_t max_response_packet_size;
747781 uint32_t flags;
748−} __packed;
782+} __ec_align4;
749783
750784
751785 /*****************************************************************************/
@@ -763,12 +797,12 @@ struct ec_response_get_protocol_info { · 11 unmodified lines
763797 struct ec_params_get_set_value {
764798 uint32_t flags;
765799 uint32_t value;
766−} __packed;
800+} __ec_align4;
767801
768802 struct ec_response_get_set_value {
769803 uint32_t flags;
770804 uint32_t value;
771−} __packed;
805+} __ec_align4;
772806
773807 /* More than one command can use these structs to get/set parameters. */
774808 #define EC_CMD_GSV_PAUSE_IN_S5 0x0c
@@ -893,7 +927,7 @@ enum ec_feature_code { · 118 unmodified lines
893927
894928 struct ec_response_get_features {
895929 uint32_t flags[2];
896−} __packed;
930+} __ec_align4;
897931
898932 /*****************************************************************************/
899933 /* Flash commands */
@@ -918,7 +952,7 @@ struct ec_response_flash_info { · 18 unmodified lines
918952 uint32_t write_block_size;
919953 uint32_t erase_block_size;
920954 uint32_t protect_block_size;
921−} __packed;
955+} __ec_align4;
922956
923957 /*
924958 * Flags for version 1+ flash info command
@@ -959,7 +993,7 @@ struct ec_response_flash_info_1 { · 34 unmodified lines
959993 /* Version 1 adds these fields: */
960994 uint32_t write_ideal_size;
961995 uint32_t flags;
962−} __packed;
996+} __ec_align4;
963997
964998 /*
965999 * Read flash
@@ -976,7 +1010,7 @@ struct ec_response_flash_info_1 { · 10 unmodified lines
9761010 struct ec_params_flash_read {
9771011 uint32_t offset;
9781012 uint32_t size;
979−} __packed;
1013+} __ec_align4;
9801014
9811015 /* Write flash */
9821016 #define EC_CMD_FLASH_WRITE 0x12
@@ -994,7 +1028,7 @@ struct ec_params_flash_write { · 11 unmodified lines
9941028 uint32_t offset;
9951029 uint32_t size;
9961030 /* Followed by data to write */
997−} __packed;
1031+} __ec_align4;
9981032
9991033 /* Erase flash */
10001034 #define EC_CMD_FLASH_ERASE 0x13
@@ -1007,7 +1041,7 @@ struct ec_params_flash_write { · 6 unmodified lines
10071041 struct ec_params_flash_erase {
10081042 uint32_t offset;
10091043 uint32_t size;
1010−} __packed;
1044+} __ec_align4;
10111045
10121046 /*
10131047 * Get/set flash protection.
@@ -1053,7 +1087,7 @@ struct ec_params_flash_erase { · 39 unmodified lines
10531087 struct ec_params_flash_protect {
10541088 uint32_t mask;
10551089 uint32_t flags;
1056−} __packed;
1090+} __ec_align4;
10571091
10581092 /**
10591093 * struct ec_response_flash_protect - Response to the flash protect command.
@@ -1068,7 +1102,7 @@ struct ec_response_flash_protect { · 8 unmodified lines
10681102 uint32_t flags;
10691103 uint32_t valid_flags;
10701104 uint32_t writable_flags;
1071−} __packed;
1105+} __ec_align4;
10721106
10731107 /*
10741108 * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash
@@ -1100,12 +1134,12 @@ enum ec_flash_region { · 25 unmodified lines
11001134 */
11011135 struct ec_params_flash_region_info {
11021136 uint32_t region;
1103−} __packed;
1137+} __ec_align4;
11041138
11051139 struct ec_response_flash_region_info {
11061140 uint32_t offset;
11071141 uint32_t size;
1108−} __packed;
1142+} __ec_align4;
11091143
11101144 /* Read/write VbNvContext */
11111145 #define EC_CMD_VBNV_CONTEXT 0x17
@@ -1120,11 +1154,11 @@ enum ec_vbnvcontext_op { · 8 unmodified lines
11201154 struct ec_params_vbnvcontext {
11211155 uint32_t op;
11221156 uint8_t block[EC_VBNV_BLOCK_SIZE];
1123−} __packed;
1157+} __ec_align4;
11241158
11251159 struct ec_response_vbnvcontext {
11261160 uint8_t block[EC_VBNV_BLOCK_SIZE];
1127−} __packed;
1161+} __ec_align4;
11281162
11291163 /*****************************************************************************/
11301164 /* PWM commands */
@@ -1134,14 +1168,14 @@ struct ec_response_vbnvcontext { · 3 unmodified lines
11341168
11351169 struct ec_response_pwm_get_fan_rpm {
11361170 uint32_t rpm;
1137−} __packed;
1171+} __ec_align4;
11381172
11391173 /* Set target fan RPM */
1140−#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x21
1174+#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x0021
11411175
11421176 struct ec_params_pwm_set_fan_target_rpm {
11431177 uint32_t rpm;
1144−} __packed;
1178+} __ec_align_size1;
11451179
11461180 /* Get keyboard backlight */
11471181 #define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x22
@@ -1149,21 +1183,21 @@ struct ec_params_pwm_set_fan_target_rpm { · 1 unmodified line
11491183 struct ec_response_pwm_get_keyboard_backlight {
11501184 uint8_t percent;
11511185 uint8_t enabled;
1152−} __packed;
1186+} __ec_align1;
11531187
11541188 /* Set keyboard backlight */
11551189 #define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x23
11561190
11571191 struct ec_params_pwm_set_keyboard_backlight {
11581192 uint8_t percent;
1159−} __packed;
1193+} __ec_align1;
11601194
11611195 /* Set target fan PWM duty cycle */
11621196 #define EC_CMD_PWM_SET_FAN_DUTY 0x24
11631197
11641198 struct ec_params_pwm_set_fan_duty {
11651199 uint32_t percent;
1166−} __packed;
1200+} __ec_align4;
11671201
11681202 #define EC_CMD_PWM_SET_DUTY 0x25
11691203 /* 16 bit duty cycle, 0xffff = 100% */
@@ -1183,18 +1217,18 @@ struct ec_params_pwm_set_duty { · 13 unmodified lines
11831217 uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
11841218 uint8_t pwm_type; /* ec_pwm_type */
11851219 uint8_t index; /* Type-specific index, or 0 if unique */
1186−} __packed;
1220+} __ec_align4;
11871221
11881222 #define EC_CMD_PWM_GET_DUTY 0x26
11891223
11901224 struct ec_params_pwm_get_duty {
11911225 uint8_t pwm_type; /* ec_pwm_type */
11921226 uint8_t index; /* Type-specific index, or 0 if unique */
1193−} __packed;
1227+} __ec_align1;
11941228
11951229 struct ec_response_pwm_get_duty {
11961230 uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */
1197−} __packed;
1231+} __ec_align2;
11981232
11991233 /*****************************************************************************/
12001234 /*
@@ -1207,7 +1241,7 @@ struct ec_response_pwm_get_duty { · 6 unmodified lines
12071241
12081242 struct rgb_s {
12091243 uint8_t r, g, b;
1210−};
1244+} __ec_todo_unpacked;
12111245
12121246 #define LB_BATTERY_LEVELS 4
12131247
@@ -1247,7 +1281,7 @@ struct lightbar_params_v0 { · 33 unmodified lines
12471281
12481282 /* Color palette */
12491283 struct rgb_s color[8]; /* 0-3 are Google colors */
1250−} __packed;
1284+} __ec_todo_packed;
12511285
12521286 struct lightbar_params_v1 {
12531287 /* Timing */
@@ -1290,14 +1324,14 @@ struct lightbar_params_v1 { · 36 unmodified lines
12901324
12911325 /* Color palette */
12921326 struct rgb_s color[8]; /* 0-3 are Google colors */
1293−} __packed;
1327+} __ec_todo_packed;
12941328
12951329 /* Lightbar program */
12961330 #define EC_LB_PROG_LEN 192
12971331 struct lightbar_program {
12981332 uint8_t size;
12991333 uint8_t data[EC_LB_PROG_LEN];
1300−};
1334+} __ec_todo_unpacked;
13011335
13021336 struct ec_params_lightbar {
13031337 uint8_t cmd; /* Command (see enum lightbar_command) */
@@ -1307,23 +1341,23 @@ struct ec_params_lightbar { · 3 unmodified lines
13071341 } dump, off, on, init, get_seq, get_params_v0, get_params_v1,
13081342 version, get_brightness, get_demo, suspend, resume;
13091343
1310− struct {
1344+ struct __ec_todo_unpacked {
13111345 uint8_t num;
13121346 } set_brightness, seq, demo;
13131347
1314− struct {
1348+ struct __ec_todo_unpacked {
13151349 uint8_t ctrl, reg, value;
13161350 } reg;
13171351
1318− struct {
1352+ struct __ec_todo_unpacked {
13191353 uint8_t led, red, green, blue;
13201354 } set_rgb;
13211355
1322− struct {
1356+ struct __ec_todo_unpacked {
13231357 uint8_t led;
13241358 } get_rgb;
13251359
1326− struct {
1360+ struct __ec_todo_unpacked {
13271361 uint8_t enable;
13281362 } manual_suspend_ctrl;
13291363
@@ -1331,31 +1365,31 @@ struct ec_params_lightbar { · 1 unmodified line
13311365 struct lightbar_params_v1 set_params_v1;
13321366 struct lightbar_program set_program;
13331367 };
1334−} __packed;
1368+} __ec_todo_packed;
13351369
13361370 struct ec_response_lightbar {
13371371 union {
1338− struct {
1339− struct {
1372+ struct __ec_todo_unpacked {
1373+ struct __ec_todo_unpacked {
13401374 uint8_t reg;
13411375 uint8_t ic0;
13421376 uint8_t ic1;
13431377 } vals[23];
13441378 } dump;
13451379
1346− struct {
1380+ struct __ec_todo_unpacked {
13471381 uint8_t num;
13481382 } get_seq, get_brightness, get_demo;
13491383
13501384 struct lightbar_params_v0 get_params_v0;
13511385 struct lightbar_params_v1 get_params_v1;
13521386
1353− struct {
1387+ struct __ec_todo_unpacked {
13541388 uint32_t num;
13551389 uint32_t flags;
13561390 } version;
13571391
1358− struct {
1392+ struct __ec_todo_unpacked {
13591393 uint8_t red, green, blue;
13601394 } get_rgb;
13611395
@@ -1365,7 +1399,7 @@ struct ec_response_lightbar { · 3 unmodified lines
13651399 demo, set_params_v0, set_params_v1,
13661400 set_program, manual_suspend_ctrl, suspend, resume;
13671401 };
1368−} __packed;
1402+} __ec_todo_packed;
13691403
13701404 /* Lightbar commands */
13711405 enum lightbar_command {
@@ -1432,7 +1466,7 @@ struct ec_params_led_control { · 60 unmodified lines
14321466 uint8_t flags; /* Control flags */
14331467
14341468 uint8_t brightness[EC_LED_COLOR_COUNT];
1435−} __packed;
1469+} __ec_align1;
14361470
14371471 struct ec_response_led_control {
14381472 /*
@@ -1443,7 +1477,7 @@ struct ec_response_led_control { · 4 unmodified lines
14431477 * Other values means the LED is control by PWM.
14441478 */
14451479 uint8_t brightness_range[EC_LED_COLOR_COUNT];
1446−} __packed;
1480+} __ec_align1;
14471481
14481482 /*****************************************************************************/
14491483 /* Verified boot commands */
@@ -1464,7 +1498,7 @@ struct ec_params_vboot_hash { · 14 unmodified lines
14641498 uint32_t offset; /* Offset in flash to hash */
14651499 uint32_t size; /* Number of bytes to hash */
14661500 uint8_t nonce_data[64]; /* Nonce data; ignored if nonce_size=0 */
1467−} __packed;
1501+} __ec_align4;
14681502
14691503 struct ec_response_vboot_hash {
14701504 uint8_t status; /* enum ec_vboot_hash_status */
@@ -1474,7 +1508,7 @@ struct ec_response_vboot_hash { · 3 unmodified lines
14741508 uint32_t offset; /* Offset in flash which was hashed */
14751509 uint32_t size; /* Number of bytes hashed */
14761510 uint8_t hash_digest[64]; /* Hash digest data */
1477−} __packed;
1511+} __ec_align4;
14781512
14791513 enum ec_vboot_hash_cmd {
14801514 EC_VBOOT_HASH_GET = 0, /* Get current hash status */
@@ -1634,23 +1668,23 @@ struct ec_response_motion_sensor_data { · 153 unmodified lines
16341668 /* Each sensor is up to 3-axis. */
16351669 union {
16361670 int16_t data[3];
1637− struct {
1671+ struct __ec_todo_packed {
16381672 uint16_t reserved;
16391673 uint32_t timestamp;
1640− } __packed;
1641− struct {
1674+ };
1675+ struct __ec_todo_unpacked {
16421676 uint8_t activity; /* motionsensor_activity */
16431677 uint8_t state;
16441678 int16_t add_info[2];
16451679 };
16461680 };
1647−} __packed;
1681+} __ec_todo_packed;
16481682
16491683 struct ec_params_motion_sense {
16501684 uint8_t cmd;
16511685 union {
16521686 /* Used for MOTIONSENSE_CMD_DUMP. */
1653− struct {
1687+ struct __ec_todo_unpacked {
16541688 /* no args */
16551689 } dump;
16561690
@@ -1658,13 +1692,13 @@ struct ec_params_motion_sense { · 1 unmodified line
16581692 * Used for MOTIONSENSE_CMD_EC_RATE and
16591693 * MOTIONSENSE_CMD_KB_WAKE_ANGLE.
16601694 */
1661− struct {
1695+ struct __ec_todo_unpacked {
16621696 /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */
16631697 int16_t data;
16641698 } ec_rate, kb_wake_angle;
16651699
16661700 /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
1667− struct {
1701+ struct __ec_todo_packed {
16681702 uint8_t sensor_num;
16691703
16701704 /*
@@ -1690,10 +1724,10 @@ struct ec_params_motion_sense { · 19 unmodified lines
16901724 * Compass: 1/16 uT
16911725 */
16921726 int16_t offset[3];
1693− } __packed sensor_offset;
1727+ } sensor_offset;
16941728
16951729 /* Used for MOTIONSENSE_CMD_INFO. */
1696− struct {
1730+ struct __ec_todo_packed {
16971731 uint8_t sensor_num;
16981732 } info;
16991733
@@ -1714,12 +1748,12 @@ struct ec_params_motion_sense { · 14 unmodified lines
17141748 int32_t data;
17151749 } sensor_odr, sensor_range;
17161750 };
1717−} __packed;
1751+} __ec_todo_packed;
17181752
17191753 struct ec_response_motion_sense {
17201754 union {
17211755 /* Used for MOTIONSENSE_CMD_DUMP. */
1722− struct {
1756+ struct __ec_todo_unpacked {
17231757 /* Flags representing the motion sensor module. */
17241758 uint8_t module_flags;
17251759
@@ -1734,7 +1768,7 @@ struct ec_response_motion_sense { · 8 unmodified lines
17341768 } dump;
17351769
17361770 /* Used for MOTIONSENSE_CMD_INFO. */
1737− struct {
1771+ struct __ec_todo_unpacked {
17381772 /* Should be element of enum motionsensor_type. */
17391773 uint8_t type;
17401774
@@ -1753,18 +1787,18 @@ struct ec_response_motion_sense { · 12 unmodified lines
17531787 * MOTIONSENSE_CMD_SENSOR_RANGE, and
17541788 * MOTIONSENSE_CMD_KB_WAKE_ANGLE.
17551789 */
1756− struct {
1790+ struct __ec_todo_unpacked {
17571791 /* Current value of the parameter queried. */
17581792 int32_t ret;
17591793 } ec_rate, sensor_odr, sensor_range, kb_wake_angle;
17601794
17611795 /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */
1762− struct {
1796+ struct __ec_todo_unpacked {
17631797 int16_t temp;
17641798 int16_t offset[3];
17651799 } sensor_offset, perform_calib;
17661800 };
1767−} __packed;
1801+} __ec_todo_packed;
17681802
17691803 /*****************************************************************************/
17701804 /* USB charging control commands */
@@ -1775,7 +1809,7 @@ struct ec_response_motion_sense { · 4 unmodified lines
17751809 struct ec_params_usb_charge_set_mode {
17761810 uint8_t usb_port_id;
17771811 uint8_t mode;
1778−} __packed;
1812+} __ec_align1;
17791813
17801814 /*****************************************************************************/
17811815 /* Persistent storage for host */
@@ -1791,7 +1825,7 @@ struct ec_response_pstore_info { · 9 unmodified lines
17911825 uint32_t pstore_size;
17921826 /* Access size; read/write offset and size must be a multiple of this */
17931827 uint32_t access_size;
1794−} __packed;
1828+} __ec_align4;
17951829
17961830 /*
17971831 * Read persistent storage
@@ -1803,7 +1837,7 @@ struct ec_response_pstore_info { · 5 unmodified lines
18031837 struct ec_params_pstore_read {
18041838 uint32_t offset; /* Byte offset to read */
18051839 uint32_t size; /* Size to read in bytes */
1806−} __packed;
1840+} __ec_align4;
18071841
18081842 /* Write persistent storage */
18091843 #define EC_CMD_PSTORE_WRITE 0x42
@@ -1812,7 +1846,7 @@ struct ec_params_pstore_write { · 2 unmodified lines
18121846 uint32_t offset; /* Byte offset to write */
18131847 uint32_t size; /* Size to write in bytes */
18141848 uint8_t data[EC_PSTORE_SIZE_MAX];
1815−} __packed;
1849+} __ec_align4;
18161850
18171851 /*****************************************************************************/
18181852 /* Real-time clock */
@@ -1820,11 +1854,11 @@ struct ec_params_pstore_write { · 1 unmodified line
18201854 /* RTC params and response structures */
18211855 struct ec_params_rtc {
18221856 uint32_t time;
1823−} __packed;
1857+} __ec_align4;
18241858
18251859 struct ec_response_rtc {
18261860 uint32_t time;
1827−} __packed;
1861+} __ec_align4;
18281862
18291863 /* These use ec_response_rtc */
18301864 #define EC_CMD_RTC_GET_VALUE 0x44
@@ -1855,29 +1889,29 @@ enum ec_port80_subcmd { · 24 unmodified lines
18551889 struct ec_params_port80_read {
18561890 uint16_t subcmd;
18571891 union {
1858− struct {
1892+ struct __ec_todo_unpacked {
18591893 uint32_t offset;
18601894 uint32_t num_entries;
18611895 } read_buffer;
18621896 };
1863−} __packed;
1897+} __ec_todo_packed;
18641898
18651899 struct ec_response_port80_read {
18661900 union {
1867− struct {
1901+ struct __ec_todo_unpacked {
18681902 uint32_t writes;
18691903 uint32_t history_size;
18701904 uint32_t last_boot;
18711905 } get_info;
1872− struct {
1906+ struct __ec_todo_unpacked {
18731907 uint16_t codes[EC_PORT80_SIZE_MAX];
18741908 } data;
18751909 };
1876−} __packed;
1910+} __ec_todo_packed;
18771911
18781912 struct ec_response_port80_last_boot {
18791913 uint16_t code;
1880−} __packed;
1914+} __ec_align2;
18811915
18821916 /*****************************************************************************/
18831917 /* Thermal engine commands. Note that there are two implementations. We'll
@@ -1898,17 +1932,17 @@ struct ec_params_thermal_set_threshold { · 14 unmodified lines
18981932 uint8_t sensor_type;
18991933 uint8_t threshold_id;
19001934 uint16_t value;
1901−} __packed;
1935+} __ec_align2;
19021936
19031937 /* Version 0 - get */
19041938 struct ec_params_thermal_get_threshold {
19051939 uint8_t sensor_type;
19061940 uint8_t threshold_id;
1907−} __packed;
1941+} __ec_align1;
19081942
19091943 struct ec_response_thermal_get_threshold {
19101944 uint16_t value;
1911−} __packed;
1945+} __ec_align2;
19121946
19131947
19141948 /* The version 1 structs are visible. */
@@ -1928,12 +1962,12 @@ struct ec_thermal_config { · 13 unmodified lines
19281962 uint32_t temp_host[EC_TEMP_THRESH_COUNT]; /* levels of hotness */
19291963 uint32_t temp_fan_off; /* no active cooling needed */
19301964 uint32_t temp_fan_max; /* max active cooling needed */
1931−} __packed;
1965+} __ec_align4;
19321966
19331967 /* Version 1 - get config for one sensor. */
19341968 struct ec_params_thermal_get_threshold_v1 {
19351969 uint32_t sensor_num;
1936−} __packed;
1970+} __ec_align4;
19371971 /* This returns a struct ec_thermal_config */
19381972
19391973 /*
@@ -1943,7 +1977,7 @@ struct ec_params_thermal_get_threshold_v1 { · 3 unmodified lines
19431977 struct ec_params_thermal_set_threshold_v1 {
19441978 uint32_t sensor_num;
19451979 struct ec_thermal_config cfg;
1946−} __packed;
1980+} __ec_align4;
19471981 /* This returns no data */
19481982
19491983 /****************************************************************************/
@@ -1956,14 +1990,14 @@ struct ec_params_thermal_set_threshold_v1 { · 6 unmodified lines
19561990
19571991 struct ec_params_tmp006_get_calibration {
19581992 uint8_t index;
1959−} __packed;
1993+} __ec_align1;
19601994
19611995 struct ec_response_tmp006_get_calibration {
19621996 float s0;
19631997 float b0;
19641998 float b1;
19651999 float b2;
1966−} __packed;
2000+} __ec_align4;
19672001
19682002 /* Set TMP006 calibration data */
19692003 #define EC_CMD_TMP006_SET_CALIBRATION 0x54
@@ -1975,19 +2009,19 @@ struct ec_params_tmp006_set_calibration { · 5 unmodified lines
19752009 float b0;
19762010 float b1;
19772011 float b2;
1978−} __packed;
2012+} __ec_align4;
19792013
19802014 /* Read raw TMP006 data */
19812015 #define EC_CMD_TMP006_GET_RAW 0x55
19822016
19832017 struct ec_params_tmp006_get_raw {
19842018 uint8_t index;
1985−} __packed;
2019+} __ec_align1;
19862020
19872021 struct ec_response_tmp006_get_raw {
19882022 int32_t t; /* In 1/100 K */
19892023 int32_t v; /* In nV */
1990−};
2024+} __ec_align4;
19912025
19922026 /*****************************************************************************/
19932027 /* MKBP - Matrix KeyBoard Protocol */
@@ -2014,12 +2048,12 @@ struct ec_response_mkbp_info { · 20 unmodified lines
20142048 uint32_t cols;
20152049 /* Formerly "switches", which was 0. */
20162050 uint8_t reserved;
2017−} __packed;
2051+} __ec_align_size1;
20182052
20192053 struct ec_params_mkbp_info {
20202054 uint8_t info_type;
20212055 uint8_t event_type;
2022−} __packed;
2056+} __ec_align1;
20232057
20242058 enum ec_mkbp_info_type {
20252059 /*
@@ -2067,7 +2101,7 @@ struct ec_params_mkbp_simulate_key { · 41 unmodified lines
20672101 uint8_t col;
20682102 uint8_t row;
20692103 uint8_t pressed;
2070−} __packed;
2104+} __ec_align1;
20712105
20722106 /* Configure keyboard scanning */
20732107 #define EC_CMD_MKBP_SET_CONFIG 0x64
@@ -2113,15 +2147,15 @@ struct ec_mkbp_config { · 39 unmodified lines
21132147 uint16_t debounce_up_us; /* time for debounce on key up */
21142148 /* maximum depth to allow for fifo (0 = no keyscan output) */
21152149 uint8_t fifo_max_depth;
2116−} __packed;
2150+} __ec_align_size1;
21172151
21182152 struct ec_params_mkbp_set_config {
21192153 struct ec_mkbp_config config;
2120−} __packed;
2154+} __ec_align_size1;
21212155
21222156 struct ec_response_mkbp_get_config {
21232157 struct ec_mkbp_config config;
2124−} __packed;
2158+} __ec_align_size1;
21252159
21262160 /* Run the key scan emulation */
21272161 #define EC_CMD_KEYSCAN_SEQ_CTRL 0x66
@@ -2144,18 +2178,18 @@ enum ec_collect_flags { · 16 unmodified lines
21442178
21452179 struct ec_collect_item {
21462180 uint8_t flags; /* some flags (enum ec_collect_flags) */
2147−};
2181+} __ec_align1;
21482182
21492183 struct ec_params_keyscan_seq_ctrl {
21502184 uint8_t cmd; /* Command to send (enum ec_keyscan_seq_cmd) */
21512185 union {
2152− struct {
2186+ struct __ec_align1 {
21532187 uint8_t active; /* still active */
21542188 uint8_t num_items; /* number of items */
21552189 /* Current item being presented */
21562190 uint8_t cur_item;
21572191 } status;
2158− struct {
2192+ struct __ec_todo_unpacked {
21592193 /*
21602194 * Absolute time for this scan, measured from the
21612195 * start of the sequence.
@@ -2163,22 +2197,22 @@ struct ec_params_keyscan_seq_ctrl { · 1 unmodified line
21632197 uint32_t time_us;
21642198 uint8_t scan[0]; /* keyscan data */
21652199 } add;
2166− struct {
2200+ struct __ec_align1 {
21672201 uint8_t start_item; /* First item to return */
21682202 uint8_t num_items; /* Number of items to return */
21692203 } collect;
21702204 };
2171−} __packed;
2205+} __ec_todo_packed;
21722206
21732207 struct ec_result_keyscan_seq_ctrl {
21742208 union {
2175− struct {
2209+ struct __ec_todo_unpacked {
21762210 uint8_t num_items; /* Number of items */
21772211 /* Data for each item */
21782212 struct ec_collect_item item[0];
21792213 } collect;
21802214 };
2181−} __packed;
2215+} __ec_todo_packed;
21822216
21832217 /*
21842218 * Command for retrieving the next pending MKBP event from the EC device
@@ -2216,8 +2250,8 @@ enum ec_mkbp_event { · 31 unmodified lines
22162250 EC_MKBP_EVENT_COUNT,
22172251 };
22182252
2219−union ec_response_get_next_data {
2220− uint8_t key_matrix[13];
2253+union __ec_align_offset1 ec_response_get_next_data {
2254+ uint8_t key_matrix[13];
22212255
22222256 /* Unaligned */
22232257 uint32_t host_event;
@@ -2225,9 +2259,9 @@ union ec_response_get_next_data { · 1 unmodified line
22252259 uint32_t buttons;
22262260 uint32_t switches;
22272261 uint32_t sysrq;
2228−} __packed;
2262+};
22292263
2230−union ec_response_get_next_data_v1 {
2264+union __ec_align_offset1 ec_response_get_next_data_v1 {
22312265 uint8_t key_matrix[16];
22322266 uint32_t host_event;
22332267 uint32_t buttons;
@@ -2235,19 +2269,19 @@ union ec_response_get_next_data_v1 { · 1 unmodified line
22352269 uint32_t sysrq;
22362270 uint32_t cec_events;
22372271 uint8_t cec_message[16];
2238−} __packed;
2272+};
22392273
22402274 struct ec_response_get_next_event {
22412275 uint8_t event_type;
22422276 /* Followed by event data if any */
22432277 union ec_response_get_next_data data;
2244−} __packed;
2278+} __ec_align1;
22452279
22462280 struct ec_response_get_next_event_v1 {
22472281 uint8_t event_type;
22482282 /* Followed by event data if any */
22492283 union ec_response_get_next_data_v1 data;
2250−} __packed;
2284+} __ec_align1;
22512285
22522286 /* Bit indices for buttons and switches.*/
22532287 /* Buttons */
@@ -2268,12 +2302,12 @@ struct ec_response_get_next_event_v1 { · 14 unmodified lines
22682302
22692303 struct ec_params_temp_sensor_get_info {
22702304 uint8_t id;
2271−} __packed;
2305+} __ec_align1;
22722306
22732307 struct ec_response_temp_sensor_get_info {
22742308 char sensor_name[32];
22752309 uint8_t sensor_type;
2276−} __packed;
2310+} __ec_align1;
22772311
22782312 /*****************************************************************************/
22792313
@@ -2292,11 +2326,11 @@ struct ec_response_temp_sensor_get_info { · 12 unmodified lines
22922326 */
22932327 struct ec_params_host_event_mask {
22942328 uint32_t mask;
2295−} __packed;
2329+} __ec_align4;
22962330
22972331 struct ec_response_host_event_mask {
22982332 uint32_t mask;
2299−} __packed;
2333+} __ec_align4;
23002334
23012335 /* These all use ec_response_host_event_mask */
23022336 #define EC_CMD_HOST_EVENT_GET_B 0x87
@@ -2319,7 +2353,7 @@ struct ec_response_host_event_mask { · 16 unmodified lines
23192353
23202354 struct ec_params_switch_enable_backlight {
23212355 uint8_t enabled;
2322−} __packed;
2356+} __ec_align1;
23232357
23242358 /* Enable/disable WLAN/Bluetooth */
23252359 #define EC_CMD_SWITCH_ENABLE_WIRELESS 0x91
@@ -2328,7 +2362,7 @@ struct ec_params_switch_enable_backlight { · 2 unmodified lines
23282362 /* Version 0 params; no response */
23292363 struct ec_params_switch_enable_wireless_v0 {
23302364 uint8_t enabled;
2331−} __packed;
2365+} __ec_align1;
23322366
23332367 /* Version 1 params */
23342368 struct ec_params_switch_enable_wireless_v1 {
@@ -2347,7 +2381,7 @@ struct ec_params_switch_enable_wireless_v1 { · 12 unmodified lines
23472381
23482382 /* Which flags to copy from suspend_flags */
23492383 uint8_t suspend_mask;
2350−} __packed;
2384+} __ec_align1;
23512385
23522386 /* Version 1 response */
23532387 struct ec_response_switch_enable_wireless_v1 {
@@ -2356,7 +2390,7 @@ struct ec_response_switch_enable_wireless_v1 { · 2 unmodified lines
23562390
23572391 /* Flags to leave enabled in S3 */
23582392 uint8_t suspend_flags;
2359−} __packed;
2393+} __ec_align1;
23602394
23612395 /*****************************************************************************/
23622396 /* GPIO commands. Only available on EC if write protect has been disabled. */
@@ -2367,7 +2401,7 @@ struct ec_response_switch_enable_wireless_v1 { · 4 unmodified lines
23672401 struct ec_params_gpio_set {
23682402 char name[32];
23692403 uint8_t val;
2370−} __packed;
2404+} __ec_align1;
23712405
23722406 /* Get GPIO value */
23732407 #define EC_CMD_GPIO_GET 0x93
@@ -2375,37 +2409,37 @@ struct ec_params_gpio_set { · 1 unmodified line
23752409 /* Version 0 of input params and response */
23762410 struct ec_params_gpio_get {
23772411 char name[32];
2378−} __packed;
2412+} __ec_align1;
23792413
23802414 struct ec_response_gpio_get {
23812415 uint8_t val;
2382−} __packed;
2416+} __ec_align1;
23832417
23842418 /* Version 1 of input params and response */
23852419 struct ec_params_gpio_get_v1 {
23862420 uint8_t subcmd;
23872421 union {
2388− struct {
2422+ struct __ec_align1 {
23892423 char name[32];
23902424 } get_value_by_name;
2391− struct {
2425+ struct __ec_align1 {
23922426 uint8_t index;
23932427 } get_info;
23942428 };
2395−} __packed;
2429+} __ec_align1;
23962430
23972431 struct ec_response_gpio_get_v1 {
23982432 union {
2399− struct {
2433+ struct __ec_align1 {
24002434 uint8_t val;
24012435 } get_value_by_name, get_count;
2402− struct {
2436+ struct __ec_todo_unpacked {
24032437 uint8_t val;
24042438 char name[32];
24052439 uint32_t flags;
24062440 } get_info;
24072441 };
2408−} __packed;
2442+} __ec_todo_packed;
24092443
24102444 enum gpio_get_subcmd {
24112445 EC_GPIO_GET_BY_NAME = 0,
@@ -2431,11 +2465,11 @@ struct ec_params_i2c_read { · 19 unmodified lines
24312465 uint8_t read_size; /* Either 8 or 16. */
24322466 uint8_t port;
24332467 uint8_t offset;
2434−} __packed;
2468+} __ec_align_size1;
24352469
24362470 struct ec_response_i2c_read {
24372471 uint16_t data;
2438−} __packed;
2472+} __ec_align2;
24392473
24402474 /* Write I2C bus */
24412475 #define EC_CMD_I2C_WRITE 0x95
@@ -2446,7 +2480,7 @@ struct ec_params_i2c_write { · 4 unmodified lines
24462480 uint8_t write_size; /* Either 8 or 16. */
24472481 uint8_t port;
24482482 uint8_t offset;
2449−} __packed;
2483+} __ec_align_size1;
24502484
24512485 /*****************************************************************************/
24522486 /* Charge state commands. Only available when flash write protect unlocked. */
@@ -2465,7 +2499,7 @@ enum ec_charge_control_mode { · 12 unmodified lines
24652499
24662500 struct ec_params_charge_control {
24672501 uint32_t mode; /* enum charge_control_mode */
2468−} __packed;
2502+} __ec_align4;
24692503
24702504 /*****************************************************************************/
24712505
@@ -2493,7 +2527,7 @@ enum ec_console_read_subcmd { · 21 unmodified lines
24932527
24942528 struct ec_params_console_read_v1 {
24952529 uint8_t subcmd; /* enum ec_console_read_subcmd */
2496−} __packed;
2530+} __ec_align1;
24972531
24982532 /*****************************************************************************/
24992533
@@ -2511,7 +2545,7 @@ struct ec_params_console_read_v1 { · 11 unmodified lines
25112545
25122546 struct ec_params_battery_cutoff {
25132547 uint8_t flags;
2514−} __packed;
2548+} __ec_align1;
25152549
25162550 /*****************************************************************************/
25172551 /* USB port mux control. */
@@ -2523,7 +2557,7 @@ struct ec_params_battery_cutoff { · 5 unmodified lines
25232557
25242558 struct ec_params_usb_mux {
25252559 uint8_t mux;
2526−} __packed;
2560+} __ec_align1;
25272561
25282562 /*****************************************************************************/
25292563 /* LDOs / FETs control. */
@@ -2541,7 +2575,7 @@ enum ec_ldo_state { · 11 unmodified lines
25412575 struct ec_params_ldo_set {
25422576 uint8_t index;
25432577 uint8_t state;
2544−} __packed;
2578+} __ec_align1;
25452579
25462580 /*
25472581 * Get LDO state.
@@ -2550,11 +2584,11 @@ struct ec_params_ldo_set { · 2 unmodified lines
25502584
25512585 struct ec_params_ldo_get {
25522586 uint8_t index;
2553−} __packed;
2587+} __ec_align1;
25542588
25552589 struct ec_response_ldo_get {
25562590 uint8_t state;
2557−} __packed;
2591+} __ec_align1;
25582592
25592593 /*****************************************************************************/
25602594 /* Power info. */
@@ -2570,7 +2604,7 @@ struct ec_response_power_info { · 9 unmodified lines
25702604 uint16_t voltage_system;
25712605 uint16_t current_system;
25722606 uint16_t usb_current_limit;
2573−} __packed;
2607+} __ec_align4;
25742608
25752609 /*****************************************************************************/
25762610 /* I2C passthru command */
@@ -2592,20 +2626,20 @@ struct ec_response_power_info { · 15 unmodified lines
25922626 struct ec_params_i2c_passthru_msg {
25932627 uint16_t addr_flags; /* I2C slave address (7 or 10 bits) and flags */
25942628 uint16_t len; /* Number of bytes to read or write */
2595−} __packed;
2629+} __ec_align2;
25962630
25972631 struct ec_params_i2c_passthru {
25982632 uint8_t port; /* I2C port number */
25992633 uint8_t num_msgs; /* Number of messages */
26002634 struct ec_params_i2c_passthru_msg msg[];
26012635 /* Data to write for all messages is concatenated here */
2602−} __packed;
2636+} __ec_align2;
26032637
26042638 struct ec_response_i2c_passthru {
26052639 uint8_t i2c_status; /* Status flags (EC_I2C_STATUS_...) */
26062640 uint8_t num_msgs; /* Number of messages processed */
26072641 uint8_t data[]; /* Data read by messages concatenated here */
2608−} __packed;
2642+} __ec_align1;
26092643
26102644 /*****************************************************************************/
26112645 /* Power button hang detect */
@@ -2660,7 +2694,7 @@ struct ec_params_hang_detect { · 48 unmodified lines
26602694
26612695 /* Timeout in msec before generating warm reboot, if enabled */
26622696 uint16_t warm_reboot_timeout_msec;
2663−} __packed;
2697+} __ec_align4;
26642698
26652699 /*****************************************************************************/
26662700 /* Commands for battery charging */
@@ -2706,20 +2740,20 @@ struct ec_params_charge_state { · 39 unmodified lines
27062740 /* no args */
27072741 } get_state;
27082742
2709− struct {
2743+ struct __ec_todo_unpacked {
27102744 uint32_t param; /* enum charge_state_param */
27112745 } get_param;
27122746
2713− struct {
2747+ struct __ec_todo_unpacked {
27142748 uint32_t param; /* param to set */
27152749 uint32_t value; /* value to set */
27162750 } set_param;
27172751 };
2718−} __packed;
2752+} __ec_todo_packed;
27192753
27202754 struct ec_response_charge_state {
27212755 union {
2722− struct {
2756+ struct __ec_align4 {
27232757 int ac;
27242758 int chg_voltage;
27252759 int chg_current;
@@ -2727,14 +2761,14 @@ struct ec_response_charge_state { · 1 unmodified line
27272761 int batt_state_of_charge;
27282762 } get_state;
27292763
2730− struct {
2764+ struct __ec_align4 {
27312765 uint32_t value;
27322766 } get_param;
27332767 struct {
27342768 /* no return values */
27352769 } set_param;
27362770 };
2737−} __packed;
2771+} __ec_align4;
27382772
27392773
27402774 /*
@@ -2744,7 +2778,7 @@ struct ec_response_charge_state { · 3 unmodified lines
27442778
27452779 struct ec_params_current_limit {
27462780 uint32_t limit; /* in mA */
2747−} __packed;
2781+} __ec_align4;
27482782
27492783 /*
27502784 * Set maximum external voltage / current.
@@ -2755,7 +2789,7 @@ struct ec_params_current_limit { · 4 unmodified lines
27552789 struct ec_params_external_power_limit_v1 {
27562790 uint16_t current_lim; /* in mA, or EC_POWER_LIMIT_NONE to clear limit */
27572791 uint16_t voltage_lim; /* in mV, or EC_POWER_LIMIT_NONE to clear limit */
2758−} __packed;
2792+} __ec_align2;
27592793
27602794 #define EC_POWER_LIMIT_NONE 0xffff
27612795
@@ -2771,7 +2805,7 @@ enum host_sleep_event { · 9 unmodified lines
27712805
27722806 struct ec_params_host_sleep_event {
27732807 uint8_t sleep_event;
2774−} __packed;
2808+} __ec_align1;
27752809
27762810 /*
27772811 * Use a default timeout value (CONFIG_SLEEP_TIMEOUT_MS) for detecting sleep
@@ -2802,7 +2836,7 @@ struct ec_params_host_sleep_event_v1 { · 24 unmodified lines
28022836
28032837 /* No parameters for non-suspend messages. */
28042838 };
2805−} __packed;
2839+} __ec_align2;
28062840
28072841 /* A timeout occurred when this bit is set */
28082842 #define EC_HOST_RESUME_SLEEP_TIMEOUT 0x80000000
@@ -2828,7 +2862,7 @@ struct ec_response_host_sleep_event_v1 { · 19 unmodified lines
28282862
28292863 /* No response fields for non-resume messages. */
28302864 };
2831−} __packed;
2865+} __ec_align4;
28322866
28332867 /*****************************************************************************/
28342868 /* Smart battery pass-through */
@@ -2845,25 +2879,25 @@ struct ec_response_host_sleep_event_v1 { · 10 unmodified lines
28452879
28462880 struct ec_params_sb_rd {
28472881 uint8_t reg;
2848−} __packed;
2882+} __ec_align1;
28492883
28502884 struct ec_response_sb_rd_word {
28512885 uint16_t value;
2852−} __packed;
2886+} __ec_align2;
28532887
28542888 struct ec_params_sb_wr_word {
28552889 uint8_t reg;
28562890 uint16_t value;
2857−} __packed;
2891+} __ec_align1;
28582892
28592893 struct ec_response_sb_rd_block {
28602894 uint8_t data[32];
2861−} __packed;
2895+} __ec_align1;
28622896
28632897 struct ec_params_sb_wr_block {
28642898 uint8_t reg;
28652899 uint16_t data[32];
2866−} __packed;
2900+} __ec_align1;
28672901
28682902 /*****************************************************************************/
28692903 /* Battery vendor parameters
@@ -2885,11 +2919,11 @@ struct ec_params_battery_vendor_param { · 15 unmodified lines
28852919 uint32_t param;
28862920 uint32_t value;
28872921 uint8_t mode;
2888−} __packed;
2922+} __ec_align_size1;
28892923
28902924 struct ec_response_battery_vendor_param {
28912925 uint32_t value;
2892−} __packed;
2926+} __ec_align4;
28932927
28942928 /*****************************************************************************/
28952929 /* Commands for I2S recording on audio codec. */
@@ -2920,7 +2954,7 @@ enum ec_i2s_config { · 24 unmodified lines
29202954 EC_DAI_FMT_PCM_TDM = 5,
29212955 };
29222956
2923−struct ec_param_codec_i2s {
2957+struct __ec_todo_packed ec_param_codec_i2s {
29242958 /* enum ec_codec_i2s_subcmd */
29252959 uint8_t cmd;
29262960 union {
@@ -2934,10 +2968,10 @@ struct ec_param_codec_i2s { · 7 unmodified lines
29342968 * EC_CODEC_SET_GAIN
29352969 * Value should be 0~43 for both channels.
29362970 */
2937− struct ec_param_codec_i2s_set_gain {
2971+ struct __ec_align1 ec_param_codec_i2s_set_gain {
29382972 uint8_t left;
29392973 uint8_t right;
2940− } __packed gain;
2974+ } gain;
29412975
29422976 /*
29432977 * EC_CODEC_I2S_ENABLE
@@ -2955,7 +2989,7 @@ struct ec_param_codec_i2s { · 11 unmodified lines
29552989 * EC_CODEC_I2S_SET_TDM_CONFIG
29562990 * Value should be one of ec_i2s_config.
29572991 */
2958− struct ec_param_codec_i2s_tdm {
2992+ struct __ec_todo_unpacked ec_param_codec_i2s_tdm {
29592993 /*
29602994 * 0 to 496
29612995 */
@@ -2966,14 +3000,14 @@ struct ec_param_codec_i2s { · 4 unmodified lines
29663000 int16_t ch1_delay;
29673001 uint8_t adjacent_to_ch0;
29683002 uint8_t adjacent_to_ch1;
2969− } __packed tdm_param;
3003+ } tdm_param;
29703004
29713005 /*
29723006 * EC_CODEC_I2S_SET_BCLK
29733007 */
29743008 uint32_t bclk;
29753009 };
2976−} __packed;
3010+};
29773011
29783012 /*
29793013 * For subcommand EC_CODEC_GET_GAIN.
@@ -2981,7 +3015,7 @@ struct ec_param_codec_i2s { · 1 unmodified line
29813015 struct ec_response_codec_gain {
29823016 uint8_t left;
29833017 uint8_t right;
2984−} __packed;
3018+} __ec_align1;
29853019
29863020 /*****************************************************************************/
29873021 /* System commands */
@@ -3010,7 +3044,7 @@ enum ec_reboot_cmd { · 22 unmodified lines
30103044 struct ec_params_reboot_ec {
30113045 uint8_t cmd; /* enum ec_reboot_cmd */
30123046 uint8_t flags; /* See EC_REBOOT_FLAG_* */
3013−} __packed;
3047+} __ec_align1;
30143048
30153049 /*
30163050 * Get information on last EC panic.
@@ -3153,7 +3187,7 @@ struct ec_params_reboot_ec { · 136 unmodified lines
31533187 */
31543188 struct ec_params_cec_write {
31553189 uint8_t msg[EC_MAX_CEC_MSG_LEN];
3156−} __packed;
3190+} __ec_align1;
31573191
31583192 /* Set various CEC parameters */
31593193 #define EC_CMD_CEC_SET 0x00BA
@@ -3169,7 +3203,7 @@ struct ec_params_cec_write { · 9 unmodified lines
31693203 struct ec_params_cec_set {
31703204 uint8_t cmd; /* enum cec_command */
31713205 uint8_t val;
3172−} __packed;
3206+} __ec_align1;
31733207
31743208 /* Read various CEC parameters */
31753209 #define EC_CMD_CEC_GET 0x00BB
@@ -3180,7 +3214,7 @@ struct ec_params_cec_set { · 4 unmodified lines
31803214 */
31813215 struct ec_params_cec_get {
31823216 uint8_t cmd; /* enum cec_command */
3183−} __packed;
3217+} __ec_align1;
31843218
31853219 /**
31863220 * struct ec_response_cec_get - CEC parameters get response
@@ -3191,7 +3225,7 @@ struct ec_params_cec_get { · 4 unmodified lines
31913225 */
31923226 struct ec_response_cec_get {
31933227 uint8_t val;
3194−} __packed;
3228+} __ec_align1;
31953229
31963230 /* CEC parameters command */
31973231 enum ec_cec_command {
@@ -3264,13 +3298,13 @@ enum mkbp_cec_event { · 66 unmodified lines
32643298 /* Status of EC being sent to PD */
32653299 struct ec_params_pd_status {
32663300 int8_t batt_soc; /* battery state of charge */
3267−} __packed;
3301+} __ec_align1;
32683302
32693303 /* Status of PD being sent back to EC */
32703304 struct ec_response_pd_status {
32713305 int8_t status; /* PD MCU status */
32723306 uint32_t curr_lim_ma; /* input current limit */
3273−} __packed;
3307+} __ec_align_size1;
32743308
32753309 /* Set USB type-C port role and muxes */
32763310 #define EC_CMD_USB_PD_CONTROL 0x101
@@ -3305,7 +3339,7 @@ struct ec_params_usb_pd_control { · 28 unmodified lines
33053339 uint8_t role;
33063340 uint8_t mux;
33073341 uint8_t swap;
3308−} __packed;
3342+} __ec_align1;
33093343
33103344 #define PD_CTRL_RESP_ENABLED_COMMS (1 << 0) /* Communication enabled */
33113345 #define PD_CTRL_RESP_ENABLED_CONNECTED (1 << 1) /* Device connected */
@@ -3324,7 +3358,7 @@ struct ec_response_usb_pd_control_v1 { · 12 unmodified lines
33243358 uint8_t role;
33253359 uint8_t polarity;
33263360 char state[32];
3327−} __packed;
3361+} __ec_align1;
33283362
33293363 #define EC_CMD_USB_PD_PORTS 0x102
33303364
@@ -3333,14 +3367,14 @@ struct ec_response_usb_pd_control_v1 { · 2 unmodified lines
33333367
33343368 struct ec_response_usb_pd_ports {
33353369 uint8_t num_ports;
3336−} __packed;
3370+} __ec_align1;
33373371
33383372 #define EC_CMD_USB_PD_POWER_INFO 0x103
33393373
33403374 #define PD_POWER_CHARGING_PORT 0xff
33413375 struct ec_params_usb_pd_power_info {
33423376 uint8_t port;
3343−} __packed;
3377+} __ec_align1;
33443378
33453379 enum usb_chg_type {
33463380 USB_CHG_TYPE_NONE,
@@ -3366,7 +3400,7 @@ struct usb_chg_measures { · 19 unmodified lines
33663400 uint16_t voltage_now;
33673401 uint16_t current_max;
33683402 uint16_t current_lim;
3369−} __packed;
3403+} __ec_align2;
33703404
33713405 struct ec_response_usb_pd_power_info {
33723406 uint8_t role;
@@ -3375,11 +3409,11 @@ struct ec_response_usb_pd_power_info { · 2 unmodified lines
33753409 uint8_t reserved1;
33763410 struct usb_chg_measures meas;
33773411 uint32_t max_power;
3378−} __packed;
3412+} __ec_align4;
33793413
33803414 struct ec_params_usb_pd_info_request {
33813415 uint8_t port;
3382−} __packed;
3416+} __ec_align1;
33833417
33843418 /*
33853419 * This command will return the number of USB PD charge port + the number
@@ -3389,7 +3423,7 @@ struct ec_params_usb_pd_info_request { · 3 unmodified lines
33893423 #define EC_CMD_CHARGE_PORT_COUNT 0x0105
33903424 struct ec_response_charge_port_count {
33913425 uint8_t port_count;
3392−} __packed;
3426+} __ec_align1;
33933427
33943428 /* Read USB-PD Device discovery info */
33953429 #define EC_CMD_USB_PD_DISCOVERY 0x0113
@@ -3397,7 +3431,7 @@ struct ec_params_usb_pd_discovery_entry { · 1 unmodified line
33973431 uint16_t vid; /* USB-IF VID */
33983432 uint16_t pid; /* USB-IF PID */
33993433 uint8_t ptype; /* product type (hub,periph,cable,ama) */
3400−} __packed;
3434+} __ec_align_size1;
34013435
34023436 /* Override default charge behavior */
34033437 #define EC_CMD_PD_CHARGE_PORT_OVERRIDE 0x0114
@@ -3411,7 +3445,7 @@ enum usb_pd_override_ports { · 7 unmodified lines
34113445
34123446 struct ec_params_charge_port_override {
34133447 int16_t override_port; /* Override port# */
3414−} __packed;
3448+} __ec_align2;
34153449
34163450 /* Read (and delete) one entry of PD event log */
34173451 #define EC_CMD_PD_GET_LOG_ENTRY 0x0115
@@ -3422,7 +3456,7 @@ struct ec_response_pd_log { · 4 unmodified lines
34223456 uint8_t size_port; /* [7:5] port number [4:0] payload size in bytes */
34233457 uint16_t data; /* type-defined data payload */
34243458 uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */
3425−} __packed;
3459+} __ec_align4;
34263460
34273461 /* The timestamp is the microsecond counter shifted to get about a ms. */
34283462 #define PD_LOG_TIMESTAMP_SHIFT 10 /* 1 LSB = 1024us */
@@ -3488,14 +3522,14 @@ struct mcdp_version { · 59 unmodified lines
34883522 uint8_t major;
34893523 uint8_t minor;
34903524 uint16_t build;
3491−} __packed;
3525+} __ec_align4;
34923526
34933527 struct mcdp_info {
34943528 uint8_t family[2];
34953529 uint8_t chipid[2];
34963530 struct mcdp_version irom;
34973531 struct mcdp_version fw;
3498−} __packed;
3532+} __ec_align4;
34993533
35003534 /* struct mcdp_info field decoding */
35013535 #define MCDP_CHIPID(chipid) ((chipid[0] << 8) | chipid[1])
@@ -3506,7 +3540,7 @@ struct mcdp_info { · 4 unmodified lines
35063540
35073541 struct ec_params_usb_pd_mux_info {
35083542 uint8_t port; /* USB-C port number */
3509−} __packed;
3543+} __ec_align1;
35103544
35113545 /* Flags representing mux state */
35123546 #define USB_PD_MUX_USB_ENABLED (1 << 0)
@@ -3516,7 +3550,7 @@ struct ec_params_usb_pd_mux_info { · 3 unmodified lines
35163550
35173551 struct ec_response_usb_pd_mux_info {
35183552 uint8_t flags; /* USB_PD_MUX_*-encoded USB mux state */
3519−} __packed;
3553+} __ec_align1;
35203554
35213555 /*****************************************************************************/
35223556 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t