From: Simon Horman on
On Mon, Jun 28, 2010 at 03:55:24PM +0400, Kulikov Vasiliy wrote:
> Change sizeof(x) / sizeof(*x) to ARRAY_SIZE(x).
>
> Signed-off-by: Kulikov Vasiliy <segooon(a)gmail.com>

Looks good.

Acked-by: Simon Horman <horms(a)verge.net.au>

> ---
> drivers/staging/otus/hal/hpreg.c | 17 +++++++----------
> 1 files changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/otus/hal/hpreg.c b/drivers/staging/otus/hal/hpreg.c
> index da3b774..9b04653 100644
> --- a/drivers/staging/otus/hal/hpreg.c
> +++ b/drivers/staging/otus/hal/hpreg.c
> @@ -29,9 +29,6 @@
> #include "hpreg.h"
> #include "hpusb.h"
>
> -/* used throughout this file... */
> -#define N(a) (sizeof(a) / sizeof(a[0]))
> -
> #define HAL_MODE_11A_TURBO HAL_MODE_108A
> #define HAL_MODE_11G_TURBO HAL_MODE_108G
>
> @@ -1557,7 +1554,7 @@ u8_t GetWmRD(u16_t regionCode, u16_t channelFlag, REG_DOMAIN *rd)
> u64_t flags = NO_REQ;
> REG_DMN_PAIR_MAPPING *regPair = NULL;
>
> - for (i = 0, found = 0; (i < N(regDomainPairs)) && (!found); i++) {
> + for (i = 0, found = 0; (i < ARRAY_SIZE(regDomainPairs)) && (!found); i++) {
> if (regDomainPairs[i].regDmnEnum == regionCode) {
> regPair = &regDomainPairs[i];
> found = 1;
> @@ -1581,7 +1578,7 @@ u8_t GetWmRD(u16_t regionCode, u16_t channelFlag, REG_DOMAIN *rd)
> * unitary reg domain of the pair
> */
>
> - for (i = 0 ; i < N(regDomains) ; i++) {
> + for (i = 0 ; i < ARRAY_SIZE(regDomains) ; i++) {
> if (regDomains[i].regDmnEnum == regDmn) {
> if (rd != NULL) {
> zfMemoryCopy((u8_t *)rd, (u8_t *)&regDomains[i],
> @@ -1653,7 +1650,7 @@ void zfHpGetRegulationTable(zdev_t *dev, u16_t regionCode, u16_t c_lo, u16_t c_h
>
> zmw_enter_critical_section(dev);
>
> - for (cm = modes; cm < &modes[N(modes)]; cm++) {
> + for (cm = modes; cm < &modes[ARRAY_SIZE(modes)]; cm++) {
> u16_t c;
> u64_t *channelBM = NULL;
> REG_DOMAIN *rd = NULL;
> @@ -1846,7 +1843,7 @@ void zfHpGetRegulationTablefromCountry(zdev_t *dev, u16_t CountryCode)
>
> zmw_declare_for_critical_section();
>
> - for (i = 0; i < N(allCountries); i++) {
> + for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
> if (CountryCode == allCountries[i].countryCode) {
> RegDomain = allCountries[i].regDmnEnum;
>
> @@ -1881,7 +1878,7 @@ u8_t zfHpGetRegulationTablefromISO(zdev_t *dev, u8_t *countryInfo, u8_t length)
> strLen = 3; */
> }
> /* zm_debug_msg_s("Desired iso name = ", isoName); */
> - for (i = 0; i < N(allCountries); i++) {
> + for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
> /* zm_debug_msg_s("Current iso name = ", allCountries[i].isoName); */
> if (zfMemoryIsEqual((u8_t *)allCountries[i].isoName, (u8_t *)&countryInfo[2], length-1)) {
> /* DbgPrint("Set current iso name = %s\n", allCountries[i].isoName); */
> @@ -1937,7 +1934,7 @@ const char *zfHpGetisoNamefromregionCode(zdev_t *dev, u16_t regionCode)
> {
> u16_t i;
>
> - for (i = 0; i < N(allCountries); i++) {
> + for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
> if (allCountries[i].regDmnEnum == regionCode)
> return allCountries[i].isoName;
> }
> @@ -1953,7 +1950,7 @@ u16_t zfHpGetRegionCodeFromIsoName(zdev_t *dev, u8_t *countryIsoName)
> /* if no matching item, return default */
> regionCode = DEF_REGDMN;
>
> - for (i = 0; i < N(allCountries); i++) {
> + for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
> if (zfMemoryIsEqual((u8_t *)allCountries[i].isoName, countryIsoName, 2)) {
> regionCode = allCountries[i].regDmnEnum;
> break;
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo(a)vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Paul Fulghum on
On 6/28/2010 5:54 AM, Kulikov Vasiliy wrote:
> Change sizeof(x) / sizeof(*x) to ARRAY_SIZE(x).
>
> Signed-off-by: Kulikov Vasiliy <segooon(a)gmail.com>
> ---
> drivers/char/synclink_gt.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
> index 4561ce2..334cf5c 100644
> --- a/drivers/char/synclink_gt.c
> +++ b/drivers/char/synclink_gt.c
> @@ -4845,7 +4845,7 @@ static int register_test(struct slgt_info *info)
> {
> static unsigned short patterns[] =
> {0x0000, 0xffff, 0xaaaa, 0x5555, 0x6969, 0x9696};
> - static unsigned int count = sizeof(patterns)/sizeof(patterns[0]);
> + static unsigned int count = ARRAY_SIZE(patterns);
> unsigned int i;
> int rc = 0;
>

Acked-by: Paul Fulghum <paulkf(a)microgate.com>

with the exception of the trailing CR :-)

--
Paul Fulghum
MicroGate Systems, Ltd.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Stephen Hemminger on
On Mon, 28 Jun 2010 15:54:48 +0400
Kulikov Vasiliy <segooon(a)gmail.com> wrote:

> static unsigned short patterns[] =
> {0x0000, 0xffff, 0xaaaa, 0x5555, 0x6969, 0x9696};

Unrelated, but these patterns should be const.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Greg KH on
Meta-comment:

In the future, please provide a much better Subject: line so that I
don't have to go and edit it to show exactly what it is affecting.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Jiri Kosina on
On Mon, 28 Jun 2010, Kulikov Vasiliy wrote:

> Change sizeof(x) / sizeof(*x) to ARRAY_SIZE(x).
>
> Signed-off-by: Kulikov Vasiliy <segooon(a)gmail.com>
> ---
> drivers/gpu/drm/i915/intel_sdvo.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
> index 76993ac..03c231b 100644
> --- a/drivers/gpu/drm/i915/intel_sdvo.c
> +++ b/drivers/gpu/drm/i915/intel_sdvo.c
> @@ -392,13 +392,13 @@ static void intel_sdvo_debug_write(struct intel_encoder *intel_encoder, u8 cmd,
> DRM_LOG_KMS("%02X ", ((u8 *)args)[i]);
> for (; i < 8; i++)
> DRM_LOG_KMS(" ");
> - for (i = 0; i < sizeof(sdvo_cmd_names) / sizeof(sdvo_cmd_names[0]); i++) {
> + for (i = 0; i < ARRAY_SIZE(sdvo_cmd_names); i++) {
> if (cmd == sdvo_cmd_names[i].cmd) {
> DRM_LOG_KMS("(%s)", sdvo_cmd_names[i].name);
> break;
> }
> }
> - if (i == sizeof(sdvo_cmd_names)/ sizeof(sdvo_cmd_names[0]))
> + if (i == ARRAY_SIZE(sdvo_cmd_names))
> DRM_LOG_KMS("(%02X)", cmd);
> DRM_LOG_KMS("\n");
> }

Applied to trivial queue, as linux-next as of today doesn't carry this
patch.

Thanks,

--
Jiri Kosina
SUSE Labs, Novell Inc.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/