From patchwork Tue Jul 2 13:23:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schneider X-Patchwork-Id: 11027831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7989413A4 for ; Tue, 2 Jul 2019 13:24:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60B76288AC for ; Tue, 2 Jul 2019 13:24:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 549042890B; Tue, 2 Jul 2019 13:24:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A84B0288AC for ; Tue, 2 Jul 2019 13:24:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727086AbfGBNYB (ORCPT ); Tue, 2 Jul 2019 09:24:01 -0400 Received: from smtp.radiodata.biz ([116.203.112.52]:43123 "EHLO smtp.radiodata.biz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727133AbfGBNYA (ORCPT ); Tue, 2 Jul 2019 09:24:00 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.radiodata.biz (Postfix) with ESMTP id 9BB6A3E8E7; Tue, 2 Jul 2019 15:23:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at smtp.radiodata.biz Received: from smtp.radiodata.biz ([116.203.112.52]) by localhost (smtp.radiodata.biz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oCMwPXskRp0G; Tue, 2 Jul 2019 15:23:50 +0200 (CEST) Received: from mail.radiodata.biz (p578044f8.dip0.t-ipconnect.de [87.128.68.248]) by smtp.radiodata.biz (Postfix) with ESMTPSA id E00093E8E5; Tue, 2 Jul 2019 15:23:50 +0200 (CEST) Received: from localhost (unknown [192.168.2.97]) by mail.radiodata.biz (Postfix) with ESMTPSA id 98949201A1; Tue, 2 Jul 2019 15:23:50 +0200 (CEST) From: cschneider@radiodata.biz To: linux-hwmon@vger.kernel.org Cc: christian@ch-sc.de, linux@roeck-us.net, cschneider@radiodata.biz Subject: [PATCH 1/2] hwmon: gpio-fan: move fan_alarm_init after devm_hwmon_device_register_with_groups Date: Tue, 2 Jul 2019 15:23:37 +0200 Message-Id: <20190702132338.8856-1-cschneider@radiodata.biz> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christian Schneider This makes it possible to use the hwmon_dev in fan_alarm_notify(). Otherwise it would be possible, that a interupt arrives and fan_alarm_notify() is executed, before hwmon_dev is initialized. Signed-off-by: Christian Schneider --- drivers/hwmon/gpio-fan.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index 84753680a4e8..a962a9ee7225 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c @@ -510,13 +510,6 @@ static int gpio_fan_probe(struct platform_device *pdev) platform_set_drvdata(pdev, fan_data); mutex_init(&fan_data->lock); - /* Configure alarm GPIO if available. */ - if (fan_data->alarm_gpio) { - err = fan_alarm_init(fan_data); - if (err) - return err; - } - /* Configure control GPIOs if available. */ if (fan_data->gpios && fan_data->num_gpios > 0) { if (!fan_data->speed || fan_data->num_speed <= 1) @@ -535,6 +528,13 @@ static int gpio_fan_probe(struct platform_device *pdev) if (IS_ERR(fan_data->hwmon_dev)) return PTR_ERR(fan_data->hwmon_dev); + /* Configure alarm GPIO if available. */ + if (fan_data->alarm_gpio) { + err = fan_alarm_init(fan_data); + if (err) + return err; + } + /* Optional cooling device register for Device tree platforms */ fan_data->cdev = devm_thermal_of_cooling_device_register(dev, np, "gpio-fan", fan_data, &gpio_fan_cool_ops); From patchwork Tue Jul 2 13:23:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schneider X-Patchwork-Id: 11027837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94F791580 for ; Tue, 2 Jul 2019 13:24:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B4E8288AC for ; Tue, 2 Jul 2019 13:24:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F30A2890B; Tue, 2 Jul 2019 13:24:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E1AD288AC for ; Tue, 2 Jul 2019 13:24:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727147AbfGBNYK (ORCPT ); Tue, 2 Jul 2019 09:24:10 -0400 Received: from smtp.radiodata.biz ([116.203.112.52]:53431 "EHLO smtp.radiodata.biz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbfGBNYJ (ORCPT ); Tue, 2 Jul 2019 09:24:09 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.radiodata.biz (Postfix) with ESMTP id 71C833E8E9; Tue, 2 Jul 2019 15:24:08 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at smtp.radiodata.biz Received: from smtp.radiodata.biz ([116.203.112.52]) by localhost (smtp.radiodata.biz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V7BHo_4B1Qwi; Tue, 2 Jul 2019 15:24:00 +0200 (CEST) Received: from mail.radiodata.biz (p578044f8.dip0.t-ipconnect.de [87.128.68.248]) by smtp.radiodata.biz (Postfix) with ESMTPSA id 9E6863E8E5; Tue, 2 Jul 2019 15:24:00 +0200 (CEST) Received: from localhost (unknown [192.168.2.97]) by mail.radiodata.biz (Postfix) with ESMTPSA id 5BF91201A1; Tue, 2 Jul 2019 15:24:00 +0200 (CEST) From: cschneider@radiodata.biz To: linux-hwmon@vger.kernel.org Cc: christian@ch-sc.de, linux@roeck-us.net, cschneider@radiodata.biz Subject: [PATCH 2/2] hwmon: gpio-fan: fix sysfs notifications and udev events for gpio-fan alarms Date: Tue, 2 Jul 2019 15:23:38 +0200 Message-Id: <20190702132338.8856-2-cschneider@radiodata.biz> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702132338.8856-1-cschneider@radiodata.biz> References: <20190702132338.8856-1-cschneider@radiodata.biz> MIME-Version: 1.0 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christian Schneider sysfs_notify() and kobject_uevent() are passed the wrong device. fan_data->hwmon_dev needs to be passed, so that sysfs notification goes to right place and generated uevent has the right information Signed-off-by: Christian Schneider --- drivers/hwmon/gpio-fan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index a962a9ee7225..36bca2d75e0f 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c @@ -54,8 +54,8 @@ static void fan_alarm_notify(struct work_struct *ws) struct gpio_fan_data *fan_data = container_of(ws, struct gpio_fan_data, alarm_work); - sysfs_notify(&fan_data->dev->kobj, NULL, "fan1_alarm"); - kobject_uevent(&fan_data->dev->kobj, KOBJ_CHANGE); + sysfs_notify(&fan_data->hwmon_dev->kobj, NULL, "fan1_alarm"); + kobject_uevent(&fan_data->hwmon_dev->kobj, KOBJ_CHANGE); } static irqreturn_t fan_alarm_irq_handler(int irq, void *dev_id)