Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5394419rwb; Sun, 11 Dec 2022 05:29:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf4dFeC9utfQHgfhiw/6MWsoHSJY+HKAM9/f+MJwLLZFGB9nvvhsEoQ+kPkv/9ra+1zuxPTP X-Received: by 2002:a05:6a20:d696:b0:9d:efbe:a11f with SMTP id it22-20020a056a20d69600b0009defbea11fmr16518211pzb.47.1670765341305; Sun, 11 Dec 2022 05:29:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670765341; cv=none; d=google.com; s=arc-20160816; b=fMfwy4c0Zjw3zLqjmKgjgHhkmM3sws4cH1sy6yQXe0/l9Gf5tCLEUG17yrkV8aLt5d nTDQRhasvu8RMja4gf+PObYGbRkvHtWY6SuyyRblDMYJoCetDxmwySaGcbiQ//KZQ3Zl SQS7END0vrHiQQRGwl17Azu0INgnDUZl7iEAs1754mqz3ZL4bj4Twj9s9CKNRpsUcWnO hSlxwgwJEnuueb2KtcnMQhqr+qwX10tLzuBe6Cy4nz4Ti4W2iP1rXIzcIdOeIgIUXMWd +sow75WaVvNF6n3vW4xehxPhkzz+JsrWSecUdzKzZrPKRZfRPtmSvFdv4eqM3s7Rvj/t uw2A== 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:subject:cc:to:from:date :dkim-signature; bh=cbZQ9iweReei/b1F4J39iDOB570cyyGKm60JOwHDumU=; b=HExur+DscdA7D6etjr6Esw8zZV1JIE1uqflywVXYTofiV9twavbl9lqsKGSfKcmVxW O5bcrrk2KFh66z5Kc1wx4lFQfaoqA/lBmAo5W+KXPsH0o6Hu1TegzG60I8VZXjcy1HU/ zaan+WOEp5gACFGNzXd39/bnCgzck7FLD+IVPj9s1vdYrDidxf13ZdvAnCr+SrcrIqWU I3n4IJdRIPUhvR4YQ+WVgnOEtMc/+/1AOB4j378Ihy6vMgJLjaclMVbepFjS3V2VN6WV Y+VCxOL9P/ftKDOUeMEJ5tFNbpbP+6xcLtg2+psewUxo+TjVGeYTXAHpJnTRx86cwQ2v gfyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nSBYBrnF; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020a63e855000000b00476759b8788si7489780pgk.861.2022.12.11.05.28.51; Sun, 11 Dec 2022 05:29: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=@kernel.org header.s=k20201202 header.b=nSBYBrnF; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230262AbiLKMfa (ORCPT + 75 others); Sun, 11 Dec 2022 07:35:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230026AbiLKMf3 (ORCPT ); Sun, 11 Dec 2022 07:35:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FC1C11153; Sun, 11 Dec 2022 04:35:28 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id C10D7B80ACE; Sun, 11 Dec 2022 12:35:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9F50C433D2; Sun, 11 Dec 2022 12:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670762125; bh=rGDsH1LcYLgClznS/DD5dyNhbVZXJJd+xXXfJMafRdo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nSBYBrnFFnHx0GRNMxQvsc6cMeOZkg3XeueVucUuWs7oOVCuVQ+vYwl4zdQ908B2h g+qLsbGzbuzydDma8h0Dr7T2ghgBfh6uiCkV7TlOTyjDfflXtjoVar5mO/cHCAbeSr urGJZNDHB5KQ/132MmD9PcyCDpN95zzY3++kU8REfAyJWYj7V9L/xg6buRljWoE8Fi 4/Qf1juAqJj4kDw2pgFyQrvSqAFDrfFqJtYcK7NJngk47omkLVg4RJfa+3ZvbzaiMS WwSUURRDrDHzUHOzqfRpZ/VUEmYwklUsatqTcblXpNLNC6YN/2B7PP9+UAXJWBp2gf iSsVJN/RpLYgg== Date: Sun, 11 Dec 2022 12:48:17 +0000 From: Jonathan Cameron To: Okan Sahin Cc: , Lee Jones , "Rob Herring" , Krzysztof Kozlowski , Liam Girdwood , Mark Brown , Lars-Peter Clausen , Andy Shevchenko , Marcelo Schmitt , ChiYuan Huang , "Geert Uytterhoeven" , Marcus Folkesson , Caleb Connolly , Anand Ashok Dumbre , Ramona Bolboaca , William Breathitt Gray , Manish Narani , , , Subject: Re: [PATCH 3/5] staging: drivers: regulator: Add MAX77541 Regulator Support Message-ID: <20221211124817.5bd07ef8@jic23-huawei> In-Reply-To: <20221207090906.5896-4-okan.sahin@analog.com> References: <20221207090906.5896-1-okan.sahin@analog.com> <20221207090906.5896-4-okan.sahin@analog.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.35; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Wed, 7 Dec 2022 12:08:42 +0300 Okan Sahin wrote: > This patch adds regulator driver for both MAX77541 and MAX77540. > The MAX77541 is a high-efficiency step-down converter > with two 3A switching phases for single-cell Li+ battery and 5VDC systems. > > The MAX77540 is a high-efficiency step-down converter > with two 3A switching phases. > > Signed-off-by: Okan Sahin ... > +static int max77541_regulator_probe(struct platform_device *pdev) > +{ > + struct max77541_dev *max77541 = dev_get_drvdata(pdev->dev.parent); > + struct max77541_regulator_dev *regulator; > + struct regulator_config config = {}; > + struct regulator_dev *rdev; > + int i; > + > + regulator = devm_kzalloc(&pdev->dev, sizeof(*regulator), GFP_KERNEL); > + if (!regulator) > + return -ENOMEM; > + > + regulator->dev = &pdev->dev; > + regulator->max77541 = max77541; > + > + config.dev = pdev->dev.parent; > + config.driver_data = regulator; > + config.regmap = regulator->max77541->regmap; > + > + for (i = 0; i < MAX77541_MAX_REGULATORS; i++) { > + switch (regulator->max77541->type) { > + case MAX77540: As in mfd driver, better to move this from code to constant data by using a chip_info type structure. You could just use the *_regulator_desc array, but probably better to wrap that in a structure to reduce difficulty of adding other stuff in future. > + rdev = devm_regulator_register(&pdev->dev, > + &max77540_regulators_desc[i], &config); > + if (IS_ERR(rdev)) > + return dev_err_probe(&pdev->dev, PTR_ERR(rdev), > + "Failed to register regulator\n"); > + break; > + case MAX77541: > + rdev = devm_regulator_register(&pdev->dev, > + &max77541_regulators_desc[i], &config); > + if (IS_ERR(rdev)) > + return dev_err_probe(&pdev->dev, PTR_ERR(rdev), > + "Failed to register regulator\n"); > + break; > + default: > + return -EINVAL; > + } > + } > + > + return 0; > +}