From patchwork Fri May 13 21:26:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 784242 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4DLTDpH021401 for ; Fri, 13 May 2011 21:29:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759697Ab1EMV1g (ORCPT ); Fri, 13 May 2011 17:27:36 -0400 Received: from na3sys009aog112.obsmtp.com ([74.125.149.207]:51773 "EHLO na3sys009aog112.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759155Ab1EMV1b (ORCPT ); Fri, 13 May 2011 17:27:31 -0400 Received: from mail-fx0-f45.google.com ([209.85.161.45]) by na3sys009aob112.postini.com ([74.125.148.12]) with SMTP ID DSNKTc2iP4nxhj3b+w13MtLl9ewJO5yKVtVz@postini.com; Fri, 13 May 2011 14:27:28 PDT Received: by mail-fx0-f45.google.com with SMTP id 2so2544317fxm.32 for ; Fri, 13 May 2011 14:27:26 -0700 (PDT) Received: by 10.223.22.130 with SMTP id n2mr2268481fab.50.1305322046847; Fri, 13 May 2011 14:27:26 -0700 (PDT) Received: from localhost (cs181221225.pp.htv.fi [82.181.221.225]) by mx.google.com with ESMTPS id d18sm966547fak.22.2011.05.13.14.27.24 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 May 2011 14:27:25 -0700 (PDT) From: Felipe Balbi To: Luciano Coelho Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Balbi Subject: [RFC/PATCH 09/13] net: wl12xx: sdio: add a platform_device Date: Sat, 14 May 2011 00:26:26 +0300 Message-Id: <1305321990-22041-10-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.7.4.1.343.ga91df In-Reply-To: <1305321990-22041-1-git-send-email-balbi@ti.com> References: <1305321990-22041-1-git-send-email-balbi@ti.com> Organization: Texas Instruments\n Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 13 May 2011 21:29:14 +0000 (UTC) that device will match with a driver to be added to the core driver. Signed-off-by: Felipe Balbi --- drivers/net/wireless/wl12xx/sdio.c | 45 ++++++++++++++++++++++++++++++++++++ 1 files changed, 45 insertions(+), 0 deletions(-) diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index bb7569c..5c5e4f2 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ struct wl12xx_sdio_glue { struct device *dev; struct wl1271 *wl; + struct platform_device *core; }; static const struct sdio_device_id wl1271_devices[] __devinitconst = { @@ -210,6 +212,8 @@ static int __devinit wl1271_probe(struct sdio_func *func, { const struct wl12xx_platform_data *wlan_data; + struct platform_device *core; + struct resource res[1]; struct wl12xx_sdio_glue *glue; struct ieee80211_hw *hw; struct wl1271 *wl; @@ -277,8 +281,47 @@ static int __devinit wl1271_probe(struct sdio_func *func, /* Tell PM core that we don't need the card to be powered now */ pm_runtime_put_noidle(&func->dev); + core = platform_device_alloc("wl12xx-sdio", -1); + if (!core) { + dev_err(&func->dev, "can't allocate platform_device\n"); + ret = -ENOMEM; + goto err4; + } + + core->dev.parent = &func->dev; + + memset(res, 0x00, sizeof(res) * ARRAY_SIZE(res)); + + res[0].start = wlan_data->irq; + res[0].flags = IORESOURCE_IRQ; + res[0].name = "irq"; + + ret = platform_device_add_resources(core, res, ARRAY_SIZE(res)); + if (ret) { + dev_err(&func->dev, "can't add resources\n"); + goto err5; + } + + ret = platform_device_add_data(core, wlan_data, sizeof(*wlan_data)); + if (ret) { + dev_err(&func->dev, "can't add platform data\n"); + goto err5; + } + + ret = platform_device_register(core); + if (ret) { + dev_err(&func->dev, "can't register platform device\n"); + goto err5; + } + return 0; +err5: + platform_device_put(core); + +err4: + wl1271_unregister_hw(wl); + err3: free_irq(wl->irq, wl); @@ -303,6 +346,8 @@ static void __devexit wl1271_remove(struct sdio_func *func) wl1271_unregister_hw(wl); free_irq(wl->irq, wl); wl1271_free_hw(wl); + platform_device_del(glue->core); + platform_device_put(glue->core); kfree(glue); }