From patchwork Tue Dec 21 21:58: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: 12690651 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 1134FC433F5 for ; Tue, 21 Dec 2021 21:58:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237478AbhLUV6q (ORCPT ); Tue, 21 Dec 2021 16:58:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230251AbhLUV6p (ORCPT ); Tue, 21 Dec 2021 16:58:45 -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 38B96C061574; Tue, 21 Dec 2021 13:58:45 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id y13so512086edd.13; Tue, 21 Dec 2021 13:58:45 -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=ierSayg6Die2nd/9Aa5Spr4PGfBZiSophXnaVzcqgoD5p8C72hZiPqmIJ81AS1B5JL 69FNr0LUWL67Bz32Mg7KMqnIzALCaRoUBQO7HHsBxWR+vgde+Ut6VUWOTwQyEJ4SMD5g 7DF3/yHnWgbob2w1RV4EXKjupojJ43Jtl1YPvqyNRFXMXDEgIu4MQ8/ETKra3O8Mmpwf uJ9sgGMHQ9pNCCMVOM6NkU57XPk+uoVnunbkdUjFTLngaLxPrOK9mzzQuAYUlWustn28 7FFXuSV7fFtegeqMqgnlLD8vxF8IwB7jfNz2zkl2Kq6ut6TzQo1epHon2uu921Dq0laf 36Dg== 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=ZGGnm0qmto6+bF1Qnmvz9laByFMrKdfBKEGYrxA29CdhyAKK6aGyFq76SzHC6Jjcd8 NmMklbicv3fekmcnSDvMFDnG8pxlIIi3OML9uNblwknlZ1gH9c7pbb5ao6JvhA6+YSJ6 WWVQnWa7vHf8ScM3y0qRtUy+0rXhhc4Lyh4hjyOfStP48KaVa7jaoudgU2XDow2TQkze DXjVMHANgb2LCHIhDEBHuisc3SihPQsZkVcQfHdcSEucb6z+RdPnQcMjvnT+4EUDb0jK gnzBE9HkXPaW6mh0565gSbS58Uq2BL3EyMlAMbkLHz7AC04ruMeIJaHGRJNTti/avwhq UH4Q== X-Gm-Message-State: AOAM530FHR2j0o1GWG+Zr/NAdymWmXpKHhagSJVra2WYed07BbPPR592 Gi4DN1gXXrVsMkkCQWql4Vg= X-Google-Smtp-Source: ABdhPJwRnHrUM2ZIH+Q2YXLAgYWKFCbG+Vydsnw2lQWh2CD85v+b9zIwEy6KBXunEzn0k0N3ENgoaw== X-Received: by 2002:a17:906:3e09:: with SMTP id k9mr250919eji.104.1640123923852; Tue, 21 Dec 2021 13:58:43 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id nc29sm41640ejc.3.2021.12.21.13.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:58:43 -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 v3 1/7] hwmon: (adt7x10) Store bus_dev in private data Date: Tue, 21 Dec 2021 23:58:35 +0200 Message-Id: <20211221215841.2641417-2-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221215841.2641417-1-demonsingur@gmail.com> References: <20211221215841.2641417-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:58: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: 12690653 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 95233C4332F for ; Tue, 21 Dec 2021 21:58:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237500AbhLUV6s (ORCPT ); Tue, 21 Dec 2021 16:58:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237492AbhLUV6q (ORCPT ); Tue, 21 Dec 2021 16:58:46 -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 61B50C061574; Tue, 21 Dec 2021 13:58:46 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id b13so584949edd.8; Tue, 21 Dec 2021 13:58:46 -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=D3cH2a/F3ZXGZdR1M/H1Ojzh7MgHqM8RSPtcPnS1IV3pX152Q5RDqn51wqjtYbyprh yEKfw7JfJhURocZJWeyJnLBqsknBC/QbSN3OguCGEX2TNivxUu+stBpGk6rZ/+1xqXUZ IOT3mxBduqo5/BTp/VEG5Z8eHVulR0kpi7nS7U/08mFIQnVClmG8+gzAHYxp1dV0QnpU PkKBfqPtxhBtOXiYBjFuepJV04r79tzF6mFVhM4n+qYfg18UjE3CWFpdAfVzsOYiQcDR B3z7pMZBDwb3mflHKU8BzveIfyfL/Xb7xyAz0UHuUc6SLF8T+UO2TMVBOl1X0hW/yRiQ +5Qw== 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=DlksHtOrQyZmsU7bPvY1m5kI5oD2xjdDByhRiWVnEt3lTivQMhXtjMV5XhxjrucgYm +J4W9mvh8YUFDh8DB0j2Pd2DmhnPI5S0LFKFMWD0pZMLvQGgHkknvLKX7jh/FsvgRTHv ip/unJv8M/PSwKqd8KkSObz/LyULiFwV3mjvl9oC5RCFXf64/KkejRO26uN9MJU2GWZl hE/oswgOgFqxRrCe7txs8bDWGnCbcZyoN00NwBm4W/kXwBQPA4FjvgllMKEXCFUC5OxZ wfLLqJifPkSn56DfBm2a9UNDZbgmvshVeE7NUPtEgktBASzhrV0eSfq5LqF9fmlum+xu 9jxg== X-Gm-Message-State: AOAM531GCFIUHXi3LJhB314+/S8ghse6JVOODpGSGex4UQjO28wi9W4G KGPA2TyBD3V5eD/ZhfZeYmrRywFu4Bg= X-Google-Smtp-Source: ABdhPJyqIIGze+tn1O3atyvBtE+uNQ42OU2fX45sIyTt9XrDZUXmAIRIejMOC/g0A0TkD1o4JFe6lw== X-Received: by 2002:a17:906:ae45:: with SMTP id lf5mr218735ejb.45.1640123925017; Tue, 21 Dec 2021 13:58:45 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id nc29sm41640ejc.3.2021.12.21.13.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:58:44 -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 v3 2/7] hwmon: (adt7x10) Add device managed action for restoring config Date: Tue, 21 Dec 2021 23:58:36 +0200 Message-Id: <20211221215841.2641417-3-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221215841.2641417-1-demonsingur@gmail.com> References: <20211221215841.2641417-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:58: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: 12690655 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 BA17EC433EF for ; Tue, 21 Dec 2021 21:58:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237532AbhLUV6s (ORCPT ); Tue, 21 Dec 2021 16:58:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237509AbhLUV6r (ORCPT ); Tue, 21 Dec 2021 16:58:47 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67083C061574; Tue, 21 Dec 2021 13:58:47 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id y22so691001edq.2; Tue, 21 Dec 2021 13:58:47 -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=XcqzRM8RDwerLbl1thBtWhW0C+OwpLmUtiB7M+iJjpc=; b=lCgL/d+zgS0WG1vCYmBGarUvHd9UhP6jPVURiAnIW0hwGrr85B+XKbfy8FbD3ePeNm V1/vpwQdYZKCttktHwxcEDCWyq7RqHlgd9u6g1fpjrptGeAm5+W+sma1vDMYG7gg5qqm 3Q6WUaocIGrWHuel18TjJWUMWWn2GeDTZbKmPkBZVYKrD7g2u8fd7+POP23U+dRCx0Ma LB4uOXdcBY4IXZRZV70LFfeb+cqbsr73fvETk7HcDJLxrEcrBBvDqtd9ulxUXEEHlbMk F/kOMH7bbABPDcEA5XGYpgcYuHkrinCHMzMSnWyAz9t6yclrkYpfbEQTa/JUrh7Wzdwg CWGA== 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=XcqzRM8RDwerLbl1thBtWhW0C+OwpLmUtiB7M+iJjpc=; b=wVBXGFJ2FRyvCbBbt+j2exljs8Ldx6zQx23vYcJxYJwfl6OKcIy0CJwxBgiKWVYspu gbwoQYE0QDomHNuLUjvDyjKIHpUn78EWRK317YFeQz1gNw6y2x0l45A3N8jvHdO/3YTq 2cvIHi6vblIU+pQkQx7Nsmtskc4OZrojjDzTq/hHFSPfcRYSpmPGgH+z3l0QAUixq5jB cY9OC4BD4JPiwijLDqr6IYo8132QypROHqzvonTkRlDXnX5w1pNIsdGzDBz4/j8HfI7g uLqupxOCt3zlPriSKam2EZWoQ1EIv7e8Phrypaa18b2OoNFYWeRc2KgPxwSstggwGhYB JIqQ== X-Gm-Message-State: AOAM532feeI0SDno5kKP6wmLAYMT3gpMN40Tv+9URsjVz++koj4Ikc6Z yDoCGOO2D8R/nU7FTKgO6s0= X-Google-Smtp-Source: ABdhPJwPWKxQBE+1oWwuDd+XMOaB9n2YY8RlXX2AqPOpLu4gqoc7j1gG/JEdf9FKLpJnHta0fqAPGQ== X-Received: by 2002:a17:907:d89:: with SMTP id go9mr205828ejc.417.1640123925987; Tue, 21 Dec 2021 13:58:45 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id nc29sm41640ejc.3.2021.12.21.13.58.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:58:45 -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 v3 3/7] hwmon: (adt7x10) Use devm_hwmon_device_register_with_info Date: Tue, 21 Dec 2021 23:58:37 +0200 Message-Id: <20211221215841.2641417-4-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221215841.2641417-1-demonsingur@gmail.com> References: <20211221215841.2641417-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. Also, pass name to core driver for the i2c device so that it can be used to register hwmon device. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7410.c | 2 +- drivers/hwmon/adt7x10.c | 233 ++++++++++++++++++++-------------------- 2 files changed, 115 insertions(+), 120 deletions(-) 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) 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:58: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: 12690657 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 C58E9C433F5 for ; Tue, 21 Dec 2021 21:58:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237564AbhLUV6t (ORCPT ); Tue, 21 Dec 2021 16:58:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237528AbhLUV6s (ORCPT ); Tue, 21 Dec 2021 16:58:48 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 219E4C061574; Tue, 21 Dec 2021 13:58:48 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id m21so1881490edc.0; Tue, 21 Dec 2021 13:58:48 -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=XB2Tr6o9qTFoFmGFrFf4pXRwC7i8kMvVUaT+EB+JEvNRTEMIlc/1p5lGZ39m8XMk7S GRkcB52AK2sy29ELZhUGSYfhC5uiRToawfsjedoZTxIysPAdrE3PLHVXCy0RVK6NcMWQ uM8FrHXrQOb/16bzkGggCTr22d1Xu28VXRBzPjdSXvdcO8OQnVj4UgLQ2iag1hszGK2n eA61+pnfVavEMtzg0vHKKaKHWpWhbBnQu6EGpSYm/BRKEtg2s6cyG2mQ5jynOYT2ots7 7m3XEymFa7yw9bWex/hqItU80e5xUzVBTAnVThUFWAgIcTY+FlTKrw3gF/Hqo5AMYOqT wOeA== 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=fzKD2A8jGw+ZS6ZkbhPBxgANl0gYy3Ar1spbCI++5Ih4PY6d2nkK/xHKbapEVKomcN J4YRWo6U7oBJZgsVZaQA/S1aB91P+ZVZw4ZQywJHQOviXfR4XrDXCCYSCu7PguQtxQoR fZtLh07KkYF5YLnuo7mU2Ct6cAqbIPKz4tAkIYvPulme7gtFcqYSufGoJDOGDBWd24/3 Y4cq+sRuRHR8dJO54BGjWxLgCDovj7UjdZ52Y4ycEB9+urFGazhU5BtVwV7hr3N4WqjD v5AI+Vc1BvSt92aD48ndONtFGqfB3Y2IOXp24+0GlPDbOwl745wnjNm7PPMUdJ5d47wn Yx8A== X-Gm-Message-State: AOAM532z5/zuS1ncdPAL9RSnN6s4fCAgGYtFdEdtRG91EkE1rYAaNR/2 ZwqZ/OqscMcFMWmzPhrNvOY= X-Google-Smtp-Source: ABdhPJw9HbpnoQ5r4jEJa9z3MfkenIhrxCUjYfO33xFG0Xtb+uqiWGhCGyyAr0OJuW0wGW83BINjtA== X-Received: by 2002:a17:906:2192:: with SMTP id 18mr189324eju.635.1640123926767; Tue, 21 Dec 2021 13:58:46 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id nc29sm41640ejc.3.2021.12.21.13.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:58:46 -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 v3 4/7] hwmon: (adt7x10) Use devm_request_threaded_irq Date: Tue, 21 Dec 2021 23:58:38 +0200 Message-Id: <20211221215841.2641417-5-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221215841.2641417-1-demonsingur@gmail.com> References: <20211221215841.2641417-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:58:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12690659 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 5E9FFC433EF for ; Tue, 21 Dec 2021 21:58:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237556AbhLUV6w (ORCPT ); Tue, 21 Dec 2021 16:58:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237579AbhLUV6t (ORCPT ); Tue, 21 Dec 2021 16:58:49 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 298BCC06173F; Tue, 21 Dec 2021 13:58:49 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id j6so520460edw.12; Tue, 21 Dec 2021 13:58:49 -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=qOR8cKxnS3ZJJz3OxqRS3itG7sanLjdILZWuTHo09csws4f4eFsGVX1pzrKpACL375 BIaUzK5aUDNDol2+pbW2sQI9AZA3bDcAH0yJ3WgHX2h3PlSmX9xJu0YJu77hbX2Zgp3m I+RFc34f7ieVSpI196swXqsYgO/1XhquxxfMNtHsqj1BxYEM2qkLo3ZfDBAihX6V4IOv O/i3XXtiLrwFvc/FcCgxtIDzfwKNBrpeNqWdUTNQ6PazvzQru2s3UO2/8c9sJfug2Yfg IetXODEQCwTMuqPJL+ByNE9AtmK9LVSzx2S6Hw8FGW0mdc2oidg4YvZTwI7aV/hDtBkz Qxcw== 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=Ks8IQO1kS+duxzq4ALUN0WOkWuNYyiyYJTEoUWohOP3XP7UTqQ5Tk94gMclVRPC33V DVzDP05tDJbLBc1P9IMROxfpgPscSPGZfnMCabvT2lLP4uRv6qZnTIRI7bsHc32oqt8m DT3qOxGXLNwJS3yM605cSRdoDGBPdeSox2sme8t+FQ4nz501hfxvLNS5QEwH/zeRjLJH THRmWpAvAUXC67fbQ5IneuZa1mQuhz9gGKmDfEYp4Q1R3jpVyZqPObCPSA3SiBr3TGA1 +UOnnA8ulIui2c35PJZ+A2t92uQ+zKdMxh1P7a9LHjBiAfPQkl+DbQu+kJ7n4g/GpM1I Tdww== X-Gm-Message-State: AOAM531fY2n8aXHQ+TWKUNN4AvpHWBcGK4FjMGaZTfVSE340YuOw26b3 gqD9/KgqSFphLmRe6m6Uc9vVxearg38= X-Google-Smtp-Source: ABdhPJzjx0M0kbQ8GokJoi0CRdhwYdurHNLq0F3uCkAm3peN6cBjtiC0G1C0TC1htpBKWxEGPguE9g== X-Received: by 2002:a17:907:da8:: with SMTP id go40mr247976ejc.78.1640123927790; Tue, 21 Dec 2021 13:58:47 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id nc29sm41640ejc.3.2021.12.21.13.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:58:47 -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 v3 5/7] hwmon: (adt7x10) Remove empty driver removal callback Date: Tue, 21 Dec 2021 23:58:39 +0200 Message-Id: <20211221215841.2641417-6-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221215841.2641417-1-demonsingur@gmail.com> References: <20211221215841.2641417-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:58:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12690663 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 AEB4DC433F5 for ; Tue, 21 Dec 2021 21:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237814AbhLUV67 (ORCPT ); Tue, 21 Dec 2021 16:58:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237606AbhLUV6u (ORCPT ); Tue, 21 Dec 2021 16:58:50 -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 345B0C061401; Tue, 21 Dec 2021 13:58:50 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id f5so621754edq.6; Tue, 21 Dec 2021 13:58:50 -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=iq/pk6NgohH+0UaKLHMIjTOf1BJewCVzMaRX8fja+VP6gaZtT/BnkkjWeosA6wufww ap9VDDkIqd+LjxK2qA9+Fv/rb3FhqFtDzGP4voHVrfui64fITFhXejU2n9Dx2C3rjY54 45cxcw0jUmR2Y43429FyZtqCm7BpiMwZiENY/hlAQWEck0VkcV6+wWVRoiplU4WPsCn0 vobPpEuzB35uSOICtNVJYnKdH/K8sjcVbM/0sI/2SNowcfj15e0MFFhS8eqPZ/F8z40B /ZJ9skqbu4xzzI0+mdF0ff5noCWzkfQtnA9xlcDpXroX3nfz8U4uqiw0cwouJlik5W6p PsYQ== 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=crLBEIrLUiMEBKAM6+PgnCSLHD18IRHEfHBNemjBRIGeYTBEadPSODztjzLUfSG+w+ Iz4qzYpbC8elaj2zbksxfUau6azM5E8FyBvneDM6E67pV+YMm4DR8nZR97lSvLfsriNU MyEDIE58f1LMIymzflkFh2KzOAUKgJOr5T7xUZq+YrXuJNA1oGUzoaEXarWkhALYFxxz 6DQab9GYGPnJaVXcOlESpbsCTnWBkIJP0OFaQGbafRLlnIfLNhn/Aw0rbhktIuOpM2is bt+awyExVO7IsDXYdGZfoFnWERV3Hc/VSMmIRAgrpw3iv02vGZoC7P9RoK/ulvxJs0Hh P7CQ== X-Gm-Message-State: AOAM532uDggSpYBkCM8zQ97vairKSdHPGjp8Q0AIr2UElShxgdm8iyau GcK0NRqJalvTQ5B47tjInfGpU9vQqJo= X-Google-Smtp-Source: ABdhPJytYgC1ieiOXEq23LGTvZpYuCfpCilP37zIO4lKpGr1ajXJTGAM+chws8JHAYec2Kvdm6MXuQ== X-Received: by 2002:a17:907:6eac:: with SMTP id sh44mr200986ejc.507.1640123928855; Tue, 21 Dec 2021 13:58:48 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id nc29sm41640ejc.3.2021.12.21.13.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:58:48 -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 v3 6/7] hwmon: (adt7x10) Pass hwinfo dev to irq handler Date: Tue, 21 Dec 2021 23:58:40 +0200 Message-Id: <20211221215841.2641417-7-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221215841.2641417-1-demonsingur@gmail.com> References: <20211221215841.2641417-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:58:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12690661 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 59CE5C433EF for ; Tue, 21 Dec 2021 21:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237793AbhLUV66 (ORCPT ); Tue, 21 Dec 2021 16:58:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237549AbhLUV6v (ORCPT ); Tue, 21 Dec 2021 16:58:51 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 387C8C061746; Tue, 21 Dec 2021 13:58:51 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id z29so604123edl.7; Tue, 21 Dec 2021 13:58:51 -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=MYoLkBG+axga/Oggw4eeYKGjRf8jdqPMoctwhgKBRq0IcUGwMTdG5zRFDAYFISzuJr uQyNfH679XJC+jZtn+RgzXExlmb6ZMYk6Hk4RfSYH6IBcZIpm4lnYvahEcFlgUWIuQVO R+VLL00pq5B2o4XQrfDMOUykbBQUYFtjOOT6b4i5pcfntTcYRUuHKLbXetSR205E7acv Ban5x6+GXTlEC5Zkta8uymPetyCQ0qRa0WO1S7T16YMc7Bu6rs97rFHrcO6gFfgbFtDZ /7uzYCSxOaRBE7Hfi908hLLAAF6bkgAUXhj1QTuPoI4yLvBnhtRbbkCzgaXu9+rduwpz h13w== 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=lg3SVABjX+uutWYJJs9uByWOS2kRANeWwOVik5zkgmhYW0Ct7kxvjxbWN8p2d62JKR Errx3i8+Nwtgbr79DoXjVEFLt3WslCOvsJ/KTnR63jqaJUPC5stLrW6GO2RpfNbHUdqE s/ZAYgufQtTLgw/2cU3b2Z7SHv+FOa/ppvz2Nk7n8Mw8RWMdcmCvY9hIq40GGS50uzk+ 3TxFcs8Z1r+2OvM0ayq4FM3bgtrxRtvosIF5dqIw4aIWWscLhUCi8OujGvFVRD1MWCOz uRGSI8AELO4wGyykkiUtRrbZ8Wg2T1GwQI4bJIW5kGIol8GnlV41HiRb8fch052Bxh2d HOng== X-Gm-Message-State: AOAM530g3/rWnG3lCq/TXzBE6WynEoTSZET6TJtw3HD2R5hjx0xoJBoC yg0NBblhgoI/806jcjrgGKY= X-Google-Smtp-Source: ABdhPJxQB6VZO9ytHpTGwPPz1Y+BwHv9b0sjQTvuy4A3o7avgCr9CXxOtjQ23PVRHAiuxg+9zj/uQQ== X-Received: by 2002:a05:6402:1014:: with SMTP id c20mr256187edu.186.1640123929806; Tue, 21 Dec 2021 13:58:49 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id nc29sm41640ejc.3.2021.12.21.13.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 13:58:49 -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 v3 7/7] hwmon: (adt7x10) Use hwmon_notify_event Date: Tue, 21 Dec 2021 23:58:41 +0200 Message-Id: <20211221215841.2641417-8-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221215841.2641417-1-demonsingur@gmail.com> References: <20211221215841.2641417-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; }