Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4126714ybe; Mon, 9 Sep 2019 04:46:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlQvZGKBR2qxqcIkLVRlpi0L8f6EaKVY4cCQWVNuIJbrA5TkqqDFb9TzWiwE1RwMlK9ZWz X-Received: by 2002:aa7:dccb:: with SMTP id w11mr23453431edu.235.1568029603155; Mon, 09 Sep 2019 04:46:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568029603; cv=none; d=google.com; s=arc-20160816; b=mXKsHzKt+aOTgCDIZ6C8G1GBCoTJ+jbSQGX+RLalNXjlm76EoyzqzCQIz7ynqv0i2j ZXFtpJapYfW2zv5RMTKAuDKUmhjEbkqOWg5wsELJ/HYhaEwYq/xXK3IEEzjRIPi9F4rV NkO2LG/El0mbni6QM9fctn+GEzxVbmF7dwzf6Cs/GAyMLJoUUypc2++ARMWwT9USJId4 m1bDJTkSrYfaa/1HieoRGOF27y/LrAGAFbr1w1sHeCbWQ3rrpxBLjzTdPYJ42eNfW16E u7SIC9aUd3+HqzDj+pHPLEBWJ5vsIm/5wox94Svlf7hNwqVGB3iRA4GG1zHT961lTVi5 Gg1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B02Qbu3y/rfKVlrTFyOEjNElUmEaLYIUOdfMIA0bTW8=; b=GHvoOvC1GPC/yNRcys8mgyuqKLJJHTpCPOBgeCyCE0JPC8z6WDSlccyYo+ImZ8Pc4V EHGrLwBpwIks1uX/zBx6I4codzUydJVaH4cvSXeSuMdT0y/tOldGVRELhuQ3GtiDKxla qfZHDRIV1ijAbYpgv1looM+cfn+/829cWfPww6rINhJXf6Wz3DLoHInTH9NYtNSgBSFW SjMxdjcenKQNL5AI40Kgk89ACOv64oEt8M7/pO19a2/KrF/EnyYZsWB/m9LYuJuIgF+e d/6GDC58ToRgtZcQ2NSufHIvhx0obzXdTff66mMGXRghYzByj6IOh6AwBQdnPu5utoIZ V1oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sy7te74d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sa2si7299563ejb.303.2019.09.09.04.46.19; Mon, 09 Sep 2019 04:46:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sy7te74d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732847AbfIHMwA (ORCPT + 99 others); Sun, 8 Sep 2019 08:52:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:43624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732802AbfIHMvv (ORCPT ); Sun, 8 Sep 2019 08:51:51 -0400 Received: from localhost (unknown [62.28.240.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E6C4C218AC; Sun, 8 Sep 2019 12:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567947110; bh=GtZ1QyGmnGcackSwHi14x+wKZew0gFtJ0eiFWT+vkwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sy7te74dhRFpQOL51+B7ph6nvkaKX1MFjwBewJ70YwEY3dYiPo7IdYPIW7ppBHPt7 CvA1pk0LlfXw/FR0fdI/voRBPBM8GbicMsYSSwhRZCdPgXrvPJrc7xmtA63hYs3bBP iVaDAaFvAlGJgn8bG0zk0/r/9UbXUIrqEfQMV1bk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Tissoires , Jiri Kosina , Sasha Levin Subject: [PATCH 5.2 66/94] HID: cp2112: prevent sleeping function called from invalid context Date: Sun, 8 Sep 2019 13:42:02 +0100 Message-Id: <20190908121152.324236353@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121150.420989666@linuxfoundation.org> References: <20190908121150.420989666@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 2d05dba2b25ecb0f8fc3a0b4eb2232da6454a47b ] When calling request_threaded_irq() with a CP2112, the function cp2112_gpio_irq_startup() is called in a IRQ context. Therefore we can not sleep, and we can not call cp2112_gpio_direction_input() there. Move the call to cp2112_gpio_direction_input() earlier to have a working driver. Signed-off-by: Benjamin Tissoires Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-cp2112.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 8bbe3d0cbe5d9..8fd44407a0df7 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -1152,8 +1152,6 @@ static unsigned int cp2112_gpio_irq_startup(struct irq_data *d) INIT_DELAYED_WORK(&dev->gpio_poll_worker, cp2112_gpio_poll_callback); - cp2112_gpio_direction_input(gc, d->hwirq); - if (!dev->gpio_poll) { dev->gpio_poll = true; schedule_delayed_work(&dev->gpio_poll_worker, 0); @@ -1201,6 +1199,12 @@ static int __maybe_unused cp2112_allocate_irq(struct cp2112_device *dev, return PTR_ERR(dev->desc[pin]); } + ret = cp2112_gpio_direction_input(&dev->gc, pin); + if (ret < 0) { + dev_err(dev->gc.parent, "Failed to set GPIO to input dir\n"); + goto err_desc; + } + ret = gpiochip_lock_as_irq(&dev->gc, pin); if (ret) { dev_err(dev->gc.parent, "Failed to lock GPIO as interrupt\n"); -- 2.20.1