On Sun, Oct 01, 2017 at 03:30:51PM -0400, Jérémy Lefaure wrote: > Using the ARRAY_SIZE macro improves the readability of the code. > > Found with Coccinelle with the following semantic patch: > @r depends on (org || report)@ > type T; > T[] E; > position p; > @@ > ( > (sizeof(E)@p /sizeof(*E)) > | > (sizeof(E)@p /sizeof(E[...])) > | > (sizeof(E)@p /sizeof(T)) > ) > > Signed-off-by: Jérémy Lefaure <jeremy.lefaure@xxxxxxxxxxxx> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> /Jarkko > --- > drivers/char/tpm/tpm_tis.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c > index ebd0e75a3e4d..e2d1055fb814 100644 > --- a/drivers/char/tpm/tpm_tis.c > +++ b/drivers/char/tpm/tpm_tis.c > @@ -30,6 +30,7 @@ > #include <linux/freezer.h> > #include <linux/of.h> > #include <linux/of_device.h> > +#include <linux/kernel.h> > #include "tpm.h" > #include "tpm_tis_core.h" > > @@ -365,7 +366,7 @@ static struct pnp_driver tis_pnp_driver = { > }, > }; > > -#define TIS_HID_USR_IDX sizeof(tpm_pnp_tbl)/sizeof(struct pnp_device_id) -2 > +#define TIS_HID_USR_IDX (ARRAY_SIZE(tpm_pnp_tbl) - 2) > module_param_string(hid, tpm_pnp_tbl[TIS_HID_USR_IDX].id, > sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444); > MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe"); > -- > 2.14.1 >