From patchwork Fri Nov 7 14:49:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 40419 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4BF35240F7 for ; Fri, 7 Nov 2014 14:50:26 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf3457340eek.5 for ; Fri, 07 Nov 2014 06:50:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=UykQLPqr9jzfWQfLmzDvOCKyDJe9mRjHP0UF2JHAuqE=; b=nF243dNBLMbtIdbBD0UvGTFkltwe94Iw6/LdpzyDqP2ByGPU6FFejPlQicGXKH6lm8 Nh2NVWZrNnIcIv4i9jGo1mMRbrRxqihgrLdinqMF+dqgrkObVxYcqq3B5436Jpu077ui pXu/yGVXoPqsOMWcOh/+IXR90d7iGp6tY+WweP3x/+8dtJT3G7tKT1QBl7Q+C4ZOn0p1 +NudhIHTJNaH/rSV64Y2XHormzcptShFwzp3f7Bb+MPCf7XgCpS7mdZPKvB0ngNINz0P Jryw4kGjije9V6NwPuer+Fm+TFHGp57ptCbKEW3td0oy/sV1z7g+q7pGT7ykleGI5I46 X2OQ== X-Gm-Message-State: ALoCoQkZUqCUFgboC6qkBArCG55Drq6W1SB/HieyPyltNOlyj1RxKfkRCh4S+6HHLaJlC2LsiVLH X-Received: by 10.194.191.137 with SMTP id gy9mr2042852wjc.0.1415371825517; Fri, 07 Nov 2014 06:50:25 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.202.166 with SMTP id kj6ls55611lac.73.gmail; Fri, 07 Nov 2014 06:50:25 -0800 (PST) X-Received: by 10.112.85.106 with SMTP id g10mr11609369lbz.38.1415371825152; Fri, 07 Nov 2014 06:50:25 -0800 (PST) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id b2si15247963lbm.104.2014.11.07.06.50.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Nov 2014 06:50:25 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id w7so2781397lbi.31 for ; Fri, 07 Nov 2014 06:50:25 -0800 (PST) X-Received: by 10.112.202.104 with SMTP id kh8mr11799906lbc.46.1415371825071; Fri, 07 Nov 2014 06:50:25 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp210465lbc; Fri, 7 Nov 2014 06:50:23 -0800 (PST) X-Received: by 10.68.179.129 with SMTP id dg1mr12321030pbc.113.1415371820251; Fri, 07 Nov 2014 06:50:20 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cs9si9127515pdb.236.2014.11.07.06.50.19 for ; Fri, 07 Nov 2014 06:50:20 -0800 (PST) Received-SPF: none (google.com: netdev-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752946AbaKGOuI (ORCPT + 3 others); Fri, 7 Nov 2014 09:50:08 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:48032 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752386AbaKGOuE (ORCPT ); Fri, 7 Nov 2014 09:50:04 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id sA7EnjB9010374; Fri, 7 Nov 2014 08:49:45 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id sA7Enjm3023704; Fri, 7 Nov 2014 08:49:45 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Fri, 7 Nov 2014 08:49:45 -0600 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id sA7EnX7E007870; Fri, 7 Nov 2014 08:49:41 -0600 From: Roger Quadros To: , CC: , , , , , , , , , , , , Roger Quadros Subject: [PATCH v4 2/8] net: can: c_can: Introduce c_can_driver_data structure Date: Fri, 7 Nov 2014 16:49:16 +0200 Message-ID: <1415371762-29885-3-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1415371762-29885-1-git-send-email-rogerq@ti.com> References: <1415371762-29885-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rogerq@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We want to have more data than just can_dev_id to be present in the driver data e.g. TI platforms need RAMINIT register description. Introduce the c_can_driver_data structure and move the can_dev_id into it. Tidy up the way it is used on probe(). Signed-off-by: Roger Quadros --- drivers/net/can/c_can/c_can.h | 4 +++ drivers/net/can/c_can/c_can_platform.c | 52 +++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h index 99ad1aa..26c975d 100644 --- a/drivers/net/can/c_can/c_can.h +++ b/drivers/net/can/c_can/c_can.h @@ -169,6 +169,10 @@ enum c_can_dev_id { BOSCH_D_CAN, }; +struct c_can_driver_data { + enum c_can_dev_id id; +}; + /* c_can private data structure */ struct c_can_priv { struct can_priv can; /* must be the first member */ diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index b144e71..1546c2b 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c @@ -167,26 +167,34 @@ static void c_can_hw_raminit(const struct c_can_priv *priv, bool enable) } } +static struct c_can_driver_data c_can_drvdata = { + .id = BOSCH_C_CAN, +}; + +static struct c_can_driver_data d_can_drvdata = { + .id = BOSCH_D_CAN, +}; + static struct platform_device_id c_can_id_table[] = { - [BOSCH_C_CAN_PLATFORM] = { + { .name = KBUILD_MODNAME, - .driver_data = BOSCH_C_CAN, + .driver_data = (kernel_ulong_t)&c_can_drvdata, }, - [BOSCH_C_CAN] = { + { .name = "c_can", - .driver_data = BOSCH_C_CAN, + .driver_data = (kernel_ulong_t)&c_can_drvdata, }, - [BOSCH_D_CAN] = { + { .name = "d_can", - .driver_data = BOSCH_D_CAN, - }, { - } + .driver_data = (kernel_ulong_t)&d_can_drvdata, + }, + { /* sentinel */ }, }; MODULE_DEVICE_TABLE(platform, c_can_id_table); static const struct of_device_id c_can_of_table[] = { - { .compatible = "bosch,c_can", .data = &c_can_id_table[BOSCH_C_CAN] }, - { .compatible = "bosch,d_can", .data = &c_can_id_table[BOSCH_D_CAN] }, + { .compatible = "bosch,c_can", .data = &c_can_drvdata }, + { .compatible = "bosch,d_can", .data = &d_can_drvdata }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, c_can_of_table); @@ -198,21 +206,19 @@ static int c_can_plat_probe(struct platform_device *pdev) struct net_device *dev; struct c_can_priv *priv; const struct of_device_id *match; - const struct platform_device_id *id; struct resource *mem, *res; int irq; struct clk *clk; - - if (pdev->dev.of_node) { - match = of_match_device(c_can_of_table, &pdev->dev); - if (!match) { - dev_err(&pdev->dev, "Failed to find matching dt id\n"); - ret = -EINVAL; - goto exit; - } - id = match->data; + const struct c_can_driver_data *drvdata; + + match = of_match_device(c_can_of_table, &pdev->dev); + if (match) { + drvdata = match->data; + } else if (pdev->id_entry->driver_data) { + drvdata = (struct c_can_driver_data *) + pdev->id_entry->driver_data; } else { - id = platform_get_device_id(pdev); + return -ENODEV; } /* get the appropriate clk */ @@ -244,7 +250,7 @@ static int c_can_plat_probe(struct platform_device *pdev) } priv = netdev_priv(dev); - switch (id->driver_data) { + switch (drvdata->id) { case BOSCH_C_CAN: priv->regs = reg_map_c_can; switch (mem->flags & IORESOURCE_MEM_TYPE_MASK) { @@ -303,7 +309,7 @@ static int c_can_plat_probe(struct platform_device *pdev) priv->device = &pdev->dev; priv->can.clock.freq = clk_get_rate(clk); priv->priv = clk; - priv->type = id->driver_data; + priv->type = drvdata->id; platform_set_drvdata(pdev, dev); SET_NETDEV_DEV(dev, &pdev->dev);