Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3306EC433EF for ; Fri, 26 Nov 2021 11:22:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343512AbhKZLZ3 convert rfc822-to-8bit (ORCPT ); Fri, 26 Nov 2021 06:25:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240528AbhKZLXZ (ORCPT ); Fri, 26 Nov 2021 06:23:25 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B297C08EC1F for ; Fri, 26 Nov 2021 02:36:39 -0800 (PST) Received: from lupine.hi.pengutronix.de ([2001:67c:670:100:3ad5:47ff:feaf:1a17] helo=lupine) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mqYan-0002aX-6K; Fri, 26 Nov 2021 11:36:33 +0100 Received: from pza by lupine with local (Exim 4.94.2) (envelope-from ) id 1mqYaj-0006P8-DU; Fri, 26 Nov 2021 11:36:29 +0100 Message-ID: <63a467164c985cadce0e28e50508363a8d2f6622.camel@pengutronix.de> Subject: Re: [PATCH v3 1/2] SPI: Add SPI driver for Sunplus SP7021 From: Philipp Zabel To: Lh Kuo =?UTF-8?Q?=E9=83=AD=E5=8A=9B=E8=B1=AA?= , Andy Shevchenko Cc: Mark Brown , "LH.Kuo" , Rob Herring , linux-spi , devicetree , Linux Kernel Mailing List , "dvorkin@tibbo.com" , "qinjian@cqplus1.com" , Wells Lu =?UTF-8?Q?=E5=91=82=E8=8A=B3=E9=A8=B0?= Date: Fri, 26 Nov 2021 11:36:29 +0100 In-Reply-To: <33d50e94059b4734939db60b5c531bc9@sphcmbx02.sunplus.com.tw> References: <1635747525-31243-1-git-send-email-lh.kuo@sunplus.com> <6eb68a8153ba46c48862d00f7aa6e0fe@sphcmbx02.sunplus.com.tw> <33d50e94059b4734939db60b5c531bc9@sphcmbx02.sunplus.com.tw> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:3ad5:47ff:feaf:1a17 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi LH, On Fri, 2021-11-26 at 07:40 +0000, Lh Kuo 郭力豪 wrote: [...] > Amended as follows, is it okay? > > ret = devm_request_irq(dev, pspim->mas_irq, sp7021_spi_mas_irq > , IRQF_TRIGGER_RISING, pdev->name, pspim); > if (ret) > return ret; Comma at the end of the line and align the next line with the opening parenthesis: ret = devm_request_irq(dev, pspim->mas_irq, sp7021_spi_mas_irq, IRQF_TRIGGER_RISING, pdev->name, pspim); You can use scripts/checkpatch --strict to find these issues before review. > > >         pspim->rstc = devm_reset_control_get_exclusive(dev, NULL); > > >         if (IS_ERR(pspim->rstc)) { > > >                 return dev_err_probe(dev, PTR_ERR(pspim->rstc), "rst > > > get fail\n"); > > > > Amended as follows, is it okay? > > pspim->rstc = devm_reset_control_get_exclusive(dev, NULL); > if (IS_ERR(pspim->rstc)) > return dev_err_probe(dev, PTR_ERR(pspim->rstc), "rst get fail\n"); Yes. > > > > >         ret = devm_spi_register_controller(dev, ctlr); > > > > You can't mix non-devm with devm APIs. Either all non-devm, or devm followed by non-devm. > > > >   I don't understand so I need to change to spi_register_controller(ctlr)? why? devm_spi_register_controller() shouldn't be called after pm_runtime_enable(). You could either switch to devm_pm_runtime_enable() or move the pm_runtime_enable() after the devm_spi_register_controller() call if possible, or switch to spi_register_controller(). > I modified the remove-function as follows. I think devm_spi_register_controller(dev, ctlr); should be no problem in the probe funciton. > static int sp7021_spi_controller_remove(struct platform_device *pdev) > { > struct spi_controller *ctlr = dev_get_drvdata(&pdev->dev); > struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr); > > pm_runtime_disable(&pdev->dev); I'm not sure if the SPI framework requires the spi_controller to be unregistered before hardware is powered off, maybe it is enough to call spi_controller_suspend() in the right place? > pm_runtime_set_suspended(&pdev->dev); > reset_control_assert(pspim->rstc); > clk_disable_unprepare(pspim->spi_clk); > > return 0; > } regards Philipp