From patchwork Mon Jun 10 18:10:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13692340 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 5DE0A14AD35; Mon, 10 Jun 2024 18:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718043054; cv=none; b=WlHfLdCMi6cQ+Fq0j2QR+UbrX7ycunRCY5t2O2cDTyQRLVvXfmn+xFQS/LCxedlaL0m75v1oC93TlX/r+miZwrn4Wd3hNRMLRf0mydO7PDKWDPJx+vpFIsG7laW3e4Bpy8rNFZKZyMmWX4pqKFEqU+ZcvyuAd1oo3tjTvF5nTX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718043054; c=relaxed/simple; bh=nSKjz0KWv20MSmp1Zba7UhZtqkG9QdgLPUj3njHimJA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LTOBt3+3bnLxRe2FNG/5D/KMqpDOaFFMFVYXgyaOrMP9CeQW0u/1gXXNy1yWHu87H92P+CVg4GtnIIZyXQxs0qoitc4Zlw5BM8hdOt1WEK3Rd+o4PoTrWPaVXeAkdTjM64oaacVrQfPE3e73nZeNR9EpZNhx4/Cly+mcV0QcHf8= 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=KGObxygp; arc=none smtp.client-ip=209.85.210.171 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="KGObxygp" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-7041f4553ccso2575030b3a.1; Mon, 10 Jun 2024 11:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718043052; x=1718647852; 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=nBodwoDy4NoI0gKU3CfVEoLymIQQPIjGJMUe5cvNy78=; b=KGObxygp2JsmnV4pmbLLNrwLb/UvQDXNDJrLF7YyVrTHx9ZdaHvoh1RsUTlIzaVzRu OYuCnFhYIfHXv3Bs9wSOdvZqq4T7Cyd/uJ3cqUeRGzuEjZkb+3ZtcJHrIo2MRK5XrNx1 EsVAXngyqI9+4mRUR7iIX9hfSPWDTKkmDSfpiiOt1WzQA/p6nbC/I3nd2rVRld4I/7SV GVaDUNRA8IuyiZW+wV43dE6RRu/n107XcujigCxRBTj4sPkL9lWtGa5J5GvY2dl3k6jN iLGjiJkQybbsPl+mzEa2Deuu36x3Js2WmBkQEwHvNK0Pa2WckoSNvrsJlt4sIwfXJc9L 0TUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718043052; x=1718647852; 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=nBodwoDy4NoI0gKU3CfVEoLymIQQPIjGJMUe5cvNy78=; b=vBrV+RihUyNqoKYjFPinx9nvxPA4U3mBrxFoktmb8hsqsZbvjA4UE9kYOVRfGbgVAO NRPiTfgIJ5nmecd6/VUWVJYf5zUIe6abO2pzzF4GoNl7VyaVJZpAT7O4RQY144/coDRs t6hfGm7GPwE1a5m9Y5NF9TGI+u2WE0kzlsjGgh0Ei1HCh5IcKGm7xvCrUdkN0BcK2YsR 5HWUpANjbQNLOwT3QgCSLuJrA2kblm+MYXzgZ2G5BXEO6LogEmAzpfaOf7TGK4CS+d0q rsUA77+Y4tkUhRYebpw59iHNTCSzzAAfJ3pdcJWiI9Zv+0N4Y/k9HpKJ32NAsYzTmDmC cQug== X-Forwarded-Encrypted: i=1; AJvYcCWcj/rIXZiymMjkwIfMpEVqzSBEMbXG2xq1Homx8E+70NjJo62SRP90DLM16+BcuYM/FAiY1+p4hRuEoOpmL4Y+tIbBOsqQG9n0Kztp X-Gm-Message-State: AOJu0YyTY6wb8AM1Y1EY/OqpWC9jCMBsF1AyjEgwv0v6DlqVT84/ObUv cKFKJn028UIBZB4ZRVqgi5D4QExkKlBbXFkuhdsgNgulvYX+EKaKI11i1g== X-Google-Smtp-Source: AGHT+IE2tFZcUOCIKyL7dElvOves9MyVhE0oBcRixoK4cmeWLfET8JN+rel7uEgGfjpuzQA0DfYwfg== X-Received: by 2002:a05:6a00:1996:b0:704:2d99:9ee0 with SMTP id d2e1a72fcca58-7042d99a023mr8198447b3a.33.1718043052084; Mon, 10 Jun 2024 11:10:52 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-704326f9342sm3104637b3a.103.2024.06.10.11.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 11:10:51 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: Rob Herring , linux-kernel@vger.kernel.org, Peter Yin , Potin Lai , Daniel Matyas , Andrew Davis , Krzysztof Kozlowski , Guenter Roeck Subject: [PATCH 1/4] hwmon: (pmbus/lm25066) Let enum chips start with index 0 Date: Mon, 10 Jun 2024 11:10:43 -0700 Message-Id: <20240610181046.1991436-2-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610181046.1991436-1-linux@roeck-us.net> References: <20240610181046.1991436-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 Commit ac0c26bae662 ("hwmon: (lm25066) Use i2c_get_match_data()") changed enum chips to start with 1 instead of 0, under the assumption that the data pointer in of_device_id must not start with 0 (NULL) if i2c_get_match_data() is used. However, that is perfectly fine as long as there is also an i2c_device_id array with the same data which is used as fallback in that case. Let enum chips start with 0 to avoid confusion against other drivers where the enum starts with 0 and i2c_get_match_data() is used as well. Cc: Rob Herring Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/lm25066.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index cfffa4cdc0df..c36c124d1a2d 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c @@ -17,7 +17,7 @@ #include #include "pmbus.h" -enum chips { lm25056 = 1, lm25066, lm5064, lm5066, lm5066i }; +enum chips { lm25056, lm25066, lm5064, lm5066, lm5066i }; #define LM25066_READ_VAUX 0xd0 #define LM25066_MFR_READ_IIN 0xd1 From patchwork Mon Jun 10 18:10:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13692341 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.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 588EE14EC73; Mon, 10 Jun 2024 18:10:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718043056; cv=none; b=AzUSlC4jkoHK63De2bh1sed1bQqxKiECC1mLTuFWctqQpbLPjtuCgQWa8ttXRe2JTHgW46c1HNKdkOym17MFTeCUAHq+MdsZVw1nC4aSzqOrjy/qUuqhOSP3AeM3FN96fTYtIyufSjAz2tr/2baHV3NH9RNRxgyLS0+jvkVr+Sw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718043056; c=relaxed/simple; bh=9zjOarVLW+SBvaeGCw+THYMGtZMeawipUNd7eF/rih4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tHGX5odSOLYNT/1Hng8efbPBX0xj734CVwyVNMzaV+g3TEfTf/maHAOTK7NP/TYzUoImrYjdUstm0GBHtTumxb6HOIOexjLzGQwRFlCo8m3uA9Puyb5hcDEZdVesm/sCj0qqCDapEHzPPjQ12tuFIltcpJxGAOnU1KJGVdOoibI= 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=l4eaNNo2; arc=none smtp.client-ip=209.85.210.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="l4eaNNo2" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-7024d571d8eso225800b3a.0; Mon, 10 Jun 2024 11:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718043054; x=1718647854; 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=wI+PZ7h0a3YwBJogrFDchjGG7jDSfmWZKRcxXZ4YjYY=; b=l4eaNNo2DYI2JsAIVvQOGtZ/FpPJbzewpBdQfJRCa5cxoqf25ICK2FwHnfs+OOXh5O QdDzFhS3nsxtGJhXSUvnXXNsd+e6DdkssLfB0HpgVn2U0casKlwLt+fHsXOHRYQ5goiP B5WCl8IOC1fZngENUjkGO/Cbp9B/dRsHDHdOR7adKHGpIjvqys4NKh/WBnvobpzOoiO+ dKDA0uHUfNNCg/xl+kx7o8QZ8A9gFaaXQkYv8OjKhFzPbQXkou9Uz2HO4eippL/H2Lbg rNhz/vc/ycJQoUGFufYGQLDsQltE5QzfqPSatSQi8h9p4i6F82Rvbe5Jk9lJtG1tIP7S j2/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718043054; x=1718647854; 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=wI+PZ7h0a3YwBJogrFDchjGG7jDSfmWZKRcxXZ4YjYY=; b=SEi/MI6ps3w1kOZ6YEHXeOdvtQ4ka7EUH1nxwCCBtUkRpjStWYtjZmx15DDpzj8nLX ViKDA8BqTeZEzp6z/nBIkgHuowq80Da3KBvwTYWPtqYj8AlbAXhDLdkmbdLnZnV3/7OZ U9necx8YgenHdjBb3utobkz7hLbtF8yvQXMOxG7hp77MoyBJEu6EdbtBa7CaDT0Vbj/d xNoMB6g6OF1FBfLIqreGmeAGrb8AO6eo+ZEung/d6Y8KlrW7kJ1uXDYGLfOhA20AZr8o YxvwTLdEdDcLwQiutUMBieaJ9N5lUhfLnfGtqoTuEuodFc3Fzndqp6gLjwejzQbu/qQc sveA== X-Forwarded-Encrypted: i=1; AJvYcCUgfPGMNCpntJHpGaaFPxR89SNTvv/VM004WW1nGhW/emPPHSiXnlTa9gusDlpFzRfqJdrQPjD4L/lbzT/aFCwYNNhtxGsXzP0vvySK X-Gm-Message-State: AOJu0YyVryL+U2YHzh3hXJif68nJtRJ5pyhDtHXCdFtH5eatvk6ewe3K Qy3zyMCxe/zoZOQ0NZrLCLv/rD5kYXTfMxS3hS88/dnuzznzJ9tzOHvG5w== X-Google-Smtp-Source: AGHT+IELcIlg5odwQ6B94ZQxqkakid+M/03MSICoIEdeR0lvDXp+jSDHVwlbklfAiU0OODprzXxi9w== X-Received: by 2002:a05:6a20:431a:b0:1b8:54f8:3857 with SMTP id adf61e73a8af0-1b854f83952mr1483461637.30.1718043054091; Mon, 10 Jun 2024 11:10:54 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-6e8080c2f55sm3839630a12.83.2024.06.10.11.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 11:10:53 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: Rob Herring , linux-kernel@vger.kernel.org, Peter Yin , Potin Lai , Daniel Matyas , Andrew Davis , Krzysztof Kozlowski , Guenter Roeck Subject: [PATCH 2/4] hwmon: (nct6775) Let enum kinds start with index 0 Date: Mon, 10 Jun 2024 11:10:44 -0700 Message-Id: <20240610181046.1991436-3-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610181046.1991436-1-linux@roeck-us.net> References: <20240610181046.1991436-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 Commit 10a0575ea09d ("hwmon: (nct6775-i2c) Use i2c_get_match_data()") introduced calling i2c_get_match_data() to the nct6775 driver. As part of that commit, enum kinds was changed to start with 1, based on Adjust the 'kinds' enum to not use 0, so that no match data can be distinguished from a valid enum value. The patch had to be fixed later with commit 2792fc8f8c83 ("hwmon: (nct6775-core) Explicitly initialize nct6775_device_names indexes") and commit efe86092ab31 ("hwmon: (nct6775-platform) Explicitly initialize nct6775_sio_names indexes"). Various patches submitted later show that the change from 0 to 1 is not really necessary. As it turns out, it is perfectly fine as long as there is an i2c_device_id array with the same data as in the of_device_id array. This data is used as fallback if the data pointer in struct of_device_id is NULL (0). Let enum chips start with 0 to avoid confusion against other drivers where the enum starts with 0 and i2c_get_match_data() is used as well. Signed-off-by: Guenter Roeck --- drivers/hwmon/nct6775.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/nct6775.h b/drivers/hwmon/nct6775.h index d31e7a030216..296eff99d003 100644 --- a/drivers/hwmon/nct6775.h +++ b/drivers/hwmon/nct6775.h @@ -4,7 +4,7 @@ #include -enum kinds { nct6106 = 1, nct6116, nct6775, nct6776, nct6779, nct6791, nct6792, +enum kinds { nct6106, nct6116, nct6775, nct6776, nct6779, nct6791, nct6792, nct6793, nct6795, nct6796, nct6797, nct6798, nct6799 }; enum pwm_enable { off, manual, thermal_cruise, speed_cruise, sf3, sf4 }; From patchwork Mon Jun 10 18:10:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13692342 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 2074314F9E7; Mon, 10 Jun 2024 18:10:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718043058; cv=none; b=qn8vjbQwHy2vRA7LZDp4vBH0515Y5LAp7kW7mwA85QG9nVZ2T4Cv7J33vw1r2PtiaSdWSz//dN8ULm6suo0j98H7LprCF/Q4w3GR2QGYXo4XwZf0H39l8V3yuwcMCQ3BEGUczalPzjNvSg40+9GRUxmVETBelYr+Vs+EONwEl4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718043058; c=relaxed/simple; bh=Rs1EQsOg01uvn7Hn/G7LElJnLEEXSqxNDo6raCfoI48=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BxzTWxSBYERjaRiJiXo15XKiqDkhBDyfEHP0GxyRLOQzBsgHIUeZuomIv4VeRe3VmyUN8qa/M5IhfJrwR+2PiPf9SsReaFEegFKD9TZ2CXTBUe3To7zX4IikNnAu3uZlqC7iMbNc/VHfIPcKBv8sTT9Iugu9P0HoWdYsWluM8NQ= 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=DFQShbpm; arc=none smtp.client-ip=209.85.214.170 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="DFQShbpm" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1f6c7cdec83so38053065ad.0; Mon, 10 Jun 2024 11:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718043056; x=1718647856; 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=BjScR7Hzj+gJrS89xsExlnr/l0kAWC+C16dhfMmwLaM=; b=DFQShbpmMlvwqBRDeuF6latViwJg/ZsTyuLq5nUZm3TDA+eSXGU1e3QpS7nd5zjRzR sKjpnvsjXAnRTm7AR3+yFXl/mNursqG9GcHUH/ub39s6vwhhajqMXVirlO08cyYFeng6 HHf+rBDTga0mcOrskMuOqVO6baCQibFZpctWQVamXGFnKgTWab3W+AgWIStsrsgpZckM JZ10AS0ZkSw/l3DjS3P05unarlDT7lxVzI9ZXKMA8qakR9nNSt6F0G2GPFctXi9Eb7UK OMExXTOTuZphltGOgriHQubWI1xDXYcdoEQ2CLI6/n3XR8AR5G8CQhVahy6PC8vwrtke iE8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718043056; x=1718647856; 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=BjScR7Hzj+gJrS89xsExlnr/l0kAWC+C16dhfMmwLaM=; b=Ef+tD0qHj45agfkBzD6Y1Fs2eZaJDMNz8Mk73tVPopM1DmI67BCXv2AjjyTXFupTuh 9JdQsIDEvYzbnhtmrufdmFHGjbeofe9q7QH6ORMFp2EMM1PsWzErr1UMyYN+m/vcrqbq 1EFCw/klEYRnCYYmBIhhuewe1RV7DhjiZ0eO1SPYX/hW/a7VCQCNB/tzpDlAJm7T9zUV sCkZ7Tfi/nfy7/zlm3AsQe5rom8cF9rODLMzCbVfQLXcuFJ1FozCFNl3gkaxVr2n4G5B PJ1APBmnoeeAl8VUoDtRDmf4f/jBMBkMZlYbmLp1732ZpXY02EYVfZ/ohMHF9JoOymfU eNug== X-Forwarded-Encrypted: i=1; AJvYcCV9DIVke+R6gCtvVUreJqWnhchd0WzbA6qBUl4kpWCtrGjDg0h9KtGOgX9+WcrDBU9lLTQgV2UWb1fmGgUJHr7b27xkMX0hFf/yRJzf X-Gm-Message-State: AOJu0Yxq04t2WS1t2Pf0gcNexS7NtY7U49QInNtwt4a3YMBwTj1ev8eQ 4oaSJvHLv8be/NcpOgdmfaBmgW0pS59jRda1wUWyVcsDUA490HYAmE58ow== X-Google-Smtp-Source: AGHT+IGHPmpBl6Bdl8Qp2JyReyGq7gwQ2acm2l6XNo5wrNkRMx+/bDt+7N9rhANpv/GyIIB7hPwqCQ== X-Received: by 2002:a17:902:e84a:b0:1f7:1a9:bf05 with SMTP id d9443c01a7336-1f701a9c351mr65788585ad.53.1718043055831; Mon, 10 Jun 2024 11:10:55 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f71ba3bad1sm15530405ad.218.2024.06.10.11.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 11:10:55 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: Rob Herring , linux-kernel@vger.kernel.org, Peter Yin , Potin Lai , Daniel Matyas , Andrew Davis , Krzysztof Kozlowski , Guenter Roeck Subject: [PATCH 3/4] hwmon: (pmbus/mp2856) Let enum chips start with index 0 Date: Mon, 10 Jun 2024 11:10:45 -0700 Message-Id: <20240610181046.1991436-4-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610181046.1991436-1-linux@roeck-us.net> References: <20240610181046.1991436-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 Earlier it was assumed that the data pointer in of_device_id must not start with 0 (NULL) if i2c_get_match_data() is used. However, it turns out that this is perfectly fine as long as there is also an i2c_device_id array with the same data, which is used as fallback in that case. Let enum chips start with 0 to avoid confusion against other drivers where the enum starts with 0 and i2c_get_match_data() is used as well. While doing that, remove chip_id from struct mp2856_data since it is only used in the probe function, and typecast the result of i2c_get_match_data() to kernel_ulong_t to avoid the double typecast. Cc: Peter Yin Cc: Potin Lai Signed-off-by: Guenter Roeck --- drivers/hwmon/pmbus/mp2856.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/pmbus/mp2856.c b/drivers/hwmon/pmbus/mp2856.c index 6969350f5d7d..41bb86667091 100644 --- a/drivers/hwmon/pmbus/mp2856.c +++ b/drivers/hwmon/pmbus/mp2856.c @@ -46,7 +46,7 @@ #define MP2856_PAGE_NUM 2 -enum chips { mp2856 = 1, mp2857 }; +enum chips { mp2856, mp2857 }; static const int mp2856_max_phases[][MP2856_PAGE_NUM] = { [mp2856] = { MP2856_MAX_PHASE_RAIL1, MP2856_MAX_PHASE_RAIL2 }, @@ -66,7 +66,6 @@ struct mp2856_data { int vout_format[MP2856_PAGE_NUM]; int curr_sense_gain[MP2856_PAGE_NUM]; int max_phases[MP2856_PAGE_NUM]; - enum chips chip_id; }; #define to_mp2856_data(x) container_of(x, struct mp2856_data, info) @@ -397,6 +396,7 @@ static int mp2856_probe(struct i2c_client *client) { struct pmbus_driver_info *info; struct mp2856_data *data; + enum chips chip_id; int ret; data = devm_kzalloc(&client->dev, sizeof(struct mp2856_data), @@ -404,9 +404,9 @@ static int mp2856_probe(struct i2c_client *client) if (!data) return -ENOMEM; - data->chip_id = (enum chips)(uintptr_t)i2c_get_match_data(client); + chip_id = (kernel_ulong_t)i2c_get_match_data(client); - memcpy(data->max_phases, mp2856_max_phases[data->chip_id], + memcpy(data->max_phases, mp2856_max_phases[chip_id], sizeof(data->max_phases)); memcpy(&data->info, &mp2856_info, sizeof(*info)); From patchwork Mon Jun 10 18:10:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13692343 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 DC7AE15098E; Mon, 10 Jun 2024 18:10:58 +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=1718043060; cv=none; b=SUB2lEaJfP+rSe1lRrlXE3NB0HAiGA7T+8ebpC4O6lZkQZwn5aCgqKIuON99yKnRti9ORf0PS1jKNwQbcqUmMS/R+ehRT55HAwtRrOc/C42RVSX2bhM1wxFkUfe2bsKv7t5Bd48Ehc52NhYzv0cLYb6VVvP9TskDsMwtxacDtgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718043060; c=relaxed/simple; bh=8TaujMwdgSneCfMTDXBI6ITPwOa00KHwjWVTqUEnIr0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KvWmNfxGZ6EIKWh/WE4ZZZ0+tLKGqu5PlvuI9OcI2Ylcu6NMH6hgYE2f0KAV1j1cqM+5HGDcMNJewLKtlWSHSJS3u7eDL2iz0NACj2piV6eiqc+YkelDwzSZUmE6WErToU0GCYtmUSJ62bdZHZBjzc6mlDvkkJSGdO4vl/HiPyw= 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=G0uOp1oR; 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="G0uOp1oR" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-7042ee09f04so1780769b3a.0; Mon, 10 Jun 2024 11:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718043058; x=1718647858; 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=Ah0Dh0Ya0pvnHgWC+yxqoBec5cmdNc4DrDcokbfP3BU=; b=G0uOp1oR1lCtzYdw40yLqvzsY1W4JN77oTdCK7iQZrgPZtn2ey9GzqLf71NBVS/NkC eJYCB84AXocuxq/Coq57KC6iFaSUARZKz5VsSt2zLD2lPax444/y9K9LVpe232qO1vEw Aw+7aVVwsHwotx13753jc3kutI4RRtgnunOTwIEPXUYgEjwat7O6MuTCv7m4ISt8rXff cDukq8nnk/CWArK24OaI88DfHA70GEi7yJzOamE2oewlMD8k4jhtKOLr4Ph4W2WR4nA1 FgyzI15Kc6428JAxqMmim+bRRY5zSzFVa7/x3yGRn5wUm7VhwIhMPLQEeYnkNe7Zx06G zNmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718043058; x=1718647858; 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=Ah0Dh0Ya0pvnHgWC+yxqoBec5cmdNc4DrDcokbfP3BU=; b=EcbhyGjtaSVRl6xf95zFWL/SC5a8S2GSeRlvnKdOnQdXoMhLjlduJB/sMdYrV4PfNB yEJM530DlGsEXM+un8OlTANe1IS28QjS0j+4TXtxM8vdcYCuAJjlVzxIS9Dn0/jn/6eU erIaPKwTQDvFSfeusXO/Zz+I8A8RyqvrQibTsq/zyBfKkzb83VZ3Tsi2d5IJWpJT/G8b 0kohJuT8CCg67KxWo+P7MIgxX83yi//so/GSeTVW3+5nUqByyhpqS+P+AWxKx8llX90C URf/S9U9+J97gfb0Zqp0F3+paMSGaxOUqQPo+lVoVj6vDkyRzh+bV2Asg9nyamA6se64 mILQ== X-Forwarded-Encrypted: i=1; AJvYcCXXEaw+/dku84AUVpugUj+Zb+iZbhnD9UyjlSAwCcsa4bOqaUMLn7ft6QFdp41IRuCNK/rNYTZG0QUBsgnEzxq/UnrMHPWUAtsMi0aW X-Gm-Message-State: AOJu0YyX36mF7GNlSmWJqtErmZ0KyVa4N/DDk3S4D8yxaYhMBe0vhszU oog+0JcncFLM677AKnw2AUIuP8ys/SKwFduHgN/gMKEXhA7ZsUgUVWYYRw== X-Google-Smtp-Source: AGHT+IExL81YqzOb/K5/BG9qjCpKDPD94xS28sVG9pO7hfUNP0seAyXDh6MVH7UsCCjQAe3cW0Zu2g== X-Received: by 2002:a05:6a21:3a86:b0:1b5:ac9b:a59e with SMTP id adf61e73a8af0-1b5ac9ba77bmr7352956637.32.1718043057716; Mon, 10 Jun 2024 11:10:57 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70414a801besm5489914b3a.126.2024.06.10.11.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 11:10:57 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: linux-hwmon@vger.kernel.org Cc: Rob Herring , linux-kernel@vger.kernel.org, Peter Yin , Potin Lai , Daniel Matyas , Andrew Davis , Krzysztof Kozlowski , Guenter Roeck Subject: [PATCH 4/4] hwmon: (pmbus/max31827) Explain why enum chips must not start with 0 Date: Mon, 10 Jun 2024 11:10:46 -0700 Message-Id: <20240610181046.1991436-5-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240610181046.1991436-1-linux@roeck-us.net> References: <20240610181046.1991436-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 If a driver calls device_get_match_data(), the .data pointer in its id data structures must not be NULL/0 because device_get_match_data() returns NULL if an entry is not found. Explain that in a comment to avoid confusion why this is required in this driver but not in other drivers. Cc: Daniel Matyas Signed-off-by: Guenter Roeck Acked-by: Nuno Sa --- drivers/hwmon/max31827.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/hwmon/max31827.c b/drivers/hwmon/max31827.c index f8a13b30f100..391cb059e94d 100644 --- a/drivers/hwmon/max31827.c +++ b/drivers/hwmon/max31827.c @@ -46,6 +46,11 @@ #define MAX31827_M_DGR_TO_16_BIT(x) (((x) << 4) / 1000) #define MAX31827_DEVICE_ENABLE(x) ((x) ? 0xA : 0x0) +/* + * The enum passed in the .data pointer of struct of_device_id must + * start with a value != 0 since that is a requirement for using + * device_get_match_data(). + */ enum chips { max31827 = 1, max31828, max31829 }; enum max31827_cnv {