From patchwork Tue Apr 5 01:16:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Nieder X-Patchwork-Id: 685801 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p351GqlY004523 for ; Tue, 5 Apr 2011 01:16:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751723Ab1DEBQt (ORCPT ); Mon, 4 Apr 2011 21:16:49 -0400 Received: from mail-gy0-f174.google.com ([209.85.160.174]:61673 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751583Ab1DEBQs (ORCPT ); Mon, 4 Apr 2011 21:16:48 -0400 Received: by gyd10 with SMTP id 10so2391842gyd.19 for ; Mon, 04 Apr 2011 18:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=VV2Tgpuw4A24DY0CeVwIXWiXkEcjQZJJKmg1VsHtfXI=; b=OiYgHaiIk7lKMg1T/LnhkTmK4KmYKSulL8dPwM4rBBX47LRqfYxHAzvHfzMDlarJgy Zgd9b65qwy1sgI+3GcR8ntC/OP5OOPqXhqlTIZbrSpu61X7DInGCcZrTvPUSa9NCuQOF XJSIjhvqKX2veJ5dORXJzD9hdnFLUr6tjLhio= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=aUQAbxbL3Fhd6rOGXxUWOpEOgmcJtLwFVXynbygqUVq8CEH7ZnImHDsejCL0vTtLJq 2PniBN56ii1P1LapzpqPmjPh3bi8yqHimy1jNRvVAWq7PHrxXnuswqfo2V8s7fZGKHRf Zr0t+ooIgkG1QdQSVJu3Apyuse0mKfF4W5Uio= Received: by 10.236.28.9 with SMTP id f9mr3880508yha.18.1301966207266; Mon, 04 Apr 2011 18:16:47 -0700 (PDT) Received: from elie (adsl-69-209-53-77.dsl.chcgil.ameritech.net [69.209.53.77]) by mx.google.com with ESMTPS id l6sm2610247yhn.34.2011.04.04.18.16.44 (version=SSLv3 cipher=OTHER); Mon, 04 Apr 2011 18:16:45 -0700 (PDT) Date: Mon, 4 Apr 2011 20:16:40 -0500 From: Jonathan Nieder To: Andreas Huber Cc: linux-media@vger.kernel.org, Huber Andreas , Mauro Carvalho Chehab , Hans Verkuil , linux-kernel@vger.kernel.org, andrew.walker27@ntlworld.com, Ben Hutchings , Trent Piepho , Roland Stoll Subject: Re: [PATCH 3/3] [media] cx88: use a mutex to protect cx8802_devlist Message-ID: <20110405011640.GB1830@elie> References: <20110327150610.4029.95961.reportbug@xen.corax.at> <20110327152810.GA32106@elie> <20110402093856.GA17015@elie> <20110402094451.GD17015@elie> <4D971B8D.4040305@corax.at> <20110402192902.GD20064@elie> <4D978378.7060106@gmx.at> <4D992920.4040400@gmx.at> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4D992920.4040400@gmx.at> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 05 Apr 2011 01:17:04 +0000 (UTC) Hi again, Andreas Huber wrote: > [...] > /* Make sure we can acquire the hardware */ > drv = cx8802_get_driver(dev, CX88_MPEG_BLACKBIRD); // HOW TO DEAL WITH NULL ?????? > if (drv) { Reasonable question. Could you try this patch? -- 8< -- Subject: [media] cx88: lock device during driver initialization Reported-by: Andreas Huber Signed-off-by: Jonathan Nieder --- drivers/media/video/cx88/cx88-blackbird.c | 2 -- drivers/media/video/cx88/cx88-mpeg.c | 5 ++--- drivers/media/video/cx88/cx88.h | 7 ++----- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index a6f7d53..f637d34 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c @@ -1335,11 +1335,9 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) blackbird_register_video(dev); /* initial device configuration: needed ? */ - mutex_lock(&dev->core->lock); // init_controls(core); cx88_set_tvnorm(core,core->tvnorm); cx88_video_mux(core,0); - mutex_unlock(&dev->core->lock); return 0; diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index 6b58647..b18f9fe 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c @@ -714,18 +714,17 @@ int cx8802_register_driver(struct cx8802_driver *drv) drv->request_release = cx8802_request_release; memcpy(driver, drv, sizeof(*driver)); + mutex_lock(&drv->core->lock); err = drv->probe(driver); if (err == 0) { i++; - mutex_lock(&drv->core->lock); list_add_tail(&driver->drvlist, &dev->drvlist); - mutex_unlock(&drv->core->lock); } else { printk(KERN_ERR "%s/2: cx8802 probe failed, err = %d\n", dev->core->name, err); } - + mutex_unlock(&drv->core->lock); } err = i ? 0 : -ENODEV; diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 9731daa..3d32f4a 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h @@ -505,13 +505,10 @@ struct cx8802_driver { int (*suspend)(struct pci_dev *pci_dev, pm_message_t state); int (*resume)(struct pci_dev *pci_dev); + /* Callers to the following functions must hold core->lock */ + /* MPEG 8802 -> mini driver - Driver probe and configuration */ - - /* Caller must _not_ hold core->lock */ int (*probe)(struct cx8802_driver *drv); - - /* Callers to the following functions must hold core->lock */ - int (*remove)(struct cx8802_driver *drv); /* MPEG 8802 -> mini driver - Access for hardware control */