From patchwork Tue Dec 21 12:39: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: 12689595 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 46DC8C433F5 for ; Tue, 21 Dec 2021 12:39:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237673AbhLUMjz (ORCPT ); Tue, 21 Dec 2021 07:39:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237669AbhLUMjz (ORCPT ); Tue, 21 Dec 2021 07:39:55 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0839DC061574; Tue, 21 Dec 2021 04:39:55 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id b13so22919314edd.8; Tue, 21 Dec 2021 04:39: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:mime-version :content-transfer-encoding; bh=TZKAtR6UT3uSpTIEo5wgVOep5oODFFJr46+sXEmJhnY=; b=cYxoDmd5pHtB+fdeCXL9u3p5LFjnVJR5wWCzVbFPhtTY9S/iLZRItpeZndrhGfP8Ou wod5QyiZj5cZo3KzXTC2oh5ojx2nq3qv3Q7ZYlbGPKCbbNeM36LnxiQDcFj8oxjfYvcp m/3VCJppwjLApDFwsc8K2tCNG6yN8R3dcLJ1R/UhQFboRB5fRo9SL1cbOdcr6xJTTz2D 5ItNdNhyo/48uiGphLRwG5EBXFh/nkyWxxc+WVt6g52mIkNGRDIvJTcxwcT1Gyy+ykLq byKe4OSmmhskIRhLUtTSyGrCLsGBEmFkzdFYEV74FI7t3dkSiplTBKnf4YVXyxLYwUVj vB2w== 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:mime-version :content-transfer-encoding; bh=TZKAtR6UT3uSpTIEo5wgVOep5oODFFJr46+sXEmJhnY=; b=yxT4he0hhq9OFFXYKbpNBWWkBTBNE4n0RNG3ubjx0sKPKyPDKfKuVwEBh2cOVpxPvu 3BkdCS8/C7AsEuOMq49HVJGFmaN6EIWd2rbVTWwTZzVmdmJKYAhFJXxU6vS0AYWk04G0 khtM8mdmYxquC7Yb70XaIjfmVk44Ov8y3ZfqLryg2LmGHAJcZY1rv8I58JV0bBZFat4O OFTkeEl13cir+uDiQMEWomnCvXLYDqRh4nH2Ywu311cyaq7ifCY6XQQkKbfcZWO0Uwmy zyO/AJO2kbO08yzHqOA83CZP+smweF+IM+fA3LVGHDcmdBSjeF3OCTBnS///kX4fMEAG mKgQ== X-Gm-Message-State: AOAM530M/LhhhDEYEr1N+6/26IWRaqzlq208Nzlmz4tKyaKMFAf8z68Y tdJ2j4EHsCapltQ8+5/OCKY= X-Google-Smtp-Source: ABdhPJxorBbs+ZOY4zrPiT3tvXwEQD7t8LKd8Ic0fGCMm81ZtPpPeeNsDQVKo+AeLchg5K1AYcLStw== X-Received: by 2002:a17:906:544f:: with SMTP id d15mr2521978ejp.373.1640090393563; Tue, 21 Dec 2021 04:39:53 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id bx6sm2849438edb.78.2021.12.21.04.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 04:39: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 v1 01/10] hwmon: adt7x10: store bus_dev in private data Date: Tue, 21 Dec 2021 14:39:35 +0200 Message-Id: <20211221123944.2683245-1-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 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 12:39: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: 12689597 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 8EACBC433FE for ; Tue, 21 Dec 2021 12:39:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237687AbhLUMj5 (ORCPT ); Tue, 21 Dec 2021 07:39:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237669AbhLUMj4 (ORCPT ); Tue, 21 Dec 2021 07:39:56 -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 432B8C061574; Tue, 21 Dec 2021 04:39:56 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id m21so24311080edc.0; Tue, 21 Dec 2021 04:39: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=PGHTomnoudSBnMwZzQI7q9ra+4K/DkR0i4tdpCjGhhU=; b=TL9redEFE4M3KTGl7z0gfGeJ3GuHGGY48qXquQmTXZz+6UPccpyo2PhTmFyQvs74Ae bssz1Yyds6Wc8vf+j9YwThVpfSrr+M/CsNOx8w6uUNTcipLfKJZ5fhQcj5CyGuAouLns MKz19EmVZQu0Mkk7o7dtoRR22TXBRNRKyCy0iiLecMY3S5KuqmMT78d8K0a7aRPXee51 ILQeGDb3Q8l6oKiOxcwzv/TYlXopoLoRSr0k8Zomhvzh/dWtBS4ZSIK4NxlWkmDk13DM Z+YCnWGPQOlRBDZbORloEo77j+LdJPJ7uSs8qY8IxMhu6bZiI9S1hBVvJ2mPrtYk23Dk wNcA== 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=PGHTomnoudSBnMwZzQI7q9ra+4K/DkR0i4tdpCjGhhU=; b=o37mq/NHUObL63i+7o2leVZj+n15mFEGa78FS3/74CGI3R/6X5m9JPMp0RmcPtzRjL R3U9xcVWnPKXqyeh9DMuopt1rM0jSsBqJxEwBrjlwRD6soHtAL5bD7xrtPnVWNTnsxhr fD9pa31TV40cCZQhGd7lJ3TC2FIHa/snekAdQqhyYu6NW12C4OB6O8fHH8MyeO1JHRWt 55/h8vC72zi5YnxTOgsVLRmqPQBUaih5DjnOzAdrHF5UI4t2XQVDUFWeDupB+a6VhfF5 N/J9r4F0TsA8JXjABugxZ9sBhMWvs34eWloZ2z1VDYJxjnZSWVzOqECLHUJ7YwZkiYIH ovIg== X-Gm-Message-State: AOAM531Rwp6ymoZ2HH8ModYfODj7HvqAsHlNH1yIBXqeTTxWx6qOPVoT qWnxBo/34of0q3LMqQTPgkwPYPwIzck= X-Google-Smtp-Source: ABdhPJyZlf5MKekK91WHsEQH+gMTu7ZvoXySteKyWTeXR3Iis/zvJRFEo6ZqgJM9pUH5ksGspRfo5A== X-Received: by 2002:a17:906:c111:: with SMTP id do17mr2441150ejc.284.1640090394843; Tue, 21 Dec 2021 04:39:54 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id bx6sm2849438edb.78.2021.12.21.04.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 04:39: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 v1 02/10] hwmon: adt7x10: do not create name attr Date: Tue, 21 Dec 2021 14:39:36 +0200 Message-Id: <20211221123944.2683245-2-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221123944.2683245-1-demonsingur@gmail.com> References: <20211221123944.2683245-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 created automatically by hwmon. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7x10.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index 2439da9b64e6..dbe9f1ad7db0 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -54,7 +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; @@ -316,14 +315,6 @@ static ssize_t adt7x10_alarm_show(struct device *dev, return sprintf(buf, "%d\n", !!(ret & attr->index)); } -static ssize_t name_show(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct adt7x10_data *data = dev_get_drvdata(dev); - - return sprintf(buf, "%s\n", data->name); -} - 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); @@ -337,7 +328,6 @@ 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, @@ -368,7 +358,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); @@ -406,21 +395,10 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, if (ret) goto exit_restore; - /* - * 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; + goto exit_remove; } if (irq > 0) { @@ -435,9 +413,6 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, 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); exit_restore: @@ -454,8 +429,6 @@ void adt7x10_remove(struct device *dev, int irq) 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); if (data->oldconfig != data->config) adt7x10_write_byte(dev, ADT7X10_CONFIG, data->oldconfig); From patchwork Tue Dec 21 12:39: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: 12689599 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 DD86EC4332F for ; Tue, 21 Dec 2021 12:39:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237695AbhLUMj6 (ORCPT ); Tue, 21 Dec 2021 07:39:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237692AbhLUMj5 (ORCPT ); Tue, 21 Dec 2021 07:39:57 -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 3B24CC061574; Tue, 21 Dec 2021 04:39:57 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id o20so51392497eds.10; Tue, 21 Dec 2021 04:39: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=DtXTHbqxfUrJd07UnlL9gYnL8S+oVs50aZUatV+N5Uw=; b=FSw9+p/bP0dPHT8ZbOR/9MypFRQZNBtRi265hJmv3xL71xTmimNX+sOIm39KjoR7SP EqMkfTTjpVSy6UTc3nUmk9L1rtCbnxAWxoHj07V5+1OHRgCW4r0OYVQM8jl8WJkVeKvi f5CZJmoNf4IVBWxQG/ZGlMBbcWJmMxsM0xV91HZSeJBIN3D0zIwv1Sb0OpiJ4/Bj9zYJ z7q06PTRgsGymoe9qEB4wWVYeiJDdY1fZh6SbgSqEs8XBRrMr/hB9u5TswUTkBjKrGSK LQpQPpZKnbDMPUSVD1skT1nOMn+vpXWW1IPJVc+CbDEDmNeSnWHmH7+3EbakIXEFUsTX HU9g== 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=DtXTHbqxfUrJd07UnlL9gYnL8S+oVs50aZUatV+N5Uw=; b=UgRYhPISK/+CFEaMAvUOUBK1Qgxo/XrkzMgKIAY1GDiPMP29ZpK4UYkI+hoOfbZeti 9HqDbTpDNyi9ZPP3v1/HSDKESbjMT+RXe4l6U7HXmcdEK1+GWh+P9jxx+8n3CEDjMVEw PbtHS2wRHA3312RJSgbCE40qRNu41Na4xvhoyV8TwCGqMSmwrKzWv+/2BCiTVWX94ZoY bfelCZrBWSnjxorUhPHOEJMIv4ZKEbPpxSDRjnj0vjAUJCg6FtH1ZEKSsnIdMw5YjkON 2TpP8nwvjOl+BoqS0iatCMEQqK7Gw+DIZeOPsJXeXnU/s8LtzQKWpT7BWk8NWKGRBjUc 6dDw== X-Gm-Message-State: AOAM5312oy3eGgHc/Ozjd1Q3Yw4w33sFPT4YCPmIPz+3Y882pZT51bOs eVglC7tFs5G85PttArdBI7L7WXasbGY= X-Google-Smtp-Source: ABdhPJz+Jqsrx9cTrcMWsi+kFG0/IHU6mcAzciy758RLbJeLxFR+KAC/VHk8/AiC2/eESdSUOYsl0Q== X-Received: by 2002:a17:907:76d4:: with SMTP id kf20mr2571064ejc.44.1640090395900; Tue, 21 Dec 2021 04:39:55 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id bx6sm2849438edb.78.2021.12.21.04.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 04:39: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 v1 03/10] hwmon: adt7x10: use devm_request_threaded_irq Date: Tue, 21 Dec 2021 14:39:37 +0200 Message-Id: <20211221123944.2683245-3-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221123944.2683245-1-demonsingur@gmail.com> References: <20211221123944.2683245-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 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index dbe9f1ad7db0..48adc0344e88 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -402,9 +402,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) goto exit_hwmon_device_unregister; } @@ -425,9 +427,6 @@ 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); sysfs_remove_group(&dev->kobj, &adt7x10_group); if (data->oldconfig != data->config) From patchwork Tue Dec 21 12:39: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: 12689601 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 8AF4BC433EF for ; Tue, 21 Dec 2021 12:39:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237716AbhLUMj7 (ORCPT ); Tue, 21 Dec 2021 07:39:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237699AbhLUMj6 (ORCPT ); Tue, 21 Dec 2021 07:39:58 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E691C061574; Tue, 21 Dec 2021 04:39:58 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id y22so51604184edq.2; Tue, 21 Dec 2021 04:39: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=CBWf5Ppx/7/fPv+nycLzgXWnMKE3Jr3+eX+TUHaX4/c=; b=KoNUzHGpgrrSXFs6K6HgqGD0vm2SvFkfsxXPlJNt+KI/wq+tdab4/hFC6/57aACmIA AKu1DuR7R6MTOF0sTPXQrrM/27V6vyYCgzjhSh9JcPEwHkqOouCBIPtZRIJptLNRNDNP IVBULjwqfM6TbhDKWxjS87WEOrnElrpx4mk82PeaNavs33dpuA4denZXEsfzrq7j73x9 3V1fg059bL3DalmuRWHnSF5xNEKjLnsOGMiR4Tf+jbSF3sdtgj/nFWat0smn3exuigrW EUhajQCYaRfuGdc/RVpn9zNM63nVkVPVbbN10ksoQutnwZDAqWVtRDBsDRcMy/rqkZVS Bx1w== 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=CBWf5Ppx/7/fPv+nycLzgXWnMKE3Jr3+eX+TUHaX4/c=; b=EnXegOmqFRL3HNFjYgGTmqZ12IsCsb0uozF1mmag3ZnXTfQumGZehCzqcy/On8cKtE vmcuH8S/ELAkqtFTCYHz7xFBn+UHHfxHUbWncN8DUoi3Q7eXFbttP0WLhZOv00U3d71c HJHnWhOE0FAWSnVzLPB/zyc0wlZvhYunz6x5byl0Pr577VSTHCU5Y8KOtlBPutJOLn5u +XUJ6EyXORrQxp1baod5B79WeIpAaEDCfQmEZntJG8Q0iOhqNsCsoMTRpaZj/CAM66Qx FBXUcfxeq+aaQ9OKCgMvb7YBOVChhZ/FpKKPZem2Rj6aIJ1mbpfBmSqeHzyL7kXK3e5I AWKw== X-Gm-Message-State: AOAM5329IHxpeSgNCSTXm8rtyvJB51blQOmVlggUr8uhsXr0q/3AJY9V TG6thjO7k1u7OvdfKybeBGo= X-Google-Smtp-Source: ABdhPJyPmJ26z4eTRp+XmO+ZZ7PKM1K2ZN34dxMKBq2pz5GJ3s3eLofqRJUF/q9z+CXfNPUjCDoW2g== X-Received: by 2002:aa7:d593:: with SMTP id r19mr3140820edq.168.1640090396802; Tue, 21 Dec 2021 04:39:56 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id bx6sm2849438edb.78.2021.12.21.04.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 04:39: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 v1 04/10] hwmon: adt7x10: avoid storing hwinfo dev into private data Date: Tue, 21 Dec 2021 14:39:38 +0200 Message-Id: <20211221123944.2683245-4-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221123944.2683245-1-demonsingur@gmail.com> References: <20211221123944.2683245-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 Store it later in the code to reduce the number of references to the private data structure, so it is easier to remove it altogether. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7x10.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index 48adc0344e88..25c1ab199658 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -351,6 +351,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); @@ -395,9 +396,9 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, if (ret) goto exit_restore; - data->hwmon_dev = hwmon_device_register(dev); - if (IS_ERR(data->hwmon_dev)) { - ret = PTR_ERR(data->hwmon_dev); + hdev = hwmon_device_register(dev); + if (IS_ERR(hdev)) { + ret = PTR_ERR(hdev); goto exit_remove; } @@ -411,10 +412,12 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, goto exit_hwmon_device_unregister; } + data->hwmon_dev = hdev; + return 0; exit_hwmon_device_unregister: - hwmon_device_unregister(data->hwmon_dev); + hwmon_device_unregister(hdev); exit_remove: sysfs_remove_group(&dev->kobj, &adt7x10_group); exit_restore: From patchwork Tue Dec 21 12:39: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: 12689603 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 D56FDC433FE for ; Tue, 21 Dec 2021 12:40:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237726AbhLUMkA (ORCPT ); Tue, 21 Dec 2021 07:40:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237669AbhLUMj7 (ORCPT ); Tue, 21 Dec 2021 07:39:59 -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 17559C061574; Tue, 21 Dec 2021 04:39:59 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id x15so51582179edv.1; Tue, 21 Dec 2021 04:39: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=ygo8ojrCo6BZT32LoIuN07MJGwf7kqUO/5JQytz0V/s=; b=GCege4vuFl7SWJxuixyuNgk5DAhMWrElUtjVPPtUjDP1lVOZhMjw/ZfbxHA+yaMjyh FPNygCD54AWOko8COyuDLXP1AjIKnoCAZFImdEhV3q++6UcUCOge29u0jO5Pzx8HeLhK rMdhKbXr1dDCGmeZzeX0zHK7i0wzBPtudkZbkk/LTv6HX/amBxSLMKBW5d8eu22UoYus 33bs9Y7dUq/WVy34AUJHJvhtHJt/ciHL1Pk7zM3OgwlCwqwjY/J+0Eps4w1foU7IfUpH vLx1D01UDivKyvuuYjDFuFHmz39vxezjDQk2Fl1EYVPBpKs5liL7sSCtoPTcEkm9gBO9 8s2w== 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=ygo8ojrCo6BZT32LoIuN07MJGwf7kqUO/5JQytz0V/s=; b=pjG9HOPBa7sRgNACX1E8O2AciICcgc1OyC/cA361jSz23ilgYy9+Wdpqzz01i3WgTM pj1uR9Bxeb2RgVx0zr/U+D9MQiPpVuD9ttD5CJFWCffPH7BHPEBzOu3yGyX79DsD1ut6 5MqrMxwj0H81ZOfkOr1GmWMhK3yFP+qDDgfXVk9Ud0BIlUuZI7iwv+yA2Qxp9C9n2Up7 //txFV7v5k3uM9BVErMFPqfnb2YouAfWxtbjPmzB6UyTMudFC8JX0R3EhkoQ8NFZNR29 jZ7E/yfRkjrQsbL9qHVgWcuOMUPr15NOZBfJbYRPEGZOSok4dao5h7qg5Bmr9Wn2zkDh KtdQ== X-Gm-Message-State: AOAM530Uq5K3vZxPISp3n8vf3HnoyhZzSNLfvZbhXUwJsKwNLU4bTwef O/1JaPflXrQYbCe7wzIRLWk= X-Google-Smtp-Source: ABdhPJzDKbYAb40eOpQQohllGJi1aX/EbebO/vPFulK8FiyD6xOty3p6IxpGRm7mJr0xOAOE2ECfaA== X-Received: by 2002:aa7:c943:: with SMTP id h3mr3001616edt.233.1640090397706; Tue, 21 Dec 2021 04:39:57 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id bx6sm2849438edb.78.2021.12.21.04.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 04:39: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 v1 05/10] hwmon: adt7x10: pass hwinfo dev to irq handler Date: Tue, 21 Dec 2021 14:39:39 +0200 Message-Id: <20211221123944.2683245-5-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221123944.2683245-1-demonsingur@gmail.com> References: <20211221123944.2683245-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 25c1ab199658..ec7e526b3441 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -102,7 +102,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); @@ -407,7 +409,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) goto exit_hwmon_device_unregister; } From patchwork Tue Dec 21 12:39: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: 12689605 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 E8B43C433F5 for ; Tue, 21 Dec 2021 12:40:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237699AbhLUMkD (ORCPT ); Tue, 21 Dec 2021 07:40:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237735AbhLUMkA (ORCPT ); Tue, 21 Dec 2021 07:40:00 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03F44C061574; Tue, 21 Dec 2021 04:40:00 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id o6so5331990edc.4; Tue, 21 Dec 2021 04:39: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=yLI7yyMCR/wZwwErBiG14/ZfDoLMNfHa8Yt+CsPWzTc=; b=S1BtZp8Pen+EHSXCAVWQ3WL5JxPyGtEL/tT+DwJPR5tKdiB4G2+xP2Uj69mImKTaFz epCeKJUDNuSV7bURwDSoy/u978p7PPd2tRU3LShWLNEcVe2daMLSxcdEZH4lc5hstin2 PdINhW/N4bKxoMMy+1rqnB4B6NSSSg0VA3dSGjXciw7PUxc1FJ6O33HqBvZDAlwvtebG wcxLpuu2VkP81MuC2jmzrkWrv695ICVlJQqqVslaLzC+SwwiqYYPzTxC2MrRy27fvcAz XHZYj4LOMc+wWx2KvReL8brXkyErKXB5R9IKAbk/OHoKIqzheRKpPlZI26NIywN5lsH2 6HGw== 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=yLI7yyMCR/wZwwErBiG14/ZfDoLMNfHa8Yt+CsPWzTc=; b=N6b3TnEOwdwdqcsXiNTqdt4zD3W0v62R4wRJW2EbhtGxj+0U85JHMlYwn0u/QX3er8 A0Ldol0ktFoI0yLUtpSMlz6aJwSf8m05Q+ncMpMiBCs3U7Tp/VuSR3Bjn0BPdI2Kof1v tgwsDczGpzitnQtRUO47DC6EwAGGWfyR1G4m/vgCeu/0NziUuYItPG1OHzIEv23AbqNb jhWNhWN2jOQypwiMt3v67PbGMDk8lj6lr8I1GtRpcVQkXVkkkB2BAPaAw7fxMHYdjomo cHWqbeBpOqxpCx7w09XHm+8Ow4L1Hpmpum2J0Kvih+6nko5WX+La0W44tqBq9TYgSHBJ 19VQ== X-Gm-Message-State: AOAM532D/xJbKrmoV+m4kARNe2Vme6+WSKJOfoDthwzD/pNEE7Kw2+ot qDFKZtXPAg1ioVQaycyMz4E= X-Google-Smtp-Source: ABdhPJyIazNCi4XVKYVsjXsFeoIBARZIknQOnQALt0b9ZGvgcGnNWay3m5U7/KMhUSOufJk2dpS3iQ== X-Received: by 2002:a05:6402:3512:: with SMTP id b18mr1969514edd.315.1640090398611; Tue, 21 Dec 2021 04:39:58 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id bx6sm2849438edb.78.2021.12.21.04.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 04:39: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 v1 06/10] hwmon: adt7x10: extract read/write methods from show/store Date: Tue, 21 Dec 2021 14:39:40 +0200 Message-Id: <20211221123944.2683245-6-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221123944.2683245-1-demonsingur@gmail.com> References: <20211221123944.2683245-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 These will later be used by hwmon read and write callbacks. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7x10.c | 128 +++++++++++++++++++++++++++++----------- 1 file changed, 95 insertions(+), 33 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index ec7e526b3441..32ea9438ad64 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -219,14 +219,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); @@ -234,39 +231,62 @@ 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 ssize_t adt7x10_temp_show(struct device *dev, + struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct adt7x10_data *data = dev_get_drvdata(dev); - int nr = attr->index; - long temp; + long val; int ret; - ret = kstrtol(buf, 10, &temp); + ret = adt7x10_temp_read(data, attr->index, &val); if (ret) return ret; + return sprintf(buf, "%ld\n", val); +} + +static int adt7x10_temp_write(struct adt7x10_data *data, unsigned int nr, + long temp) +{ + struct device *dev = data->bus_dev; + int 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 ssize_t adt7x10_temp_store(struct device *dev, + struct device_attribute *da, + const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct adt7x10_data *data = dev_get_drvdata(dev); int nr = attr->index; + long temp; + int ret; + + ret = kstrtol(buf, 10, &temp); + if (ret) + return ret; + + ret = adt7x10_temp_write(data, nr, temp); + + return ret ?: count; +} + +static int adt7x10_hyst_read(struct adt7x10_data *data, unsigned int nr, + long *val) +{ int hyst; hyst = (data->hyst & ADT7X10_T_HYST_MASK) * 1000; @@ -277,44 +297,86 @@ 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 ssize_t adt7x10_t_hyst_show(struct device *dev, + struct device_attribute *da, char *buf) { + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct adt7x10_data *data = dev_get_drvdata(dev); - int limit, ret; - long hyst; + int nr = attr->index; + long val; + int ret; - ret = kstrtol(buf, 10, &hyst); + ret = adt7x10_hyst_read(data, nr, &val); if (ret) return ret; + + return sprintf(buf, "%ld\n", val); +} + +static int adt7x10_hyst_write(struct adt7x10_data *data, long hyst) +{ + struct device *dev = data->bus_dev; + int limit; + /* 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); + 0, ADT7X10_T_HYST_MASK); + return adt7x10_write_byte(dev, ADT7X10_T_HYST, data->hyst); +} + +static ssize_t adt7x10_t_hyst_store(struct device *dev, + struct device_attribute *da, + const char *buf, size_t count) +{ + struct adt7x10_data *data = dev_get_drvdata(dev); + int ret; + long hyst; + + ret = kstrtol(buf, 10, &hyst); if (ret) return ret; - return count; + ret = adt7x10_hyst_write(data, hyst); + + return ret ?: count; +} + +static int adt7x10_alarm_read(struct adt7x10_data *data, unsigned int index, + long *val) +{ + struct device *dev = data->bus_dev; + int ret; + + ret = adt7x10_read_byte(dev, ADT7X10_STATUS); + if (ret < 0) + return ret; + + *val = !!(ret & index); + + return 0; } static ssize_t adt7x10_alarm_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct adt7x10_data *data = dev_get_drvdata(dev); + long val; int ret; - ret = adt7x10_read_byte(dev, ADT7X10_STATUS); - if (ret < 0) + ret = adt7x10_alarm_read(data, attr->index, &val); + if (ret) return ret; - return sprintf(buf, "%d\n", !!(ret & attr->index)); + return sprintf(buf, "%ld\n", val); } static SENSOR_DEVICE_ATTR_RO(temp1_input, adt7x10_temp, 0); From patchwork Tue Dec 21 12:39: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: 12689607 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 392BDC4332F for ; Tue, 21 Dec 2021 12:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237750AbhLUMkE (ORCPT ); Tue, 21 Dec 2021 07:40:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237753AbhLUMkB (ORCPT ); Tue, 21 Dec 2021 07:40:01 -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 41526C061401; Tue, 21 Dec 2021 04:40:01 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id w16so23087042edc.11; Tue, 21 Dec 2021 04:40: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=IcB2BjW/je/z2W0QLJ5NHEYQ0lcg6pJsIYClTsB+508=; b=iGVwW/gcp13Lf/qugV37HY3XYTYotylcxpUaWyFad+xJ25j6f4VftJN+vVgKlfE9eL 0VJj9kvHBGDoDFG+aIT9UQkfU1Y8fWd2x1m8bsbpNdvrzomAEyTPDX0rx5JFDVUa00pp ZUvfhjBt/hndX+Lwg1IPbrkBBVVCVkf8pI3/HlfFHfHveFAo9Afhid3dPZrAbMmpaQst F5wAbAJDIgQj3OnqNVhz+ymBYlXzn7JxMyX2G2IvJlhCW+7zqTvjSs59t6INK56o+Lmk NJFna+zYBG9sza3qPH6yj2MdMbai+qbuDJZBX1ntvo59Oh3YKn/7/Xb6yBYHm9fZelgs 4Jrg== 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=IcB2BjW/je/z2W0QLJ5NHEYQ0lcg6pJsIYClTsB+508=; b=tHVYcQch6JoqLjUnXij5Wj88Zc1BGnj3HKLd1y3y1YfkG1FJQf3HuqD+I8efWSlPuK +zStZtTlJp1LoTKnhdluRFNfAa2e/UL5uuTRJwwMDKnnGBDN65im4CxKMv5vaGSAyFI+ YmokOL+sQmAGcuHqlijdw81VJnGmCdJqwTXlxIWYuvBcSjdhuojFKX3d0cz5G9kgOW2q 6KLOJ/GtODw/gxEilZTtjG509EwWeB42MxDuDc2HWG1eigSIpJTqyk9yjXcTk9bauFgn mTMMyIZ/1aDTlmysz+Vc1NUoRWHyr/WQZhlXit+gOeQQaVWvk7dR/XTypj3aGVnDiLhJ 7dEw== X-Gm-Message-State: AOAM531dyteG1qYQqAFycgioCXm+ZhxACmhktJyxpBmdnAzHSYcTFd+Y 8aJ+XQW0bv8sBg731bAu8j8= X-Google-Smtp-Source: ABdhPJwb60KFw5+WUwAN7WIqnP22dg1Z/yN2by40cdR6lbFcchg2Scf3oHhKqE5uzIf5mBXhmrLS8A== X-Received: by 2002:a50:ec89:: with SMTP id e9mr3134208edr.162.1640090399475; Tue, 21 Dec 2021 04:39:59 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id bx6sm2849438edb.78.2021.12.21.04.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 04:39: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 v1 07/10] hwmon: adt7x10: remove attrs Date: Tue, 21 Dec 2021 14:39:41 +0200 Message-Id: <20211221123944.2683245-7-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221123944.2683245-1-demonsingur@gmail.com> References: <20211221123944.2683245-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 These will be replaced by hwmon read and write callbacks. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7x10.c | 124 +--------------------------------------- 1 file changed, 1 insertion(+), 123 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index 32ea9438ad64..2d36088e1a07 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -236,21 +236,6 @@ static int adt7x10_temp_read(struct adt7x10_data *data, int index, long *val) return 0; } -static ssize_t adt7x10_temp_show(struct device *dev, - struct device_attribute *da, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct adt7x10_data *data = dev_get_drvdata(dev); - long val; - int ret; - - ret = adt7x10_temp_read(data, attr->index, &val); - if (ret) - return ret; - - return sprintf(buf, "%ld\n", val); -} - static int adt7x10_temp_write(struct adt7x10_data *data, unsigned int nr, long temp) { @@ -265,25 +250,6 @@ static int adt7x10_temp_write(struct adt7x10_data *data, unsigned int nr, return ret; } -static ssize_t adt7x10_temp_store(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct adt7x10_data *data = dev_get_drvdata(dev); - int nr = attr->index; - long temp; - int ret; - - ret = kstrtol(buf, 10, &temp); - if (ret) - return ret; - - ret = adt7x10_temp_write(data, nr, temp); - - return ret ?: count; -} - static int adt7x10_hyst_read(struct adt7x10_data *data, unsigned int nr, long *val) { @@ -303,22 +269,6 @@ static int adt7x10_hyst_read(struct adt7x10_data *data, unsigned int nr, return 0; } -static ssize_t adt7x10_t_hyst_show(struct device *dev, - struct device_attribute *da, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct adt7x10_data *data = dev_get_drvdata(dev); - int nr = attr->index; - long val; - int ret; - - ret = adt7x10_hyst_read(data, nr, &val); - if (ret) - return ret; - - return sprintf(buf, "%ld\n", val); -} - static int adt7x10_hyst_write(struct adt7x10_data *data, long hyst) { struct device *dev = data->bus_dev; @@ -332,23 +282,6 @@ static int adt7x10_hyst_write(struct adt7x10_data *data, long hyst) return adt7x10_write_byte(dev, ADT7X10_T_HYST, data->hyst); } -static ssize_t adt7x10_t_hyst_store(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct adt7x10_data *data = dev_get_drvdata(dev); - int ret; - long hyst; - - ret = kstrtol(buf, 10, &hyst); - if (ret) - return ret; - - ret = adt7x10_hyst_write(data, hyst); - - return ret ?: count; -} - static int adt7x10_alarm_read(struct adt7x10_data *data, unsigned int index, long *val) { @@ -364,53 +297,6 @@ static int adt7x10_alarm_read(struct adt7x10_data *data, unsigned int index, return 0; } -static ssize_t adt7x10_alarm_show(struct device *dev, - struct device_attribute *da, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct adt7x10_data *data = dev_get_drvdata(dev); - long val; - int ret; - - ret = adt7x10_alarm_read(data, attr->index, &val); - if (ret) - return ret; - - return sprintf(buf, "%ld\n", val); -} - -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 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 attribute_group adt7x10_group = { - .attrs = adt7x10_attributes, -}; - int adt7x10_probe(struct device *dev, const char *name, int irq, const struct adt7x10_ops *ops) { @@ -455,15 +341,10 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, if (ret) goto exit_restore; - /* Register sysfs hooks */ - ret = sysfs_create_group(&dev->kobj, &adt7x10_group); - if (ret) - goto exit_restore; - hdev = hwmon_device_register(dev); if (IS_ERR(hdev)) { ret = PTR_ERR(hdev); - goto exit_remove; + goto exit_restore; } if (irq > 0) { @@ -482,8 +363,6 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, exit_hwmon_device_unregister: hwmon_device_unregister(hdev); -exit_remove: - sysfs_remove_group(&dev->kobj, &adt7x10_group); exit_restore: adt7x10_write_byte(dev, ADT7X10_CONFIG, data->oldconfig); return ret; @@ -495,7 +374,6 @@ void adt7x10_remove(struct device *dev, int irq) struct adt7x10_data *data = dev_get_drvdata(dev); hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&dev->kobj, &adt7x10_group); if (data->oldconfig != data->config) adt7x10_write_byte(dev, ADT7X10_CONFIG, data->oldconfig); } From patchwork Tue Dec 21 12:39:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12689609 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 EBCFBC43217 for ; Tue, 21 Dec 2021 12:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237669AbhLUMkF (ORCPT ); Tue, 21 Dec 2021 07:40:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237757AbhLUMkC (ORCPT ); Tue, 21 Dec 2021 07:40:02 -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 CB9E3C061747; Tue, 21 Dec 2021 04:40:01 -0800 (PST) Received: by mail-ed1-x536.google.com with SMTP id f5so28352980edq.6; Tue, 21 Dec 2021 04:40: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=IyNVKXDWR36ykQcClTsSbztRleUEblizENFlHFdt5IA=; b=TbmZ3FEnJJhfZTBC2nxDLfieJ/gZf8DFoEe4NTn0luMUu9vG5m9hM4HfxGeRsxn3aL hXDAjSQ0HqNZ6r3zuS9FVw8REsS1G/q/Y69ECCD1YXlt5f2e/sDRo8SAvcakw3+iKZFJ 9zB+Zju2zwnsmp+6G00plfdfyofSmECNX/Vy5crFqOKdiFUuzQP6+3D27Xrb8BTcGQ0L o6RQa3kIr/5erkedjn1EooC1rjXaMCmy4BX8/mYBljPvgnBZDHwMS8lpFE2nKlEABGVj qjve7xyDXbNH6LeI96F3VCVh4/ghs0C1PkARC+xuXeKhCb5xOBxpCNpHhXTf2SxR4X3+ jkZA== 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=IyNVKXDWR36ykQcClTsSbztRleUEblizENFlHFdt5IA=; b=ACmnG3nPbPhAxKIMTO9xNjVGcuOoHG7liAK72H6E8cqFx9AfH4ZbbZiqOkeyctQWCY us2uDyFqXzEGr2zkb0jXMe2jAGkRAxbqlTQUzIr/xmJ5MHqLwuWBJRcs/7tve25xmqez kh5SiDC3tfheAahxgsAsbnA/QcZWFMuBVBMgz3vo5IRGsKje2Q5fxqNm6L9/An78BOU5 BlFEVOUVGoFDGiUOadsD55yphMwErj2hPZAEsoEU/S+8vOcn7zhPi+p8uF6RTq+3DW1f T9nE9TZC24v2bB87FAEk3Htr//JeIgRwpomtmrY+mmcTdWTD93K0BSEwyZM/dCwy6fsB I29g== X-Gm-Message-State: AOAM530vFG/F5BovQyvb6WS1IeNLc7OgKL2Nottws1gl7l9FtF3b+KBq q6tgUpH8IAoL9pA5dqD5uAE= X-Google-Smtp-Source: ABdhPJxDfYl3wI6S0e0cy8glih1BjFWnHK50u77PY7PQxb/u7j+1hcF3tZnMmzLxT5yH3qWzfzR8gg== X-Received: by 2002:a05:6402:d05:: with SMTP id eb5mr3117833edb.360.1640090400452; Tue, 21 Dec 2021 04:40:00 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id bx6sm2849438edb.78.2021.12.21.04.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 04:40:00 -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 v1 08/10] hwmon: adt7x10: use hwmon_device_register_with_info Date: Tue, 21 Dec 2021 14:39:42 +0200 Message-Id: <20211221123944.2683245-8-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221123944.2683245-1-demonsingur@gmail.com> References: <20211221123944.2683245-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 | 93 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index 2d36088e1a07..dd4901299590 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -297,6 +297,95 @@ static int adt7x10_alarm_read(struct adt7x10_data *data, unsigned int 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 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); + + 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 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 hwmon_chip_info adt7x10_chip_info = { + .ops = &adt7x10_hwmon_ops, + .info = adt7x10_info, +}; + int adt7x10_probe(struct device *dev, const char *name, int irq, const struct adt7x10_ops *ops) { @@ -341,7 +430,9 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, if (ret) goto exit_restore; - hdev = hwmon_device_register(dev); + hdev = hwmon_device_register_with_info(dev, name, data, + &adt7x10_chip_info, NULL); + if (IS_ERR(hdev)) { ret = PTR_ERR(hdev); goto exit_restore; From patchwork Tue Dec 21 12:39:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12689613 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 B4ED6C433EF for ; Tue, 21 Dec 2021 12:40:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237771AbhLUMkG (ORCPT ); Tue, 21 Dec 2021 07:40:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237766AbhLUMkD (ORCPT ); Tue, 21 Dec 2021 07:40:03 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9E64C061748; Tue, 21 Dec 2021 04:40:02 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id b13so22921026edd.8; Tue, 21 Dec 2021 04:40:02 -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=+fSw3aeBsQx4xHt3HVrtz0g005ZmrGJREKdBB2cH2X4=; b=MtmcEKI8cC5idJ79i5BqiKloiR5o/Q0cRSsSYbjLFnfyLfzF6itgj2AyQ6p4s1YdPE UaZPLo8hq6LzrJ3Rw+XUK8Lg5c91uaao8B7MbgGNCFwujexN03DkLmTk1kjymqPxkWRv PZ5l0/WKrjzn64I6cZSs60YbF3LzcSNqhkWu4bQH3tn+thalP6bQUxLPXtX3KdvgnJAg Pv069O76miMCRVmuQfa5NjLeUycKr5voQ78lr1WiukOlKuUbd6H7zwU/hd+lkhJS/i/p nlNZc8ApDQZq2ACbGn1aFK+ZHrxXqZiuL7NC1GT4ZFFqYdSFKnWkrX8Z5dWtGfr5shAh ry7A== 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=+fSw3aeBsQx4xHt3HVrtz0g005ZmrGJREKdBB2cH2X4=; b=yk2CFHVYlul5NdFfJ9eRnNtBbLr4KYX78//JRzF9ZFq07b1q2Iq9reNf0mu0b09rXy PY8cWCemXuW/f4mh3WQ3mW1bT+XTR52nrpxu885MzbxR/6tLlvvx/FMPVPcbv0jJ9+3M Z9FdkxrUziLWUhexYmNnfUwL1wcrqxEuzsE1D+D4j1kxwP0+KByPkwMmI7UPOEd7+OD5 RHgP7TlxUxPQ93MMmKG7QTxD8QRgbRqfWe1Ix6ssre7wRoonOgU0uZFEnn8OUBkXnPGk cj0NiWezlE9AXkAErem0GNYR4bt55rLbSgVbbJ2bIfeOHBTZzkuO3ikmTFJDc+nSJUvA YMTA== X-Gm-Message-State: AOAM532Ltd/AAYOJxfVIuSJMQatTn0wmFu1wUDUav4cy8InYvBAZtoOr W0bgPwtZ8bgpltWCs0QLkP8= X-Google-Smtp-Source: ABdhPJwvlurP56Bp5BBsbroOfW+6MYGEuJe02XFaboGtQnxI7w06JmAUCdrOf+ImtYbfoi1X0DR1wA== X-Received: by 2002:aa7:c0d2:: with SMTP id j18mr3102268edp.281.1640090401482; Tue, 21 Dec 2021 04:40:01 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id bx6sm2849438edb.78.2021.12.21.04.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 04:40:01 -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 v1 09/10] hwmon: adt7x10: use devm_hwmon_device_register_with_info Date: Tue, 21 Dec 2021 14:39:43 +0200 Message-Id: <20211221123944.2683245-9-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221123944.2683245-1-demonsingur@gmail.com> References: <20211221123944.2683245-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 core driver remove function. Signed-off-by: Cosmin Tanislav --- drivers/hwmon/adt7x10.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/hwmon/adt7x10.c b/drivers/hwmon/adt7x10.c index dd4901299590..c03805c72906 100644 --- a/drivers/hwmon/adt7x10.c +++ b/drivers/hwmon/adt7x10.c @@ -54,7 +54,6 @@ /* Each client has this additional data */ struct adt7x10_data { const struct adt7x10_ops *ops; - struct device *hwmon_dev; struct device *bus_dev; struct mutex update_lock; u8 config; @@ -430,8 +429,8 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, if (ret) goto exit_restore; - hdev = hwmon_device_register_with_info(dev, name, data, - &adt7x10_chip_info, NULL); + hdev = devm_hwmon_device_register_with_info(dev, name, data, + &adt7x10_chip_info, NULL); if (IS_ERR(hdev)) { ret = PTR_ERR(hdev); @@ -445,15 +444,11 @@ int adt7x10_probe(struct device *dev, const char *name, int irq, IRQF_ONESHOT, dev_name(dev), hdev); if (ret) - goto exit_hwmon_device_unregister; + goto exit_restore; } - data->hwmon_dev = hdev; - return 0; -exit_hwmon_device_unregister: - hwmon_device_unregister(hdev); exit_restore: adt7x10_write_byte(dev, ADT7X10_CONFIG, data->oldconfig); return ret; @@ -464,7 +459,6 @@ void adt7x10_remove(struct device *dev, int irq) { struct adt7x10_data *data = dev_get_drvdata(dev); - hwmon_device_unregister(data->hwmon_dev); if (data->oldconfig != data->config) adt7x10_write_byte(dev, ADT7X10_CONFIG, data->oldconfig); } From patchwork Tue Dec 21 12:39:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cosmin Tanislav X-Patchwork-Id: 12689611 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 2A0C1C433FE for ; Tue, 21 Dec 2021 12:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237761AbhLUMkF (ORCPT ); Tue, 21 Dec 2021 07:40:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237692AbhLUMkE (ORCPT ); Tue, 21 Dec 2021 07:40:04 -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 D7C77C061574; Tue, 21 Dec 2021 04:40:03 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id z5so51534893edd.3; Tue, 21 Dec 2021 04:40:03 -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=BDU6EJnDi6WvDkKmHwhya2IVRURBubZ/mSUv5bglbg4=; b=qHvP+2Q2Qfb+Y3QOhtSDJKJVIKl4tRJlReBpbrSXA9xTsPDbENJUjdXSdstuxr9ker FU3oKs/pwwzn1wBIdcAYkksLlCIdibs1C3U/lb9s4Em+KkNqtKuaH09v+MbBO8TuJZIv WxqJslFndp+SyH9VWHjPdwyLNIa0qKhvnQ07v/c5CbAc/n2psQe2nuQi3tdFIvlsb58u 5TUMKLuK83O5hy8rkT5Ig8NWRFyDJdOGFpW8oc2XG/+cc3GaVz6iFU3cmHKJSvlaBXtS Iin+tI1kqJmRV/s1nDkJVdnVU+F85oDBWLa0A0aBBXXcl0A72Gr5B19gUYCuRKmvpiWx KmTw== 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=BDU6EJnDi6WvDkKmHwhya2IVRURBubZ/mSUv5bglbg4=; b=nqg2lCvItlPxF9oW+bcAaruEvfcN59GHSXXQon9rhoYbvjVUP/G/CAjb3umJveAC2c 62W44r3PwB4WhHlJYRGPXU29gjO6Oyv9ApG/N2lgvkXmr1Aqh8xSMTTz8Jm7hSPNlaMR lNyrGs8vIpGQ1+pikowMTPQXIQPrYhIuZ4l/cQWVSqJ1JxcLyZ+dU9F9JvNzmMeiJeSn M+Aw/zfBFXGDuhRhqOetGUnMlXckZUfJRyIXra+0q1SZZFW2TOKasRdbZkEe8Ar5c8Z5 0SMwg8m0y697DYYyKB1V+bX0d4MuBWCXsmAAHgeT24r7NktRVaovg+MC0bglDNE4Q2KX 2rbQ== X-Gm-Message-State: AOAM531vCxX3X4laSMQeU21PObgW1Ugj8HqjApHTivYSZKk4y8xqu/4D D79bQ7DAA0lddgtU2SKLP4dqd4CTBxw= X-Google-Smtp-Source: ABdhPJzMaIlI84TReDumH3BOgLnU3Oh89XQvF84HO5TTuwZQ0X6qFNocxBcU4p1/NV0hkGgnSgn+Gg== X-Received: by 2002:aa7:d94d:: with SMTP id l13mr3054747eds.208.1640090402531; Tue, 21 Dec 2021 04:40:02 -0800 (PST) Received: from demon-pc.localdomain ([188.24.42.157]) by smtp.gmail.com with ESMTPSA id bx6sm2849438edb.78.2021.12.21.04.40.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Dec 2021 04:40:02 -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 v1 10/10] hwmon: adt7x10: use hwmon_notify_event Date: Tue, 21 Dec 2021 14:39:44 +0200 Message-Id: <20211221123944.2683245-10-demonsingur@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211221123944.2683245-1-demonsingur@gmail.com> References: <20211221123944.2683245-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 c03805c72906..1a99989a744d 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; }