From patchwork Thu Dec 4 16:58:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 5439201 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 160969F1D4 for ; Thu, 4 Dec 2014 17:00:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C0FE2024D for ; Thu, 4 Dec 2014 17:00:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 416AC20148 for ; Thu, 4 Dec 2014 17:00:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932550AbaLDRAF (ORCPT ); Thu, 4 Dec 2014 12:00:05 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:33338 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932313AbaLDRAE (ORCPT ); Thu, 4 Dec 2014 12:00:04 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id sB4Gwpxb022333; Thu, 4 Dec 2014 10:58:51 -0600 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id sB4GwpWs020081; Thu, 4 Dec 2014 10:58:51 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Thu, 4 Dec 2014 10:58:50 -0600 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id sB4GwoAh014648; Thu, 4 Dec 2014 10:58:50 -0600 From: Nishanth Menon To: Guenter Roeck , Jean Delvare CC: , , , Nishanth Menon Subject: [PATCH] hwmon: (gpio-fan) Allow usage of gpio operations that may sleep Date: Thu, 4 Dec 2014 10:58:47 -0600 Message-ID: <1417712328-29831-1-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Certain I2C based GPIO expanders could be used in sleepable context, this results in: [ 115.890569] ------------[ cut here ]------------ [ 115.895422] WARNING: CPU: 0 PID: 1115 at drivers/gpio/gpiolib.c:1370 gpiod_set_raw_value+0x40/0x4c() [ 115.905024] Modules linked in: [ 115.908229] CPU: 0 PID: 1115 Comm: sh Tainted: G W 3.18.0-rc7-next-20141203-dirty #1 [ 115.917461] Hardware name: Generic DRA74X (Flattened Device Tree) [ 115.923876] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 115.932013] [] (show_stack) from [] (dump_stack+0x78/0x94) [ 115.939594] [] (dump_stack) from [] (warn_slowpath_common+0x7c/0xb4) [ 115.948094] [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24) [ 115.957315] [] (warn_slowpath_null) from [] (gpiod_set_raw_value+0x40/0x4c) [ 115.966457] [] (gpiod_set_raw_value) from [] (set_fan_speed+0x4c/0x64) [ 115.975145] [] (set_fan_speed) from [] (set_rpm+0x98/0xac) [ 115.982742] [] (set_rpm) from [] (dev_attr_store+0x18/0x24) [ 115.990426] [] (dev_attr_store) from [] (sysfs_kf_write+0x4c/0x50) [ 115.998742] [] (sysfs_kf_write) from [] (kernfs_fop_write+0xbc/0x19c) [ 116.007333] [] (kernfs_fop_write) from [] (vfs_write+0xb0/0x1a0) [ 116.015461] [] (vfs_write) from [] (SyS_write+0x44/0x84) [ 116.022881] [] (SyS_write) from [] (ret_fast_syscall+0x0/0x48) [ 116.030833] ---[ end trace 3a0b636123acab82 ]--- So, switch over to sleepable GPIO operations as there is no mandatory need for non-sleepable gpio operations in the fan driver. This allows the fan driver to be used with i2c based gpio expanders such as palmas_gpio. Signed-off-by: Nishanth Menon --- based on next-20141204 , but can rebase to required branch as needed. drivers/hwmon/gpio-fan.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index 4efa173..7802eb2 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c @@ -79,7 +79,7 @@ static ssize_t show_fan_alarm(struct device *dev, { struct gpio_fan_data *fan_data = dev_get_drvdata(dev); struct gpio_fan_alarm *alarm = fan_data->alarm; - int value = gpio_get_value(alarm->gpio); + int value = gpio_get_value_cansleep(alarm->gpio); if (alarm->active_low) value = !value; @@ -131,7 +131,7 @@ static void __set_fan_ctrl(struct gpio_fan_data *fan_data, int ctrl_val) int i; for (i = 0; i < fan_data->num_ctrl; i++) - gpio_set_value(fan_data->ctrl[i], (ctrl_val >> i) & 1); + gpio_set_value_cansleep(fan_data->ctrl[i], (ctrl_val >> i) & 1); } static int __get_fan_ctrl(struct gpio_fan_data *fan_data) @@ -142,7 +142,7 @@ static int __get_fan_ctrl(struct gpio_fan_data *fan_data) for (i = 0; i < fan_data->num_ctrl; i++) { int value; - value = gpio_get_value(fan_data->ctrl[i]); + value = gpio_get_value_cansleep(fan_data->ctrl[i]); ctrl_val |= (value << i); } return ctrl_val; @@ -369,7 +369,8 @@ static int fan_ctrl_init(struct gpio_fan_data *fan_data, if (err) return err; - err = gpio_direction_output(ctrl[i], gpio_get_value(ctrl[i])); + err = gpio_direction_output(ctrl[i], + gpio_get_value_cansleep(ctrl[i])); if (err) return err; }