From patchwork Thu Oct 20 20:42:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 6390 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp315918wrr; Thu, 20 Oct 2022 13:48:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6HiaYYGwWz7ry/iqAgpkJKDud0ykwopUjSmHkA1JIDMuvLjq3Zo2Bl2g9OaRLY9toqzITy X-Received: by 2002:a05:6402:4444:b0:458:f355:ce04 with SMTP id o4-20020a056402444400b00458f355ce04mr14090520edb.422.1666298888821; Thu, 20 Oct 2022 13:48:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666298888; cv=none; d=google.com; s=arc-20160816; b=yVTodrvV/DY73RANHxgTjUy/ZzjSelh4Vu0uQ4S+s+q/W3QuPbkXlhHVFgz9u9f14l haoW+QeiL9mOgG3K5J22JfcmMSsjvR3KV07V+2rC9yh0zc8bn3702epdTZLkouxSKupa AA7QXqlE66AywjI1qVZZyIZk8zaGosLKNKShrb3aX/zp+8wgECz92HF2rtLb7lc0ghoI M7peLTE23Rqo3P6s6ud4W3C6gXhWU7Nm/TFus6YdLxznROQfMXOjKSAzHCgCGl+OcpE7 ylXUVBTvZ3HOXAL6KUG2R2QaXY89lXR7310cKLG8lMKtCcRwBvBTggyYHqFOrt3ulIJk UwzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KjNsD9ApdVm77p2puLT+MDSmjh5XUsqleYLmRgmghlY=; b=Wkxv5n2tB3u8kIZ7vRAUOr2uVFcXpwnPldVFOdLOAfeCtC89nDzrEXhRLeRBQYiujB UFwBQcAT9WR/zS4Yoj+wVQrmLGSB63HRlYgqZkba5IzBm7hhd48gVKH57FMOCGgEWAWH w8ew4seoevxeEOJHzVSlWgX1U/eXThaHt5TE+Ao9hrUyurVRBI7Tlh51EM6sYUY/L70h MW2dAW9qreSQ29kw70bpfCYkHH/w2VACa54yWC+rYK+MM//SwloC+x4GObc8ZneDGOfy b4umNTWAtnznEjGOmRtiGg0P9I6qcTJLi3EM+Zqxa0PYVlSkvvEX+eq0LawlUCsla8c8 RBYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="n/OTYWRt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a170906560c00b00781cc939dd4si13835775ejq.669.2022.10.20.13.47.44; Thu, 20 Oct 2022 13:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="n/OTYWRt"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229866AbiJTUoK (ORCPT + 99 others); Thu, 20 Oct 2022 16:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229747AbiJTUnO (ORCPT ); Thu, 20 Oct 2022 16:43:14 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D7B220C991; Thu, 20 Oct 2022 13:43:12 -0700 (PDT) Received: from jupiter.universe (dyndsl-091-096-059-009.ewe-ip-backbone.de [91.96.59.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id 76C676602543; Thu, 20 Oct 2022 21:42:57 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1666298577; bh=C4rSlAjjk6FnyUjlV+Ulcq/vHVHixGWvQH5PlFR+XVY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n/OTYWRtkPo8jULj0SiGB8tTBE851CvThHmdtxEUBU93lXaY5Q4bznVE0glJl25ga Biw/Sf3MtpBF1s/xQsjx3JPLxKH4RW4cYkLSzXGmqP1v1DDBqlPanXAFu68mwPu8ef lsLuRWrlIv1RGLAlUaFfYE5n/+MzrtH07jeevRLGgox0pprt+Ak+XIf4ZnomoR/lE5 NoyNUIhVBdJb/UJzMT8P6LhvT1MClOcEiw1Up8WDpRkwURyutjjADFiFtfsIHp5LBN j0mxmtRFygLPBDQQyzxmeEZK859lAXvy1QoLAmG6msV0GUcL1YBEsQYaffq0NQ+JNg 1+YxmHT65sS6g== Received: by jupiter.universe (Postfix, from userid 1000) id 591E448089A; Thu, 20 Oct 2022 22:42:52 +0200 (CEST) From: Sebastian Reichel To: Heiko Stuebner , Rob Herring , Krzysztof Kozlowski , Lee Jones Cc: Michael Turquette , Stephen Boyd , Linus Walleij , Mark Brown , Liam Girdwood , Alexandre Belloni , Alessandro Zummo , linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , kernel@collabora.com Subject: [PATCHv4 05/13] mfd: rk808: use dev_err_probe Date: Thu, 20 Oct 2022 22:42:43 +0200 Message-Id: <20221020204251.108565-6-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221020204251.108565-1-sebastian.reichel@collabora.com> References: <20221020204251.108565-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747241023932915852?= X-GMAIL-MSGID: =?utf-8?q?1747241023932915852?= Use dev_err_probe instead of dev_err in probe function, which simplifies code a little bit and prints the error code. Also drop possibly incorrect printing of chip id registers while touching the error message. Acked-for-MFD-by: Lee Jones Signed-off-by: Sebastian Reichel --- drivers/mfd/rk808.c | 48 +++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c index e2e7a2c85019..5e0e5f320525 100644 --- a/drivers/mfd/rk808.c +++ b/drivers/mfd/rk808.c @@ -664,18 +664,12 @@ static int rk808_probe(struct i2c_client *client, /* Read chip variant */ msb = i2c_smbus_read_byte_data(client, pmic_id_msb); - if (msb < 0) { - dev_err(&client->dev, "failed to read the chip id at 0x%x\n", - RK808_ID_MSB); - return msb; - } + if (msb < 0) + return dev_err_probe(&client->dev, msb, "failed to read the chip id MSB\n"); lsb = i2c_smbus_read_byte_data(client, pmic_id_lsb); - if (lsb < 0) { - dev_err(&client->dev, "failed to read the chip id at 0x%x\n", - RK808_ID_LSB); - return lsb; - } + if (lsb < 0) + return dev_err_probe(&client->dev, lsb, "failed to read the chip id LSB\n"); rk808->variant = ((msb << 8) | lsb) & RK8XX_ID_MSK; dev_info(&client->dev, "chip id: 0x%x\n", (unsigned int)rk808->variant); @@ -724,44 +718,34 @@ static int rk808_probe(struct i2c_client *client, i2c_set_clientdata(client, rk808); rk808->regmap = devm_regmap_init_i2c(client, rk808->regmap_cfg); - if (IS_ERR(rk808->regmap)) { - dev_err(&client->dev, "regmap initialization failed\n"); - return PTR_ERR(rk808->regmap); - } + if (IS_ERR(rk808->regmap)) + return dev_err_probe(&client->dev, PTR_ERR(rk808->regmap), + "regmap initialization failed\n"); - if (!client->irq) { - dev_err(&client->dev, "No interrupt support, no core IRQ\n"); - return -EINVAL; - } + if (!client->irq) + return dev_err_probe(&client->dev, -EINVAL, "No interrupt support, no core IRQ\n"); ret = devm_regmap_add_irq_chip(&client->dev, rk808->regmap, client->irq, IRQF_ONESHOT, -1, rk808->regmap_irq_chip, &rk808->irq_data); - if (ret) { - dev_err(&client->dev, "Failed to add irq_chip %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, "Failed to add irq_chip\n"); for (i = 0; i < nr_pre_init_regs; i++) { ret = regmap_update_bits(rk808->regmap, pre_init_reg[i].addr, pre_init_reg[i].mask, pre_init_reg[i].value); - if (ret) { - dev_err(&client->dev, - "0x%x write err\n", - pre_init_reg[i].addr); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, "0x%x write err\n", + pre_init_reg[i].addr); } ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE, cells, nr_cells, NULL, 0, regmap_irq_get_domain(rk808->irq_data)); - if (ret) { - dev_err(&client->dev, "failed to add MFD devices %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&client->dev, ret, "failed to add MFD devices\n"); if (of_property_read_bool(np, "rockchip,system-power-controller")) { ret = devm_register_sys_off_handler(&client->dev,