From patchwork Thu Nov 21 21:44:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13882392 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 125C41D89FE; Thu, 21 Nov 2024 21:45:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732225508; cv=none; b=I5vgGbPyYboolX0pLUFCcKd2hEzK0UMeHTjgODxeOxhqnuPzk0tvSB9C8i6FdDAkx9zmaDEBFT/hduKSiu/cEwym946qHnM/nmbXM0v+ws5tG5IIB8h/ZrfvhXGTM5aYeU6WJiWZ9rOeIG6Z2RsEU9FZ+SkAN3+OjwRxTnEk6yU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732225508; c=relaxed/simple; bh=0LAXpjrIXDTGcDjf5bRQOuzZP1InxdcfDurREwzcnTQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G5d2BaM4gbLa7l11b8BJJwOShg1xbQYkw7ieUsH8OhZPihYDXQS53L3gh4Q6oqoNBrtVrRNCvs5cXuvsnD7U5hHD3VBvuNBkwa2HtzL8C0yrpjGonJPUPn3dRVNmFnh4MIzvz0BgUapTEysXl7ko82jA38AwwXrlawQT2rLuGoY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nABexF3n; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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="nABexF3n" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3822ec43fb0so1066897f8f.3; Thu, 21 Nov 2024 13:45:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732225504; x=1732830304; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eo67Lrb2R1KJFTkaX2vbfvEw3YlDY32zvrK100N1eVo=; b=nABexF3nl5P1cToD9aRDW8mAPU86PUTI8Z6OmQG0DvbwhGwNQflaZjq6zHF138wo+1 oFiOioC/oVwT/sbEDkZgf8IBA/+1ZcuUqGs1K0su83Le+uwrFjVa8OdDTsFmoaFVegKD mpxGi6mVDUb3+dQH9lMUNFIuJOBiQDTUY4c5WsvecRjBSmKjakmozQTmDnzBSaoUpbRS LaesVHHCJWjRDUmQ2UjVbdjCNjFvhuTu23mQWkvrYAW6WtAigOZzx495bffT6pX0qeeO TmJFnQfE+ax1n+pUzlwsaTQJ2QeLOLfVMCxpaBTKnJju8HlPQ2bVRN8qqiJ17+Q8FbA+ KVFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732225504; x=1732830304; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eo67Lrb2R1KJFTkaX2vbfvEw3YlDY32zvrK100N1eVo=; b=nuGdUKqKtcXGnCTDKuU81ObH+EmiDzILuTySvEfMNzMQf7oKqY6IkIccGsWIuFrPhL AWtRRf2Izd0TwbwQrD4924T0ICiMNx7L+jnwWASAeWebhrbRSEdkh05elq9tnu34D7B1 fsIb+plCLSOm3UQ0Elw3bI8cMBNxMHJ7JbYUvNiXKTrAHuWmjgMQ8D7+14qYABJyOPl4 67ipwP8oh1kCqCM2yQ1hHiJ/80rb5YiNdasWJTIsTerIcKgP6ycaFfWUGGKWh6DRIspG LxgrPIMYT4l+hwvdAnN7V92m8kYFkgUXhQ8LH3qfIoCCSIYNd6/4K1xcb/4vnvFAoVDQ TCYg== X-Forwarded-Encrypted: i=1; AJvYcCXJxsEnwt06/ZhnVqpwZqdpJu39LJezIEEQPUjtkM+CuPgorqUVhskrwLW0PowzL7Vql52W5ZityIu2Vw==@vger.kernel.org X-Gm-Message-State: AOJu0YybgOkfO71eLCN3HIPSodJ+cpxoeH016/sxeXfNVuC3EuLg8dYV tYdhtn9+tMCCkLeWLIKghkv6NJncIqFMZKMn+7lApNLT59O50XQG X-Gm-Gg: ASbGncvOQEJwa0FKTG1bhPpKR4bpObHRxHclk3ClF4QMpTEKghceXN8Ymia87dGPdIJ LHw1aP41e2ghKE6KCTRytOi6kPrlnt/J6IUQbSXgWyFpyvEYjG7nOVLykI93rPLa+oVrbVnmOam d4tU8vNUcRRNTcNVMRJYErWSNblaom6AcijjXXrSIyu4EGe0qigEItgM6YtshWa2nTCwQgeLFoP h8jDtm25JimUo3SlfyvGzbUE0/Ff5VR1CPAW+qfyBzeTSJ1fQ6ASuo/1yQ50y/wwKsAldggdpon ZKLw0yXTGwJyShnhSNO5K3SJ6uz3JQ86fsxfHEsNs0CfIUGxanXt4O09igQdn61kz7W4q/nw X-Google-Smtp-Source: AGHT+IENwl0u1jAvGV1j4IqYjte0F/icltzkCHHVniwwHntxK7xdgRyqdF4VU4jh6dTQTYsiByRC1Q== X-Received: by 2002:a05:6000:389:b0:382:37b2:87ee with SMTP id ffacd0b85a97d-38260b581b7mr511271f8f.21.1732225504274; Thu, 21 Nov 2024 13:45:04 -0800 (PST) Received: from [127.0.1.1] (2a02-8389-41cf-e200-7b6a-90cc-9bcd-a2c3.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:7b6a:90cc:9bcd:a2c3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fb53858sm636694f8f.62.2024.11.21.13.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 13:45:03 -0800 (PST) From: Javier Carrasco Date: Thu, 21 Nov 2024 22:44:55 +0100 Subject: [PATCH 1/2] MAINTAINERS: Drop IIO from the title of the Chipcap 2 hwmon driver Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241121-chipcap_no_iio-v1-1-6c157848a36f@gmail.com> References: <20241121-chipcap_no_iio-v1-0-6c157848a36f@gmail.com> In-Reply-To: <20241121-chipcap_no_iio-v1-0-6c157848a36f@gmail.com> To: Jean Delvare , Guenter Roeck Cc: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1732225501; l=734; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=0LAXpjrIXDTGcDjf5bRQOuzZP1InxdcfDurREwzcnTQ=; b=jhJ6h9hUObbVBStEWbwVgH8AvgjAQcJGzcIjb6BzlYvuzzjsOdECp66P5VFoodfOL8uW4+X3L Gv1/L8d6weDDgSryfhOvmCQMIcJ7rNa4lWtNK2fYNMM1p2BzdvmUH9t X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The Chipcap 2 driver belongs to hwmon, and not to iio. When at it, drop the sensor type description, as that is documented elsewhere. Signed-off-by: Javier Carrasco --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 20df6282d1d2..91936a9ba56f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1226,7 +1226,7 @@ S: Maintained F: Documentation/devicetree/bindings/rtc/amlogic,a4-rtc.yaml F: drivers/rtc/rtc-amlogic-a4.c -AMPHENOL CHIPCAP 2 HUMIDITY-TEMPERATURE IIO DRIVER +AMPHENOL CHIPCAP 2 DRIVER M: Javier Carrasco L: linux-hwmon@vger.kernel.org S: Maintained From patchwork Thu Nov 21 21:44:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13882393 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 928641DDA2F; Thu, 21 Nov 2024 21:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732225509; cv=none; b=hac2YJaUqrpjo86RrWVgylsmA3IOEt5R7zGiQ+beAtAKKN7Bi9u9OvovRAGbFdkxlAKlcdVNiAVpvyTA9tFZjWqrEqkmsGVtAbo5UNgcK8PHOa/VqEkRb880WoaBm4f0vVP04k3Ow2HxF/CYrpdMkwTkYU23B0hgwoDSkrJI1qA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732225509; c=relaxed/simple; bh=cAPRlqfmem4ZUOZNsb73Kqr8EsdpJovMlH2T1kFWOXM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A5tWCMM596I7dyukX38WLjaesFXZ0IN910+3/wzzhS+d/UMAkzpO8gPsTdryc7EhnBR3JJnY22YP4WFbQCRaVnbTNzhVxXDe6zWcS3xR5ExmankdK7moKbYTIh/C48N4M1ydJJZDXxNplXrEvoBWH6Kmi25bc+WweK3TN1hSV5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QiNv2vpk; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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="QiNv2vpk" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3824a8a5c56so922004f8f.3; Thu, 21 Nov 2024 13:45:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732225506; x=1732830306; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bsO5TXWUmIJB0UF9EZfURqtCuTGKyAOmc2IK79hH25k=; b=QiNv2vpkZiTsbLJFeRFMavl2c19DJs1VuyqhYsyWyZIx0pFEmz/qdAaUv8014WMAc8 Gj1xryKtgvlylc3JG6wJYnuNAY2AGb3kjJphJhfhS24oLu+9q/oLHnsSCx8LDh29Shrp gI+HTGM5JqQTbpjl69iM/LBQJySoUia9iUwMABTpwtGCcj7w0Kxq4CF/1V1s0aQOKKJI owdVizS+6lLfmF47UvvDIUVC4GyM2fxelycpqYzTE3zlPcIzxnikZNR2h31d/ZhImFey k18R1q0iX+6Q7b5ztLfaWpNGYjOfbymRodLRPLaViOehVgvbZO884p5Ja8togRO+wWqF DzTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732225506; x=1732830306; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bsO5TXWUmIJB0UF9EZfURqtCuTGKyAOmc2IK79hH25k=; b=YbwKnsbzpStvvEYLglVDhWLA+f1mSek8aOUgGBaFdRehYgBEF7MOJPk49ZjfgJpW2U 1d+VUCCOnIvdugInKSSouTk95hTDSgcUorkplyWEi2AGl+IpNzkgn79F4voZ4FaUF8L6 qP9pDdxw6/dMZhVhqocDqFE1/58hE//i6OrOPqtOzNB1NJYMTR22cB2Dd2vho4zByjAZ 9wBRMb30Hat0KBpoGB6Ocrb20YkR2mJYfska2b6WFh0bwDiW7ItPYDqN50Lm92zyu3fa 3Awh1yuQAyinWDb9F7lmXcccSkgf7XoXFErr+9jb6GC5XTGkrMRpQqCmMaAwFYN1Ia1q kRTg== X-Forwarded-Encrypted: i=1; AJvYcCWrEh5j6x9cTJXoUqw+5GiaibDfteDy9SpsaxKeQRNYBY0qwZnf45A6QGezvQc3DiZZ+dV5esn9JBK5Nw==@vger.kernel.org X-Gm-Message-State: AOJu0YzXrjNV9dk8/8Y4FilmNkeKF1qm9e7Bfk2FKT9hzMK4gWbahid7 tqkvPXL01H1GWjaUPsrNLxqBjc447w5l74dmglh9YUNX8ReJ2DS7 X-Gm-Gg: ASbGncsvmwbDPkhDh5GaK15RSp6JrF+L5YPg7pyccHDPtfC8nqljHXvHXdE8Z5lZdJ1 PdRN5Jpao2J9E/cqUXVYx0ys4fiV6KTGzl9Ca8cpV+I4DTEffxCdQ03zOqrjkx9qrPMq5eIKYgc ROioDuhqi3xzzEhqEA+WJ2CdOufp+TbuoKFL/txOJMEKYe3GYbPc3rQV874cLUyUP+VCySyP0JT T4lpO9XfzFah8bzy4fs8b/WPAaDBm21MpPWv+CvbKyMMZ8KhQuPLZmGqkvw8PwLLbU16ls+BfO+ YzwzLREdEQdHLwUXNXh0RCl8AzX+Jy/fX/vMA75Uh4gbyiGv0S0+80q9zDcX7hZNxL/SbZPE X-Google-Smtp-Source: AGHT+IECyXWoa3vNC6aG+mGBIil4TrFWvVZHen3azU0MomrvCyNE6ChZKRoohVA5IsGJ/8moQEvjew== X-Received: by 2002:a5d:588f:0:b0:382:4851:46d2 with SMTP id ffacd0b85a97d-38260b45c95mr572678f8f.1.1732225505587; Thu, 21 Nov 2024 13:45:05 -0800 (PST) Received: from [127.0.1.1] (2a02-8389-41cf-e200-7b6a-90cc-9bcd-a2c3.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:7b6a:90cc:9bcd:a2c3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fb53858sm636694f8f.62.2024.11.21.13.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 13:45:05 -0800 (PST) From: Javier Carrasco Date: Thu, 21 Nov 2024 22:44:56 +0100 Subject: [PATCH 2/2] hwmon: (chipcap2) Switch to guard() for mutext handling Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241121-chipcap_no_iio-v1-2-6c157848a36f@gmail.com> References: <20241121-chipcap_no_iio-v1-0-6c157848a36f@gmail.com> In-Reply-To: <20241121-chipcap_no_iio-v1-0-6c157848a36f@gmail.com> To: Jean Delvare , Guenter Roeck Cc: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1732225501; l=3960; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=cAPRlqfmem4ZUOZNsb73Kqr8EsdpJovMlH2T1kFWOXM=; b=jk/nhwFA9U5gAWsQlRrkxtnSLmtgSRavfXDCD7rTFNPFtnNfJbGbEbqg7O9x3906nlVIxjAgo mLeq7kDrZ4pDEaAGeRAdxrbqWp6snw3H7zeuEOGhcPy45T/MgVluUW8 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to guard() for mutex handling to simplify the code, getting rid of the 'ret = x, break; return ret;' construct and returning the result of the operation instead. Signed-off-by: Javier Carrasco --- drivers/hwmon/chipcap2.c | 63 ++++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/drivers/hwmon/chipcap2.c b/drivers/hwmon/chipcap2.c index edf454474f11..9d071f7ca9d2 100644 --- a/drivers/hwmon/chipcap2.c +++ b/drivers/hwmon/chipcap2.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -556,55 +557,40 @@ static int cc2_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *val) { struct cc2_data *data = dev_get_drvdata(dev); - int ret = 0; - mutex_lock(&data->dev_access_lock); + guard(mutex)(&data->dev_access_lock); switch (type) { case hwmon_temp: - ret = cc2_measurement(data, type, val); - break; + return cc2_measurement(data, type, val); case hwmon_humidity: switch (attr) { case hwmon_humidity_input: - ret = cc2_measurement(data, type, val); - break; + return cc2_measurement(data, type, val); case hwmon_humidity_min: - ret = cc2_get_reg_val(data, CC2_R_ALARM_L_ON, val); - break; + return cc2_get_reg_val(data, CC2_R_ALARM_L_ON, val); case hwmon_humidity_min_hyst: - ret = cc2_get_reg_val(data, CC2_R_ALARM_L_OFF, val); - break; + return cc2_get_reg_val(data, CC2_R_ALARM_L_OFF, val); case hwmon_humidity_max: - ret = cc2_get_reg_val(data, CC2_R_ALARM_H_ON, val); - break; + return cc2_get_reg_val(data, CC2_R_ALARM_H_ON, val); case hwmon_humidity_max_hyst: - ret = cc2_get_reg_val(data, CC2_R_ALARM_H_OFF, val); - break; + return cc2_get_reg_val(data, CC2_R_ALARM_H_OFF, val); case hwmon_humidity_min_alarm: - ret = cc2_humidity_min_alarm_status(data, val); - break; + return cc2_humidity_min_alarm_status(data, val); case hwmon_humidity_max_alarm: - ret = cc2_humidity_max_alarm_status(data, val); - break; + return cc2_humidity_max_alarm_status(data, val); default: - ret = -EOPNOTSUPP; + return -EOPNOTSUPP; } - break; default: - ret = -EOPNOTSUPP; + return -EOPNOTSUPP; } - - mutex_unlock(&data->dev_access_lock); - - return ret; } static int cc2_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long val) { struct cc2_data *data = dev_get_drvdata(dev); - int ret; u16 arg; u8 cmd; @@ -614,41 +600,28 @@ static int cc2_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, if (val < 0 || val > CC2_RH_MAX) return -EINVAL; - mutex_lock(&data->dev_access_lock); + guard(mutex)(&data->dev_access_lock); switch (attr) { case hwmon_humidity_min: cmd = CC2_W_ALARM_L_ON; arg = cc2_rh_to_reg(val); - ret = cc2_write_reg(data, cmd, arg); - break; - + return cc2_write_reg(data, cmd, arg); case hwmon_humidity_min_hyst: cmd = CC2_W_ALARM_L_OFF; arg = cc2_rh_to_reg(val); - ret = cc2_write_reg(data, cmd, arg); - break; - + return cc2_write_reg(data, cmd, arg); case hwmon_humidity_max: cmd = CC2_W_ALARM_H_ON; arg = cc2_rh_to_reg(val); - ret = cc2_write_reg(data, cmd, arg); - break; - + return cc2_write_reg(data, cmd, arg); case hwmon_humidity_max_hyst: cmd = CC2_W_ALARM_H_OFF; arg = cc2_rh_to_reg(val); - ret = cc2_write_reg(data, cmd, arg); - break; - + return cc2_write_reg(data, cmd, arg); default: - ret = -EOPNOTSUPP; - break; + return -EOPNOTSUPP; } - - mutex_unlock(&data->dev_access_lock); - - return ret; } static int cc2_request_ready_irq(struct cc2_data *data, struct device *dev)