greybus: get rid of a weird idiom
authorAlex Elder <elder@linaro.org>
Tue, 23 Sep 2014 17:46:33 +0000 (12:46 -0500)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 24 Sep 2014 03:40:29 +0000 (20:40 -0700)
It strikes me as strange to add one to a value while checking to see
if it exceeds a maximum.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/core.c

index 296ff61..33d7a33 100644 (file)
@@ -282,7 +282,7 @@ static int create_string(struct greybus_module *gmod,
        int string_size;
        struct gmod_string *gmod_string;
 
-       if ((gmod->num_strings + 1) >= MAX_STRINGS_PER_MODULE) {
+       if (gmod->num_strings == MAX_STRINGS_PER_MODULE) {
                dev_err(gmod->dev.parent,
                        "too many strings for this module!\n");
                return -EINVAL;
@@ -315,7 +315,7 @@ static int create_cport(struct greybus_module *gmod,
 {
        struct gmod_cport *gmod_cport;
 
-       if ((gmod->num_cports + 1) >= MAX_CPORTS_PER_MODULE) {
+       if (gmod->num_cports == MAX_CPORTS_PER_MODULE) {
                dev_err(gmod->dev.parent, "too many cports for this module!\n");
                return -EINVAL;
        }