linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/5] DRM: Add support for the sii902x HDMI/DVI encoder
Date: Tue, 12 Jul 2011 15:21:07 +0200	[thread overview]
Message-ID: <20110712132107.GO6069@pengutronix.de> (raw)
In-Reply-To: <CAHXqBFJX01ZFeYMi=weK3LWhhFTkJ-_R6WPO_d2FDJ9cbBxSLQ@mail.gmail.com>

On Fri, Jul 08, 2011 at 11:01:18PM +0200, Micha?? Miros??aw wrote:
> 2011/6/7 Sascha Hauer <s.hauer@pengutronix.de>:
> [...]
> > --- /dev/null
> > +++ b/drivers/gpu/drm/i2c/sii902x.c
> > @@ -0,0 +1,334 @@
> [...]
> > +static int sii902x_write(struct i2c_client *client, uint8_t addr, uint8_t val)
> > +{
> > + ? ? ? int ret;
> > +
> > + ? ? ? ret = i2c_smbus_write_byte_data(client, addr, val);
> > + ? ? ? if (ret) {
> > + ? ? ? ? ? ? ? dev_dbg(&client->dev, "%s failed with %d\n", __func__, ret);
> > + ? ? ? }
> > + ? ? ? return ret;
> > +}
> 
> Return value is never tested.

Yes, but there is not much I can do about it. This function is called
from void functions most of the time, so I can't even forward the error.

> 
> > +static irqreturn_t sii902x_detect_handler(int irq, void *data)
> > +{
> > + ? ? ? struct sii902x_priv *priv = data;
> > + ? ? ? struct i2c_client *client = priv->client;
> > + ? ? ? int dat;
> > +
> > + ? ? ? dat = sii902x_read(client, 0x3D);
> > + ? ? ? if (dat & 0x1) {
> > + ? ? ? ? ? ? ? /* cable connection changes */
> > + ? ? ? ? ? ? ? if (dat & 0x4) {
> > + ? ? ? ? ? ? ? ? ? ? ? printk("plugin\n");
> > + ? ? ? ? ? ? ? } else {
> > + ? ? ? ? ? ? ? ? ? ? ? printk("plugout\n");
> > + ? ? ? ? ? ? ? }
> 
> Missing code?

Yes. I will either remove interrupt support or put the missing code in.

> 
> > + ? ? ? }
> > + ? ? ? sii902x_write(client, 0x3D, dat);
> > +
> > + ? ? ? return IRQ_HANDLED;
> > +}
> [...]
> > +/* I2C driver functions */
> > +
> > +static int
> > +sii902x_probe(struct i2c_client *client, const struct i2c_device_id *id)
> > +{
> > + ? ? ? int dat, ret;
> > + ? ? ? struct sii902x_priv *priv;
> > + ? ? ? const char *drm_name = "imx-drm.0"; /* FIXME: pass from pdata */
> > + ? ? ? int encon_id = 0; /* FIXME: pass from pdata */
> > +
> > + ? ? ? priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> > + ? ? ? if (!priv)
> > + ? ? ? ? ? ? ? return -ENOMEM;
> > +
> > + ? ? ? priv->client = client;
> > +
> > + ? ? ? /* Set 902x in hardware TPI mode on and jump out of D3 state */
> > + ? ? ? if (sii902x_write(client, 0xc7, 0x00) < 0) {
> > + ? ? ? ? ? ? ? dev_err(&client->dev, "SII902x: cound not find device\n");
> > + ? ? ? ? ? ? ? return -ENODEV;
> 
> Leaks priv. Same on other error paths.

Jup, thanks for noting. There are some other bugs in the probe function,
like not checking the return value of drm_encon_register().

Will fix

> 
> > + ? ? ? }
> [...]
> 
> > +
> > +
> > +static int sii902x_remove(struct i2c_client *client)
> > +{
> > + ? ? ? struct sii902x_priv *priv;
> > + ? ? ? int ret;
> > +
> > + ? ? ? priv = i2c_get_clientdata(client);
> > +
> > + ? ? ? ret = drm_encon_unregister(&priv->encon);
> > + ? ? ? if (ret)
> > + ? ? ? ? ? ? ? return ret;
> 
> Leaks priv on error.

and forgets to free_irq()

Thanks
 Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2011-07-12 13:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07 10:45 [RFC PATCH] KMS support for i.MX51/53 Sascha Hauer
2011-06-07 10:45 ` [PATCH 1/5] DRM: add i.MX IPUv3 base driver Sascha Hauer
2011-06-07 15:45   ` Fabio Estevam
2011-06-07 10:45 ` [PATCH 2/5] DRM i.MX IPU: Add support for IPU submodules Sascha Hauer
2011-06-07 10:45 ` [PATCH 3/5] DRM: Add drm encoder/connector helper Sascha Hauer
2011-06-07 10:45 ` [PATCH 4/5] DRM: Add support for the sii902x HDMI/DVI encoder Sascha Hauer
2011-07-08 20:42   ` Alex Deucher
2011-07-08 21:01   ` Michał Mirosław
2011-07-12 13:21     ` Sascha Hauer [this message]
2011-06-07 10:45 ` [PATCH 5/5] DRM: Add i.MX IPUv3 support Sascha Hauer
2011-06-07 11:17 ` [RFC PATCH] KMS support for i.MX51/53 Alan Cox
2011-06-07 19:12   ` Sascha Hauer
2011-06-07 19:59     ` Alan Cox
2011-06-08  8:54       ` 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=20110712132107.GO6069@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).