From patchwork Tue Apr 19 16:38:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 563369 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp3461720map; Tue, 19 Apr 2022 10:23:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwpS8Q4+LyCiNvBNrsBFtaS8SghEFfUsy42gFjBJAi3+w53+rcvR1e62oDvnSCFafCY5Bk X-Received: by 2002:a63:f641:0:b0:3a2:cea2:bcf with SMTP id u1-20020a63f641000000b003a2cea20bcfmr15504046pgj.506.1650389022054; Tue, 19 Apr 2022 10:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650389022; cv=none; d=google.com; s=arc-20160816; b=oSwVhaX9XAGV/qzR9adDqd0GebU85TKZ4VL46XQugqrdmoXM0Hk/YoE5/qFCAymAg9 G5c7SiQ/NZRqpfAi47/+UGr4Nk1XhpoPRkHw9St5j04osYiJLsykrqWyv4kEZbkuCgRO M7VNjldV2GYQsCJo5UDGRGaTQjXAVnP4AYfiAHjQT3EYsloJodDnpLOFoAsU41Jkn1PV PBe/S6EGuyj2drJOEgZrLaCcBWV3X+o2TuhkadeZEtvgmB+3LB5wDfcjfz0tmyK38j5z 2ts8XPvLHRz2CX4H5k/1ELs6n+FjbepVwIrKNkI2OgPimSldsWq3/om1OM710RVmtjcT 7XRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=JV4TNcu3RG8idD7cAr5sUdshqdKs/mLmt8vWrzhDh74=; b=pzeT4ykI1kOLLA3K0PfZZJUMqCrPCgkE5gVuw0HCyO/rSJtZIIdloFymcYku46P/dE rkp5qJm4aSeZuGF4iceACGY8XnaiXSPaSDU4CfrH7F6N1LZ6fBpW7EiqlnjCc/w6OUDv YqWTl6dmS9yQBUMTVkF7aQajqrq0LSbcxnowg40mgoUQ/VT7DAieFEqtcnhDHG+MUqoE mRCcL6CC6emcR7OOcf4qyDmEGA9u1IgQ4tO1P1eBU3/pNHA7u1UOcYRkTgTDEMsRIZaO Pjjj8+6/NN898iVB5uB4bCL8YwmQ5zQao/VuJP7UOZEVg7g2aXCGajGZwj/nBzx7OJ5q GPcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=shSBuy3R; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=IfCx1sYs; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id r12-20020a63b10c000000b003992202943fsi13514837pgf.364.2022.04.19.10.23.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 10:23:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=shSBuy3R; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=IfCx1sYs; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JV4TNcu3RG8idD7cAr5sUdshqdKs/mLmt8vWrzhDh74=; b=shSBuy3RWkCLMt 1fqC4ZsQD5YfQ0TqV9/7I0WNfQq3IENhvmXVmPvsU9msO9+U/Cb3GDKMvmo//UTGwWYef0raFYYF6 6jCzDH+JQu0iBUgQuhZM3HuO3hDxSa0DhrFudQbmQKd71g45CVjr63j+mLQzTUk4sA15+EDA/VKMZ YsEs3ZLTsAclefQxveA1A/ZOE5kGYpDhFi0HFZVVW1G/2B5t1890SX3cttzz8IaSifw9C8p/S+DFk qtXyIrqVgK2FaBAJ2bzu7NcAy8A/28S/kl8BKI3DZo0aT3VUDqiWjxaXz99javAlwl0M+kGaD+iXk ti3dK3OdUN3YUOs6+4qQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngrZd-005HA0-GX; Tue, 19 Apr 2022 17:23:33 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngqxK-004yTK-6B; Tue, 19 Apr 2022 16:44:00 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 951AA61877; Tue, 19 Apr 2022 16:43:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EC2BC385A5; Tue, 19 Apr 2022 16:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650386637; bh=qlaYFyobKEQjnzQZM9MNp5qNQqkRYezyfa1kDOn31O4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IfCx1sYsItrvvOhd62OVGq73m59nNboCQp/gH4IxEBVU5zCvpQPCNPA7TuLYFXC6C LwaFif0SpZk4iKNSuUv5XERVH3Itoh7apK3zIBcowiSB/8aMiJR+86E55VqZMRViGM vxBgMMnsawZno/joMpTCd+ep1ROboUpME3CMorprNKBdA5wmg9bbhuyypuFsCjLW8G yE/u4h18EsDdKvT5ABnu1pHVnRKTIiK1fqnwH6cD1Nj0kuQJNcwzeZUE12odIw17Nr I4FoURlNeI1+CxCMlSZX0Yt4E6U9SjEz7W8MiBWwtf7IWB7ooRCN+I7IGpKqWmgJa2 GROrW1/+TSmQA== From: Arnd Bergmann To: robert.jarzmik@free.fr, linux-arm-kernel@lists.infradead.org Cc: Arnd Bergmann , Daniel Mack , Haojian Zhuang , Marek Vasut , Philipp Zabel , Lubomir Rintel , Paul Parsons , Tomas Cech , Sergey Lapin , Thomas Bogendoerfer , Michael Turquette , Stephen Boyd , "Rafael J. Wysocki" , Viresh Kumar , Dmitry Torokhov , Ulf Hansson , Dominik Brodowski , Helge Deller , Mark Brown , Linus Walleij , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-ide@vger.kernel.org, linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, linux-input@vger.kernel.org, patches@opensource.cirrus.com, linux-leds@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, linux-rtc@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, alsa-devel@alsa-project.org, Sebastian Reichel Subject: [PATCH 39/48] power: tosa: simplify probe function Date: Tue, 19 Apr 2022 18:38:01 +0200 Message-Id: <20220419163810.2118169-40-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20220419163810.2118169-1-arnd@kernel.org> References: <20220419163810.2118169-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220419_094358_420311_6CC991E6 X-CRM114-Status: GOOD ( 15.83 ) X-Spam-Score: -5.4 (-----) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Arnd Bergmann We have three power supplies that need similar initialization. As a preparation for the gpio lookup table conversion, split out the initialization into a separate function. Content analysis details: (-5.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [139.178.84.217 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.2 DKIMWL_WL_HIGH DKIMwl.org - High trust sender X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org From: Arnd Bergmann We have three power supplies that need similar initialization. As a preparation for the gpio lookup table conversion, split out the initialization into a separate function. Reviewed-by: Sebastian Reichel Acked-by: Sebastian Reichel Cc: linux-pm@vger.kernel.org Signed-off-by: Arnd Bergmann --- drivers/power/supply/tosa_battery.c | 50 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/drivers/power/supply/tosa_battery.c b/drivers/power/supply/tosa_battery.c index 32cc31cd4761..b26b0eca33e1 100644 --- a/drivers/power/supply/tosa_battery.c +++ b/drivers/power/supply/tosa_battery.c @@ -343,12 +343,24 @@ static int tosa_bat_resume(struct platform_device *dev) #define tosa_bat_resume NULL #endif +static int tosa_power_supply_register(struct device *dev, + struct tosa_bat *bat, + const struct power_supply_desc *desc) +{ + struct power_supply_config cfg = { + .drv_data = bat, + }; + + mutex_init(&bat->work_lock); + bat->psy = power_supply_register(dev, desc, &cfg); + + return PTR_ERR_OR_ZERO(bat->psy); +} + + static int tosa_bat_probe(struct platform_device *dev) { int ret; - struct power_supply_config main_psy_cfg = {}, - jacket_psy_cfg = {}, - bu_psy_cfg = {}; if (!machine_is_tosa()) return -ENODEV; @@ -357,36 +369,22 @@ static int tosa_bat_probe(struct platform_device *dev) if (ret) return ret; - mutex_init(&tosa_bat_main.work_lock); - mutex_init(&tosa_bat_jacket.work_lock); - INIT_WORK(&bat_work, tosa_bat_work); - main_psy_cfg.drv_data = &tosa_bat_main; - tosa_bat_main.psy = power_supply_register(&dev->dev, - &tosa_bat_main_desc, - &main_psy_cfg); - if (IS_ERR(tosa_bat_main.psy)) { - ret = PTR_ERR(tosa_bat_main.psy); + ret = tosa_power_supply_register(&dev->dev, &tosa_bat_main, + &tosa_bat_main_desc); + if (ret) goto err_psy_reg_main; - } - jacket_psy_cfg.drv_data = &tosa_bat_jacket; - tosa_bat_jacket.psy = power_supply_register(&dev->dev, - &tosa_bat_jacket_desc, - &jacket_psy_cfg); - if (IS_ERR(tosa_bat_jacket.psy)) { - ret = PTR_ERR(tosa_bat_jacket.psy); + ret = tosa_power_supply_register(&dev->dev, &tosa_bat_jacket, + &tosa_bat_jacket_desc); + if (ret) goto err_psy_reg_jacket; - } - bu_psy_cfg.drv_data = &tosa_bat_bu; - tosa_bat_bu.psy = power_supply_register(&dev->dev, &tosa_bat_bu_desc, - &bu_psy_cfg); - if (IS_ERR(tosa_bat_bu.psy)) { - ret = PTR_ERR(tosa_bat_bu.psy); + ret = tosa_power_supply_register(&dev->dev, &tosa_bat_bu, + &tosa_bat_bu_desc); + if (ret) goto err_psy_reg_bu; - } ret = request_irq(gpio_to_irq(TOSA_GPIO_BAT0_CRG), tosa_bat_gpio_isr,