From patchwork Fri Jun 7 23:54:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 2691671 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id DD31440077 for ; Fri, 7 Jun 2013 23:53:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757300Ab3FGXx6 (ORCPT ); Fri, 7 Jun 2013 19:53:58 -0400 Received: from mail-lb0-f172.google.com ([209.85.217.172]:64180 "EHLO mail-lb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752900Ab3FGXx5 (ORCPT ); Fri, 7 Jun 2013 19:53:57 -0400 Received: by mail-lb0-f172.google.com with SMTP id v20so292652lbc.3 for ; Fri, 07 Jun 2013 16:53:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:organization:to:subject:date:user-agent:cc:references :in-reply-to:mime-version:content-type:content-transfer-encoding :message-id:x-gm-message-state; bh=2xtyCYrv8fQmbzPdW9LFVxBjRQFvmTtEQrfn990j7ZM=; b=IKMvWV8akRSHwaHHQV8u9CyRzExeIqikWDmqgQDIUS2FpZndWD7OzK4AB6Tn9oU1XO gyAD3SDQfB927jss4lmbYzXIzTyQw5TGl+m2fZDofVYzaa+z/kuftPhliUAic/4ts5Z2 7+pzZwIYSEjAbX7nGo4ZfmD/JSNp66X36nK35ZGpfAy5AyKPxcC+xvRVflYW7PfR2IkZ aCWKmTNQITAboxWqxINrp8fNC5XRyjamFVVHihk0S5VM3WHzfl4frHP/Vci1elonbrpA fAqJ0rECmzTJgVacRWmkqMG1OGISIDZnVgvHE4ahiEvkOnJ04hnhgwrUZLnoqAU61rKu tC+Q== X-Received: by 10.112.89.73 with SMTP id bm9mr2247050lbb.39.1370649236432; Fri, 07 Jun 2013 16:53:56 -0700 (PDT) Received: from wasted.dev.rtsoft.ru (ppp91-76-150-46.pppoe.mtu-net.ru. [91.76.150.46]) by mx.google.com with ESMTPSA id n1sm348194lae.0.2013.06.07.16.53.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 07 Jun 2013 16:53:55 -0700 (PDT) From: Sergei Shtylyov Organization: Cogent Embedded To: netdev@vger.kernel.org Subject: [PATCH 1/9] sh_eth: create initial ID table Date: Sat, 8 Jun 2013 03:54:02 +0400 User-Agent: KMail/1.13.5 (Linux/2.6.32.26-175.fc12.i686.PAE; KDE/4.4.5; i686; ; ) Cc: nobuhiro.iwamatsu.yj@renesas.com, linux-sh@vger.kernel.org References: <201306080351.39018.sergei.shtylyov@cogentembedded.com> In-Reply-To: <201306080351.39018.sergei.shtylyov@cogentembedded.com> MIME-Version: 1.0 Message-Id: <201306080354.03424.sergei.shtylyov@cogentembedded.com> X-Gm-Message-State: ALoCoQm+SsYss9scrN2Ve6bTAApbzwg0AJ77BgnFCqVxTmRwloox52fKGIi4AiqKwjWikeEbWalP Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org We are trying to get away from the current driver's scheme of identifying a SoC based on #ifdef's and the platform device ID table matching seems to be a good replacement -- we can use the 'driver_data' field of 'struct platform_device_id' as a pointer to a 'struct sh_eth_cpu_data'. Start by creating the initial table with driver's name as the only entry without the driver data. Check the driver data in the probe() method and if it's not NULL override 'mdp->cd' from it. Signed-off-by: Sergei Shtylyov --- drivers/net/ethernet/renesas/sh_eth.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: net-next/drivers/net/ethernet/renesas/sh_eth.c =================================================================== --- net-next.orig/drivers/net/ethernet/renesas/sh_eth.c +++ net-next/drivers/net/ethernet/renesas/sh_eth.c @@ -2519,6 +2519,7 @@ static int sh_eth_drv_probe(struct platf struct net_device *ndev = NULL; struct sh_eth_private *mdp = NULL; struct sh_eth_plat_data *pd = pdev->dev.platform_data; + const struct platform_device_id *id = platform_get_device_id(pdev); /* get base addr */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -2582,6 +2583,8 @@ static int sh_eth_drv_probe(struct platf #else mdp->cd = &sh_eth_my_cpu_data; #endif + if (id->driver_data) + mdp->cd = (struct sh_eth_cpu_data *)id->driver_data; sh_eth_set_default_cpu_data(mdp->cd); /* set function */ @@ -2696,9 +2699,16 @@ static const struct dev_pm_ops sh_eth_de #define SH_ETH_PM_OPS NULL #endif +static struct platform_device_id sh_eth_id_table[] = { + { CARDNAME }, + { } +}; +MODULE_DEVICE_TABLE(platform, sh_eth_id_table); + static struct platform_driver sh_eth_driver = { .probe = sh_eth_drv_probe, .remove = sh_eth_drv_remove, + .id_table = sh_eth_id_table, .driver = { .name = CARDNAME, .pm = SH_ETH_PM_OPS,