Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752420AbdIRISi (ORCPT ); Mon, 18 Sep 2017 04:18:38 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:56521 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751568AbdIRISh (ORCPT ); Mon, 18 Sep 2017 04:18:37 -0400 Date: Mon, 18 Sep 2017 10:18:24 +0200 From: Maxime Ripard To: Stefan =?iso-8859-1?Q?Br=FCns?= Cc: linux-sunxi@googlegroups.com, devicetree@vger.kernel.org, dmaengine@vger.kernel.org, Vinod Koul , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Chen-Yu Tsai , Rob Herring , Code Kipper , Andre Przywara Subject: Re: [PATCH v2 07/10] dmaengine: sun6i: Retrieve channel count/max request from devicetree Message-ID: <20170918081824.iiebcj63wvnean57@flea.lan> References: <20170917031956.28010-1-stefan.bruens@rwth-aachen.de> <20170917031956.28010-8-stefan.bruens@rwth-aachen.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="a5lxixo24iqhcmfo" Content-Disposition: inline In-Reply-To: <20170917031956.28010-8-stefan.bruens@rwth-aachen.de> User-Agent: NeoMutt/20170714 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2439 Lines: 73 --a5lxixo24iqhcmfo Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, On Sun, Sep 17, 2017 at 05:19:53AM +0200, Stefan Br=FCns wrote: > + ret =3D of_property_read_u32(np, "dma-channels", &sdc->num_pchans); > + if (ret && !sdc->num_pchans) { > + dev_err(&pdev->dev, "Can't get dma-channels.\n"); > + return ret; > + } > + > + if (sdc->num_pchans > DMA_MAX_CHANNELS) { > + dev_err(&pdev->dev, "Number of dma-channels out of range.\n"); > + return -EINVAL; > + } > + > + ret =3D of_property_read_u32(np, "dma-requests", &sdc->max_request); > + if (ret && !sdc->max_request) { > + dev_info(&pdev->dev, "Missing dma-requests, using %u.\n", > + DMA_CHAN_MAX_DRQ); > + sdc->max_request =3D DMA_CHAN_MAX_DRQ; > + } > + > + if (sdc->max_request > DMA_CHAN_MAX_DRQ) { > + dev_err(&pdev->dev, "Value of dma-requests out of range.\n"); > + return -EINVAL; > + } I'm not really convinced about these two checks. They don't catch all errors (the range between the actual number of channels / DRQ and the maximum allowed per the registers), they might increase in the future too, and if we want to make that check actually working, we would have to duplicate the number of requests and channels into the driver. Which is kind of the opposite of what we're trying to do here :) Once removed, Acked-by: Maxime Ripard Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com --a5lxixo24iqhcmfo Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJZv4FQAAoJEBx+YmzsjxAgZ5cP/RDr2PJeZe5ecqXrxw0k11+n fsk0RhgSkoCaZiCl7fLudlxJXSPSdx65y/5jm9h7roftX8YfqWMF2LygvRgbZWf7 AKeOF5Bw8X159p5KNAbb01CKg5UeHDKGBqvvDvcQhyPQedjWHg1UzjWQveASMXFN b67k0nfTkJVCcfwXlAVxw3l36nd9rNuoZ91IjvZ/atOwhDiJGoewTxjvNBn9q1qz +RrMBuicKongx0mPL10hURY6kD1L++i3bQEpJHQELh+jf0If2VXkSvnKAKWigaUY vuwGg1hiHAX9ADg6gVu9DORYFPUmOpY6FbKA3DhkC+WzbnDVpDUbXdb41UR4DLNx xbZdu8DeR3oSF+Sh9LJSoDdjFaqh7eK+iDSaKz58hHHQn3f3sOwFZebSrha1kSdK 4YeD0MAcorPqXYXVKqve87CAGFFeFTwty+BGd/niZAFpPc5IEt/FUqCQ+MqlsIyn O56ZRfGWJWM82Bqc07JYOsTX6zE1jC2qTEUfqeTpShooMvRGZzn8Vz+QUX1JvcBl 1wkhZ+DVhp8E77YEjQUKJX9elJ4NHRaVQZWvFKKYPRqB583YYhR/aiFz9qDpuKzC +VKVgBmM7/ShMO/hRYZrS606D5iJ9k+1ScgsMb2PCRU3UhPqWkvZJfb0nQbIoOvV 6cjzXCzLwEYGmC52YnpE =sZVO -----END PGP SIGNATURE----- --a5lxixo24iqhcmfo--