Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6971512imm; Tue, 24 Jul 2018 06:24:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc7vdnTy7+MTk6ETijgt7rUZCPLswWgSacdfeXwhtPhq1lazyzoKJpNlZCY8HsgJAOyIbmD X-Received: by 2002:a63:9f0a:: with SMTP id g10-v6mr16572921pge.324.1532438653203; Tue, 24 Jul 2018 06:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532438653; cv=none; d=google.com; s=arc-20160816; b=OPMTYh/FJtHYQ5RqC1nUm6A304/xH03vDswcVWSAwkiziA0FPR3psYqOaRdshOK+3O hl1xJa64Z0sicBF6003KzjGpzK9duMWIo7ourxWGCa7XtbFBaiqjDtoyLtiGlVez8IUT SUFMB49FGv/XUY7Y4vVl6/gJLg6jnwEdZf4kMHazInIGm+PKtLIz3dFXKfFY+XQJZWeO d1CLHMUwUzYPWgDa8CstQt9VxMaYIgyRHWyv2phepWr/NDmDRGxssESPc+bjPwoEcvRm NYpVLA5fnD9zWoFxSeo2aN5c4QIljiXDMACmFybGk/U5cEOzuORQDLOKqUvaZtCVltdO xJ5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=YhzLQ1ymoMWiVSxQ4swlJ7y2vTQzil3e2oWfWXxTIYM=; b=MME34Y17cI6wex/J7V/0UoJd/3Dt1WRkTEGEMI45hgJmTlW6CnGZkVNkcfp3GC7aT+ aZGS7zDCQzJpBvHxs72XHBn1eiRZjpcaXGVW+B2qJ1qHJFpiiJLTbwGQA+ODPa3BSDmc tgYJZ3qnvYcbGOAOIW0XZ5rF2YifU9xLEteioa6o+8xoPT8dz2Nlc+HTi9diZViRVbd3 wd++3nHAFNX3DieRB/xz6VnyOQfmmAbIqHd7LYyF8Sk7gXEnBaeLcCZUPhPbGRljt3Ye XnVXeuHO+BtCzQma0S3tEh7Y3rtwdmy31S/cYv0qx7EKuVTiiuhIjR8MvI/GwBzeHzFC LHkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="QQL/j7yH"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t9-v6si11743754pgo.42.2018.07.24.06.23.58; Tue, 24 Jul 2018 06:24:13 -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="QQL/j7yH"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388322AbeGXO3g (ORCPT + 99 others); Tue, 24 Jul 2018 10:29:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:60534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388295AbeGXO3g (ORCPT ); Tue, 24 Jul 2018 10:29:36 -0400 Received: from localhost (unknown [171.61.90.205]) (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 46F8F20852; Tue, 24 Jul 2018 13:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1532438588; bh=5gMAuvLfwZnQAzioqK7tm85OE6ffyBDtYnpSQyDE6O8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QQL/j7yHmAr7DiGBY3/zN/coXs8/82ng1Lzyi5zEAAuScUHcEWE+iM0NmJKwLT6RR 45cYEZcJWx2uFb1TgwXR0YOMvkQnLD0wgD21/FZL0Z1PxMedlinyB6HQ2XmvvGlqSd 3YX7Dcl2XnUbuxx+hhClPiuERVtn0vC7CT6+Zd6U= Date: Tue, 24 Jul 2018 18:52:59 +0530 From: Vinod To: Paul Cercueil Cc: Rob Herring , Mark Rutland , Ralf Baechle , Paul Burton , James Hogan , Zubair Lutfullah Kakakhel , Mathieu Malaterre , Daniel Silsby , dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@linux-mips.org Subject: Re: [PATCH v3 03/18] dmaengine: dma-jz4780: Avoid hardcoding number of channels Message-ID: <20180724132259.GF3661@vkoul-mobl> References: <20180721110643.19624-1-paul@crapouillou.net> <20180721110643.19624-4-paul@crapouillou.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180721110643.19624-4-paul@crapouillou.net> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-07-18, 13:06, Paul Cercueil wrote: > +static const struct jz4780_dma_soc_data jz4780_dma_soc_data[] = { > + [ID_JZ4780] = { .nb_channels = 32, }, why the array of structs? > +}; > + > +static const struct of_device_id jz4780_dma_dt_match[] = { > + { .compatible = "ingenic,jz4780-dma", .data = (void *)ID_JZ4780 }, the data should be jz4780_dma_soc_data? as you would add more data later.. and not the enum.. > - jzdma = devm_kzalloc(dev, sizeof(*jzdma), GFP_KERNEL); > + version = (enum jz_version)of_id->data; > + soc_data = &jz4780_dma_soc_data[version]; this can be simplified if we do: soc_data = device_get_match_data(pdev); with: static const struct jz4780_dma_soc_data jz4780_dma_soc_data = { .nb_channels = 32, }; and { .compatible = "ingenic,jz4780-dma", .data = (void *)jz4780_dma_soc_data }, You add more parameters in future patches and store soc_data in driver object and use as is.. > + jzdma = devm_kzalloc(dev, sizeof(*jzdma) > + + sizeof(*jzdma->chan) * soc_data->nb_channels, > + GFP_KERNEL); > if (!jzdma) > return -ENOMEM; > > + jzdma->soc_data = soc_data; > + jzdma->version = version; why do you need to store version, driver should handle values and not versions.. -- ~Vinod