Skip to contentSkip to conversation

Add cec_get_drvdata()

PATCH In review Jose Abreu 3 participants 11 messages Mar 24, 2017 – Mar 28, 2017

Subsystems (6)
lore
Share & tools
lore

Jose Abreu

author
#0 lore raw

cover Add cec_get_drvdata()

Hi,

This series introduces a new helper function called cec_get_drvdata() which returns the adapter private data and can be used by drivers that use CEC.

Best regards,
Jose Miguel Abreu

Jose Abreu (8):
[media] cec: Add cec_get_drvdata()
[media] staging: st-cec: Use cec_get_drvdata()
[media] staging: s5p-cec: Use cec_get_drvdata()
[media] i2c: adv7511: Use cec_get_drvdata()
[media] i2c: adv7604: Use cec_get_drvdata()
[media] i2c: adv7842: Use cec_get_drvdata()
[media] usb: pulse8-cec: Use cec_get_drvdata()
[media] platform: vivid: Use cec_get_drvdata()

 drivers/media/i2c/adv7511.c               | 6 +++---
 drivers/media/i2c/adv7604.c               | 6 +++---
 drivers/media/i2c/adv7842.c               | 6 +++---
 drivers/media/platform/vivid/vivid-cec.c  | 4 ++--
 drivers/media/usb/pulse8-cec/pulse8-cec.c | 6 +++---
 drivers/staging/media/s5p-cec/s5p_cec.c   | 6 +++---
 drivers/staging/media/st-cec/stih-cec.c   | 6 +++---
 include/media/cec.h                       | 5 +++++
 8 files changed, 25 insertions(+), 20 deletions(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/8 cec: Add cec_get_drvdata()

Add a helper function to get driver private data from CEC adapter. This helps the readability a little bit and allows to change the 'priv' field name to something else without needing to touch all drivers.

---
 include/media/cec.h | 5 +++++
 1 file changed, 5 insertions(+)
include/media/cec.h +5 -0
index 96a0aa7..0daff8c 100644
@@ -184,6 +184,11 @@ struct cec_adapter {
 	char input_drv[32];
 };
 
+static inline void *cec_get_drvdata(const struct cec_adapter *adap)
+{
+	return adap->priv;
+}
+
 static inline bool cec_has_log_addr(const struct cec_adapter *adap, u8 log_addr)
 {
 	return adap->log_addrs.log_addr_mask & (1 << log_addr);
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH 2/8 staging: st-cec: Use cec_get_drvdata()

In reply to Jose Abreu

Use helper function to get driver private data from CEC adapter.

Cc Benjamin Gaignard <[email protected]>
---
 drivers/staging/media/st-cec/stih-cec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/st-cec/stih-cec.c +3 -3
index 3c25638..521206d 100644
@@ -133,7 +133,7 @@ struct stih_cec {
 
 static int stih_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-	struct stih_cec *cec = adap->priv;
+	struct stih_cec *cec = cec_get_drvdata(adap);
 
 	if (enable) {
 		/* The doc says (input TCLK_PERIOD * CEC_CLK_DIV) = 0.1ms */
@@ -189,7 +189,7 @@ static int stih_cec_adap_enable(struct cec_adapter *adap, bool enable)
 
 static int stih_cec_adap_log_addr(struct cec_adapter *adap, u8 logical_addr)
 {
-	struct stih_cec *cec = adap->priv;
+	struct stih_cec *cec = cec_get_drvdata(adap);
 	u32 reg = readl(cec->regs + CEC_ADDR_TABLE);
 
 	reg |= 1 << logical_addr;
@@ -205,7 +205,7 @@ static int stih_cec_adap_log_addr(struct cec_adapter *adap, u8 logical_addr)
 static int stih_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 				  u32 signal_free_time, struct cec_msg *msg)
 {
-	struct stih_cec *cec = adap->priv;
+	struct stih_cec *cec = cec_get_drvdata(adap);
 	int i;
 
 	/* Copy message into registers */
Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH 2/8] [media] staging: st-cec: Use cec_get_drvdata()

2017-03-24 17:47 GMT+01:00 Jose Abreu <[email protected]>:

Quoted 2 lines

Use helper function to get driver private data from CEC adapter.

That looks good for me but does it make sense to merge that now ? or should we wait until
cec drivers as move out of staging ?
Hans what is your view on that ?

Quoted 42 lines
Cc Benjamin Gaignard <[email protected]>
---
 drivers/staging/media/st-cec/stih-cec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/st-cec/stih-cec.c +3 -4
index 3c25638..521206d 100644
@@ -133,7 +133,7 @@ struct stih_cec {
 
 static int stih_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-       struct stih_cec *cec = adap->priv;
+       struct stih_cec *cec = cec_get_drvdata(adap);
 
        if (enable) {
                /* The doc says (input TCLK_PERIOD * CEC_CLK_DIV) = 0.1ms */
@@ -189,7 +189,7 @@ static int stih_cec_adap_enable(struct cec_adapter *adap, bool enable)
 
 static int stih_cec_adap_log_addr(struct cec_adapter *adap, u8 logical_addr)
 {
-       struct stih_cec *cec = adap->priv;
+       struct stih_cec *cec = cec_get_drvdata(adap);
        u32 reg = readl(cec->regs + CEC_ADDR_TABLE);
 
        reg |= 1 << logical_addr;
@@ -205,7 +205,7 @@ static int stih_cec_adap_log_addr(struct cec_adapter *adap, u8 logical_addr)
 static int stih_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
                                  u32 signal_free_time, struct cec_msg *msg)
 {
-       struct stih_cec *cec = adap->priv;
+       struct stih_cec *cec = cec_get_drvdata(adap);
        int i;
 
        /* Copy message into registers */
--

1.9.1

#4 lore raw

Re: [PATCH 2/8] [media] staging: st-cec: Use cec_get_drvdata()

Quoted 8 lines · Benjamin Gaignard

2017-03-24 17:47 GMT+01:00 Jose Abreu <[email protected]>:

Quoted 2 lines

Use helper function to get driver private data from CEC adapter.

That looks good for me but does it make sense to merge that now ? or should we wait until
cec drivers as move out of staging ?
Hans what is your view on that ?

Why not merge this? It makes no sense not to update staging drivers. Just because they are in staging doesn't mean you can't improve them :-)

Regards,

Hans

Quoted 43 lines
Quoted 43 lines
Cc Benjamin Gaignard <[email protected]>
---
 drivers/staging/media/st-cec/stih-cec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/st-cec/stih-cec.c +3 -4
index 3c25638..521206d 100644
@@ -133,7 +133,7 @@ struct stih_cec {
 
 static int stih_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-       struct stih_cec *cec = adap->priv;
+       struct stih_cec *cec = cec_get_drvdata(adap);
 
        if (enable) {
                /* The doc says (input TCLK_PERIOD * CEC_CLK_DIV) = 0.1ms */
@@ -189,7 +189,7 @@ static int stih_cec_adap_enable(struct cec_adapter *adap, bool enable)
 
 static int stih_cec_adap_log_addr(struct cec_adapter *adap, u8 logical_addr)
 {
-       struct stih_cec *cec = adap->priv;
+       struct stih_cec *cec = cec_get_drvdata(adap);
        u32 reg = readl(cec->regs + CEC_ADDR_TABLE);
 
        reg |= 1 << logical_addr;
@@ -205,7 +205,7 @@ static int stih_cec_adap_log_addr(struct cec_adapter *adap, u8 logical_addr)
 static int stih_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
                                  u32 signal_free_time, struct cec_msg *msg)
 {
-       struct stih_cec *cec = adap->priv;
+       struct stih_cec *cec = cec_get_drvdata(adap);
        int i;
 
        /* Copy message into registers */
--

1.9.1

author
#5 lore raw

PATCH 3/8 staging: s5p-cec: Use cec_get_drvdata()

In reply to Jose Abreu

Use helper function to get driver private data from CEC adapter.

---
 drivers/staging/media/s5p-cec/s5p_cec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/s5p-cec/s5p_cec.c +3 -3
index 2a07968..a30b80a 100644
@@ -37,7 +37,7 @@
 
 static int s5p_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-	struct s5p_cec_dev *cec = adap->priv;
+	struct s5p_cec_dev *cec = cec_get_drvdata(adap);
 
 	if (enable) {
 		pm_runtime_get_sync(cec->dev);
@@ -61,7 +61,7 @@ static int s5p_cec_adap_enable(struct cec_adapter *adap, bool enable)
 
 static int s5p_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 {
-	struct s5p_cec_dev *cec = adap->priv;
+	struct s5p_cec_dev *cec = cec_get_drvdata(adap);
 
 	s5p_cec_set_addr(cec, addr);
 	return 0;
@@ -70,7 +70,7 @@ static int s5p_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 static int s5p_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 				 u32 signal_free_time, struct cec_msg *msg)
 {
-	struct s5p_cec_dev *cec = adap->priv;
+	struct s5p_cec_dev *cec = cec_get_drvdata(adap);
 
 	/*
 	 * Unclear if 0 retries are allowed by the hardware, so have 1 as
Signature · 1 line
1.9.1
author
#6 lore raw

PATCH 4/8 i2c: adv7511: Use cec_get_drvdata()

In reply to Jose Abreu

Use helper function to get driver private data from CEC adapter.

---
 drivers/media/i2c/adv7511.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/i2c/adv7511.c +3 -3
index 8c9e289..ccc4786 100644
@@ -734,7 +734,7 @@ static int adv7511_s_power(struct v4l2_subdev *sd, int on)
 #if IS_ENABLED(CONFIG_VIDEO_ADV7511_CEC)
 static int adv7511_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-	struct adv7511_state *state = adap->priv;
+	struct adv7511_state *state = cec_get_drvdata(adap);
 	struct v4l2_subdev *sd = &state->sd;
 
 	if (state->i2c_cec == NULL)
@@ -769,7 +769,7 @@ static int adv7511_cec_adap_enable(struct cec_adapter *adap, bool enable)
 
 static int adv7511_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 {
-	struct adv7511_state *state = adap->priv;
+	struct adv7511_state *state = cec_get_drvdata(adap);
 	struct v4l2_subdev *sd = &state->sd;
 	unsigned int i, free_idx = ADV7511_MAX_ADDRS;
 
@@ -824,7 +824,7 @@ static int adv7511_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 static int adv7511_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 				     u32 signal_free_time, struct cec_msg *msg)
 {
-	struct adv7511_state *state = adap->priv;
+	struct adv7511_state *state = cec_get_drvdata(adap);
 	struct v4l2_subdev *sd = &state->sd;
 	u8 len = msg->len;
 	unsigned int i;
Signature · 1 line
1.9.1
author
#7 lore raw

PATCH 5/8 i2c: adv7604: Use cec_get_drvdata()

In reply to Jose Abreu

Use helper function to get driver private data from CEC adapter.

---
 drivers/media/i2c/adv7604.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/i2c/adv7604.c +3 -3
index d8bf435..f1fa9ce 100644
@@ -2050,7 +2050,7 @@ static void adv76xx_cec_isr(struct v4l2_subdev *sd, bool *handled)
 
 static int adv76xx_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-	struct adv76xx_state *state = adap->priv;
+	struct adv76xx_state *state = cec_get_drvdata(adap);
 	struct v4l2_subdev *sd = &state->sd;
 
 	if (!state->cec_enabled_adap && enable) {
@@ -2080,7 +2080,7 @@ static int adv76xx_cec_adap_enable(struct cec_adapter *adap, bool enable)
 
 static int adv76xx_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 {
-	struct adv76xx_state *state = adap->priv;
+	struct adv76xx_state *state = cec_get_drvdata(adap);
 	struct v4l2_subdev *sd = &state->sd;
 	unsigned int i, free_idx = ADV76XX_MAX_ADDRS;
 
@@ -2135,7 +2135,7 @@ static int adv76xx_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 static int adv76xx_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 				     u32 signal_free_time, struct cec_msg *msg)
 {
-	struct adv76xx_state *state = adap->priv;
+	struct adv76xx_state *state = cec_get_drvdata(adap);
 	struct v4l2_subdev *sd = &state->sd;
 	u8 len = msg->len;
 	unsigned int i;
Signature · 1 line
1.9.1
author
#8 lore raw

PATCH 6/8 i2c: adv7842: Use cec_get_drvdata()

In reply to Jose Abreu

Use helper function to get driver private data from CEC adapter.

---
 drivers/media/i2c/adv7842.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/i2c/adv7842.c +3 -3
index 2d61f0c..303effd 100644
@@ -2250,7 +2250,7 @@ static void adv7842_cec_isr(struct v4l2_subdev *sd, bool *handled)
 
 static int adv7842_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-	struct adv7842_state *state = adap->priv;
+	struct adv7842_state *state = cec_get_drvdata(adap);
 	struct v4l2_subdev *sd = &state->sd;
 
 	if (!state->cec_enabled_adap && enable) {
@@ -2279,7 +2279,7 @@ static int adv7842_cec_adap_enable(struct cec_adapter *adap, bool enable)
 
 static int adv7842_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 {
-	struct adv7842_state *state = adap->priv;
+	struct adv7842_state *state = cec_get_drvdata(adap);
 	struct v4l2_subdev *sd = &state->sd;
 	unsigned int i, free_idx = ADV7842_MAX_ADDRS;
 
@@ -2334,7 +2334,7 @@ static int adv7842_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 static int adv7842_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 				     u32 signal_free_time, struct cec_msg *msg)
 {
-	struct adv7842_state *state = adap->priv;
+	struct adv7842_state *state = cec_get_drvdata(adap);
 	struct v4l2_subdev *sd = &state->sd;
 	u8 len = msg->len;
 	unsigned int i;
Signature · 1 line
1.9.1
author
#9 lore raw

PATCH 7/8 usb: pulse8-cec: Use cec_get_drvdata()

In reply to Jose Abreu

Use helper function to get driver private data from CEC adapter.

---
 drivers/media/usb/pulse8-cec/pulse8-cec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/usb/pulse8-cec/pulse8-cec.c +3 -3
index 7c18dae..1dfc2de 100644
@@ -461,7 +461,7 @@ static int pulse8_apply_persistent_config(struct pulse8 *pulse8,
 
 static int pulse8_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
-	struct pulse8 *pulse8 = adap->priv;
+	struct pulse8 *pulse8 = cec_get_drvdata(adap);
 	u8 cmd[16];
 	int err;
 
@@ -474,7 +474,7 @@ static int pulse8_cec_adap_enable(struct cec_adapter *adap, bool enable)
 
 static int pulse8_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
 {
-	struct pulse8 *pulse8 = adap->priv;
+	struct pulse8 *pulse8 = cec_get_drvdata(adap);
 	u16 mask = 0;
 	u16 pa = adap->phys_addr;
 	u8 cmd[16];
@@ -594,7 +594,7 @@ static int pulse8_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
 static int pulse8_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 				    u32 signal_free_time, struct cec_msg *msg)
 {
-	struct pulse8 *pulse8 = adap->priv;
+	struct pulse8 *pulse8 = cec_get_drvdata(adap);
 	u8 cmd[2];
 	unsigned int i;
 	int err;
Signature · 1 line
1.9.1
author
#10 lore raw

PATCH 8/8 platform: vivid: Use cec_get_drvdata()

In reply to Jose Abreu

Use helper function to get driver private data from CEC adapter.

---
 drivers/media/platform/vivid/vivid-cec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/vivid/vivid-cec.c +2 -2
index cb49335..653f409 100644
@@ -135,7 +135,7 @@ static int vivid_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
 static int vivid_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 				   u32 signal_free_time, struct cec_msg *msg)
 {
-	struct vivid_dev *dev = adap->priv;
+	struct vivid_dev *dev = cec_get_drvdata(adap);
 	struct vivid_cec_work *cw = kzalloc(sizeof(*cw), GFP_KERNEL);
 	long delta_jiffies = 0;
 
@@ -166,7 +166,7 @@ static int vivid_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 
 static int vivid_received(struct cec_adapter *adap, struct cec_msg *msg)
 {
-	struct vivid_dev *dev = adap->priv;
+	struct vivid_dev *dev = cec_get_drvdata(adap);
 	struct cec_msg reply;
 	u8 dest = cec_msg_destination(msg);
 	u8 disp_ctl;
Signature · 1 line
1.9.1