aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2017-07-15 08:32:56 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-07-26 05:46:44 -0400
commitfc1ff45a07abf240aa0c6586c11465c86c8cab8d (patch)
tree0eba84919fe75c472cb44ad97159f5c8b502190d
parent9b7c0c476f66ee212925c801c4141fdd83b7336d (diff)
media: cec-notifier: small improvements
Allow calling cec_notifier_set_phys_addr and cec_notifier_set_phys_addr_from_edid with a NULL notifier, in which case these functions do nothing. Add a cec_notifier_phys_addr_invalidate helper function (the notifier equivalent of cec_phys_addr_invalidate). These changes simplify drm CEC driver support. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/cec/cec-notifier.c6
-rw-r--r--include/media/cec-notifier.h15
2 files changed, 21 insertions, 0 deletions
diff --git a/drivers/media/cec/cec-notifier.c b/drivers/media/cec/cec-notifier.c
index 74dc1c32080e..08b619d0ea1e 100644
--- a/drivers/media/cec/cec-notifier.c
+++ b/drivers/media/cec/cec-notifier.c
@@ -87,6 +87,9 @@ EXPORT_SYMBOL_GPL(cec_notifier_put);
87 87
88void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa) 88void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa)
89{ 89{
90 if (n == NULL)
91 return;
92
90 mutex_lock(&n->lock); 93 mutex_lock(&n->lock);
91 n->phys_addr = pa; 94 n->phys_addr = pa;
92 if (n->callback) 95 if (n->callback)
@@ -100,6 +103,9 @@ void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n,
100{ 103{
101 u16 pa = CEC_PHYS_ADDR_INVALID; 104 u16 pa = CEC_PHYS_ADDR_INVALID;
102 105
106 if (n == NULL)
107 return;
108
103 if (edid && edid->extensions) 109 if (edid && edid->extensions)
104 pa = cec_get_edid_phys_addr((const u8 *)edid, 110 pa = cec_get_edid_phys_addr((const u8 *)edid,
105 EDID_LENGTH * (edid->extensions + 1), NULL); 111 EDID_LENGTH * (edid->extensions + 1), NULL);
diff --git a/include/media/cec-notifier.h b/include/media/cec-notifier.h
index 298f996969df..a4f7429c4ae5 100644
--- a/include/media/cec-notifier.h
+++ b/include/media/cec-notifier.h
@@ -57,6 +57,7 @@ void cec_notifier_put(struct cec_notifier *n);
57 * @pa: the CEC physical address 57 * @pa: the CEC physical address
58 * 58 *
59 * Set a new CEC physical address. 59 * Set a new CEC physical address.
60 * Does nothing if @n == NULL.
60 */ 61 */
61void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa); 62void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa);
62 63
@@ -66,6 +67,7 @@ void cec_notifier_set_phys_addr(struct cec_notifier *n, u16 pa);
66 * @edid: the struct edid pointer 67 * @edid: the struct edid pointer
67 * 68 *
68 * Parses the EDID to obtain the new CEC physical address and set it. 69 * Parses the EDID to obtain the new CEC physical address and set it.
70 * Does nothing if @n == NULL.
69 */ 71 */
70void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n, 72void cec_notifier_set_phys_addr_from_edid(struct cec_notifier *n,
71 const struct edid *edid); 73 const struct edid *edid);
@@ -118,4 +120,17 @@ static inline void cec_notifier_unregister(struct cec_notifier *n)
118 120
119#endif 121#endif
120 122
123/**
124 * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID
125 *
126 * @n: the CEC notifier
127 *
128 * This is a simple helper function to invalidate the physical
129 * address. Does nothing if @n == NULL.
130 */
131static inline void cec_notifier_phys_addr_invalidate(struct cec_notifier *n)
132{
133 cec_notifier_set_phys_addr(n, CEC_PHYS_ADDR_INVALID);
134}
135
121#endif 136#endif