From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 6/7] video: imx-hdmi: fix dev_get_drvdata misuse
Date: Wed, 7 Oct 2020 11:50:57 +0200 [thread overview]
Message-ID: <20201007095058.22950-6-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20201007095058.22950-1-a.fatoum@pengutronix.de>
The driver has a couple of issues in how it handles match data:
- First use of dev_get_drvdata is superfluous as result is unused
- Second use of dev_get_drvdata stores a sizeof(const void *)
into an enum typed object
- hdmi->dev_type contains a truncated pointer to a struct
dw_hdmi_data and compares it with an enum, which will always fail
Fix these and while it, refactor the code a bit to get rid of
dw_hdmi_data, whose only other member is unused.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/video/imx-ipu-v3/imx-hdmi.c | 39 ++++++-----------------------
1 file changed, 8 insertions(+), 31 deletions(-)
diff --git a/drivers/video/imx-ipu-v3/imx-hdmi.c b/drivers/video/imx-ipu-v3/imx-hdmi.c
index 17b6e4cc257d..1e55c97d2426 100644
--- a/drivers/video/imx-ipu-v3/imx-hdmi.c
+++ b/drivers/video/imx-ipu-v3/imx-hdmi.c
@@ -1083,19 +1083,18 @@ static void dw_hdmi_enable_video_path(struct dw_hdmi *hdmi)
/* Workaround to clear the overflow condition */
static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi)
{
- int count;
+ int count = 4;
u8 val;
/* TMDS software reset */
hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, HDMI_MC_SWRSTZ);
val = hdmi_readb(hdmi, HDMI_FC_INVIDCONF);
- if (hdmi->dev_type == IMX6DL_HDMI) {
- hdmi_writeb(hdmi, val, HDMI_FC_INVIDCONF);
- return;
- }
- for (count = 0; count < 4; count++)
+ if (hdmi->dev_type == IMX6DL_HDMI)
+ count = 1;
+
+ while (count--)
hdmi_writeb(hdmi, val, HDMI_FC_INVIDCONF);
}
@@ -1193,28 +1192,13 @@ static void initialize_hdmi_ih_mutes(struct dw_hdmi *hdmi)
hdmi_writeb(hdmi, ih_mute, HDMI_IH_MUTE);
}
-struct dw_hdmi_data {
- unsigned ipu_mask;
- enum dw_hdmi_devtype devtype;
-};
-
-static struct dw_hdmi_data imx6q_hdmi_data = {
- .ipu_mask = 0xf,
- .devtype = IMX6Q_HDMI,
-};
-
-static struct dw_hdmi_data imx6dl_hdmi_data = {
- .ipu_mask = 0x3,
- .devtype = IMX6DL_HDMI,
-};
-
static struct of_device_id dw_hdmi_dt_ids[] = {
{
.compatible = "fsl,imx6q-hdmi",
- .data = &imx6q_hdmi_data,
+ .data = (void *)IMX6Q_HDMI,
}, {
.compatible = "fsl,imx6dl-hdmi",
- .data = &imx6dl_hdmi_data,
+ .data = (void *)IMX6DL_HDMI,
}, {
/* sentinel */
}
@@ -1276,11 +1260,6 @@ static int dw_hdmi_probe(struct device_d *dev)
struct device_node *np = dev->device_node;
struct dw_hdmi *hdmi;
int ret;
- const struct dw_hdmi_data *devtype;
-
- ret = dev_get_drvdata(dev, (const void **)&devtype);
- if (ret)
- return ret;
hdmi = xzalloc(sizeof(*hdmi));
@@ -1289,9 +1268,7 @@ static int dw_hdmi_probe(struct device_d *dev)
hdmi->sample_rate = 48000;
hdmi->ratio = 100;
- ret = dev_get_drvdata(dev, (const void **)&hdmi->dev_type);
- if (ret)
- return ret;
+ hdmi->dev_type = (enum dw_hdmi_devtype)device_get_match_data(dev);
hdmi->ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-10-07 9:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-07 9:50 [PATCH v2 1/7] driver: introduce less error-prone dev_get_drvdata alternative Ahmad Fatoum
2020-10-07 9:50 ` [PATCH v2 2/7] led: pca955x: fix probing from device tree Ahmad Fatoum
2020-10-07 9:50 ` [PATCH v2 3/7] dma: apbh: fix out-of-bounds write on 64-bit SoCs Ahmad Fatoum
2020-10-07 9:50 ` [PATCH v2 4/7] aiodev: lm75: " Ahmad Fatoum
2020-10-07 9:50 ` [PATCH v2 5/7] mtd: nand-mxs: " Ahmad Fatoum
2020-10-07 9:50 ` Ahmad Fatoum [this message]
2020-10-07 9:50 ` [PATCH v2 7/7] driver: migrate some from dev_get_drvdata to device_get_match_data Ahmad Fatoum
2020-10-09 6:48 ` [PATCH v2 1/7] driver: introduce less error-prone dev_get_drvdata alternative Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201007095058.22950-6-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox