From patchwork Wed Nov 16 10:05:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vaittinen, Matti" X-Patchwork-Id: 13044609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CD0BC433FE for ; Wed, 16 Nov 2022 10:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232125AbiKPKGO (ORCPT ); Wed, 16 Nov 2022 05:06:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231629AbiKPKGO (ORCPT ); Wed, 16 Nov 2022 05:06:14 -0500 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 185808F; Wed, 16 Nov 2022 02:06:13 -0800 (PST) Received: by mail-lj1-f177.google.com with SMTP id k19so21169539lji.2; Wed, 16 Nov 2022 02:06:13 -0800 (PST) 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=OdCk/i513kMMAJ+DkyLvEiWGOZZpsa1KluZXc3adt2s=; b=gMnLwBENppi0q8Mxp9H8G4bKEGmmGwJOWSaSSdT90HCK5hNtIyvNmGU5mT01YgQCbp keisqPaSfBWp7mPi62c540GP8aVNDDKlQ1v7IF1aamFl/hyCoTMNfVQu0LpfgcFr8oYK NjXs/OMQe0XpgsDTxoT+3ZozMg4hzw91fIp9NCn2h7Aaz4yQBLyFjh+/D4HPe3+G/G8R bAh1NDVpu/J4OBabGB8yJAjQpuCiauOlO8LzpZW3r/nim3TmndNXl1M9yGF8ml4/yrdW JC48diak+YJU4vIOqFMG30qt/pDpYE3G6UCWJGXqvEc3LjeOtVmujjIkA/gk3y/UVYnJ p0UQ== X-Gm-Message-State: ANoB5pnxPcKm+Ao2l6CVLrvCCqB7xcz/yQ7Dbgr1x6WHcwRrPkKtkoTU IXVp343Dgr8QGoD8xclbr37cg8myzWE= X-Google-Smtp-Source: AA0mqf7v3Z1IOvNFxMwudHwY9nPh40xyL7BRyyG/NI859k8v6Fr1ukOKjNxWPS+RZdvx4AsDQIE7WA== X-Received: by 2002:a2e:8706:0:b0:26d:e3ae:886a with SMTP id m6-20020a2e8706000000b0026de3ae886amr8016298lji.531.1668593171311; Wed, 16 Nov 2022 02:06:11 -0800 (PST) Received: from dc75zzyyyyyyyyyyyyydt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyydt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::7]) by smtp.gmail.com with ESMTPSA id s23-20020a2e83d7000000b00268cfcf841asm2920650ljh.56.2022.11.16.02.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 02:06:10 -0800 (PST) Date: Wed, 16 Nov 2022 12:05:56 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Sebastian Reichel , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] power: supply: 88pm860x: simplify using devm Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Use devm variants for requesting threaded IRQ and for power-supply registration. Clean up error path and remove the .remove-callback. Signed-off-by: Matti Vaittinen --- Oh, found this commit while cleaning-up my local git branches. Seems like I never got around sending this? Please note, commit is untested as I don't have the 88pm860x HW --- drivers/power/supply/88pm860x_charger.c | 38 ++++++------------------- 1 file changed, 9 insertions(+), 29 deletions(-) base-commit: 094226ad94f471a9f19e8f8e7140a09c2625abaa diff --git a/drivers/power/supply/88pm860x_charger.c b/drivers/power/supply/88pm860x_charger.c index f21ce52fbc04..2b9fcb7e71d7 100644 --- a/drivers/power/supply/88pm860x_charger.c +++ b/drivers/power/supply/88pm860x_charger.c @@ -690,8 +690,7 @@ static int pm860x_charger_probe(struct platform_device *pdev) (chip->id == CHIP_PM8607) ? chip->companion : chip->client; if (!info->i2c_8606) { dev_err(&pdev->dev, "Missed I2C address of 88PM8606!\n"); - ret = -EINVAL; - goto out; + return -EINVAL; } info->dev = &pdev->dev; @@ -704,44 +703,26 @@ static int pm860x_charger_probe(struct platform_device *pdev) psy_cfg.drv_data = info; psy_cfg.supplied_to = pm860x_supplied_to; psy_cfg.num_supplicants = ARRAY_SIZE(pm860x_supplied_to); - info->usb = power_supply_register(&pdev->dev, &pm860x_charger_desc, - &psy_cfg); + info->usb = devm_power_supply_register(&pdev->dev, &pm860x_charger_desc, + &psy_cfg); if (IS_ERR(info->usb)) { - ret = PTR_ERR(info->usb); - goto out; + return PTR_ERR(info->usb); } pm860x_init_charger(info); for (i = 0; i < ARRAY_SIZE(info->irq); i++) { - ret = request_threaded_irq(info->irq[i], NULL, - pm860x_irq_descs[i].handler, - IRQF_ONESHOT, pm860x_irq_descs[i].name, info); + ret = devm_request_threaded_irq(&pdev->dev, info->irq[i], NULL, + pm860x_irq_descs[i].handler, + IRQF_ONESHOT, + pm860x_irq_descs[i].name, info); if (ret < 0) { dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", info->irq[i], ret); - goto out_irq; + return ret; } } return 0; - -out_irq: - power_supply_unregister(info->usb); - while (--i >= 0) - free_irq(info->irq[i], info); -out: - return ret; -} - -static int pm860x_charger_remove(struct platform_device *pdev) -{ - struct pm860x_charger_info *info = platform_get_drvdata(pdev); - int i; - - power_supply_unregister(info->usb); - for (i = 0; i < info->irq_nums; i++) - free_irq(info->irq[i], info); - return 0; } static struct platform_driver pm860x_charger_driver = { @@ -749,7 +730,6 @@ static struct platform_driver pm860x_charger_driver = { .name = "88pm860x-charger", }, .probe = pm860x_charger_probe, - .remove = pm860x_charger_remove, }; module_platform_driver(pm860x_charger_driver);