From patchwork Tue Dec 21 21:04:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12690613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8EE9C433F5 for ; Tue, 21 Dec 2021 21:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235471AbhLUVEz (ORCPT ); Tue, 21 Dec 2021 16:04:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235412AbhLUVEy (ORCPT ); Tue, 21 Dec 2021 16:04:54 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DECEC061574; Tue, 21 Dec 2021 13:04:54 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id o20so97694eds.10; Tue, 21 Dec 2021 13:04:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZcYF0sJxfCsW5AbyQlpVqnAvfQ5ZjjzzRLMoH53YhLw=; b=MI6nFeKhN4kO+GnEbPmN2onIF42QVIuJjmDzri49wV8fPFu32dfsCFF+jgxvsx+fgq lmQJziN+hvI2EbGQJX0pSxB0qG2D8GlLE46eaX75+z8m1Rjm9Vn824NZbglgYoBJ4EXK MUa5jLxQhKjp3LDek9Ch8VzA0BxnpI/HpE49C9qOYTJ1OpUU5As8cECsZ91v1rIqOFUZ Le7S9nyEl/7BvfhMVhivRcTR7+rtm02qRrmw5n4VM7xht2KL+9tKxD++LPi2ZtgnGvQ8 X1OII5Z+v7L03E4gKPR2LA2gSLyjUonO2pnwWn56k42wlYB5e/x+PtQg2RnEJE6+XHaH m4NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZcYF0sJxfCsW5AbyQlpVqnAvfQ5ZjjzzRLMoH53YhLw=; b=oSQvyJYJybSzaWa1fKy6Edbe3WXr/dADZr6NpICpM4d3l3FZ5y9eAEp2dv0mMx8MuX tvxa1iujZtAwfeD8Z6IjjCnWCYLj2uvm3Qjh3ZskRYDQ2IcaAS2zPQ+/AFJQQBqbV4wI CgeL9Kgs/GA05/F1oY4TaNaI6N8e7pJQ85jVyEERLpSAovc97pMQ1o/Wzr9g0k6tb8jO fRu83yMoKGtaUYC23CHnAO3e1MZ8p2svN+4mv+zdJBjUoXC4SEsBQOb2w2lqqIEjwjGN /Y7QSmMcYcW5EMBptkrwPHIMmOHZLqvgZMpvvCOIUIjDcZqD+86ev9GymgfiHTAIs/cM i+1g== X-Gm-Message-State: AOAM530x1Guk64/U7ww/SF1P4zx7xHPLLYRUqh5dZOmxtLAnrCBqGHLG Bow7vVX4iSIyLFvNWNza0Aw= X-Google-Smtp-Source: ABdhPJyGMRs03jmtnz8auj9jakNys4ZUnQxuuZ7ifmy2DHdpSx60FHDGs19ZrPBojG6GEjtcMQlEDA== X-Received: by 2002:a05:6402:11c9:: with SMTP id j9mr91173edw.346.1640120692884; Tue, 21 Dec 2021 13:04:52 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id c3sm6355041edr.33.2021.12.21.13.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:04:52 -0800 (PST) From: Cosmin Tanislav Cc: cosmin.tanislav@analog.com, demonsingur@gmail.com, Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/8] hwmon: (adt7410) Pass name to core driver Date: Tue, 21 Dec 2021 23:04:31 +0200 Message-Id: <20211221210438.2637430-2-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221210438.2637430-1-demonsingur@gmail.com> References: <20211221210438.2637430-1-demonsingur@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Cosmin Tanislav It will later be used to register hwmon device using hwmon_device_register_with_info. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7410.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/adt7410.c b/drivers/hwmon/adt7410.c index 973db057427b..ef4b5af865e9 100644 --- a/drivers/hwmon/adt7410.c +++ b/drivers/hwmon/adt7410.c @@ -45,7 +45,7 @@ static int adt7410_i2c_probe(struct i2c_client *client) I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) return -ENODEV; - return adt7x10_probe(&client->dev, NULL, client->irq, &adt7410_i2c_ops); + return adt7x10_probe(&client->dev, client->name, client->irq, &adt7410_i2c_ops); } static int adt7410_i2c_remove(struct i2c_client *client) From patchwork Tue Dec 21 21:04:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12690615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF6BDC433FE for ; Tue, 21 Dec 2021 21:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235747AbhLUVE4 (ORCPT ); Tue, 21 Dec 2021 16:04:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235693AbhLUVEz (ORCPT ); Tue, 21 Dec 2021 16:04:55 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76A71C061574; Tue, 21 Dec 2021 13:04:55 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id y13so50608edd.13; Tue, 21 Dec 2021 13:04:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TZKAtR6UT3uSpTIEo5wgVOep5oODFFJr46+sXEmJhnY=; b=VK+87iuBvV8zx2wZiGTy57iAglu49ew5ziU8ZI4+Dooq4lZjOPXnCxmAZZ0SJOpX3M vrb/hcifRNBScCQaExQCQVWxSMUXyTLUJBKusKEDR7axBTYJGN1VgpE2JJXTIrYoJ5k6 aNi5yTWLoMYASXuPEt+6lsqpmFdXuPOO64h7NRqWKn3V8W2ssRCPnJBcVou2EQ/SSmx/ 6szrByGskCZj7QKB3yhYY3TCaezW2tniVZ/BMWJcysK8jxiIVr8u9KNJ9fjl5qxdcer0 0m002iEQH+BYaFT9X+jNK6AsyQadVWPNNJYEHwNvTPQQv2rmIzbUdJfYD5TyKntk8cj2 GrEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TZKAtR6UT3uSpTIEo5wgVOep5oODFFJr46+sXEmJhnY=; b=xsBVogarOt4NvmBuLws1NfppGVLYokH1P10lWeCAi/q9yfeN6s8QIHz2PWvc+rZJ+U DI+SwI7JlzVxLWeI05rOH/IKI4DYLthnHkWujT5+hYDR5AOulQ6+O9e5I9ctumV1lMb7 C0/XCLWpbWut3dKcXXZd4/UAWcdJ8w3uhyfW0MvaPVloTtRPDdUiEV2yZK9QCLn77iSR 2bb3fotRE9GIbODHEuDTy1vlHhk78YUWzwgusDPAFGxpWQvmjATIRC0OBKx3jBt7or+f 6UcVtEchBxL3xKqLfCbFofsDXyYMoAWSptHM+Nw79hfIOc+F9I9OG4q8rrh99BEh7haR l4Og== X-Gm-Message-State: AOAM531OIirmxv9fviJ5hfRrD9xOLKSBiIX/kLpCYVXHUoS+ZRWXzbFC 7rtbDYrmJ0+15OzRg7m5Puk= X-Google-Smtp-Source: ABdhPJwPotBXoPTQTGEYuzkga9vzLD7AUMEIRJUZXKT4zZrSr29PC+yP9x16UH0cggJKMjOlt6kvBw== X-Received: by 2002:a17:907:169f:: with SMTP id hc31mr51798ejc.703.1640120694107; Tue, 21 Dec 2021 13:04:54 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id c3sm6355041edr.33.2021.12.21.13.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:04:53 -0800 (PST) From: Cosmin Tanislav Cc: cosmin.tanislav@analog.com, demonsingur@gmail.com, Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/8] hwmon: (adt7x10) Store bus_dev in private data Date: Tue, 21 Dec 2021 23:04:32 +0200 Message-Id: <20211221210438.2637430-3-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221210438.2637430-1-demonsingur@gmail.com> References: <20211221210438.2637430-1-demonsingur@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Cosmin Tanislav It will later be used to access the bus device because callbacks only provide the hwmon device. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7x10.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index e9d33aa78a19..2439da9b64e6 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -56,6 +56,7 @@ struct adt7x10_data { const struct adt7x10_ops *ops; const char *name; struct device *hwmon_dev; + struct device *bus_dev; struct mutex update_lock; u8 config; u8 oldconfig; @@ -368,6 +369,7 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, data->ops = ops; data->name = name; + data->bus_dev = dev; dev_set_drvdata(dev, data); mutex_init(&data->update_lock); From patchwork Tue Dec 21 21:04:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12690617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40A48C433EF for ; Tue, 21 Dec 2021 21:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235800AbhLUVE6 (ORCPT ); Tue, 21 Dec 2021 16:04:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235412AbhLUVE5 (ORCPT ); Tue, 21 Dec 2021 16:04:57 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DBF6C061574; Tue, 21 Dec 2021 13:04:56 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id o6so200841edc.4; Tue, 21 Dec 2021 13:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dJbcpdnDDMMTdDCFrmCCsQpcL+qTK/8WeB+Pk+8w5E4=; b=ahXmpG1e/FJAPO0+XmSPXXwt38Y+SOz9yvH7JUZmK/RgXPRiaAx1O+a/dLqNTvtvU6 0YNl2xTv51nmPyflVpKQTv5v1tNzAP4i2+fCaWNghVJsn8F1aRwvVh0oK4XVD7krEzXp Wd5GxBlKw22EZYq/myzz8EGSoO61QZhV46z29exB+OwsmHxLia/Vbs9mkvCI2Wty8HBV EGJaG2A0Yu9WlkOdZk3i2rg1vxK8e9nJXNFi6I7JKNA/gzYJrcmeeoF9G+hcEzUgAkKO W9eCgQYGPcbWK3cR7w+AI8LSpr3xo/hNJZUV0sWsdZ9GLL95MQzKr/4iBzh9n8aGg7Td YYFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dJbcpdnDDMMTdDCFrmCCsQpcL+qTK/8WeB+Pk+8w5E4=; b=09EhqJgo9BuHAB//aN8FZKx2Gr7v/1a03Wn73BXSLJ++8m40prGP2ZIGSjIcxfP/NG p4L62/aOKCZ4yKAdNi+wZhEWpLsgY0dCMfo6Xn+wQwHmbZul/nIJ8FGpFY7F1JDvETRw YZKt8jfoI1ps/oGkilWqmmfPajo66utD5FyQs/O/hTKnZcB8eo6y4R/qmTqobgNZPMV0 5JvDw1UOXdzH/prNtm9lavNsj+U04b8IrtsNlR0V7grxGe62HmQ7TrWbPgV6t/cN4nRp bZ9p6U6ojheUpMXeS6ogvESGWyTeblp4LeUttLDu5wgshSSY8yeJ4RgNm5G0qnMylBOC jBPg== X-Gm-Message-State: AOAM530FYj7JbEzwQFuvnaR8FaNlavPx5APkcQsn5pLRn+jd9boI/ywl VQ/HgqTk7GX+KO9ZcMCdw3g= X-Google-Smtp-Source: ABdhPJyukoCDTR66KhUgA4WN9oCzhbkGVhBrNVa0NA9NSfBNWJpS2AvVsUrcMTGnvHmxQ7WzKLMkpw== X-Received: by 2002:a05:6402:4302:: with SMTP id m2mr69541edc.349.1640120695134; Tue, 21 Dec 2021 13:04:55 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id c3sm6355041edr.33.2021.12.21.13.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:04:54 -0800 (PST) From: Cosmin Tanislav Cc: cosmin.tanislav@analog.com, demonsingur@gmail.com, Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/8] hwmon: (adt7x10) Add device managed action for restoring config Date: Tue, 21 Dec 2021 23:04:33 +0200 Message-Id: <20211221210438.2637430-4-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221210438.2637430-1-demonsingur@gmail.com> References: <20211221210438.2637430-1-demonsingur@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Cosmin Tanislav To simplify the core driver remove function. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7x10.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index 2439da9b64e6..e8a6c541a590 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -357,6 +357,17 @@ static const struct attribute_group adt7x10_group = { .attrs = adt7x10_attributes, }; +static void adt7x10_restore_config(void *private) +{ + struct adt7x10_data *data = private; + struct device *dev = data->bus_dev; + + if (data->oldconfig == data->config) + return; + + adt7x10_write_byte(dev, ADT7X10_CONFIG, data->oldconfig); +} + int adt7x10_probe(struct device *dev, const char *name, int irq, const struct adt7x10_ops *ops) { @@ -397,14 +408,18 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, } dev_dbg(dev, "Config %02x\n", data->config); + ret = devm_add_action_or_reset(dev, adt7x10_restore_config, data); + if (ret) + return ret; + ret = adt7x10_fill_cache(dev); if (ret) - goto exit_restore; + return ret; /* Register sysfs hooks */ ret = sysfs_create_group(&dev->kobj, &adt7x10_group); if (ret) - goto exit_restore; + return ret; /* * The I2C device will already have it's own 'name' attribute, but for @@ -440,8 +455,6 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, device_remove_file(dev, &dev_attr_name); exit_remove: sysfs_remove_group(&dev->kobj, &adt7x10_group); -exit_restore: - adt7x10_write_byte(dev, ADT7X10_CONFIG, data->oldconfig); return ret; } EXPORT_SYMBOL_GPL(adt7x10_probe); @@ -457,8 +470,6 @@ void adt7x10_remove(struct device *dev, int irq) if (data->name) device_remove_file(dev, &dev_attr_name); sysfs_remove_group(&dev->kobj, &adt7x10_group); - if (data->oldconfig != data->config) - adt7x10_write_byte(dev, ADT7X10_CONFIG, data->oldconfig); } EXPORT_SYMBOL_GPL(adt7x10_remove); From patchwork Tue Dec 21 21:04:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12690623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69671C4332F for ; Tue, 21 Dec 2021 21:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235782AbhLUVFA (ORCPT ); Tue, 21 Dec 2021 16:05:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235693AbhLUVE6 (ORCPT ); Tue, 21 Dec 2021 16:04:58 -0500 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 923BCC061574; Tue, 21 Dec 2021 13:04:57 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id y13so50893edd.13; Tue, 21 Dec 2021 13:04:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3hzVVNNTwrq5MeJGsLzNhP86bxCeJA6LTvVaw5X/r10=; b=OskEJq3/KW0MjeBrRUj3nwaN1hCEx/JS5FDibN8BKckUHdzuLbgpfC9w90XWXZOI0K eF/P/q5GyEH/B/dLv+G40qyTekRs1M3J7ZyFXXgLwYrid688fzMyhmzG7fJyjikg6whD l47Mp9bTmsh29mZ6yUwaByz9bI/qpD2zz8H73t4HDJ73jWQCkPC3Hoe2Q4UgOD8bkDBt v4jiW5qP1jWPs7Dw4pFwj3EmOFj3ikJcbZcvCOnAvkTiXeSs3ETZRvvyLz8eMsAuqRgD Cm53eLPplQdAD56pAul16B1D67+mvCsGQnUpfpSS4+0T+aAWYw/1WPtt4B/BQD0rGRh0 SMSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3hzVVNNTwrq5MeJGsLzNhP86bxCeJA6LTvVaw5X/r10=; b=RY4tObGq1btJuhPWZKeiYYdi9PYgO+zWpX702rxePa2yGWXq4OwidC9XWFe4bxodGh yuRwKD0LIBBh4zFGOsuBZmZRKUFr8iTZsRhLAFMFjtg09LN3n96uDXYsAqgJkyCXeaDh piQWozd3DBInGS7nNANcIm3zqtX55qsASyiB4nbjQqHaj3/uDtYaTIkX2GEQJKLl+l20 PYLaMoOPySdb4Pw7zgTsUQvd1wPrc1q8yjZ0SDGDV2VViIcAnCwHtpwpwcY+kC1zUzM7 TfgiNLsmC7bPO6Vk8tqjalv7S8cY4SbPk3fdLzgBjsaiu+t26GZRfvrW2VprczrDKdcA 0SRg== X-Gm-Message-State: AOAM532ITYLQP998J4MY2r0tztIN6bLQdIj+zwOxbA8clatM1ihVvqBh q0vZbCcRlBYV2AKYu3E06BM= X-Google-Smtp-Source: ABdhPJxWGRdFKqq/zWCWc/m1Az1dr/zE11NNWeTLyh9L4cbqYAdCcCSr+/Wrcp/sg5q+mPOg7m3G9A== X-Received: by 2002:a17:906:ca44:: with SMTP id jx4mr72640ejb.135.1640120696190; Tue, 21 Dec 2021 13:04:56 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id c3sm6355041edr.33.2021.12.21.13.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:04:55 -0800 (PST) From: Cosmin Tanislav Cc: cosmin.tanislav@analog.com, demonsingur@gmail.com, Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/8] hwmon: (adt7x10) Use devm_hwmon_device_register_with_info Date: Tue, 21 Dec 2021 23:04:34 +0200 Message-Id: <20211221210438.2637430-5-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221210438.2637430-1-demonsingur@gmail.com> References: <20211221210438.2637430-1-demonsingur@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Cosmin Tanislav Describe the only available channel, implement read, write and is_visible callbacks. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7x10.c | 233 ++++++++++++++++++++-------------------- 1 file changed, 114 insertions(+), 119 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index e8a6c541a590..2e6e54bf1d15 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -54,8 +54,6 @@ /* Each client has this additional data */ struct adt7x10_data { const struct adt7x10_ops *ops; - const char *name; - struct device *hwmon_dev; struct device *bus_dev; struct mutex update_lock; u8 config; @@ -218,14 +216,11 @@ static int ADT7X10_REG_TO_TEMP(struct adt7x10_data *data, s16 reg) /* sysfs attributes for hwmon */ -static ssize_t adt7x10_temp_show(struct device *dev, - struct device_attribute *da, char *buf) +static int adt7x10_temp_read(struct adt7x10_data *data, int index, long *val) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct adt7x10_data *data = dev_get_drvdata(dev); - + struct device *dev = data->bus_dev; - if (attr->index == 0) { + if (index == 0) { int ret; ret = adt7x10_update_temp(dev); @@ -233,39 +228,28 @@ static ssize_t adt7x10_temp_show(struct device *dev, return ret; } - return sprintf(buf, "%d\n", ADT7X10_REG_TO_TEMP(data, - data->temp[attr->index])); + *val = ADT7X10_REG_TO_TEMP(data, data->temp[index]); + + return 0; } -static ssize_t adt7x10_temp_store(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) +static int adt7x10_temp_write(struct adt7x10_data *data, unsigned int nr, + long temp) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct adt7x10_data *data = dev_get_drvdata(dev); - int nr = attr->index; - long temp; + struct device *dev = data->bus_dev; int ret; - ret = kstrtol(buf, 10, &temp); - if (ret) - return ret; - mutex_lock(&data->update_lock); data->temp[nr] = ADT7X10_TEMP_TO_REG(temp); ret = adt7x10_write_word(dev, ADT7X10_REG_TEMP[nr], data->temp[nr]); - if (ret) - count = ret; mutex_unlock(&data->update_lock); - return count; + + return ret; } -static ssize_t adt7x10_t_hyst_show(struct device *dev, - struct device_attribute *da, char *buf) +static int adt7x10_hyst_read(struct adt7x10_data *data, unsigned int nr, + long *val) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct adt7x10_data *data = dev_get_drvdata(dev); - int nr = attr->index; int hyst; hyst = (data->hyst & ADT7X10_T_HYST_MASK) * 1000; @@ -276,85 +260,127 @@ static ssize_t adt7x10_t_hyst_show(struct device *dev, */ if (nr == 2) /* min has positive offset, others have negative */ hyst = -hyst; - return sprintf(buf, "%d\n", - ADT7X10_REG_TO_TEMP(data, data->temp[nr]) - hyst); + + *val = ADT7X10_REG_TO_TEMP(data, data->temp[nr]) - hyst; + + return 0; } -static ssize_t adt7x10_t_hyst_store(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) +static int adt7x10_hyst_write(struct adt7x10_data *data, long hyst) { - struct adt7x10_data *data = dev_get_drvdata(dev); - int limit, ret; - long hyst; + struct device *dev = data->bus_dev; + int limit; - ret = kstrtol(buf, 10, &hyst); - if (ret) - return ret; /* convert absolute hysteresis value to a 4 bit delta value */ limit = ADT7X10_REG_TO_TEMP(data, data->temp[1]); hyst = clamp_val(hyst, ADT7X10_TEMP_MIN, ADT7X10_TEMP_MAX); data->hyst = clamp_val(DIV_ROUND_CLOSEST(limit - hyst, 1000), - 0, ADT7X10_T_HYST_MASK); - ret = adt7x10_write_byte(dev, ADT7X10_T_HYST, data->hyst); - if (ret) - return ret; - - return count; + 0, ADT7X10_T_HYST_MASK); + return adt7x10_write_byte(dev, ADT7X10_T_HYST, data->hyst); } -static ssize_t adt7x10_alarm_show(struct device *dev, - struct device_attribute *da, char *buf) +static int adt7x10_alarm_read(struct adt7x10_data *data, unsigned int index, + long *val) { - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct device *dev = data->bus_dev; int ret; ret = adt7x10_read_byte(dev, ADT7X10_STATUS); if (ret < 0) return ret; - return sprintf(buf, "%d\n", !!(ret & attr->index)); + *val = !!(ret & index); + + return 0; +} + +static umode_t adt7x10_is_visible(const void *data, + enum hwmon_sensor_types type, + u32 attr, int channel) +{ + umode_t mode = 0444; + + switch (attr) { + case hwmon_temp_max: + case hwmon_temp_min: + case hwmon_temp_crit: + case hwmon_temp_max_hyst: + mode |= 0200; + break; + default: + break; + } + + return mode; +} + +static int adt7x10_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + struct adt7x10_data *data = dev_get_drvdata(dev); + + switch (attr) { + case hwmon_temp_input: + return adt7x10_temp_read(data, 0, val); + case hwmon_temp_max: + return adt7x10_temp_read(data, 1, val); + case hwmon_temp_min: + return adt7x10_temp_read(data, 2, val); + case hwmon_temp_crit: + return adt7x10_temp_read(data, 3, val); + case hwmon_temp_max_hyst: + return adt7x10_hyst_read(data, 1, val); + case hwmon_temp_min_hyst: + return adt7x10_hyst_read(data, 2, val); + case hwmon_temp_crit_hyst: + return adt7x10_hyst_read(data, 3, val); + case hwmon_temp_min_alarm: + return adt7x10_alarm_read(data, ADT7X10_STAT_T_LOW, val); + case hwmon_temp_max_alarm: + return adt7x10_alarm_read(data, ADT7X10_STAT_T_HIGH, val); + case hwmon_temp_crit_alarm: + return adt7x10_alarm_read(data, ADT7X10_STAT_T_CRIT, val); + default: + return -EOPNOTSUPP; + } } -static ssize_t name_show(struct device *dev, struct device_attribute *da, - char *buf) +static int adt7x10_write(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long val) { struct adt7x10_data *data = dev_get_drvdata(dev); - return sprintf(buf, "%s\n", data->name); + switch (attr) { + case hwmon_temp_max: + return adt7x10_temp_write(data, 1, val); + case hwmon_temp_min: + return adt7x10_temp_write(data, 2, val); + case hwmon_temp_crit: + return adt7x10_temp_write(data, 3, val); + case hwmon_temp_max_hyst: + return adt7x10_hyst_write(data, val); + default: + return -EOPNOTSUPP; + } } -static SENSOR_DEVICE_ATTR_RO(temp1_input, adt7x10_temp, 0); -static SENSOR_DEVICE_ATTR_RW(temp1_max, adt7x10_temp, 1); -static SENSOR_DEVICE_ATTR_RW(temp1_min, adt7x10_temp, 2); -static SENSOR_DEVICE_ATTR_RW(temp1_crit, adt7x10_temp, 3); -static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, adt7x10_t_hyst, 1); -static SENSOR_DEVICE_ATTR_RO(temp1_min_hyst, adt7x10_t_hyst, 2); -static SENSOR_DEVICE_ATTR_RO(temp1_crit_hyst, adt7x10_t_hyst, 3); -static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, adt7x10_alarm, - ADT7X10_STAT_T_LOW); -static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, adt7x10_alarm, - ADT7X10_STAT_T_HIGH); -static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, adt7x10_alarm, - ADT7X10_STAT_T_CRIT); -static DEVICE_ATTR_RO(name); - -static struct attribute *adt7x10_attributes[] = { - &sensor_dev_attr_temp1_input.dev_attr.attr, - &sensor_dev_attr_temp1_max.dev_attr.attr, - &sensor_dev_attr_temp1_min.dev_attr.attr, - &sensor_dev_attr_temp1_crit.dev_attr.attr, - &sensor_dev_attr_temp1_max_hyst.dev_attr.attr, - &sensor_dev_attr_temp1_min_hyst.dev_attr.attr, - &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, - &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, - &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, - &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, - NULL +static const struct hwmon_channel_info *adt7x10_info[] = { + HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MIN | + HWMON_T_CRIT | HWMON_T_MAX_HYST | HWMON_T_MIN_HYST | + HWMON_T_CRIT_HYST | HWMON_T_MIN_ALARM | + HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM), + NULL, +}; + +static const struct hwmon_ops adt7x10_hwmon_ops = { + .is_visible = adt7x10_is_visible, + .read = adt7x10_read, + .write = adt7x10_write, }; -static const struct attribute_group adt7x10_group = { - .attrs = adt7x10_attributes, +static const struct hwmon_chip_info adt7x10_chip_info = { + .ops = &adt7x10_hwmon_ops, + .info = adt7x10_info, }; static void adt7x10_restore_config(void *private) @@ -372,6 +398,7 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, const struct adt7x10_ops *ops) { struct adt7x10_data *data; + struct device *hdev; int ret; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); @@ -379,7 +406,6 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, return -ENOMEM; data->ops = ops; - data->name = name; data->bus_dev = dev; dev_set_drvdata(dev, data); @@ -416,26 +442,11 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, if (ret) return ret; - /* Register sysfs hooks */ - ret = sysfs_create_group(&dev->kobj, &adt7x10_group); - if (ret) + hdev = devm_hwmon_device_register_with_info(dev, name, data, + &adt7x10_chip_info, NULL); + if (IS_ERR(hdev)) { + ret = PTR_ERR(hdev); return ret; - - /* - * The I2C device will already have it's own 'name' attribute, but for - * the SPI device we need to register it. name will only be non NULL if - * the device doesn't register the 'name' attribute on its own. - */ - if (name) { - ret = device_create_file(dev, &dev_attr_name); - if (ret) - goto exit_remove; - } - - data->hwmon_dev = hwmon_device_register(dev); - if (IS_ERR(data->hwmon_dev)) { - ret = PTR_ERR(data->hwmon_dev); - goto exit_remove_name; } if (irq > 0) { @@ -443,33 +454,17 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, dev_name(dev), dev); if (ret) - goto exit_hwmon_device_unregister; + return ret; } return 0; - -exit_hwmon_device_unregister: - hwmon_device_unregister(data->hwmon_dev); -exit_remove_name: - if (name) - device_remove_file(dev, &dev_attr_name); -exit_remove: - sysfs_remove_group(&dev->kobj, &adt7x10_group); - return ret; } EXPORT_SYMBOL_GPL(adt7x10_probe); void adt7x10_remove(struct device *dev, int irq) { - struct adt7x10_data *data = dev_get_drvdata(dev); - if (irq > 0) free_irq(irq, dev); - - hwmon_device_unregister(data->hwmon_dev); - if (data->name) - device_remove_file(dev, &dev_attr_name); - sysfs_remove_group(&dev->kobj, &adt7x10_group); } EXPORT_SYMBOL_GPL(adt7x10_remove); From patchwork Tue Dec 21 21:04:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12690619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85158C43219 for ; Tue, 21 Dec 2021 21:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235906AbhLUVFA (ORCPT ); Tue, 21 Dec 2021 16:05:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235835AbhLUVE7 (ORCPT ); Tue, 21 Dec 2021 16:04:59 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81F21C061574; Tue, 21 Dec 2021 13:04:58 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id y13so51023edd.13; Tue, 21 Dec 2021 13:04:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=86w3eyiKacs5uaGphCz79xA1hlTYBtSnubTIMb1PBmo=; b=NX7xCB8Aex6XzSuYGWqRHcYEon+NkTDZ8fmUSilRev/npT7EUQw97FTSHfa2OvA1FL 09d6d7GsJ2x6UaAPGPMcktUhk1ouJtu85K9ys5YlfvJPWf8QhAqdtWUF/Zr9lDvehvYx 7fLdoMbZ8bHo/UCH9HYPxzKFKn07eYG3orXU5hfkSD/pwe1gI3PUkaeogO7hZJKPO83n ZUjNAelWqUIx1lEkc4WqwGn+IqxcYPmqfFgQAy1vchIUoTa1soz4x9WpwX8XQESHf3xk HO8j9KKKtokt2uAOGGKue27O7rF7uh0rs2BhdCJQU/mEFwiHtHN2Sc0NkwUzozFj8DIY 8WAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=86w3eyiKacs5uaGphCz79xA1hlTYBtSnubTIMb1PBmo=; b=3nLREtmV7tIcAkRZQHHq9qbm1F6Jn0QXOa/aPzmL6jacLPvWvOTNB/BZNWnyH6Xe8S hgi53C0AyFFkHd2zJgkM7rR8ChekKPm2n7fFMjRmVWVETLhMOCY8mAahJjhz6tcOz6Rc +tdmo3E3kg/Se4Lup5AHeveCO6FlNDU7WbfeRbonW+/4oPN0AlGsN9gkJiYTLxMzyNLb BSXs3plBPvY6pyZuRhiwK3G3g7ilRWboHrR2a4UOGsCVZoYU7EHN9Ge0L51Q63nwnwmD EoxktMHicWV8lVQl+m8A0K/IoPryhX7iiQiPRlLD577I6tDg8zT1MzqtATxLBZ66j+Sb iJYA== X-Gm-Message-State: AOAM5319u3blAaKWKi/HB8u9AEKbDgLuTNAE40gjM0M/PsDoHDs/+MGw 5oqrQIuIe901P1qFVPRVsPQ= X-Google-Smtp-Source: ABdhPJziDgJtitq2IfFdP6PBQ0inrdNJj/TOlJ4S7JkXy9qgbL/gvATdzwO36GseeKS1d/Hn0VSTVw== X-Received: by 2002:a17:907:9694:: with SMTP id hd20mr84497ejc.360.1640120697164; Tue, 21 Dec 2021 13:04:57 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id c3sm6355041edr.33.2021.12.21.13.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:04:56 -0800 (PST) From: Cosmin Tanislav Cc: cosmin.tanislav@analog.com, demonsingur@gmail.com, Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/8] hwmon: (adt7x10) Use devm_request_threaded_irq Date: Tue, 21 Dec 2021 23:04:35 +0200 Message-Id: <20211221210438.2637430-6-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221210438.2637430-1-demonsingur@gmail.com> References: <20211221210438.2637430-1-demonsingur@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Cosmin Tanislav To simplify the core driver remove function. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7x10.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index 2e6e54bf1d15..84e8879d4ca7 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -450,9 +450,11 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, } if (irq > 0) { - ret = request_threaded_irq(irq, NULL, adt7x10_irq_handler, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - dev_name(dev), dev); + ret = devm_request_threaded_irq(dev, irq, NULL, + adt7x10_irq_handler, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + dev_name(dev), dev); if (ret) return ret; } @@ -463,8 +465,6 @@ EXPORT_SYMBOL_GPL(adt7x10_probe); void adt7x10_remove(struct device *dev, int irq) { - if (irq > 0) - free_irq(irq, dev); } EXPORT_SYMBOL_GPL(adt7x10_remove); From patchwork Tue Dec 21 21:04:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12690621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A91BC4321E for ; Tue, 21 Dec 2021 21:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235953AbhLUVFB (ORCPT ); Tue, 21 Dec 2021 16:05:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235412AbhLUVE7 (ORCPT ); Tue, 21 Dec 2021 16:04:59 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82A89C061574; Tue, 21 Dec 2021 13:04:59 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id y13so51204edd.13; Tue, 21 Dec 2021 13:04:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BA+v3goAVRURICMHVlSY017b1rgwX+hSP8YzYWtBDZY=; b=mSiUnTv5w8enX0b6/8PFH7o2UKqfd/ZnuYkWlWm2rTNcqT2nP63+87lcDFw89xn8t0 fofeZCh77i//ggBh5SiSRyPOvYAPilwof2iW1RkqZUuRWfVb5Qch4+3V+FescsgZGa5Y +Ro2B8b7O7MuG4rLliCsgPcJZR+FSRUFtxDYParJnCfanU5nYevGkAzPoY3v/6OWYrep iYCGaJ3LmzAVIQsHuv3aD5E1iNNbJ7VGmzquMlu/EGzmGGc4qLUCI7HmjorFTq3qCTXe uiIvlyitqD+aNiJIVMF4/kTm1pOEHdt/yxrNVyFPeA9QEHk/OEDAeRTuRY7BB08WLS3V wh3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BA+v3goAVRURICMHVlSY017b1rgwX+hSP8YzYWtBDZY=; b=VXzXuJ548CjRkjmmQNgtpyl9rXY7/tQ41SzrMdU8+fQ1CRcUeF60QPRzMAwN3IvAhf X7db5zDymfcOgiTGI3zicAruG+DG8M4Gkha+O3w9uPMopRngTqv0sbAV1jR3wUSbTpyj QiJA9yuwAp0zASh0Cf7FrRbxYRJDw1AyIzfU+Ro/HduMfg8qsSQlvmV4Nie78oSUhqLH N8QCUNGSZ3cU1BLnsAj+fEDtZugDAgRjOKgB+fZ8sJ61TVwNync1K9+k19GgZVR0slEE Ir5LY3nW8D7Jep22Hdkfq9uH03XnZP0Fc7kPtrgKr0G87O0LTtN5EekFUIIDTryJFLCA Q9yg== X-Gm-Message-State: AOAM533nojMQFMg9xtlJTRUbetM8GsJnyn6PR5aV9q5jKZeVCeVQQJNd YdUJijVsQ3luSpPA/f9WMbg= X-Google-Smtp-Source: ABdhPJyitlYUpvhWvCVjI1iSiy0RIei5/ke1CSbDRQOK2r9PgLzKBzV+blp3rzf6lSBwHtnXGlVA6w== X-Received: by 2002:a05:6402:3589:: with SMTP id y9mr118876edc.44.1640120698122; Tue, 21 Dec 2021 13:04:58 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id c3sm6355041edr.33.2021.12.21.13.04.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:04:57 -0800 (PST) From: Cosmin Tanislav Cc: cosmin.tanislav@analog.com, demonsingur@gmail.com, Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/8] hwmon: (adt7x10) Remove empty driver removal callback Date: Tue, 21 Dec 2021 23:04:36 +0200 Message-Id: <20211221210438.2637430-7-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221210438.2637430-1-demonsingur@gmail.com> References: <20211221210438.2637430-1-demonsingur@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Cosmin Tanislav Not used to do anything anymore. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7310.c | 7 ------- drivers/hwmon/adt7410.c | 7 ------- drivers/hwmon/adt7x10.c | 5 ----- drivers/hwmon/adt7x10.h | 1 - 4 files changed, 20 deletions(-) diff --git a/drivers/hwmon/adt7310.c b/drivers/hwmon/adt7310.c index c40cac16af68..4a69b394525b 100644 --- a/drivers/hwmon/adt7310.c +++ b/drivers/hwmon/adt7310.c @@ -88,12 +88,6 @@ static int adt7310_spi_probe(struct spi_device *spi) &adt7310_spi_ops); } -static int adt7310_spi_remove(struct spi_device *spi) -{ - adt7x10_remove(&spi->dev, spi->irq); - return 0; -} - static const struct spi_device_id adt7310_id[] = { { "adt7310", 0 }, { "adt7320", 0 }, @@ -107,7 +101,6 @@ static struct spi_driver adt7310_driver = { .pm = ADT7X10_DEV_PM_OPS, }, .probe = adt7310_spi_probe, - .remove = adt7310_spi_remove, .id_table = adt7310_id, }; module_spi_driver(adt7310_driver); diff --git a/drivers/hwmon/adt7410.c b/drivers/hwmon/adt7410.c index ef4b5af865e9..2ad79533a384 100644 --- a/drivers/hwmon/adt7410.c +++ b/drivers/hwmon/adt7410.c @@ -48,12 +48,6 @@ static int adt7410_i2c_probe(struct i2c_client *client) return adt7x10_probe(&client->dev, client->name, client->irq, &adt7410_i2c_ops); } -static int adt7410_i2c_remove(struct i2c_client *client) -{ - adt7x10_remove(&client->dev, client->irq); - return 0; -} - static const struct i2c_device_id adt7410_ids[] = { { "adt7410", 0 }, { "adt7420", 0 }, @@ -68,7 +62,6 @@ static struct i2c_driver adt7410_driver = { .pm = ADT7X10_DEV_PM_OPS, }, .probe_new = adt7410_i2c_probe, - .remove = adt7410_i2c_remove, .id_table = adt7410_ids, .address_list = I2C_ADDRS(0x48, 0x49, 0x4a, 0x4b), }; diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index 84e8879d4ca7..72d3a5de359e 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -463,11 +463,6 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, } EXPORT_SYMBOL_GPL(adt7x10_probe); -void adt7x10_remove(struct device *dev, int irq) -{ -} -EXPORT_SYMBOL_GPL(adt7x10_remove); - #ifdef CONFIG_PM_SLEEP static int adt7x10_suspend(struct device *dev) diff --git a/drivers/hwmon/adt7x10.h b/drivers/hwmon/adt7x10.h index a1ae682eb32e..bde674e24ca0 100644 --- a/drivers/hwmon/adt7x10.h +++ b/drivers/hwmon/adt7x10.h @@ -26,7 +26,6 @@ struct adt7x10_ops { int adt7x10_probe(struct device *dev, const char *name, int irq, const struct adt7x10_ops *ops); -void adt7x10_remove(struct device *dev, int irq); #ifdef CONFIG_PM_SLEEP extern const struct dev_pm_ops adt7x10_dev_pm_ops; From patchwork Tue Dec 21 21:04:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12690627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBB16C4167D for ; Tue, 21 Dec 2021 21:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236058AbhLUVFC (ORCPT ); Tue, 21 Dec 2021 16:05:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235921AbhLUVFA (ORCPT ); Tue, 21 Dec 2021 16:05:00 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 450F1C061574; Tue, 21 Dec 2021 13:05:00 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id j6so64672edw.12; Tue, 21 Dec 2021 13:05:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4Jkv8qUJh2Qvz2gJBqyHxg6YZrouzoh2tHirL2oPEjY=; b=igfTCNPeEqrqU2Hlj2M3+4Twi3UY6fy00PXLLPVMJHkVRtq+C6LNSOPfeO1myu9+sG 7C486YJZmJ2QLd3bpJ/HgjczJViInA/lSBYRZXYah+AOLGB4l/8jktXDSImj0dnnzjRx xbaX7sISKTDtlGZqT2sGPRP6m0Tyg/ZoqvNemXUKwcv1w7Ax8131WmwWPpWmt/6xgd8H bnNdM0rFMJcx0k0/hfmjqAoVXUYOem7LaslXcxfhey/BBtH6N3xkOFuQie+AkNhBI8+M 4icpt/NkPigDKo5mKLm/+9PjxXKI6+NSNKFURDtRshZfB9E7iVXc8CMjEu4tcfly4BTO 6lYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4Jkv8qUJh2Qvz2gJBqyHxg6YZrouzoh2tHirL2oPEjY=; b=KKaqSi3vD1jGIT22X5ghP9mrYOLtfkgOnIyVQ4ODsP5xL97ABHo1wjHGrxEg4CfpCJ PjE/JsW2cP88A8cnB+U0Ru6lW/JYcO+199QW7wP6vpysGCEebQxNXbZWvNQ/0bKHYMon cXsvdm8nkn+w1oBCXO5X1sdK/8dT0fLSn8Sed26GEiK0Enym3dJWQnLOHoz0OwcolXws O8UbTvDmCQkbbDEpaiYsobHoVnLIAq/0gUWfIIVynnlxCLkOypXs0CwlPx2slbE16FIv sz0PrTFGy0guQkP8IHY2YZ2TpElG9ukBsIqSbIwhsuTYEUK4SZGvEXQ64CNqg1WLJsCW dv0Q== X-Gm-Message-State: AOAM5338R9l7xoI5laej0txnSFHBb17UMuAE2kIqWL71Hfl4RRfAo9Ge 7xjM4v0IfBiAPxLANFIbDog= X-Google-Smtp-Source: ABdhPJw2FNEV6mhN+5J/mxizTrVgzadVXqSACd6DMMMlfaVPvw/gXCJGg4WrGD73vqPN617f3lUmaw== X-Received: by 2002:a17:907:7f8f:: with SMTP id qk15mr65929ejc.455.1640120698934; Tue, 21 Dec 2021 13:04:58 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id c3sm6355041edr.33.2021.12.21.13.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:04:58 -0800 (PST) From: Cosmin Tanislav Cc: cosmin.tanislav@analog.com, demonsingur@gmail.com, Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/8] hwmon: (adt7x10) Pass hwinfo dev to irq handler Date: Tue, 21 Dec 2021 23:04:37 +0200 Message-Id: <20211221210438.2637430-8-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221210438.2637430-1-demonsingur@gmail.com> References: <20211221210438.2637430-1-demonsingur@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Cosmin Tanislav The irq handler will need to trigger events on the hwmon device. Pass it so that we don't store it in private data. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7x10.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index 72d3a5de359e..964cbe43de46 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -101,7 +101,9 @@ static const u8 ADT7X10_REG_TEMP[4] = { static irqreturn_t adt7x10_irq_handler(int irq, void *private) { - struct device *dev = private; + struct device *hdev = private; + struct adt7x10_data *d = dev_get_drvdata(hdev); + struct device *dev = d->bus_dev; int status; status = adt7x10_read_byte(dev, ADT7X10_STATUS); @@ -454,7 +456,7 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, adt7x10_irq_handler, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - dev_name(dev), dev); + dev_name(dev), hdev); if (ret) return ret; } From patchwork Tue Dec 21 21:04:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12690625 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAD9AC4167B for ; Tue, 21 Dec 2021 21:05:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235887AbhLUVFD (ORCPT ); Tue, 21 Dec 2021 16:05:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235982AbhLUVFB (ORCPT ); Tue, 21 Dec 2021 16:05:01 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D919C061574; Tue, 21 Dec 2021 13:05:01 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id f5so164970edq.6; Tue, 21 Dec 2021 13:05:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3Yt9Z3R3Mz6HQLD0UxdravpstVCwaJ2Fm/yBXqM+ku8=; b=n4OLQvlvm5aFJWIzBc3FERjNuR4yhgkD1lK9T8MKYXL5tTNS6gkGDPxr1Hlvp/6KnS AsrmgKRDUIas/iyyQjSP/PjNwW+wrTHeQZ9cjtaCxMiGvpBpbQyHwtL6g7O9Cr6pUTfx cw4QVTwoHWyPGj4pARhneCKAT+5UUh4msyVBvLoAMiMFD4qKalf3l1IZ5eNzUb7AQrYM BZPZA/izGmjGhhTFbNMRqq7eqV1omYgTikvOfXjl7rYrRwV8TaTm/MZNW9jygMOPNxPa bd2BwOmT9oBd34OZso1vkStFOYZOCfEAlTVr6XIIBGXhj61pPZncdXfaiQ93p4aB0qSi kBPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3Yt9Z3R3Mz6HQLD0UxdravpstVCwaJ2Fm/yBXqM+ku8=; b=5Z8nXG2MmQitkUCadDXNjWqt1W+NMiD68ZtxnvuXstRAhxy4t0AZgZTfLowkpPwjXB CbS+D1CgmRyeOUSUVTDeJ5bqOK3t0KosXKlVWAOdqmbfng5Gya3vgMBfGmjnjF+VNhYG gWoMU81aWm4TC1+rRNe5ztExEm9d0qcqavWwUr4L5iF2TPMn8cRDfNj/9YQF3mgOGDjn ltTtGEgoXyn3C+oLcgqDDStXKN47KEtRxPLlR4m+IiCrjIQSvRKrgASGrqhjO4dz9VJN 3R1e4lDxTTqDnGqjlgMrbzuB6vRjui5LY2An7+K+CBfUBmUwrLkacx3hWt/Zpo3duQG+ w9MA== X-Gm-Message-State: AOAM530B6TMRlZ8kjsphaTA52T2ZepwxkMTiwIiB+wbXY0Gx3wQuCkU4 Zpesbu+2kvS4YlnCZwpnYJE= X-Google-Smtp-Source: ABdhPJwIcImfbuQL6/fk0MuX0JYLCLcGLsaZzjCJjUTJefgrKdFcDv9rMHlUMTrO7j4ZzbES9/fVAg== X-Received: by 2002:a17:906:6a0d:: with SMTP id qw13mr89358ejc.490.1640120699786; Tue, 21 Dec 2021 13:04:59 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id c3sm6355041edr.33.2021.12.21.13.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:04:59 -0800 (PST) From: Cosmin Tanislav Cc: cosmin.tanislav@analog.com, demonsingur@gmail.com, Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/8] hwmon: (adt7x10) Use hwmon_notify_event Date: Tue, 21 Dec 2021 23:04:38 +0200 Message-Id: <20211221210438.2637430-9-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221210438.2637430-1-demonsingur@gmail.com> References: <20211221210438.2637430-1-demonsingur@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Cosmin Tanislav The hwmon subsystem provides means of notifying userspace about events. Use it. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7x10.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index 964cbe43de46..994160bd8901 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -111,11 +111,11 @@ static irqreturn_t adt7x10_irq_handler(int irq, void *private) return IRQ_HANDLED; if (status & ADT7X10_STAT_T_HIGH) - sysfs_notify(&dev->kobj, NULL, "temp1_max_alarm"); + hwmon_notify_event(hdev, hwmon_temp, hwmon_temp_max_alarm, 0); if (status & ADT7X10_STAT_T_LOW) - sysfs_notify(&dev->kobj, NULL, "temp1_min_alarm"); + hwmon_notify_event(hdev, hwmon_temp, hwmon_temp_min_alarm, 0); if (status & ADT7X10_STAT_T_CRIT) - sysfs_notify(&dev->kobj, NULL, "temp1_crit_alarm"); + hwmon_notify_event(hdev, hwmon_temp, hwmon_temp_crit_alarm, 0); return IRQ_HANDLED; }