From patchwork Wed Apr 7 16:04:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 91073 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o37G5bqm005667 for ; Wed, 7 Apr 2010 16:05:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932862Ab0DGQFf (ORCPT ); Wed, 7 Apr 2010 12:05:35 -0400 Received: from smtp.nokia.com ([192.100.105.134]:62354 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932570Ab0DGQFe (ORCPT ); Wed, 7 Apr 2010 12:05:34 -0400 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o37G5Psp007673 for ; Wed, 7 Apr 2010 11:05:33 -0500 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 7 Apr 2010 19:05:12 +0300 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 7 Apr 2010 19:05:12 +0300 Received: from localhost.localdomain (esdhcp04088.research.nokia.com [172.21.40.88]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o37G4YN9015130; Wed, 7 Apr 2010 19:05:07 +0300 From: felipe.balbi@nokia.com To: Linux OMAP Mailing List Cc: Felipe Balbi Subject: [RFC PATCH 25/37] cbus: retu: allocate platform_device for Retu's children Date: Wed, 7 Apr 2010 19:04:16 +0300 Message-Id: <1270656268-7034-26-git-send-email-felipe.balbi@nokia.com> X-Mailer: git-send-email 1.7.0.rc0.33.g7c3932 In-Reply-To: <1270656268-7034-1-git-send-email-felipe.balbi@nokia.com> References: <1270656268-7034-1-git-send-email-felipe.balbi@nokia.com> X-OriginalArrivalTime: 07 Apr 2010 16:05:12.0749 (UTC) FILETIME=[1AC635D0:01CAD66C] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 07 Apr 2010 16:05:38 +0000 (UTC) diff --git a/drivers/cbus/retu.c b/drivers/cbus/retu.c index ea09c17..bc81a9b 100644 --- a/drivers/cbus/retu.c +++ b/drivers/cbus/retu.c @@ -330,6 +330,67 @@ static void retu_power_off(void) } /** + * retu_allocate_child - Allocates one Retu child + * @name: name of new child + * @parent: parent device for this child + */ +static struct device *retu_allocate_child(char *name, struct device *parent) +{ + struct platform_device *pdev; + int status; + + pdev = platform_device_alloc(name, -1); + if (!pdev) { + dev_dbg(parent, "can't allocate %s\n", name); + goto err; + } + + pdev->dev.parent = parent; + + status = platform_device_add(pdev); + if (status < 0) { + dev_dbg(parent, "can't add %s\n", name); + goto err; + } + + return &pdev->dev; + +err: + platform_device_put(pdev); + return NULL; +} + +/** + * retu_allocate_children - Allocates Retu's children + */ +static int retu_allocate_children(struct device *parent) +{ + struct device *child; + + child = retu_allocate_child("retu-pwrbutton", parent); + if (!child) + return -ENOMEM; + + child = retu_allocate_child("retu-headset", parent); + if (!child) + return -ENOMEM; + + child = retu_allocate_child("retu-rtc", parent); + if (!child) + return -ENOMEM; + + child = retu_allocate_child("retu-user", parent); + if (!child) + return -ENOMEM; + + child = retu_allocate_child("retu-wdt", parent); + if (!child) + return -ENOMEM; + + return 0; +} + +/** * retu_probe - Probe for Retu ASIC * @dev: the Retu device * @@ -400,6 +461,19 @@ static int __devinit retu_probe(struct platform_device *pdev) } #endif + ret = retu_allocate_children(&pdev->dev); + if (ret < 0) { + dev_err(&pdev->dev, "Unable to allocate Retu children\n"); +#ifdef CONFIG_CBUS_RETU_USER + retu_user_cleanup(); +#endif + retu_write_reg(RETU_REG_IMR, 0xffff); + free_irq(gpio_to_irq(retu_irq_pin), 0); + gpio_free(retu_irq_pin); + tasklet_kill(&retu_tasklet); + return ret; + } + return 0; }