From patchwork Thu Aug 1 14:49:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13750610 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE37F198A10 for ; Thu, 1 Aug 2024 14:49:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523767; cv=none; b=mevz11zRcLDstcrzvEPed6340adA4lmXAdWYSTQN5ui3UxidXrF/aZRQvlkskYBxJ6DTX5jHq7uatozwVIMmWIdhpy4Vseb3BOIDDcyAY/3TRj7W7M1oxRxskiMbnA+EpJSI1RloygvnksL5iq3tMm+IXY/RZirmBRfbVMdmP3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523767; c=relaxed/simple; bh=LC0clT8WFU6qIQxSILnxhfKrHuibEGbgMT3lvfGQx9I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gs77ckxwgkUN9dpFd/hnMd6V0wRTKrg13FlJolbFxCAYkiawD4GzE4Eg66FfIzjtD2quYPEqV5hiZTT0A5fSoneTItMXmLeRrTQxU3eOKzRr1Gvuzg+ImpGpm1IEmhiJ849Ims3RyVnboYwmKFONuScen4ZVI7Nk8/Aw4suGQ1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fU1BWeOp; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fU1BWeOp" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2cb81c0ecb4so1655788a91.0 for ; Thu, 01 Aug 2024 07:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722523764; x=1723128564; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=h7kpafWE7ZxSKn48/frTNbSlf6U7pKkGaZJ1ZDSR/Io=; b=fU1BWeOphFfsv1pw+UkVh/pCxH1Em02gXU3lpE68UEwDmhSFAZQnec54biPmqddq3k BKRZ3QH7vzEV+JtWkYUdihBZ9mYH1qjaCKuPJcizUMKOg99HKH4UtbShZQdaQbhTrlOi bR5kuudLYrE4V8o1y8hvPySYf7bk+4z1aqjbWWUHQB2ZCRxtyFekWYiIEPMkbbiuqk1S riMpCGi7omrvPXnnRsX1KQRi94Eb4ey6SPdqTjCC21/VfKgL947zMu4XxPsx+JQyb6v5 SBcQ4fNNOJes9+GXhlR++0tWFk7vsKqzFE7GtAjaj4JbRxn2sEciotbkL4eOWPZljj5X Q2cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722523764; x=1723128564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=h7kpafWE7ZxSKn48/frTNbSlf6U7pKkGaZJ1ZDSR/Io=; b=LQrOQHW+LATa+8RWw/l+oNUFcn+YupqCimfJhbRFuHWJnjbDl9/OGSw9oLBI8ewbJO NEZ14fwJnxy5DHhJbs09VljaBlhcIIvBOGQ6XOW3D6ApyjFtq87OS3cWdkegm9+u6WHC +/82uz74yQxMcgMzGck47ulMZCkn8r511kvuu7iGsu3a32J1EdA443P5p300SLE3vbVP Scf9ubC+5BiiJKyoh6k1z++Zjj0GrPKWPqZ36Mmd550QJ5cX43xTMTkjk7rdd/k6MW76 c/cexrJ0Ux6pDg5Z4qUhKRToJh22/THbCINDZ2kUHXbYAw9kkBXXcSBMeDFGEeRroojV +s7w== X-Gm-Message-State: AOJu0YxyZ9vR24L6TVWSS2VyytwstPz3469/dnBiFnjq7OHRJA3FjEuD /1hE35P02YQt/HUrkLSAZ/B8fEjaq+LFk+ppczTediaUj18sVFHoemTY4g== X-Google-Smtp-Source: AGHT+IFg/FXbnxbVGTFe04+U6+yI8V6hoqwTh2VZKF4uEaGm/Fbe3PG3NzqBltvztrvOpjFST4+qRA== X-Received: by 2002:a17:90b:4d05:b0:2c9:5a71:1500 with SMTP id 98e67ed59e1d1-2cff9d8389emr395031a91.0.1722523764537; Thu, 01 Aug 2024 07:49:24 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cfdc406a0dsm3480139a91.3.2024.08.01.07.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:49:23 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: Hardware Monitoring Cc: Guenter Roeck Subject: [PATCH 1/6] hwmon: (lm92) Improve auto-detection accuracy Date: Thu, 1 Aug 2024 07:49:13 -0700 Message-Id: <20240801144918.6156-2-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801144918.6156-1-linux@roeck-us.net> References: <20240801144918.6156-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Checking three configuration register bits and the manufacturer ID register to auto-detect LM92 is a bit vague. Repeat twice on replicated register addresses to improve detection accuracy. Check the manufacturer ID first and bail out immediately without reading the other register if there is a mismatch to reduce the number of i2c transfers needed in that case. Also explicitly test for an error from reading the configuration register to avoid potential situations where the returned error masked against 0xe0 is 0. While at it, drop "lm92: Found National Semiconductor LM92 chip" detection noise. Signed-off-by: Guenter Roeck Reviewed-by: Tzung-Bi Shih --- drivers/hwmon/lm92.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 46579a3e1715..e2d8c8afcbfa 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -272,20 +272,28 @@ static int lm92_detect(struct i2c_client *new_client, struct i2c_board_info *info) { struct i2c_adapter *adapter = new_client->adapter; - u8 config; - u16 man_id; + u8 config_addr = LM92_REG_CONFIG; + u8 man_id_addr = LM92_REG_MAN_ID; + int i, regval; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) return -ENODEV; - config = i2c_smbus_read_byte_data(new_client, LM92_REG_CONFIG); - man_id = i2c_smbus_read_word_data(new_client, LM92_REG_MAN_ID); - - if ((config & 0xe0) == 0x00 && man_id == 0x0180) - pr_info("lm92: Found National Semiconductor LM92 chip\n"); - else - return -ENODEV; + /* + * Register values repeat with multiples of 8. + * Read twice to improve detection accuracy. + */ + for (i = 0; i < 2; i++) { + regval = i2c_smbus_read_word_data(new_client, man_id_addr); + if (regval != 0x0180) + return -ENODEV; + regval = i2c_smbus_read_byte_data(new_client, config_addr); + if (regval < 0 || (regval & 0xe0)) + return -ENODEV; + config_addr += 8; + man_id_addr += 8; + } strscpy(info->type, "lm92", I2C_NAME_SIZE); From patchwork Thu Aug 1 14:49:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13750611 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBA81198A10 for ; Thu, 1 Aug 2024 14:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523769; cv=none; b=IpNJTrCy5zV4WHYIgRJUIWCA0X8/hDdcPAfrvIk19LTYH6fck4JKyLKMYGQpJNih5669DfiMmRwmntOczVWA2fQGzbKww/P0QL4pXMKO90Xmx3unfi582ju0iJnDtSOvaRbalQMFko5mnVFFNQZUatd5M68vIzw8Kj5Q96S+3zY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523769; c=relaxed/simple; bh=UR9xa6bVBt6OjVHZ2VXaCQw4f5DAkA1TE0HN0Rz/ZkM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ujr9syK43LQ52QRjMOsJRQQ2Ndc0JHT5cfmjk9zOqM78AFfNVEH3EB9i0gxQ8Y9+P4wBsOunjkJHZcjIiLEpPX6GQ6LUJxH9Zt9bvTa4av/WUrqyXbJEBzfeFX9DvqL7nmyddiM+nZ5QokvtfQTucdOSPDhMc+4skxpGG7Lg3z4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WH12gpCR; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WH12gpCR" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1fc49c0aaffso53233485ad.3 for ; Thu, 01 Aug 2024 07:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722523766; x=1723128566; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=SoFYCzZprZgrFFcZ5xijm5hTD1LSeDYpkaNcO8pG47c=; b=WH12gpCROoFeSrONk80GOr7d7uxS+C5UIWfjUUP4xi90OPtHm6hk9apC9bsfvypQzb LDOAH9ojE4KAYJAQA+DAhzoINBDsnGvkgwMvbryfnMlWQW5BKe9S2x0H0nuW8hzYpMN9 oZXibdAPxqFHFocNtwfuMK4GxbI38nAl29a/AjkkHrGckkw//BvTtk0DxWf6VGNI1qmA tjbSGSadLjLOKjqlmxRwj8q3LrN6cyrFlvclcAlCNdzitO/A3NuoFeyuGqq+p3Drz5FH YPFQu9AiqFtTFHGeoVRvGPRLsYaUbGpuEwNXKeiaJ5coVAusjQwF9Kq3gRHmJht0JVUm TX6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722523766; x=1723128566; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SoFYCzZprZgrFFcZ5xijm5hTD1LSeDYpkaNcO8pG47c=; b=UGyCmARav2ssdZLYC85AZzahtpbVVHY2OWHaEMHGNWAfNTyPJRRJrXujgglD+eE3LN BOiI8eGYM0hEZvVJH9i5FLYolXntJeCfx3e+qIRP8acozPhS1hfLMAO642kSk7QUV34K qYdogGTpecGDCKQzlb/ogNxixezLdGCtYA7bkQHSroc+uqrU3lHOS7cSGRhRmaUubwkh 3OhOYkdIDZ4ReLITPWoDJxAHyiAUjAK96FZ68VR8GfvDsLU69nivQKMgho/ucYnR7qFc IWBdNm2qYuqBQTtZa3SuL0KpvsBvi/UUfgzNQ4Vn5BT2tq1zmXfO5/2kudyJwhOzDh3V nHBw== X-Gm-Message-State: AOJu0Yw779UN7ET95ZdOXR/FZJaEb+XJln8zFcgVTkmGuh/sg6GIJkJd jA5qXH8qdJUF2P8YZ3Rcmp/G96zlkJWFHs1/ApnO3XqxswepJsOxbNzDCA== X-Google-Smtp-Source: AGHT+IF68RdXnZ8S9yTvFjvfiTtWYJkRbZEahaEh7cbCRVODiM3PmaHR3bkRAmDSLjf3p33faHbd+Q== X-Received: by 2002:a17:902:da85:b0:1fb:a077:a846 with SMTP id d9443c01a7336-1ff57257ce7mr6375775ad.3.1722523766442; Thu, 01 Aug 2024 07:49:26 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7c7ffecsm140982435ad.40.2024.08.01.07.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:49:25 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: Hardware Monitoring Cc: Guenter Roeck Subject: [PATCH 2/6] hwmon: (lm92) Reorder include files to alphabetic order Date: Thu, 1 Aug 2024 07:49:14 -0700 Message-Id: <20240801144918.6156-3-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801144918.6156-1-linux@roeck-us.net> References: <20240801144918.6156-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Simplify driver maintenance by reordering files to alphabetic order. No functional change. Signed-off-by: Guenter Roeck Reviewed-by: Tzung-Bi Shih --- drivers/hwmon/lm92.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index e2d8c8afcbfa..b0179d72b779 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -27,15 +27,15 @@ * with the LM92. */ -#include -#include -#include -#include +#include #include #include -#include -#include +#include +#include #include +#include +#include +#include /* * The LM92 and MAX6635 have 2 two-state pins for address selection, From patchwork Thu Aug 1 14:49:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13750612 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64842198A10 for ; Thu, 1 Aug 2024 14:49:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523770; cv=none; b=GA3FMGTLhgVnvc3lquuDBD+tpxXDYBqJRb97RQvrI4yzShHga9Rw4VM1+yQuH0bxihzmY7jLesVdi9egPdE+g5HO4MaemY/PkOpioPqZt+tgf3e3RPW+r+cwDunhlXsL27WQSuR01D0X9L58cGKaW9jdokM4YXnNzQrpwJAh3DY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523770; c=relaxed/simple; bh=czQRo5n2OpOOBzHXJUNeOtPfQZNe78muTTFNCcOHRzg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UKcmFmncTaL8JejJqIsMN1dpdPSf5AlmT41nqcnGAKnWWQd1pMhIMdQxOn/cty1zFo1vsmYwgS/9yptLr9dJuudIeFIkvtBcoub3qQ2tC2v2eot1dB6xiVL0qmZoz/P4EfvUlZdmGSQzhKacqrAXetXBJCXj7AQByd3eoORd7fE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FaHJ7iQe; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FaHJ7iQe" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-70d23caf8ddso6109432b3a.0 for ; Thu, 01 Aug 2024 07:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722523768; x=1723128568; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=DWKzig5pf01PlSBu3e8F4D6XxwfVIYNrVD3oMGmQhEE=; b=FaHJ7iQedlfTvzmlmIulfdEZSWP0hyX+W0BQuwJA2pWzA1y1OoWJamdlWFSkcORHCp mZIfB6obPHouz/h/ciYI0rRRoYK8Y64bNFEhJOJT+z+UkS1R1V08QwRWCvzQs6wyIRsg 286YGrLye2XjU/ekMrJIKuOsLeZhpn+3Mj8TjZHACigprbLUxgeVtTHsWwxxxB0gsRfj 2gttRszTZRq46yZQXgCkZ/OsQsc9IJ9Kzh3z4efPUM7XZqsoDM8z3Rq3MNBQaG7F3I8B ycOqwBEsG+Mu6zpnMI/eCLCrnrA/cbkj3MDk3vJm1vidO4OrNg+0033Gbuv8DWyaaESp qb1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722523768; x=1723128568; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DWKzig5pf01PlSBu3e8F4D6XxwfVIYNrVD3oMGmQhEE=; b=g7V1YiYSHRzOouT0tFjJ2Aetoadf9pHi1uL1hkJOQo7Oo/kq0YdFWpRq2lffqsVFbf Sk5PjoQQ18AtS9jiiQbXeSGjeGMe35/S78u+lQR0xOKukPIeLzrw4cd+WO2Fggci8Bs5 nHQGFyyU1C0YeotXznsRZ3jOtcnNDayp3OvIyFpCN0Xh6p8xjCUXp3PGukonv6yUHlK8 R5sHlJRp7oH+D2MtRLdfBcGWmy2LshqC5F1chGIlhp/LANPApN3JV+VaDv3Ycj2hkIq7 3/1uL3sBeyWLyivxwxmWGUVV/5bS5F3ehu/wANh6djzf3jwQTfpgkSCddqG56fomPjo/ DCyg== X-Gm-Message-State: AOJu0Yx1vTY+oocjgZ81atIcl37UnWkB8kzuwgdZbpvx12JndMVZvtkH QAaHrNSiIhBSfuxcmSBJEZowBE/KGBU9g4awNmYP2XdfqSWxOzJsnpG6zw== X-Google-Smtp-Source: AGHT+IGNEtN/Uvy7KS07RKJ9TMqfgT6QHlOi7d5EA7zpWjlOhgFTsDyw0EUt0IDXKbPiaWjSncLu5Q== X-Received: by 2002:a05:6a20:a11f:b0:1c4:944c:41e2 with SMTP id adf61e73a8af0-1c699683bdbmr679907637.51.1722523768177; Thu, 01 Aug 2024 07:49:28 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cfdc4064e4sm3477681a91.9.2024.08.01.07.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:49:27 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: Hardware Monitoring Cc: Guenter Roeck Subject: [PATCH 3/6] hwmon: (lm92) Replace chip IDs with limit register resolution Date: Thu, 1 Aug 2024 07:49:15 -0700 Message-Id: <20240801144918.6156-4-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801144918.6156-1-linux@roeck-us.net> References: <20240801144918.6156-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The chip IDs are not used by the driver. Drop them. Use driver data to store the limit register resolution instead, and use this information when writing temperature limits to improve chip specific rounding and to avoid writing into unused register bits. Signed-off-by: Guenter Roeck Reviewed-by: Tzung-Bi Shih --- drivers/hwmon/lm92.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index b0179d72b779..5ff45a0033f1 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -43,8 +43,6 @@ */ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END }; -enum chips { lm92, max6635 }; - /* The LM92 registers */ #define LM92_REG_CONFIG 0x01 /* 8-bit, RW */ #define LM92_REG_TEMP 0x00 /* 16-bit, RO */ @@ -66,10 +64,10 @@ static inline int TEMP_FROM_REG(s16 reg) return reg / 8 * 625 / 10; } -static inline s16 TEMP_TO_REG(long val) +static inline s16 TEMP_TO_REG(long val, int resolution) { val = clamp_val(val, -60000, 160000); - return val * 10 / 625 * 8; + return DIV_ROUND_CLOSEST(val << (resolution - 9), 1000) << (16 - resolution); } /* Alarm flags are stored in the 3 LSB of the temperature register */ @@ -99,6 +97,7 @@ static const u8 regs[t_num_regs] = { struct lm92_data { struct i2c_client *client; struct mutex update_lock; + int resolution; bool valid; /* false until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -159,7 +158,7 @@ static ssize_t temp_store(struct device *dev, return err; mutex_lock(&data->update_lock); - data->temp[nr] = TEMP_TO_REG(val); + data->temp[nr] = TEMP_TO_REG(val, data->resolution); i2c_smbus_write_word_swapped(client, regs[nr], data->temp[nr]); mutex_unlock(&data->update_lock); return count; @@ -201,7 +200,8 @@ static ssize_t temp_hyst_store(struct device *dev, val = clamp_val(val, -120000, 220000); mutex_lock(&data->update_lock); data->temp[t_hyst] = - TEMP_TO_REG(TEMP_FROM_REG(data->temp[attr->index]) - val); + TEMP_TO_REG(TEMP_FROM_REG(data->temp[attr->index]) - val, + data->resolution); i2c_smbus_write_word_swapped(client, LM92_REG_TEMP_HYST, data->temp[t_hyst]); mutex_unlock(&data->update_lock); @@ -311,6 +311,7 @@ static int lm92_probe(struct i2c_client *new_client) return -ENOMEM; data->client = new_client; + data->resolution = (unsigned long)i2c_get_match_data(new_client); mutex_init(&data->update_lock); /* Initialize the chipset */ @@ -326,9 +327,10 @@ static int lm92_probe(struct i2c_client *new_client) * Module and driver stuff */ +/* .driver_data is limit register resolution */ static const struct i2c_device_id lm92_id[] = { - { "lm92", lm92 }, - { "max6635", max6635 }, + { "lm92", 13 }, + { "max6635", 9 }, { } }; MODULE_DEVICE_TABLE(i2c, lm92_id); From patchwork Thu Aug 1 14:49:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13750613 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B1811A6177 for ; Thu, 1 Aug 2024 14:49:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523773; cv=none; b=cl/ZgoBV/TGGxrALSc12lKyZdYdFz3ctByL0SEBb9fFmEoLaXC1/dwWp6fBg6ZYFfmBKVVkMSC3+mmJ5404h61wlVvFf1kY1VfnB6+V+WshEKYWc0KlUzweSWFUGz0VKbDsLcadQO4v1JmlcTtVKlEpnX4cXfC+UvsHunMjrB9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523773; c=relaxed/simple; bh=hEU4t3zpJFqT+gHtfdmiDePTKORzXQ44Jt5Q2vY9Ci4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YDNIowSnQ6dEs6zGGzp5tOaqONcL7VWbIkxOV6/N9M7rqBpaJKTtfK3cjx7MDtPsyGR9/AgD3Fck+gXcAeOo+5kjErh6iJRZ36c8Wk6k5l3Nl3xVRX8TH87e8pFK4YCYVIH9zh/b5LAOB+LDwWcyAFADXRsnFQglCyWmtBiGNnY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=L8nE0lVM; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L8nE0lVM" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7104f939aaaso1676921b3a.1 for ; Thu, 01 Aug 2024 07:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722523770; x=1723128570; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=zv0TrArq45XgZYbIuFpB/lId/LqjjjZ2YXVdYkvEPdw=; b=L8nE0lVMj+hITZ1eFYQ8zrTvwwdG8vkPdkXiwad73cw7Il6MTcFxU9Q+K/x6pQLsc6 wJ+8l9byPiUrYDPgBe2JKpjiYGTz0PAu8P12z1ive2BU6JJlTSBwclm5dH48ijEYPTMg ne9rtOt/vjEGT9QREXnbP0kGI01JgCqLfFvduCU3ZBDi3RdhRGsoJk+r891SAeCOFWXV Gbsbc+RQQgAhd1ShVeoxuk9NJbDoLObmv2vT5HQH0ashfpZEILjWfxZF67QYaN8Zvf6b 9hF7JyMlMU9AQ/hunWVQRBwWuzJIf3HG6JQpb4oUDXEuIIYMlHRdd89Jp57hdVymzfez 5XXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722523770; x=1723128570; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=zv0TrArq45XgZYbIuFpB/lId/LqjjjZ2YXVdYkvEPdw=; b=WbabTvZ9zJczIcAxyPZZnF5kgCMCGNMt41joMNnydL7cwuHkgS4RN7lEryaSwkZCak gV5TL8Ssk9fxaVM9n2gDuR2KMfCXJBy6wI0CiIdM5MIpdQqpnR2zW+YFknmNM3nLlRRQ mn30QzstdFTbqoaz0mq7yDmzJf4zaZ9q2EUSEZR7+cSj1P44aR5/kXoWRhtoBDXnkJiC xUivfwnM8M2Qu6Dzvcq7Lo+MWbwdbskcE4y08j1vyc1ZN+awPkD+4+nczJVO22wYlTF2 gum9WVx4go8Lq+Pzocr/lZWC4xjV1N9ReNiruZ5y7I5WpvUZBAOiWUANC3D8JEANabUA Grtw== X-Gm-Message-State: AOJu0Yw+jIcMuMTxDsKJXQttI0sOe5zHfCvbIlfHoCiU05NnbhOXkpHb 2gIPzwl8cGMAh1KZeYHzh7oq+/7FrpYKXIf0Lg6N0VE3IMj2PUIP2U3d0A== X-Google-Smtp-Source: AGHT+IGlicqg5A9vtrePSmoA/l7BssapU3fOMqpSfyVBTdDkBSfLrWCtyJLVnOu+AQKxTz1LwD8PTA== X-Received: by 2002:a05:6a20:12c1:b0:1bd:260e:be97 with SMTP id adf61e73a8af0-1c69966bad5mr542105637.53.1722523770140; Thu, 01 Aug 2024 07:49:30 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72b89csm11935057b3a.94.2024.08.01.07.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:49:29 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: Hardware Monitoring Cc: Guenter Roeck Subject: [PATCH 4/6] hwmon: (lm92) Convert to use regmap Date: Thu, 1 Aug 2024 07:49:16 -0700 Message-Id: <20240801144918.6156-5-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801144918.6156-1-linux@roeck-us.net> References: <20240801144918.6156-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use regmap for local caching and for multi-byte operations to be able to use regmap API functions and to reduce the need for locking in the driver. Signed-off-by: Guenter Roeck Reviewed-by: Tzung-Bi Shih --- drivers/hwmon/Kconfig | 1 + drivers/hwmon/lm92.c | 204 +++++++++++++++++++++++++++--------------- 2 files changed, 131 insertions(+), 74 deletions(-) diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index b60fe2e58ad6..b2ace4857130 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1511,6 +1511,7 @@ config SENSORS_LM90 config SENSORS_LM92 tristate "National Semiconductor LM92 and compatibles" depends on I2C + select REGMAP_I2C help If you say yes here you get support for National Semiconductor LM92 and Maxim MAX6635 sensor chips. diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 5ff45a0033f1..89befc7f59a5 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -32,9 +32,9 @@ #include #include #include -#include #include #include +#include #include /* @@ -81,65 +81,40 @@ enum temp_index { t_crit, t_min, t_max, - t_hyst, t_num_regs }; -static const u8 regs[t_num_regs] = { +static const u8 lm92_regs[t_num_regs] = { [t_input] = LM92_REG_TEMP, [t_crit] = LM92_REG_TEMP_CRIT, [t_min] = LM92_REG_TEMP_LOW, [t_max] = LM92_REG_TEMP_HIGH, - [t_hyst] = LM92_REG_TEMP_HYST, }; /* Client data (each client gets its own) */ struct lm92_data { - struct i2c_client *client; + struct regmap *regmap; struct mutex update_lock; int resolution; - bool valid; /* false until following fields are valid */ - unsigned long last_updated; /* in jiffies */ - - /* registers values */ - s16 temp[t_num_regs]; /* index with enum temp_index */ }; /* * Sysfs attributes and callback functions */ -static struct lm92_data *lm92_update_device(struct device *dev) -{ - struct lm92_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->client; - int i; - - mutex_lock(&data->update_lock); - - if (time_after(jiffies, data->last_updated + HZ) || - !data->valid) { - dev_dbg(&client->dev, "Updating lm92 data\n"); - for (i = 0; i < t_num_regs; i++) { - data->temp[i] = - i2c_smbus_read_word_swapped(client, regs[i]); - } - data->last_updated = jiffies; - data->valid = true; - } - - mutex_unlock(&data->update_lock); - - return data; -} - static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct lm92_data *data = lm92_update_device(dev); + struct lm92_data *data = dev_get_drvdata(dev); + u32 temp; + int err; - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); + err = regmap_read(data->regmap, lm92_regs[attr->index], &temp); + if (err) + return err; + + return sprintf(buf, "%d\n", TEMP_FROM_REG(temp)); } static ssize_t temp_store(struct device *dev, @@ -148,7 +123,7 @@ static ssize_t temp_store(struct device *dev, { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct lm92_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->client; + struct regmap *regmap = data->regmap; int nr = attr->index; long val; int err; @@ -157,10 +132,9 @@ static ssize_t temp_store(struct device *dev, if (err) return err; - mutex_lock(&data->update_lock); - data->temp[nr] = TEMP_TO_REG(val, data->resolution); - i2c_smbus_write_word_swapped(client, regs[nr], data->temp[nr]); - mutex_unlock(&data->update_lock); + err = regmap_write(regmap, lm92_regs[nr], TEMP_TO_REG(val, data->resolution)); + if (err) + return err; return count; } @@ -168,28 +142,42 @@ static ssize_t temp_hyst_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct lm92_data *data = lm92_update_device(dev); + u32 regs[2] = { lm92_regs[attr->index], LM92_REG_TEMP_HYST }; + struct lm92_data *data = dev_get_drvdata(dev); + u16 regvals[2]; + int err; - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index]) - - TEMP_FROM_REG(data->temp[t_hyst])); + err = regmap_multi_reg_read(data->regmap, regs, regvals, 2); + if (err) + return err; + + return sprintf(buf, "%d\n", + TEMP_FROM_REG(regvals[0]) - TEMP_FROM_REG(regvals[1])); } static ssize_t temp1_min_hyst_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct lm92_data *data = lm92_update_device(dev); + static u32 regs[2] = { LM92_REG_TEMP_LOW, LM92_REG_TEMP_HYST }; + struct lm92_data *data = dev_get_drvdata(dev); + u16 regvals[2]; + int err; - return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[t_min]) - + TEMP_FROM_REG(data->temp[t_hyst])); + err = regmap_multi_reg_read(data->regmap, regs, regvals, 2); + if (err) + return err; + + return sprintf(buf, "%d\n", + TEMP_FROM_REG(regvals[0]) + TEMP_FROM_REG(regvals[1])); } static ssize_t temp_hyst_store(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct lm92_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->client; + struct regmap *regmap = data->regmap; + u32 temp; long val; int err; @@ -199,29 +187,45 @@ static ssize_t temp_hyst_store(struct device *dev, val = clamp_val(val, -120000, 220000); mutex_lock(&data->update_lock); - data->temp[t_hyst] = - TEMP_TO_REG(TEMP_FROM_REG(data->temp[attr->index]) - val, - data->resolution); - i2c_smbus_write_word_swapped(client, LM92_REG_TEMP_HYST, - data->temp[t_hyst]); + err = regmap_read(regmap, LM92_REG_TEMP_CRIT, &temp); + if (err) + goto unlock; + val = TEMP_TO_REG(TEMP_FROM_REG(temp) - val, data->resolution); + err = regmap_write(regmap, LM92_REG_TEMP_HYST, val); +unlock: mutex_unlock(&data->update_lock); + if (err) + return err; return count; } static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct lm92_data *data = lm92_update_device(dev); + struct lm92_data *data = dev_get_drvdata(dev); + u32 temp; + int err; - return sprintf(buf, "%d\n", ALARMS_FROM_REG(data->temp[t_input])); + err = regmap_read(data->regmap, LM92_REG_TEMP, &temp); + if (err) + return err; + + return sprintf(buf, "%d\n", ALARMS_FROM_REG(temp)); } static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, char *buf) { + struct lm92_data *data = dev_get_drvdata(dev); int bitnr = to_sensor_dev_attr(attr)->index; - struct lm92_data *data = lm92_update_device(dev); - return sprintf(buf, "%d\n", (data->temp[t_input] >> bitnr) & 1); + u32 temp; + int err; + + err = regmap_read(data->regmap, LM92_REG_TEMP, &temp); + if (err) + return err; + + return sprintf(buf, "%d\n", (temp >> bitnr) & 1); } static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, t_input); @@ -240,15 +244,9 @@ static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 1); * Detection and registration */ -static void lm92_init_client(struct i2c_client *client) +static int lm92_init_client(struct regmap *regmap) { - u8 config; - - /* Start the conversions if needed */ - config = i2c_smbus_read_byte_data(client, LM92_REG_CONFIG); - if (config & 0x01) - i2c_smbus_write_byte_data(client, LM92_REG_CONFIG, - config & 0xFE); + return regmap_clear_bits(regmap, LM92_REG_CONFIG, 0x01); } static struct attribute *lm92_attrs[] = { @@ -300,25 +298,83 @@ static int lm92_detect(struct i2c_client *new_client, return 0; } -static int lm92_probe(struct i2c_client *new_client) +/* regmap */ + +static int lm92_reg_read(void *context, unsigned int reg, unsigned int *val) { + int ret; + + if (reg == LM92_REG_CONFIG) + ret = i2c_smbus_read_byte_data(context, reg); + else + ret = i2c_smbus_read_word_swapped(context, reg); + if (ret < 0) + return ret; + + *val = ret; + return 0; +} + +static int lm92_reg_write(void *context, unsigned int reg, unsigned int val) +{ + if (reg == LM92_REG_CONFIG) + return i2c_smbus_write_byte_data(context, LM92_REG_CONFIG, val); + + return i2c_smbus_write_word_swapped(context, reg, val); +} + +static bool lm92_regmap_is_volatile(struct device *dev, unsigned int reg) +{ + return reg == LM92_REG_TEMP; +} + +static bool lm92_regmap_is_writeable(struct device *dev, unsigned int reg) +{ + return reg >= LM92_REG_CONFIG; +} + +static const struct regmap_config lm92_regmap_config = { + .reg_bits = 8, + .val_bits = 16, + .max_register = LM92_REG_TEMP_HIGH, + .cache_type = REGCACHE_MAPLE, + .volatile_reg = lm92_regmap_is_volatile, + .writeable_reg = lm92_regmap_is_writeable, +}; + +static const struct regmap_bus lm92_regmap_bus = { + .reg_write = lm92_reg_write, + .reg_read = lm92_reg_read, +}; + +static int lm92_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; struct device *hwmon_dev; struct lm92_data *data; + struct regmap *regmap; + int err; - data = devm_kzalloc(&new_client->dev, sizeof(struct lm92_data), - GFP_KERNEL); + regmap = devm_regmap_init(dev, &lm92_regmap_bus, client, + &lm92_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + data = devm_kzalloc(dev, sizeof(struct lm92_data), GFP_KERNEL); if (!data) return -ENOMEM; - data->client = new_client; - data->resolution = (unsigned long)i2c_get_match_data(new_client); + data->regmap = regmap; + data->resolution = (unsigned long)i2c_get_match_data(client); mutex_init(&data->update_lock); /* Initialize the chipset */ - lm92_init_client(new_client); + err = lm92_init_client(regmap); + if (err) + return err; - hwmon_dev = devm_hwmon_device_register_with_groups(&new_client->dev, - new_client->name, + hwmon_dev = devm_hwmon_device_register_with_groups(dev, + client->name, data, lm92_groups); return PTR_ERR_OR_ZERO(hwmon_dev); } From patchwork Thu Aug 1 14:49:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13750614 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BDB61A7203 for ; Thu, 1 Aug 2024 14:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523775; cv=none; b=YJLvDonYeEDADF1SZyVKXCkHQrqTHpqFYF6++T+YWLzjaKHZ9tzNqbBax3Nl+jeYCh1vL1vf0XQfKBQVXJg7RiYyWIAghh+6ztFu4tt5AKhpGI03FFz/4GcBIXonxSCd5svMKQTyokJxlVza4ctczKd4N3SLfXIturfpH1P0RXM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523775; c=relaxed/simple; bh=FkC0wNVPzGGr+GND3CmMRL+x9WIm1VA8XL1Osp14SYo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eZqEe1AynzmoSvMsJzY8EPVhk75N11+B84cYabycHWZ5ykLbQ2Q6psV1P8n9XsGc74qcKJVZWP5otHhk1He6MQG4NERdj5RUYag7e3bqWHwlg7Nc5J2+zgHOnYrIncaxTuh8JFtUAsad8+oCh0AcCpi8ARwMgqowifuz+hx72ZE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XWvs5r03; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XWvs5r03" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1ff4fa918afso5965395ad.1 for ; Thu, 01 Aug 2024 07:49:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722523772; x=1723128572; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Q44f3rAhana6df4QRKvQQHrENJNEMANcfFhXIOj5R8s=; b=XWvs5r03zXAEEs4tj6nZ3BzJfxmwAAE634yPxrUVOEB9M5s4TUMQyR4K5NS/XwxcZ9 uBb6ewoGvkkqWIJugEVBuKXtf0TrjmppSmMcAe+bSPGtaLwY5bEz2+t+2/8G2NlAMTje lCnGgSQ4HAKbxR+zhSR492UacHwBjQQIArukPFnMIeUe2Z9/kFplhxIehw3MWCLPU0FO yeor7Gy/f5zKIaE7aFsa5ARQlnsnTKsESS0JAchzMI95ewJSkNTnnkI4n8boeQ+9rN4m d7+AYqbp2S7BkHaZlkhsx9c/gSBpSadme/X03VTc03lqM3mQO7hrasRM1Fns45HF4Rvz 5eLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722523772; x=1723128572; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Q44f3rAhana6df4QRKvQQHrENJNEMANcfFhXIOj5R8s=; b=uPVdS6dj7brmuT34YweUprehBp7f4I9GKGJ3/+F/5v1QP5Jc21oggz8i9gUq+LaPx5 LlZLQVLLBwUdCBi3ZFlyIX0mi/psfLwbJRDicvqTeRJfeTxjZQrd2P9xgglZF2Nj4jtm GDNLnNF+rtv3zLlm1Ltl2yiZqWvjlRfIkYFc3yPDFORcdIdC51VUGtnOH6FQNjGfwrIk C/dTklkZNYklBjM/baNIYetmDTyTThfgHcwRf80ekpNlX8SDJm1VkDW9c75SQ6+FI0Cl nOwPmVzSRbt4vacArW+dswL1WwjMcy0nTJhagboaAj/ijgueff7fGRSI5BqJ/SDcxqOP yCfg== X-Gm-Message-State: AOJu0YyQV7R80S0YGuX0e6nU445/RVwfTYdteVkEpbhznd+omqDPE7RL a/fqa4GcVITmt26Slri/s6YsH83fJfugJ220OB4Go0Fjl/efAsq1y5aj1A== X-Google-Smtp-Source: AGHT+IElNH2RE6oTeUIH3UxWY5KSyHWRYX5N7JRLnq3TvtcGgN32EeAyb/FffnCEVxtbvKZrbNK+Xw== X-Received: by 2002:a17:903:24f:b0:1fa:8f64:8afd with SMTP id d9443c01a7336-1ff5722eb62mr5819695ad.11.1722523771927; Thu, 01 Aug 2024 07:49:31 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f1ae9dsm139929055ad.188.2024.08.01.07.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:49:31 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: Hardware Monitoring Cc: Guenter Roeck Subject: [PATCH 5/6] hwmon: (lm92) Convert to with_info hwmon API Date: Thu, 1 Aug 2024 07:49:17 -0700 Message-Id: <20240801144918.6156-6-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801144918.6156-1-linux@roeck-us.net> References: <20240801144918.6156-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert driver to with_info hwmon API to simplify the code and to reduce its size. No functional change. Signed-off-by: Guenter Roeck Reviewed-by: Tzung-Bi Shih --- drivers/hwmon/lm92.c | 347 +++++++++++++++++++++++-------------------- 1 file changed, 188 insertions(+), 159 deletions(-) diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 89befc7f59a5..0be439b38ee1 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -76,21 +75,6 @@ static inline u8 ALARMS_FROM_REG(s16 reg) return reg & 0x0007; } -enum temp_index { - t_input, - t_crit, - t_min, - t_max, - t_num_regs -}; - -static const u8 lm92_regs[t_num_regs] = { - [t_input] = LM92_REG_TEMP, - [t_crit] = LM92_REG_TEMP_CRIT, - [t_min] = LM92_REG_TEMP_LOW, - [t_max] = LM92_REG_TEMP_HIGH, -}; - /* Client data (each client gets its own) */ struct lm92_data { struct regmap *regmap; @@ -98,147 +82,209 @@ struct lm92_data { int resolution; }; -/* - * Sysfs attributes and callback functions - */ - -static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, - char *buf) +static int lm92_temp_read(struct lm92_data *data, u32 attr, int channel, long *val) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct lm92_data *data = dev_get_drvdata(dev); - u32 temp; - int err; - - err = regmap_read(data->regmap, lm92_regs[attr->index], &temp); - if (err) - return err; - - return sprintf(buf, "%d\n", TEMP_FROM_REG(temp)); -} - -static ssize_t temp_store(struct device *dev, - struct device_attribute *devattr, const char *buf, - size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct lm92_data *data = dev_get_drvdata(dev); - struct regmap *regmap = data->regmap; - int nr = attr->index; - long val; - int err; - - err = kstrtol(buf, 10, &val); - if (err) - return err; - - err = regmap_write(regmap, lm92_regs[nr], TEMP_TO_REG(val, data->resolution)); - if (err) - return err; - return count; -} - -static ssize_t temp_hyst_show(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - u32 regs[2] = { lm92_regs[attr->index], LM92_REG_TEMP_HYST }; - struct lm92_data *data = dev_get_drvdata(dev); - u16 regvals[2]; - int err; - - err = regmap_multi_reg_read(data->regmap, regs, regvals, 2); - if (err) - return err; - - return sprintf(buf, "%d\n", - TEMP_FROM_REG(regvals[0]) - TEMP_FROM_REG(regvals[1])); -} - -static ssize_t temp1_min_hyst_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - static u32 regs[2] = { LM92_REG_TEMP_LOW, LM92_REG_TEMP_HYST }; - struct lm92_data *data = dev_get_drvdata(dev); - u16 regvals[2]; - int err; - - err = regmap_multi_reg_read(data->regmap, regs, regvals, 2); - if (err) - return err; - - return sprintf(buf, "%d\n", - TEMP_FROM_REG(regvals[0]) + TEMP_FROM_REG(regvals[1])); -} - -static ssize_t temp_hyst_store(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - struct lm92_data *data = dev_get_drvdata(dev); + int reg = -1, hyst_reg = -1, alarm_bit = 0; struct regmap *regmap = data->regmap; u32 temp; - long val; - int err; + int ret; - err = kstrtol(buf, 10, &val); - if (err) - return err; + switch (attr) { + case hwmon_temp_input: + reg = LM92_REG_TEMP; + break; + case hwmon_temp_min: + reg = LM92_REG_TEMP_LOW; + break; + case hwmon_temp_max: + reg = LM92_REG_TEMP_HIGH; + break; + case hwmon_temp_crit: + reg = LM92_REG_TEMP_CRIT; + break; + case hwmon_temp_min_hyst: + hyst_reg = LM92_REG_TEMP_LOW; + break; + case hwmon_temp_max_hyst: + hyst_reg = LM92_REG_TEMP_HIGH; + break; + case hwmon_temp_crit_hyst: + hyst_reg = LM92_REG_TEMP_CRIT; + break; + case hwmon_temp_min_alarm: + alarm_bit = 0; + break; + case hwmon_temp_max_alarm: + alarm_bit = 1; + break; + case hwmon_temp_crit_alarm: + alarm_bit = 2; + break; + default: + return -EOPNOTSUPP; + } + if (reg >= 0) { + ret = regmap_read(regmap, reg, &temp); + if (ret < 0) + return ret; + *val = TEMP_FROM_REG(temp); + } else if (hyst_reg >= 0) { + u32 regs[2] = { hyst_reg, LM92_REG_TEMP_HYST }; + u16 regvals[2]; - val = clamp_val(val, -120000, 220000); - mutex_lock(&data->update_lock); - err = regmap_read(regmap, LM92_REG_TEMP_CRIT, &temp); - if (err) - goto unlock; - val = TEMP_TO_REG(TEMP_FROM_REG(temp) - val, data->resolution); - err = regmap_write(regmap, LM92_REG_TEMP_HYST, val); + ret = regmap_multi_reg_read(regmap, regs, regvals, 2); + if (ret) + return ret; + if (attr == hwmon_temp_min_hyst) + *val = TEMP_FROM_REG(regvals[0]) + TEMP_FROM_REG(regvals[1]); + else + *val = TEMP_FROM_REG(regvals[0]) - TEMP_FROM_REG(regvals[1]); + } else { + ret = regmap_read(regmap, LM92_REG_TEMP, &temp); + if (ret) + return ret; + *val = !!(temp & BIT(alarm_bit)); + } + return 0; +} + +static int lm92_chip_read(struct lm92_data *data, u32 attr, long *val) +{ + u32 temp; + int ret; + + switch (attr) { + case hwmon_chip_alarms: + ret = regmap_read(data->regmap, LM92_REG_TEMP, &temp); + if (ret) + return ret; + *val = ALARMS_FROM_REG(temp); + break; + default: + return -EOPNOTSUPP; + } + return 0; +} + +static int lm92_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, + int channel, long *val) +{ + struct lm92_data *data = dev_get_drvdata(dev); + + switch (type) { + case hwmon_chip: + return lm92_chip_read(data, attr, val); + case hwmon_temp: + return lm92_temp_read(data, attr, channel, val); + default: + return -EOPNOTSUPP; + } +} + +static int lm92_temp_write(struct lm92_data *data, u32 attr, long val) +{ + struct regmap *regmap = data->regmap; + int reg, err; + u32 temp; + + switch (attr) { + case hwmon_temp_min: + reg = LM92_REG_TEMP_LOW; + break; + case hwmon_temp_max: + reg = LM92_REG_TEMP_HIGH; + break; + case hwmon_temp_crit: + reg = LM92_REG_TEMP_CRIT; + break; + case hwmon_temp_crit_hyst: + val = clamp_val(val, -120000, 220000); + mutex_lock(&data->update_lock); + err = regmap_read(regmap, LM92_REG_TEMP_CRIT, &temp); + if (err) + goto unlock; + val = TEMP_TO_REG(TEMP_FROM_REG(temp) - val, data->resolution); + err = regmap_write(regmap, LM92_REG_TEMP_HYST, val); unlock: - mutex_unlock(&data->update_lock); - if (err) + mutex_unlock(&data->update_lock); return err; - return count; + default: + return -EOPNOTSUPP; + } + return regmap_write(regmap, reg, TEMP_TO_REG(val, data->resolution)); } -static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, - char *buf) +static int lm92_write(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long val) { struct lm92_data *data = dev_get_drvdata(dev); - u32 temp; - int err; - err = regmap_read(data->regmap, LM92_REG_TEMP, &temp); - if (err) - return err; - - return sprintf(buf, "%d\n", ALARMS_FROM_REG(temp)); + switch (type) { + case hwmon_temp: + return lm92_temp_write(data, attr, val); + default: + return -EOPNOTSUPP; + } } -static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, - char *buf) +static umode_t lm92_is_visible(const void *_data, enum hwmon_sensor_types type, + u32 attr, int channel) { - struct lm92_data *data = dev_get_drvdata(dev); - int bitnr = to_sensor_dev_attr(attr)->index; - u32 temp; - int err; - - err = regmap_read(data->regmap, LM92_REG_TEMP, &temp); - if (err) - return err; - - return sprintf(buf, "%d\n", (temp >> bitnr) & 1); + switch (type) { + case hwmon_chip: + switch (attr) { + case hwmon_chip_alarms: + return 0444; + default: + break; + } + break; + case hwmon_temp: + switch (attr) { + case hwmon_temp_min: + case hwmon_temp_max: + case hwmon_temp_crit: + case hwmon_temp_crit_hyst: + return 0644; + case hwmon_temp_input: + case hwmon_temp_min_hyst: + case hwmon_temp_max_hyst: + case hwmon_temp_min_alarm: + case hwmon_temp_max_alarm: + case hwmon_temp_crit_alarm: + return 0444; + default: + break; + } + break; + default: + break; + } + return 0; } -static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, t_input); -static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp, t_crit); -static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, temp_hyst, t_crit); -static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, t_min); -static DEVICE_ATTR_RO(temp1_min_hyst); -static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, t_max); -static SENSOR_DEVICE_ATTR_RO(temp1_max_hyst, temp_hyst, t_max); -static DEVICE_ATTR_RO(alarms); -static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 2); -static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 0); -static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 1); +static const struct hwmon_channel_info * const lm92_info[] = { + HWMON_CHANNEL_INFO(chip, HWMON_C_ALARMS), + HWMON_CHANNEL_INFO(temp, + HWMON_T_INPUT | + HWMON_T_MIN | HWMON_T_MIN_HYST | + HWMON_T_MAX | HWMON_T_MAX_HYST | + HWMON_T_CRIT | HWMON_T_CRIT_HYST | + HWMON_T_MIN_ALARM | HWMON_T_MAX_ALARM | + HWMON_T_CRIT_ALARM), + NULL +}; + +static const struct hwmon_ops lm92_hwmon_ops = { + .is_visible = lm92_is_visible, + .read = lm92_read, + .write = lm92_write, +}; + +static const struct hwmon_chip_info lm92_chip_info = { + .ops = &lm92_hwmon_ops, + .info = lm92_info, +}; /* * Detection and registration @@ -249,22 +295,6 @@ static int lm92_init_client(struct regmap *regmap) return regmap_clear_bits(regmap, LM92_REG_CONFIG, 0x01); } -static struct attribute *lm92_attrs[] = { - &sensor_dev_attr_temp1_input.dev_attr.attr, - &sensor_dev_attr_temp1_crit.dev_attr.attr, - &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, - &sensor_dev_attr_temp1_min.dev_attr.attr, - &dev_attr_temp1_min_hyst.attr, - &sensor_dev_attr_temp1_max.dev_attr.attr, - &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, - &dev_attr_alarms.attr, - &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, - &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, - &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, - NULL -}; -ATTRIBUTE_GROUPS(lm92); - /* Return 0 if detection is successful, -ENODEV otherwise */ static int lm92_detect(struct i2c_client *new_client, struct i2c_board_info *info) @@ -373,9 +403,8 @@ static int lm92_probe(struct i2c_client *client) if (err) return err; - hwmon_dev = devm_hwmon_device_register_with_groups(dev, - client->name, - data, lm92_groups); + hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, data, + &lm92_chip_info, NULL); return PTR_ERR_OR_ZERO(hwmon_dev); } From patchwork Thu Aug 1 14:49:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13750615 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 394291A617F for ; Thu, 1 Aug 2024 14:49:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523776; cv=none; b=Qi/SWc/Fyv2XpQ3jY/29SAZq7qRaEIMELGd3cPk17B7wjPKeC4qm5VOOddg0jhi4cHkicZTh9seuFo8vihchVOkmxTzfozhUmUR+wD516GyeC9hdEouePFbgX5yjdpqXvdN3JhaeoCqAmaaFaU03JnovRC6qFYAumdp9ARPal0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722523776; c=relaxed/simple; bh=JH5lYA7VqCTKZ3DK03YwyhZf0ymRT4+TdtYv8tuo1Vs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z0vjYxtaMgjy60C/NgCVZXxko91LDb0VZ35RMciiH75u6oJw6Y9Qlz/lfchR/s1nLHh7n+k6ECzRIEdjTtOqg6i5R2Wgg/HWxp8AddKVGBY7bpPDoPoH7Ew2ho/ZbMIZPsGCuEYC3x0TeE9Tc8GqBBpGnVfLvo4iYxplfdza9xw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fYpUPeN7; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fYpUPeN7" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-70d1fb6c108so5164981b3a.3 for ; Thu, 01 Aug 2024 07:49:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722523774; x=1723128574; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=MuytEM3n0tgnd9qbXK4VEid7SLNyto6RStRQXDeGveY=; b=fYpUPeN7WCWLAV7J6lHwV0RToT1EKTWeXauVSbfwg4oG0bhRnVX/0g2NN9zD1ohqD6 Ca0LvKeMxdbTqLJj7LLJexbbKWO35wb5hnOQ5jXngQ/6pczKem2fpAbrs0TqUu6j/w+s w71V0UvXA/CqX3JN5GTv0EsG+gsoUhGOOe8inzk6mXjKtVsjCE4HStNpJUO8eerNGO5M /81f3YVQX/Lfyh7xrUlGjfOxzvAZmqPACzns1SMcurF+zk1aCG8JllqioClC9VphOXJY IjpnOrb5v8WGUAveHuNjIoQcmaoB2se63wk8LGHHZnuhumsd9dQDOm4CahvLPA215J6p KihQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722523774; x=1723128574; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MuytEM3n0tgnd9qbXK4VEid7SLNyto6RStRQXDeGveY=; b=NKqNdl4ACnuJx7PRHzGgrX+WQoQz1dY1/l1fO8NTl0oPAoVnAGC+G0DzfjqTGxTNMw NCLomENvrhGx5P3m3QYfwrrMMMG+Ocim2we5Br8JjuupsOX0Dv+AJ+7/uv0rR91Ema4X W8VrMhGTLEKip7flb1RpyKVgAfudO4lOjoJysZDCQPb2yRi9HsaAYmJtSeIdaCo2XlYK Z7SXYc9i1XiBcvoGr9ycXXreVtnuK8ukBHcqJVtaB4TUjg3dohJWSHhPCHft9izmd9tb LKSK4xkasx4N7nNJxQMGC3Z7Xu04baII46E1DWjuejmcpx1+oTKbbrTMQMbSkcVpZYPr qIYw== X-Gm-Message-State: AOJu0YykgYfyzTyCEVz2Yj9wVPV4Le9LEiJuBsXezJCjciY7yiTe7prR qekfeRtSnSXwjNsVOFPy3zYzbIUyyh9mZCMMvAIQctAq4+RXG6y+rPYY/Q== X-Google-Smtp-Source: AGHT+IF0udbaolj31iVADJnZu5xGJFrvXVzl/nLqJlPIdzhqFBUTGzwv30PTr3/fsqBR+xoqMyXLWw== X-Received: by 2002:a05:6a00:3d56:b0:710:66ca:5e83 with SMTP id d2e1a72fcca58-7106cfa1e9emr568883b3a.5.1722523773843; Thu, 01 Aug 2024 07:49:33 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70ead72b7easm11624556b3a.89.2024.08.01.07.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:49:33 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: Hardware Monitoring Cc: Guenter Roeck Subject: [PATCH 6/6] hwmon: (lm92) Update documentation Date: Thu, 1 Aug 2024 07:49:18 -0700 Message-Id: <20240801144918.6156-7-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801144918.6156-1-linux@roeck-us.net> References: <20240801144918.6156-1-linux@roeck-us.net> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Update datasheet references. Replace misleading 'force parameter needed' with 'must be instantiated explicitly'. Explain the reason for the missing auto-detection. Mention all supported chips in Kconfig. Signed-off-by: Guenter Roeck Reviewed-by: Tzung-Bi Shih --- Documentation/hwmon/lm92.rst | 26 +++++++++++++------------- drivers/hwmon/Kconfig | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Documentation/hwmon/lm92.rst b/Documentation/hwmon/lm92.rst index c131b923ed36..d71cdb2af339 100644 --- a/Documentation/hwmon/lm92.rst +++ b/Documentation/hwmon/lm92.rst @@ -3,29 +3,29 @@ Kernel driver lm92 Supported chips: - * National Semiconductor LM92 + * National Semiconductor / Texas Instruments LM92 Prefix: 'lm92' Addresses scanned: I2C 0x48 - 0x4b - Datasheet: http://www.national.com/pf/LM/LM92.html + Datasheet: https://www.ti.com/lit/gpn/LM92 - * National Semiconductor LM76 + * National Semiconductor / Texas Instruments LM76 Prefix: 'lm92' - Addresses scanned: none, force parameter needed + Addresses scanned: none, must be instantiated explicitly - Datasheet: http://www.national.com/pf/LM/LM76.html + Datasheet: https://www.ti.com/lit/gpn/LM76 - * Maxim MAX6633/MAX6634/MAX6635 + * Maxim /Analog Devices MAX6633/MAX6634/MAX6635 Prefix: 'max6635' - Addresses scanned: none, force parameter needed + Addresses scanned: none, must be instantiated explicitly - Datasheet: http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3074 + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/max6633-max6635.pdf Authors: @@ -36,13 +36,13 @@ Authors: Description ----------- -This driver implements support for the National Semiconductor LM92 -temperature sensor. +This driver implements support for the National Semiconductor / Texas +Instruments LM92 temperature sensor. Each LM92 temperature sensor supports a single temperature sensor. There are alarms for high, low, and critical thresholds. There's also an hysteresis to control the thresholds for resetting alarms. -Support was added later for the LM76 and Maxim MAX6633/MAX6634/MAX6635, -which are mostly compatible. They have not all been tested, so you -may need to use the force parameter. +The driver also supports LM76 and Maxim MAX6633/MAX6634/MAX6635, which are +mostly compatible but do not have a vendor ID register and therefore must be +instantiated explicitly. diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index b2ace4857130..702ed8502aa2 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1514,7 +1514,7 @@ config SENSORS_LM92 select REGMAP_I2C help If you say yes here you get support for National Semiconductor LM92 - and Maxim MAX6635 sensor chips. + and LM76 as well as Maxim MAX6633/6634/6635 sensor chips. This driver can also be built as a module. If so, the module will be called lm92.