Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1219249ybh; Sat, 3 Aug 2019 20:55:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqynC8znDepBlHf8EjWGf0j0HFR4VvoFk+dLdc63xaPB3PsyZIwmOO3xYaK9BUupvFfm4D9I X-Received: by 2002:a63:2a08:: with SMTP id q8mr98654813pgq.415.1564890919285; Sat, 03 Aug 2019 20:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564890919; cv=none; d=google.com; s=arc-20160816; b=Z4Eae03t/ICq1o1/PTAQzILabOvL3PmIW2CZtduZIeVrwIGL1cKClUyRjP0YjQcHNp vxm+le+RyxPT1sW0pE/2mzAD1kfiwb2+g+jtFKS2KxzhecC4y1yKF0O9Fx95/naTPlql 1XvPrWqFYo8bj3f5d/MR3p3KxpoiF2bjs+mJJjKg/wnWCTE/eTcteqaHzNd2AexQgnMc rmDdEKm4dDXHqouShapeVf/LGcvAyzDpJcelE9GKfghJfX10duA6d3gNX8nKRP8M2uuR 5FDUJ36wsAA6dYuPsyFeq4kL7ewLa+p6Zix2tqSxx/2HYHYoUtV30lOO5QrtP1B4Ma0G yAEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Gu8G8y6Ne0ryjTmF9kVNzse2VVG5LtflJsXjD47kfSE=; b=tiTWrD+4qtnteQpnf2DaZI9miLXYOCxVTmZpXa65domfzJJ6cfXy2+HwPa52NsPixJ WLuObR9thk7z2GgoQiNgDYr1L3mQlStNZHuWMlB6wGhmgMlp0fOvpBOrRXNhoQUnS0/E KkbJfRbL/HCnfx+mrhYDyaDK24AmubgPVYVaMa5z90nbeBY1oGGmo1FlKYolovD36kNb kCk+iHswM7YROyjJ3GhKhtiWxKTwX3u5NvGsfF/b9ElEBPh/STp4KfuUEagQiWhPZQeG pGmfdhDKexlAI63Wvflmfu9oTJrykORY7jXHhNlBkc8q0EifpRifM2zcXIa5QmfzJDA4 Y0Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=jXX1dtoy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si43153071pgk.456.2019.08.03.20.55.04; Sat, 03 Aug 2019 20:55:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=jXX1dtoy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388185AbfHCQR4 (ORCPT + 99 others); Sat, 3 Aug 2019 12:17:56 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:33660 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387958AbfHCQRz (ORCPT ); Sat, 3 Aug 2019 12:17:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Gu8G8y6Ne0ryjTmF9kVNzse2VVG5LtflJsXjD47kfSE=; b=jXX1dtoyVtUHxbYohmvnyEjxf M5gRSf7KQbRDdCt1G2xrGgvnfzeGaUODS73jlHhuEQ+xeIu8nGV7fxTj1zAvjWc2/saKM+EV/msqc 5ME2bZ5WJnFe4pPUZZyNyDBiP+IPqwVCzKSYPP+swO6xyt5g5FeinAejTBl32oLx1JiCHxNExUHfh 0Piel9GlHhmG0h2esCM7M25c6G1dThsWOeXoFwEbWCfyiRJ8chZuKcHuDGJKWlp/iS4iTmnUzsi1Z 8HSDL0HfhUewmzZkdy7O+9OOghZDpuzoDN95i2wZYCgGDMLk8NYLlZvwEfK8VriDMWMgm25VIqXfk Y7vqHlUjw==; Received: from [191.33.150.100] (helo=coco.lan) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1htwjB-0007VE-PE; Sat, 03 Aug 2019 16:17:54 +0000 Date: Sat, 3 Aug 2019 13:17:49 -0300 From: Mauro Carvalho Chehab To: Wolfram Sang Cc: linux-i2c@vger.kernel.org, Sean Young , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] media: ir-kbd-i2c: convert to i2c_new_dummy_device() Message-ID: <20190803131749.4d6517ab@coco.lan> In-Reply-To: <20190730175555.14098-2-wsa+renesas@sang-engineering.com> References: <20190730175555.14098-1-wsa+renesas@sang-engineering.com> <20190730175555.14098-2-wsa+renesas@sang-engineering.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, 30 Jul 2019 19:55:54 +0200 Wolfram Sang escreveu: > Convert this driver to use the new i2c_new_dummy_device() call and bail > out if the dummy device cannot be registered to make failure more > visible to the user. > Please don't do that. At first glance, devm_* sounds a good idea, but we had enough issues using it on media system. I don't mind mind much if some SoC specific would use it, but doing it on generic drivers is a very bad idea. We have removed almost all devm_* calls from the media system. The problem with devm is that it the de-allocation routines aren't called during device unbind. They happen a way later, only when the device itself is physically removed, or the driver is removed. That caused lots of headaches to debug memory lifetime issues on media. > Signed-off-by: Wolfram Sang > --- > > Change since v1: > > * reworded commit message because there was no NULL ptr access > > drivers/media/i2c/ir-kbd-i2c.c | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-) > > diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c > index 876d7587a1da..f46717052efc 100644 > --- a/drivers/media/i2c/ir-kbd-i2c.c > +++ b/drivers/media/i2c/ir-kbd-i2c.c > @@ -885,9 +885,12 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) > INIT_DELAYED_WORK(&ir->work, ir_work); > > if (probe_tx) { > - ir->tx_c = i2c_new_dummy(client->adapter, 0x70); > - if (!ir->tx_c) { > + ir->tx_c = devm_i2c_new_dummy_device(&client->dev, > + client->adapter, 0x70); > + if (IS_ERR(ir->tx_c)) { > dev_err(&client->dev, "failed to setup tx i2c address"); > + err = PTR_ERR(ir->tx_c); > + goto err_out_free; > } else if (!zilog_init(ir)) { > ir->carrier = 38000; > ir->duty_cycle = 40; > @@ -904,9 +907,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) > return 0; > > err_out_free: > - if (ir->tx_c) > - i2c_unregister_device(ir->tx_c); > - > /* Only frees rc if it were allocated internally */ > rc_free_device(rc); > return err; > @@ -919,9 +919,6 @@ static int ir_remove(struct i2c_client *client) > /* kill outstanding polls */ > cancel_delayed_work_sync(&ir->work); > > - if (ir->tx_c) > - i2c_unregister_device(ir->tx_c); > - > /* unregister device */ > rc_unregister_device(ir->rc); > Thanks, Mauro