From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sascha Hauer Subject: Re: [PATCH 4/5] DRM: Add support for the sii902x HDMI/DVI encoder Date: Tue, 12 Jul 2011 15:21:07 +0200 Message-ID: <20110712132107.GO6069@pengutronix.de> References: <1307443550-25549-1-git-send-email-s.hauer@pengutronix.de> <1307443550-25549-5-git-send-email-s.hauer@pengutronix.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1946009364==" Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: =?utf-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= Cc: Jason Chen , Konstantinos Margaritis , DRI mailing list , Eric Miao , linux-arm-kernel@lists.infradead.org List-Id: dri-devel@lists.freedesktop.org --===============1946009364== Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Fri, Jul 08, 2011 at 11:01:18PM +0200, MichaÅ‚ MirosÅ‚aw wrote: > 2011/6/7 Sascha Hauer : > [...] > > --- /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 | --===============1946009364== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============1946009364==--