From patchwork Wed Nov 23 09:19:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 24814 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2680845wrr; Wed, 23 Nov 2022 01:21:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf7KOphSIDNa1tTfOBeAMz5X2RIe3U0mmICCGiHvG7QGrK6cOPzhKspvcnKUbxeyTjXp+zFy X-Received: by 2002:a17:902:f651:b0:188:50c2:89fb with SMTP id m17-20020a170902f65100b0018850c289fbmr9046953plg.130.1669195261869; Wed, 23 Nov 2022 01:21:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669195261; cv=none; d=google.com; s=arc-20160816; b=D9lXH7EJQjpaf3Ji+CMnnN9caejN4PQ6iQdCOx7DV4GLbTQvZQNLqbajmTVTgnzwyp KzsD6Q1KUH1DBqx9qik6TxTUxYxvzVtWNQiWx1Pxqf8lB9d0bUBlRnF18qXpnkXqZBZU fgb5j0okIYdMzIn3ezRckmzez24UnnmlcQPD2VSLyMMCuJ8PRsLSnCmLva7Mxo8t6Vzx 6SSY8zBghBYWivGhJtWvcKp2tZJImFcsg+7qRUmJ1KiM3qBh4cF8DmE1q4tEypZO8xlg QUJclJgYaDDpi3jExoS4UZAD7ZBfdK8sKMhgI/ShgGIhGaVQyRK8dho4EUb+Xi+V7wu4 ii5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=0/uGIrK5/QpagY3HfNVJOY+gWJKGB/HD78CMIt9WOjU=; b=u/eiq/mL+4gV3k7bFw6y73z/EU7xMnZkKjZQbGVT+KeDAeKROmgeSKbAC/5h86ztYk BOY8zT2m1RdQRHJPmwcMAy1y6nwH6kiD9N80jgi1jNL8a52IWUEcgXYTuftZ2mzJ09BM A8DOj3zHDvkAY6Nfu76rd9FqVbeVNU646CNE3/ib7y8S4Xl95V8lBF8OPYLkj2ELDiEv gD6jKo5r1ed5IXZaV+DI1jpUo1hM9nmy1jDwzli5l4PKtlopyu0T9SAcOGZkB5eXwl+9 YDWsC+ucftyRftTVvdfT167w9WbdRDU6P68V4JPRcYpKCvCU8vuSmJb5dMbutgZoCBEp /pug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="KC/uAbtf"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d7-20020a056a0024c700b0056d568dc25fsi2506934pfv.33.2022.11.23.01.20.49; Wed, 23 Nov 2022 01:21:01 -0800 (PST) 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=@gmail.com header.s=20210112 header.b="KC/uAbtf"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237470AbiKWJUX (ORCPT + 99 others); Wed, 23 Nov 2022 04:20:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237405AbiKWJUN (ORCPT ); Wed, 23 Nov 2022 04:20:13 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D66A52189F for ; Wed, 23 Nov 2022 01:20:08 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id bp15so27239337lfb.13 for ; Wed, 23 Nov 2022 01:20:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=0/uGIrK5/QpagY3HfNVJOY+gWJKGB/HD78CMIt9WOjU=; b=KC/uAbtf/fpzdr8ScJNAcu/GE5frX/DdXyCvUQIscDw5gJP8G2QOgt54qmPjjAGPOk UKJ5um2ExWJWPFtLH+P3I16ylTheDritPYFQYauSKtJyxZvI9QKZR/6eUExCIqyZBoZA yHsJqo7QSdwTFjhmnErKDXzvfwXZATR8JqOz1wioWU0n6bcDuCcQq5hQbID2ZVYowatV 1WRYgc76BIKrn/9kuRjGUIvd1VENoLXRD1psfZwCgS+1tSQL8qNsuXhg0EDOvOswnHM8 AqaESGgqr6bQHSrRib9itEfpgyUKQGdU6baXbengOVgLm+Tm8PjxzKETzJItsDg7GVXk /B5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0/uGIrK5/QpagY3HfNVJOY+gWJKGB/HD78CMIt9WOjU=; b=uh+JzL//66XzmzTL6DPxsRDjuiCa7YBKlNtC9x7/czdgp7TqQN483dt1veK6qm/5k+ FQxUY6WB4Zmx18++7NhtrHxOz0+mMowEQTx06WzLoIv79Fe3H/VF2MnaNXYADz4kMfMc cMWNKGsKt//7bOoYim2jSk7OaKqdOMxqV6fXQ3Vp/hHSTZQTew/PR4027vEb1pT9y+vs c/2DV3jZYFyNY0asLafPCX8OslfyMw/tx0I1/TRimN5H5CiRJFD/1p4xYJNbt839Uyjd N4VSOPvBTqHy36zr0BIwnJzJklARZywhNeH/ZqO7kAdaQ6SlKPaSyvBwU86mvHOOGxs8 6wsw== X-Gm-Message-State: ANoB5pl8Gaf+WFHAssRvkcDcSeQ5zhIu5hKC3PhfxhxOxaBJQnP8Skqx uleAeK7b9KS6eIKDkYe78niR/xEoxrg= X-Received: by 2002:ac2:58d9:0:b0:4b3:ccea:9b2e with SMTP id u25-20020ac258d9000000b004b3ccea9b2emr10242849lfo.379.1669195206971; Wed, 23 Nov 2022 01:20:06 -0800 (PST) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id m19-20020a195213000000b004a46f92a15bsm2850935lfb.41.2022.11.23.01.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 01:20:06 -0800 (PST) Date: Wed, 23 Nov 2022 11:19:49 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Matti Vaittinen , Lee Jones , linux-kernel@vger.kernel.org Subject: [PATCH] mfd: rohm-bd*: Use dev_err_probe() Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1750278090493710587?= X-GMAIL-MSGID: =?utf-8?q?1750278090493710587?= The dev_err_probe() has (at least) following benefits over dev_err() when printing an error print for a failed function call at a device driver probe: - Omit error level print if error is 'EPRBE_DEFER' - Standardized print format for returned error - return the error value allowing shortening calls like: if (ret) { dev_err(...); return ret; } to if (ret) return dev_err_probe(...); Convert the ROHM BD71828, ROHM BD718x7 and ROHM BD9576 core drivers to use the dev_err_probe() when returned error is not hard-coded constant. Signed-off-by: Matti Vaittinen --- drivers/mfd/rohm-bd71828.c | 23 ++++++++++------------- drivers/mfd/rohm-bd718x7.c | 21 ++++++++------------- drivers/mfd/rohm-bd9576.c | 17 ++++++++--------- 3 files changed, 26 insertions(+), 35 deletions(-) base-commit: 094226ad94f471a9f19e8f8e7140a09c2625abaa diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c index 714d9fcbf07b..ae5430500599 100644 --- a/drivers/mfd/rohm-bd71828.c +++ b/drivers/mfd/rohm-bd71828.c @@ -515,27 +515,24 @@ static int bd71828_i2c_probe(struct i2c_client *i2c) } regmap = devm_regmap_init_i2c(i2c, regmap_config); - if (IS_ERR(regmap)) { - dev_err(&i2c->dev, "Failed to initialize Regmap\n"); - return PTR_ERR(regmap); - } + if (IS_ERR(regmap)) + return dev_err_probe(&i2c->dev, PTR_ERR(regmap), + "Failed to initialize Regmap\n"); ret = devm_regmap_add_irq_chip(&i2c->dev, regmap, i2c->irq, IRQF_ONESHOT, 0, irqchip, &irq_data); - if (ret) { - dev_err(&i2c->dev, "Failed to add IRQ chip\n"); - return ret; - } + if (ret) + return dev_err_probe(&i2c->dev, ret, + "Failed to add IRQ chip\n"); dev_dbg(&i2c->dev, "Registered %d IRQs for chip\n", irqchip->num_irqs); if (button_irq) { ret = regmap_irq_get_virq(irq_data, button_irq); - if (ret < 0) { - dev_err(&i2c->dev, "Failed to get the power-key IRQ\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(&i2c->dev, ret, + "Failed to get the power-key IRQ\n"); button.irq = ret; } @@ -547,7 +544,7 @@ static int bd71828_i2c_probe(struct i2c_client *i2c) ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, mfd, cells, NULL, 0, regmap_irq_get_domain(irq_data)); if (ret) - dev_err(&i2c->dev, "Failed to create subdevices\n"); + dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n"); return ret; } diff --git a/drivers/mfd/rohm-bd718x7.c b/drivers/mfd/rohm-bd718x7.c index bfd81f78beae..1c0f6419ee4f 100644 --- a/drivers/mfd/rohm-bd718x7.c +++ b/drivers/mfd/rohm-bd718x7.c @@ -158,18 +158,15 @@ static int bd718xx_i2c_probe(struct i2c_client *i2c, } regmap = devm_regmap_init_i2c(i2c, &bd718xx_regmap_config); - if (IS_ERR(regmap)) { - dev_err(&i2c->dev, "regmap initialization failed\n"); - return PTR_ERR(regmap); - } + if (IS_ERR(regmap)) + return dev_err_probe(&i2c->dev, PTR_ERR(regmap), + "regmap initialization failed\n"); ret = devm_regmap_add_irq_chip(&i2c->dev, regmap, i2c->irq, IRQF_ONESHOT, 0, &bd718xx_irq_chip, &irq_data); - if (ret) { - dev_err(&i2c->dev, "Failed to add irq_chip\n"); - return ret; - } + if (ret) + return dev_err_probe(&i2c->dev, ret, "Failed to add irq_chip\n"); ret = bd718xx_init_press_duration(regmap, &i2c->dev); if (ret) @@ -177,10 +174,8 @@ static int bd718xx_i2c_probe(struct i2c_client *i2c, ret = regmap_irq_get_virq(irq_data, BD718XX_INT_PWRBTN_S); - if (ret < 0) { - dev_err(&i2c->dev, "Failed to get the IRQ\n"); - return ret; - } + if (ret < 0) + return dev_err_probe(&i2c->dev, ret, "Failed to get the IRQ\n"); button.irq = ret; @@ -188,7 +183,7 @@ static int bd718xx_i2c_probe(struct i2c_client *i2c, mfd, cells, NULL, 0, regmap_irq_get_domain(irq_data)); if (ret) - dev_err(&i2c->dev, "Failed to create subdevices\n"); + dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n"); return ret; } diff --git a/drivers/mfd/rohm-bd9576.c b/drivers/mfd/rohm-bd9576.c index f37cd4f27aeb..c421867af6c9 100644 --- a/drivers/mfd/rohm-bd9576.c +++ b/drivers/mfd/rohm-bd9576.c @@ -122,10 +122,9 @@ static int bd957x_i2c_probe(struct i2c_client *i2c, } regmap = devm_regmap_init_i2c(i2c, &bd957x_regmap); - if (IS_ERR(regmap)) { - dev_err(&i2c->dev, "Failed to initialize Regmap\n"); - return PTR_ERR(regmap); - } + if (IS_ERR(regmap)) + return dev_err_probe(&i2c->dev, PTR_ERR(regmap), + "Failed to initialize Regmap\n"); /* * BD9576 behaves badly. It kepts IRQ line asserted for the whole @@ -146,10 +145,10 @@ static int bd957x_i2c_probe(struct i2c_client *i2c, ret = devm_regmap_add_irq_chip(&i2c->dev, regmap, i2c->irq, IRQF_ONESHOT, 0, &bd9576_irq_chip, &irq_data); - if (ret) { - dev_err(&i2c->dev, "Failed to add IRQ chip\n"); - return ret; - } + if (ret) + return dev_err_probe(&i2c->dev, ret, + "Failed to add IRQ chip\n"); + domain = regmap_irq_get_domain(irq_data); } else { ret = regmap_update_bits(regmap, BD957X_REG_INT_MAIN_MASK, @@ -163,7 +162,7 @@ static int bd957x_i2c_probe(struct i2c_client *i2c, ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, cells, num_cells, NULL, 0, domain); if (ret) - dev_err(&i2c->dev, "Failed to create subdevices\n"); + dev_err_probe(&i2c->dev, ret, "Failed to create subdevices\n"); return ret; }