greybus: introduce cport_id_valid()
Define a public predicate that defines whether a CPort ID is valid.
Use it in the message_send() routine, and make the message reported
more accurately reflect the error. Also use it to check whether the
CPort ID in a received message is valid; if it is not, just drop the
message.
Get rid of local variable "buffer" in message_send(); it adds no
value.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h
index 05eab4c..518f142 100644
--- a/drivers/staging/greybus/greybus.h
+++ b/drivers/staging/greybus/greybus.h
@@ -196,5 +196,10 @@
return dev->type == &greybus_connection_type;
}
+static inline bool cport_id_valid(u16 cport_id)
+{
+ return cport_id != CPORT_ID_BAD;
+}
+
#endif /* __KERNEL__ */
#endif /* __LINUX_GREYBUS_H */