From patchwork Sun Apr 7 14:58:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 10888417 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 9BA221390 for ; Sun, 7 Apr 2019 14:58:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75F5D28684 for ; Sun, 7 Apr 2019 14:58:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 666ED286BF; Sun, 7 Apr 2019 14:58:36 +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,DKIM_SIGNED, DKIM_VALID,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 E937628684 for ; Sun, 7 Apr 2019 14:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726315AbfDGO6c (ORCPT ); Sun, 7 Apr 2019 10:58:32 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41798 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbfDGO6c (ORCPT ); Sun, 7 Apr 2019 10:58:32 -0400 Received: by mail-pf1-f194.google.com with SMTP id 188so6068010pfd.8 for ; Sun, 07 Apr 2019 07:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ingics-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=YHF7Y8kKxV3es3bdywPvEUWCpVBlkjHFCF5Pn0/uSwA=; b=qLxaXgF6ogWAymGDf/hsTrxQZegU+hc4CdUa4jqkEVHrAPcRgF6rx2+53vDiXyfwVN CyLvi1PwESDIb9Xa2XGmZ5xxiP9Zs8c/37VTPlFOJZK7FYvFYYtutSppVXfxPYqYbQgO P0OgLWpx9obBzQEZ3l5YjSsLEZYfeDGjY5EAWblPKmhoWImkoc8ENKE3G8KL57ttOO3y BscTGjgIe70UfFo8kv1M5brz9ZPGCGzCHAjZzv0dBpNZhfpHNHLzIN7ciBX7Bzvjh4cO GflScoHVSHMslp4TdTSYDq7NTxiEyZ1FoSCR3h3yB23eeipfam9byOed0QFvlTzrR8yz AkfQ== 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=YHF7Y8kKxV3es3bdywPvEUWCpVBlkjHFCF5Pn0/uSwA=; b=Uwdurp0wwX6GCF17LAWNlEGB1OUqxQH2IYmIaaVMhNIoAA4o4ASOP8dqJoM+odQOIz rd0JD4GwdW4xnLxj0ZN/spWULxzSaRuo3kKjBR/4XCxSMoOYdnp4xwWZnsHFbPajnaRa o3OgvvnB2MrzjpxRPD0LsjqcfkPbcYGjlY7nHtjoXZdrH5fbWGZCBI+uv8nqm1ADbRyz XV5yTdPoVOM5MfOx3fvyfXvuq6A93pcGOvmsp5u2cLfsVaTYmsOxhy/WiIqVntgiaWR/ PULpi/jjrTNLWzuT+E5cLv8IndpxlA354JleHyyMsu62OwDH4DBlsEjc3o/ZSBgm4nms baxg== X-Gm-Message-State: APjAAAUXh7HievpcUK316X8NiMgPeWxy+P/gpB0YDrvD9z6DvC9Bt/rF V9E0QW6GxSXsxU/Wd8PLyNhCpg== X-Google-Smtp-Source: APXvYqzjiqrzGikLVJ87KvBim/uGIkL/PDROkiTSh5MEMOlObsQ4MucSxc9zsbouEwDRo7ejS5R4uQ== X-Received: by 2002:a63:5b24:: with SMTP id p36mr23897951pgb.84.1554649111289; Sun, 07 Apr 2019 07:58:31 -0700 (PDT) Received: from localhost.localdomain (118-171-136-45.dynamic-ip.hinet.net. [118.171.136.45]) by smtp.gmail.com with ESMTPSA id q80sm50753785pfa.66.2019.04.07.07.58.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Apr 2019 07:58:30 -0700 (PDT) From: Axel Lin To: Mark Brown Cc: linux-spi@vger.kernel.org, Clark Wang , Han Xu , Frank Li , Axel Lin Subject: [PATCH 1/3] spi: fsl-lpspi: Fix problematic dev_set_drvdata call Date: Sun, 7 Apr 2019 22:58:15 +0800 Message-Id: <20190407145817.11537-1-axel.lin@ingics.com> X-Mailer: git-send-email 2.17.1 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The original code already set controller as drvdata: platform_set_drvdata(pdev, controller); But commit 944c01a889d9 ("spi: lpspi: enable runtime pm for lpspi") added dev_set_drvdata(&pdev->dev, fsl_lpspi); so fsl_lpspi_remove() will get wrong pointer by platform_get_drvdata(). Fixes: 944c01a889d9 ("spi: lpspi: enable runtime pm for lpspi") Signed-off-by: Axel Lin --- drivers/spi/spi-fsl-lpspi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c index 33b6a8affd55..a5c6f27666f3 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -788,9 +788,12 @@ static irqreturn_t fsl_lpspi_isr(int irq, void *dev_id) static int fsl_lpspi_runtime_resume(struct device *dev) { - struct fsl_lpspi_data *fsl_lpspi = dev_get_drvdata(dev); + struct spi_controller *controller = dev_get_drvdata(dev); + struct fsl_lpspi_data *fsl_lpspi; int ret; + fsl_lpspi = spi_controller_get_devdata(controller); + ret = clk_prepare_enable(fsl_lpspi->clk_per); if (ret) return ret; @@ -806,7 +809,10 @@ static int fsl_lpspi_runtime_resume(struct device *dev) static int fsl_lpspi_runtime_suspend(struct device *dev) { - struct fsl_lpspi_data *fsl_lpspi = dev_get_drvdata(dev); + struct spi_controller *controller = dev_get_drvdata(dev); + struct fsl_lpspi_data *fsl_lpspi; + + fsl_lpspi = spi_controller_get_devdata(controller); clk_disable_unprepare(fsl_lpspi->clk_per); clk_disable_unprepare(fsl_lpspi->clk_ipg); @@ -853,7 +859,6 @@ static int fsl_lpspi_probe(struct platform_device *pdev) fsl_lpspi = spi_controller_get_devdata(controller); fsl_lpspi->dev = &pdev->dev; - dev_set_drvdata(&pdev->dev, fsl_lpspi); fsl_lpspi->is_slave = of_property_read_bool((&pdev->dev)->of_node, "spi-slave"); From patchwork Sun Apr 7 14:58:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 10888421 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 2B4B91390 for ; Sun, 7 Apr 2019 14:58:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 144BA28684 for ; Sun, 7 Apr 2019 14:58:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0723228694; Sun, 7 Apr 2019 14:58:39 +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,DKIM_SIGNED, DKIM_VALID,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 A31FF28684 for ; Sun, 7 Apr 2019 14:58:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726335AbfDGO6i (ORCPT ); Sun, 7 Apr 2019 10:58:38 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46558 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbfDGO6i (ORCPT ); Sun, 7 Apr 2019 10:58:38 -0400 Received: by mail-pl1-f195.google.com with SMTP id y6so5777362pll.13 for ; Sun, 07 Apr 2019 07:58:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ingics-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sYzldVv2VEOvHBX0MvX1QLE8WHuuDsl/gEqdK2Ow9B8=; b=KvghVtJWv33UBW0DvU+2LDiL2cGJ5Cd1dqahfayl+WnKUTNSHluMOowjOw1ua9XR56 SUUre+BAQ/hhNGlcWpUW+I8feu42GxsMx4efKi96txa0SFK+/cFyeWSkTWCMWYEyYK50 AGWpfMKUN0y1705o1KCoCddR7yjplUkSc8Mm0e3NinYEq0U/eK/gcFjLgXBOFuFBTI64 pqZl8V4LV+ydODyfhx00v9doNBa08hYH5fFjm8x74DYZJkeSmb4CB60aL/xAseFGl7Qx BrNCWcYnhyHjm+6uLUlUGxxdHolaAw5hktLB3hYKNuIvwTBZTSOu4R9+lkVg4fWWCZJm eEeg== 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:in-reply-to :references; bh=sYzldVv2VEOvHBX0MvX1QLE8WHuuDsl/gEqdK2Ow9B8=; b=tZtde5QNIyBu02wc8ExjPHPfx72tUelG1KOLHuwBQsbLCsJTMuWRey+3pVjoohv5P6 jSqzISZ9TZfskpOnlxyI3cSPetutdIxwexbxUauvdrWZymkrJa8JFAFpS2HWlzewax/S LoFwgK85kTNWDzSR3mv4jSysafdAblr3oeY6bVWrX6sh4yVGizAl+I5eySMxIhhrDEUq kHuXMBb3UyuJ0yiet3TfbmYx5E5fuT6KwXpZjNL4gkHDzMgt4t1ZJbuFh2Jjt11Gl9kN 9Vv0/Z0szM/2OwNXFtUad5TkjyLoLIXWqt/xYfNYtmO+TladdWXc8VFe9oRfK++QV5cO dSBw== X-Gm-Message-State: APjAAAVK4DeoYtSHnr75f1JyndLLY7oGs/tDmb/fWJq3T/gnKswcHBvJ SNUH8IXwoncnMAMD2cf//6aKNA== X-Google-Smtp-Source: APXvYqwbW6ylS5ekLDoBkGhYix5KDlOvo9UUtrpeHw1IHjAFJi1jLihS30inYOYCCRxsVOgx/GbtOA== X-Received: by 2002:a17:902:b089:: with SMTP id p9mr311065plr.185.1554649117381; Sun, 07 Apr 2019 07:58:37 -0700 (PDT) Received: from localhost.localdomain (118-171-136-45.dynamic-ip.hinet.net. [118.171.136.45]) by smtp.gmail.com with ESMTPSA id q80sm50753785pfa.66.2019.04.07.07.58.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Apr 2019 07:58:36 -0700 (PDT) From: Axel Lin To: Mark Brown Cc: linux-spi@vger.kernel.org, Clark Wang , Han Xu , Frank Li , Axel Lin Subject: [PATCH 3/3] spi: fsl-lpspi: Clean up fsl_lpspi_probe Date: Sun, 7 Apr 2019 22:58:17 +0800 Message-Id: <20190407145817.11537-3-axel.lin@ingics.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190407145817.11537-1-axel.lin@ingics.com> References: <20190407145817.11537-1-axel.lin@ingics.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use is_slave local variable to avoid calling of_property_read_bool() twice. Remove redudant assignment for controller->bus_num, set it once is enough. Move setting controller->bits_per_word_mask close to the code init other controller fields. Signed-off-by: Axel Lin --- drivers/spi/spi-fsl-lpspi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c index 9b281260fc02..d08e9324140e 100644 --- a/drivers/spi/spi-fsl-lpspi.c +++ b/drivers/spi/spi-fsl-lpspi.c @@ -843,8 +843,10 @@ static int fsl_lpspi_probe(struct platform_device *pdev) struct resource *res; int i, ret, irq; u32 temp; + bool is_slave; - if (of_property_read_bool((&pdev->dev)->of_node, "spi-slave")) + is_slave = of_property_read_bool((&pdev->dev)->of_node, "spi-slave"); + if (is_slave) controller = spi_alloc_slave(&pdev->dev, sizeof(struct fsl_lpspi_data)); else @@ -856,13 +858,9 @@ static int fsl_lpspi_probe(struct platform_device *pdev) platform_set_drvdata(pdev, controller); - controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32); - controller->bus_num = pdev->id; - fsl_lpspi = spi_controller_get_devdata(controller); fsl_lpspi->dev = &pdev->dev; - fsl_lpspi->is_slave = of_property_read_bool((&pdev->dev)->of_node, - "spi-slave"); + fsl_lpspi->is_slave = is_slave; if (!fsl_lpspi->is_slave) { for (i = 0; i < controller->num_chipselect; i++) { @@ -887,6 +885,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev) controller->prepare_message = fsl_lpspi_prepare_message; } + controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32); controller->transfer_one = fsl_lpspi_transfer_one; controller->prepare_transfer_hardware = lpspi_prepare_xfer_hardware; controller->unprepare_transfer_hardware = lpspi_unprepare_xfer_hardware;