Received: by 10.192.165.156 with SMTP id m28csp1392692imm; Wed, 11 Apr 2018 18:51:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx495pWtMSHNC6xSQ3MZGsPBNhNAOoJ7STiFiDxbIPFumHFF7Zk0nIRp1Ic8U6GvUvhUSPlqv X-Received: by 10.99.56.8 with SMTP id f8mr5188491pga.374.1523497902557; Wed, 11 Apr 2018 18:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523497902; cv=none; d=google.com; s=arc-20160816; b=t5/veYUmZ1i7mdxr6qdmgRgWoGBE0FgIm7NaOQA716XdFMMUkavoRhPY/IxRYYfLu/ DGt6GMQq+DQhUOGaBFK4OianC+gKn8rVyHZfE6XXGeGGHJlLG9rSQsjQbyj6s9YC1qEg Z5BQA43T8ynS6+Ard1H2GrEJtWzVWuFRB61gRDk7Vh2RKmZ96l9LfJww4CQb9BiWJxHV /HAj3kbUBaJkHC5HnuhwyearwfDM+Gpkx6uUqlAm/q3thoYWaKI3cUXLSZouIe9nLU2m UoQ79v0gkCJhPK9kLVBd1mCm8hHdcyDHKuYEh9OYs3xbr8jpDhajY0d+y+rDdZtxOVq5 n0xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=cXGGCcswwRTAWT71jF/xG8H5hThQXfOhy+EIAOWYthg=; b=FjMQ2rd+KRkmnETw/MfKB1pRHCrKTdTT2OkKpJCOFWv5GkV96u2d4OlDlC3hhzxJ/J jqXAIGjuBIuEl/lyLBcON4RSTumGyrP8BV34MyE5j26aiyqL2wUiAuRJGsad6DrB7GhE 38enEhNmyKZY3UX91H2hjkHLDLwrDoiOOHvoQ/LPS1JljKr1guTD0sxFKxUy1oMVKsjp G32yz2IPBk/Zr4XZgkVVgX0l97WGcYmaetHcKjIpcsJ5aA5tZlkwruBAoDJngng63Pj3 taSW7iM5zv6GhBo7wJaBvALxYTInrwc8eWGwPhCHmcYiVzPfFwGTsFtkNeR0o5XZyvRJ YyyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fos2qA4X; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v6si1507741pgq.227.2018.04.11.18.51.05; Wed, 11 Apr 2018 18:51:42 -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=@gmail.com header.s=20161025 header.b=Fos2qA4X; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752755AbeDLBsc (ORCPT + 99 others); Wed, 11 Apr 2018 21:48:32 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:35041 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751633AbeDLBsb (ORCPT ); Wed, 11 Apr 2018 21:48:31 -0400 Received: by mail-pl0-f68.google.com with SMTP id 61-v6so2742906plb.2; Wed, 11 Apr 2018 18:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=cXGGCcswwRTAWT71jF/xG8H5hThQXfOhy+EIAOWYthg=; b=Fos2qA4XKWyqDNYqwKd1tHpbL3VjlhtGn0QZLSMgQA7gr62slobf1FeSM1rii6tJpZ t3hVKkLADfBkZk0y5lHoC5mozloUxCUQLZUO5uwttvYuJNO7q14I9kjcSkw8K9rVI3U8 1shB4U4b/MO2gNuo60YJOLblOafG9cnu8kZ5fg/9ZAy1KYIZ79OIAik/a48sNY2makQ0 mfywrw4qIUTW43F+CRl6f3Kj3cU3lG6kr31H9iKikpIKCwkv0ogvh42tnTFyDZqe3USA Trfv/i96nhPA3+RawNzHjaUh7Ynr3OhRWAASdyKuQw0IsTQODW/i4O1xuNIW4Kh+dZMx Jgpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cXGGCcswwRTAWT71jF/xG8H5hThQXfOhy+EIAOWYthg=; b=pmkggGt6/INApBj1Wf5OiL8Vfq/EGy6yrZwYRFr/EU1uYk0ijvUT17Y3EULCK8vBlS 2DMwK0COXH0x/6Xr/Fzmj6FBRDtyPK5Ap4oL+iF1GrI2Hyju7rhP9tGrlyGHgVxoyngG D2HUwItuhOw9mNVtd5iS95Q850jRDHSiUqe36nxpc3JubFB5k27X8QhxvXLejwoEapSm vxNyT2nRDQlwYmXXbUqa+qjVEstMS3AZ4Hy+HPmNuKtDmSkz3JT3KzC6qJ0x0JUYFJy+ n+NH4yLVSkRgHibA7laKTd5Mwhwu2XyX4WtKd9EbCsgzI6D4ZFfhL9Z15wkscROORZ4/ VnfA== X-Gm-Message-State: ALQs6tDiURWDo6jRc9Mh43j5AWYPbhlS+UTiZ2oJ68Ll0hF84jK80Su1 tQneafSqcmUeCOn7WeGkKvg= X-Received: by 2002:a17:902:a704:: with SMTP id w4-v6mr3264706plq.5.1523497710567; Wed, 11 Apr 2018 18:48:30 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:e50f:6d1:658e:8ac3]) by smtp.gmail.com with ESMTPSA id m185sm5169532pfc.88.2018.04.11.18.48.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 11 Apr 2018 18:48:30 -0700 (PDT) From: Jia-Ju Bai To: f.fainelli@gmail.com, andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, preid@electromag.com.au Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH v2] net: dsa: b53: Using sleep-able operations in b53_switch_reset_gpio Date: Thu, 12 Apr 2018 09:48:22 +0800 Message-Id: <1523497702-7200-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org b53_switch_reset_gpio() is never called in atomic context. The call chain ending up at b53_switch_reset_gpio() is: [1] b53_switch_reset_gpio() <- b53_switch_reset() <- b53_reset_switch() <- b53_setup() b53_switch_reset_gpio() is set as ".setup" in struct dsa_switch_ops. This function is not called in atomic context. Despite never getting called from atomic context, b53_switch_reset_gpio() calls non-sleep operations mdelay() and gpio_set_value(). They are not necessary and can be replaced with msleep() and gpio_set_value_cansleep(). This is found by a static analysis tool named DCNS written by myself. And I also manually check it. Signed-off-by: Jia-Ju Bai --- v2: * Use gpio_set_value_cansleep() to replace gpio_set_value() additionally. Thanks for Florian and Phil for good advice. --- drivers/net/dsa/b53/b53_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 274f367..36cc60d 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -596,11 +596,11 @@ static void b53_switch_reset_gpio(struct b53_device *dev) /* Reset sequence: RESET low(50ms)->high(20ms) */ - gpio_set_value(gpio, 0); - mdelay(50); + gpio_set_value_cansleep(gpio, 0); + msleep(50); - gpio_set_value(gpio, 1); - mdelay(20); + gpio_set_value_cansleep(gpio, 1); + msleep(20); dev->current_page = 0xff; } -- 1.9.1