summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Norris <briannorris@chromium.org>2016-07-26 14:22:13 -0400
committerThierry Reding <thierry.reding@gmail.com>2016-09-06 04:48:54 -0400
commit065cfbbb638cce3d388020c4b97813b4a904a7c3 (patch)
tree9e71fe26e3bb9b045ff45a0d3074a1c5f71aad76
parentcd4b45ac449a01f0819b8459c451c840437aa0a3 (diff)
pwm: cros-ec: Add __packed to prevent padding
While the particular usage in question is likely safe (struct cros_ec_command is 32-bit aligned, followed by <= 32-bit fields), it's been suggested this is not a great pattern to follow for the general case -- for example, if we follow a 'struct cros_ec_command' (which is 32-bit- but not 64-bit-aligned) with a struct that starts with a 64-bit type (e.g., u64), the compiler may add padding. Let's add __packed, to inform the compiler of our true intention -- to have no padding between these struct elements -- and to future proof for any refactorings that might occur. Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
-rw-r--r--drivers/pwm/pwm-cros-ec.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/pwm/pwm-cros-ec.c b/drivers/pwm/pwm-cros-ec.c
index 99b9acc1a420..f6ca4e8c6253 100644
--- a/drivers/pwm/pwm-cros-ec.c
+++ b/drivers/pwm/pwm-cros-ec.c
@@ -38,7 +38,7 @@ static int cros_ec_pwm_set_duty(struct cros_ec_device *ec, u8 index, u16 duty)
38 struct { 38 struct {
39 struct cros_ec_command msg; 39 struct cros_ec_command msg;
40 struct ec_params_pwm_set_duty params; 40 struct ec_params_pwm_set_duty params;
41 } buf; 41 } __packed buf;
42 struct ec_params_pwm_set_duty *params = &buf.params; 42 struct ec_params_pwm_set_duty *params = &buf.params;
43 struct cros_ec_command *msg = &buf.msg; 43 struct cros_ec_command *msg = &buf.msg;
44 44
@@ -65,7 +65,7 @@ static int __cros_ec_pwm_get_duty(struct cros_ec_device *ec, u8 index,
65 struct ec_params_pwm_get_duty params; 65 struct ec_params_pwm_get_duty params;
66 struct ec_response_pwm_get_duty resp; 66 struct ec_response_pwm_get_duty resp;
67 }; 67 };
68 } buf; 68 } __packed buf;
69 struct ec_params_pwm_get_duty *params = &buf.params; 69 struct ec_params_pwm_get_duty *params = &buf.params;
70 struct ec_response_pwm_get_duty *resp = &buf.resp; 70 struct ec_response_pwm_get_duty *resp = &buf.resp;
71 struct cros_ec_command *msg = &buf.msg; 71 struct cros_ec_command *msg = &buf.msg;