From patchwork Tue Oct 31 09:56:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoniu Miclaus X-Patchwork-Id: 160051 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp121617vqg; Tue, 31 Oct 2023 02:57:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF12groRq6KqPhlacfuJP1ofo//0w8VuoKjeD4gZ8euqwosJC52jEcNv5BUl9yUzcKvIGB6 X-Received: by 2002:a05:6a00:1356:b0:6c0:4006:4195 with SMTP id k22-20020a056a00135600b006c040064195mr14734250pfu.0.1698746267245; Tue, 31 Oct 2023 02:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698746267; cv=none; d=google.com; s=arc-20160816; b=Qn9qqQ1oW9ewiDzFU4CPvM5nvt9tCotdT5TG72NGFtT8z2q84PUOBjpbjV2b9asVnp frMDKtO3T7OkRYO5+2kWIUawXGlhZQNdmVWKtInzFAUVFKWc9tbNBWOtsYrJ97+GwZa5 Kaefsqpt/GaY/LA5I2uCpgA9RNPoe2o3uzm0EQ/F3kZYQYVgstkKifOu0dbNmbFJugz5 cNgks3EbSoF5+haDhYsGFA9BAynLTlYCx7QpDu+4s/sdhc0Jk6Uv/owV+iWhM8cF1hVV 7nG2auNSLVI6s862acnHmAKhiU3JKUd8D/rs+75LNHpw9ogApA2enEgXmGDqjvz24wCj yvkg== 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:to:from; bh=nyMBjbYjg2mRAEZwT0x5rYtuCWIbH5lBnKZVas5Fg5E=; fh=cRkBSe+hjpcqVEhg/WEoAz3xUNp51kRbVcsfPJhPZ3A=; b=K67lsW1Cl1Wra8QGH7NNX+TbbFcScTE9PlVod8DewWGLmi7gKOHJs/C1ND4bUoplOL 9s4Mv2/1JTMo4jegHe5SnyjXdWhWs+U9xpF/wgwvcrY3Qsad045+WmYKXaJu9aky7OJG W5Jcc/dvUXH2B8m8ZiaHaLou0da8feLOrZ4dnPGNIQaDxesp4jnbsBKYTmmUwsEKzuo1 4m0AITuPmYSu4HI/k0wGArXS4BRKcvBN9k66elhPwrFjKNtQ3S0JTa6OSb91Hcstvqy9 p9uA8cO4exqw2xgLMnsR8oeGJm3U7Nx+jR5qTMwBkYVZGDkqP7Uv6M176Og6V6mDiFcr LTlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id i14-20020a056a00004e00b00690204af234si760063pfk.378.2023.10.31.02.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 02:57:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 84C93803D8F3; Tue, 31 Oct 2023 02:57:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235567AbjJaJ53 (ORCPT + 34 others); Tue, 31 Oct 2023 05:57:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbjJaJ51 (ORCPT ); Tue, 31 Oct 2023 05:57:27 -0400 Received: from mx0a-00128a01.pphosted.com (mx0a-00128a01.pphosted.com [148.163.135.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80E9AA1; Tue, 31 Oct 2023 02:57:25 -0700 (PDT) Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39V7VJmb030860; Tue, 31 Oct 2023 05:57:08 -0400 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com (PPS) with ESMTPS id 3u1fef689q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 31 Oct 2023 05:57:08 -0400 (EDT) Received: from ASHBMBX9.ad.analog.com (ASHBMBX9.ad.analog.com [10.64.17.10]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 39V9v7D5039683 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 31 Oct 2023 05:57:07 -0400 Received: from ASHBCASHYB4.ad.analog.com (10.64.17.132) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 31 Oct 2023 05:57:06 -0400 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBCASHYB4.ad.analog.com (10.64.17.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Tue, 31 Oct 2023 05:57:06 -0400 Received: from zeus.spd.analog.com (10.66.68.11) by ashbmbx8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.2.986.14 via Frontend Transport; Tue, 31 Oct 2023 05:57:06 -0400 Received: from amiclaus-VirtualBox.ad.analog.com (AMICLAUS-L02.ad.analog.com [10.48.65.145]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 39V9usbA024643; Tue, 31 Oct 2023 05:56:56 -0400 From: Antoniu Miclaus To: Antoniu Miclaus , Jean Delvare , Guenter Roeck , , Subject: [PATCH] hwmon: ltc2991: remove device reference from state Date: Tue, 31 Oct 2023 11:56:46 +0200 Message-ID: <20231031095647.48376-1-antoniu.miclaus@analog.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-ORIG-GUID: vlt0LP1E8CL2YEfj4nxWHBODGB3h0aeV X-Proofpoint-GUID: vlt0LP1E8CL2YEfj4nxWHBODGB3h0aeV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-30_13,2023-10-31_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 phishscore=0 priorityscore=1501 clxscore=1015 malwarescore=0 bulkscore=0 adultscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2310240000 definitions=main-2310310077 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 31 Oct 2023 02:57:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781264565878556456 X-GMAIL-MSGID: 1781264565878556456 Remove device reference from struct ltc2991_state since it is used only inside the init function. Pass the struct device as parameter to the init function instead. Signed-off-by: Antoniu Miclaus --- drivers/hwmon/ltc2991.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/hwmon/ltc2991.c b/drivers/hwmon/ltc2991.c index bd63c61129a9..773e7211643f 100644 --- a/drivers/hwmon/ltc2991.c +++ b/drivers/hwmon/ltc2991.c @@ -54,7 +54,6 @@ #define LTC2991_VCC_CH_NR 0 struct ltc2991_state { - struct device *dev; struct regmap *regmap; u32 r_sense_uohm[LTC2991_MAX_CHANNEL]; bool temp_en[LTC2991_MAX_CHANNEL]; @@ -283,19 +282,19 @@ static const struct regmap_config ltc2991_regmap_config = { .max_register = 0x1D, }; -static int ltc2991_init(struct ltc2991_state *st) +static int ltc2991_init(struct ltc2991_state *st, struct device *dev) { struct fwnode_handle *child; int ret; u32 val, addr; u8 v5_v8_reg_data = 0, v1_v4_reg_data = 0; - ret = devm_regulator_get_enable(st->dev, "vcc"); + ret = devm_regulator_get_enable(dev, "vcc"); if (ret) - return dev_err_probe(st->dev, ret, + return dev_err_probe(dev, ret, "failed to enable regulator\n"); - device_for_each_child_node(st->dev, child) { + device_for_each_child_node(dev, child) { ret = fwnode_property_read_u32(child, "reg", &addr); if (ret < 0) { fwnode_handle_put(child); @@ -312,7 +311,7 @@ static int ltc2991_init(struct ltc2991_state *st) &val); if (!ret) { if (!val) - return dev_err_probe(st->dev, -EINVAL, + return dev_err_probe(dev, -EINVAL, "shunt resistor value cannot be zero\n"); st->r_sense_uohm[addr] = val; @@ -361,18 +360,18 @@ static int ltc2991_init(struct ltc2991_state *st) ret = regmap_write(st->regmap, LTC2991_V5_V8_CTRL, v5_v8_reg_data); if (ret) - return dev_err_probe(st->dev, ret, + return dev_err_probe(dev, ret, "Error: Failed to set V5-V8 CTRL reg.\n"); ret = regmap_write(st->regmap, LTC2991_V1_V4_CTRL, v1_v4_reg_data); if (ret) - return dev_err_probe(st->dev, ret, + return dev_err_probe(dev, ret, "Error: Failed to set V1-V4 CTRL reg.\n"); ret = regmap_write(st->regmap, LTC2991_PWM_TH_LSB_T_INT, LTC2991_REPEAT_ACQ_EN); if (ret) - return dev_err_probe(st->dev, ret, + return dev_err_probe(dev, ret, "Error: Failed to set contiuous mode.\n"); /* Enable all channels and trigger conversions */ @@ -392,12 +391,11 @@ static int ltc2991_i2c_probe(struct i2c_client *client) if (!st) return -ENOMEM; - st->dev = &client->dev; st->regmap = devm_regmap_init_i2c(client, <c2991_regmap_config); if (IS_ERR(st->regmap)) return PTR_ERR(st->regmap); - ret = ltc2991_init(st); + ret = ltc2991_init(st, &client->dev); if (ret) return ret;