Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5095350ybi; Tue, 30 Jul 2019 13:41:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwU+MxwzaiHG+WUQ9yvVsAzN/wOEQFzBjElh4uxNe79yxUprIPdlbyVYvgpPrRS+EQ+qA7/ X-Received: by 2002:a17:902:6b44:: with SMTP id g4mr116348912plt.152.1564519295247; Tue, 30 Jul 2019 13:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564519295; cv=none; d=google.com; s=arc-20160816; b=vVQRpqxjbrLtb9PzaRp+etR5lLnOSpAzKKO3EdwBKSQbpTy6qa/KHW1dVORE3wk1oy 09DVOg3AF9rCfw1uX4/QtO5x3aZPwlsJzIg5IvG/qJPDAwYT29ldugfX+dmhZvibmmCf ZOzpeF6xToQpsP9akOj0X3vdM5RhTDfaG0J07qafn5jArM61qyra1o2jA1NbHriyFdv+ Z02n2PsvCaRMp6siZxHlGuNWhthIRLFCit2+LcTIM7c6yfG5TX6oEG0yYhsmv/i6kBEF kkP0NlBa9NQyvoRJ5SK4VZUTatt8A91oExMN8k8XAihmssuxCm2+ZZBOjlciE0HzmjUv JdMA== 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:date:subject:cc:to:from; bh=WIlzH7Bq0tXeD+UkumJ/gvq8Rhepw1pc3uaXvMvbWRk=; b=OgkU+weGIhekPbilbNhy4ViC66M5qSYbNL1JrXEGn5uJqMo5riV7tmsNY/x0lq1sCp xp0img2s/gXQdbQEn8pwjFMlpkB6eNPsnwxVbUHMSvW/l6yBnKdkmI46jgiOAfzkp+jw MhHhcraP0QOWXdKsBq/BB259sqXGyQaGOcV1ieDcz8BtFsbTH3Wg7JLI5Rz8txpcb4ri vHlgR4cMxjogfyiCWhTwhBDDXSFU7LdmsSD902vD4XazxYH71G3cq6QAz9v5om6qI3fU DgscjmARJgswYrV0y6QpQaVQ2plGkpnCtpNi9xaYTstWSM1sB66fKeQ9apV+esuyiLYL dx6w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si28001287plb.345.2019.07.30.13.40.31; Tue, 30 Jul 2019 13:41:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387541AbfG3R4N (ORCPT + 99 others); Tue, 30 Jul 2019 13:56:13 -0400 Received: from sauhun.de ([88.99.104.3]:55986 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727029AbfG3R4L (ORCPT ); Tue, 30 Jul 2019 13:56:11 -0400 Received: from localhost (p54B33338.dip0.t-ipconnect.de [84.179.51.56]) by pokefinder.org (Postfix) with ESMTPSA id EC5422E408C; Tue, 30 Jul 2019 19:56:09 +0200 (CEST) From: Wolfram Sang To: linux-i2c@vger.kernel.org Cc: Sean Young , linux-media@vger.kernel.org, Wolfram Sang , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] media: ir-kbd-i2c: convert to i2c_new_dummy_device() Date: Tue, 30 Jul 2019 19:55:54 +0200 Message-Id: <20190730175555.14098-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190730175555.14098-1-wsa+renesas@sang-engineering.com> References: <20190730175555.14098-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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); -- 2.20.1