Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4313543pxb; Thu, 14 Oct 2021 02:48:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwps59+QqONCFDQ6zPqIiZEl/f36UBMxVkTV+kyShzfC0PlAyVMNddP3ViNK/6W3NBSvonG X-Received: by 2002:a17:90a:6583:: with SMTP id k3mr19534732pjj.147.1634204928209; Thu, 14 Oct 2021 02:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634204928; cv=none; d=google.com; s=arc-20160816; b=e9JlJEJvp1GN+593w1/zAcP49qFVNr2K9/d2kDjrTiyaVPOYDcJIjeIC8UvAGrHZUP s+apqLKKyvEaYJePG45v8/2lUUl08CnRdAO4XXWDvbd6CZsN0bJbhWjRR8dhpkmohXpT ZHHruE4XrshdenzDg+2yGl8rWmHF2Ie76bQlD1z2KrG/pkj6gTLM7IDJdxyKNMHNAeRA zKT8w8p3aLnJLHisqH4boaRBWjS2lwXioWcdKxOTcXNmPirlvvlSinZM+3lDjtMLAwOD aKwAwBieHfyyw5uDyChkv6pO+xf7e3aC5cit/O1snpWffYGk1n8eRXYbfLtHXOVgfBTA sqCA== 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 :message-id:date:subject:cc:to:from; bh=6LvAiZdynFw4hNp3XRBhRiHha5EbJYo0ToYNz40JOaA=; b=uRJm+Oow2H2rnwj8ZGdaT8PjGLRDdzmOltpv9FWe3Jxw/XySNQQbHu6Hj9MfhtxbM1 IB6ApODi2xjoBYjAEKHNAg5T9/ymDFzsezGvxPV+MB4Jqis3PPOjE9INsyIoP0MCoR02 Ik4dyPx9NuecsXqCkwxFKsITqEf3PdaAbvInrd9TdVxZPN0/A5s+J3blwfKlD7v6MgD3 3vlXOjulh9QJo6jjeNnHZU7Oe2inRsq7iaASoxqAHQtGWK5mlIyMPSCZQrFMcwlYTRyp 72fLNwkw5viRRw5hjkhd3s0z10KjDASSMBBDyf3unS703lt2GjeTSxbMwxZO1wAdKxLI 71dg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h33si2629470pjd.123.2021.10.14.02.48.34; Thu, 14 Oct 2021 02:48:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=puri.sm Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230106AbhJNJsp (ORCPT + 99 others); Thu, 14 Oct 2021 05:48:45 -0400 Received: from comms.puri.sm ([159.203.221.185]:42902 "EHLO comms.puri.sm" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229988AbhJNJso (ORCPT ); Thu, 14 Oct 2021 05:48:44 -0400 Received: from localhost (localhost [127.0.0.1]) by comms.puri.sm (Postfix) with ESMTP id EACDDE11E8; Thu, 14 Oct 2021 02:46:09 -0700 (PDT) Received: from comms.puri.sm ([127.0.0.1]) by localhost (comms.puri.sm [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6EcBzhtxUJVG; Thu, 14 Oct 2021 02:46:09 -0700 (PDT) From: Martin Kepplinger To: sre@kernel.org, linux-pm@vger.kernel.org Cc: kernel@puri.sm, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH] power: bq25890: add return values to error messages Date: Thu, 14 Oct 2021 11:45:33 +0200 Message-Id: <20211014094533.4169157-1-martin.kepplinger@puri.sm> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add more details to the error messages that indicate what went wrong and use dev_err_probe() at a few places in the probe() path in order to avoid error messages for deferred probe after which the driver probes correctly. Signed-off-by: Martin Kepplinger --- drivers/power/supply/bq25890_charger.c | 34 ++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 0e23d2db0fc4..ec81653e58c0 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -979,13 +979,13 @@ static int bq25890_get_chip_version(struct bq25890_device *bq) id = bq25890_field_read(bq, F_PN); if (id < 0) { - dev_err(bq->dev, "Cannot read chip ID.\n"); + dev_err(bq->dev, "Cannot read chip ID: %d\n", id); return id; } rev = bq25890_field_read(bq, F_DEV_REV); if (rev < 0) { - dev_err(bq->dev, "Cannot read chip revision.\n"); + dev_err(bq->dev, "Cannot read chip revision: %d\n", rev); return rev; } @@ -1028,10 +1028,9 @@ static int bq25890_irq_probe(struct bq25890_device *bq) struct gpio_desc *irq; irq = devm_gpiod_get(bq->dev, BQ25890_IRQ_PIN, GPIOD_IN); - if (IS_ERR(irq)) { - dev_err(bq->dev, "Could not probe irq pin.\n"); - return PTR_ERR(irq); - } + if (IS_ERR(irq)) + return dev_err_probe(bq->dev, PTR_ERR(irq), + "Could not probe irq pin.\n"); return gpiod_to_irq(irq); } @@ -1153,34 +1152,33 @@ static int bq25890_probe(struct i2c_client *client, mutex_init(&bq->lock); bq->rmap = devm_regmap_init_i2c(client, &bq25890_regmap_config); - if (IS_ERR(bq->rmap)) { - dev_err(dev, "failed to allocate register map\n"); - return PTR_ERR(bq->rmap); - } + if (IS_ERR(bq->rmap)) + return dev_err_probe(dev, PTR_ERR(bq->rmap), + "failed to allocate register map\n"); for (i = 0; i < ARRAY_SIZE(bq25890_reg_fields); i++) { const struct reg_field *reg_fields = bq25890_reg_fields; bq->rmap_fields[i] = devm_regmap_field_alloc(dev, bq->rmap, reg_fields[i]); - if (IS_ERR(bq->rmap_fields[i])) { - dev_err(dev, "cannot allocate regmap field\n"); - return PTR_ERR(bq->rmap_fields[i]); - } + if (IS_ERR(bq->rmap_fields[i])) + return dev_err_probe(dev, PTR_ERR(bq->rmap_fields[i]), + "cannot allocate regmap field\n"); } i2c_set_clientdata(client, bq); ret = bq25890_get_chip_version(bq); if (ret) { - dev_err(dev, "Cannot read chip ID or unknown chip.\n"); + dev_err(dev, "Cannot read chip ID or unknown chip: %d\n", ret); return ret; } if (!dev->platform_data) { ret = bq25890_fw_probe(bq); if (ret < 0) { - dev_err(dev, "Cannot read device properties.\n"); + dev_err(dev, "Cannot read device properties: %d\n", + ret); return ret; } } else { @@ -1189,7 +1187,7 @@ static int bq25890_probe(struct i2c_client *client, ret = bq25890_hw_init(bq); if (ret < 0) { - dev_err(dev, "Cannot initialize the chip.\n"); + dev_err(dev, "Cannot initialize the chip: %d\n", ret); return ret; } @@ -1225,7 +1223,7 @@ static int bq25890_probe(struct i2c_client *client, ret = bq25890_power_supply_init(bq); if (ret < 0) { - dev_err(dev, "Failed to register power supply\n"); + dev_err_probe(dev, ret, "Failed to register power supply.\n"); goto irq_fail; } -- 2.30.2