From patchwork Sun May 16 17:04:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 99985 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 o4GH2kjt010776 for ; Sun, 16 May 2010 17:02:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753541Ab0EPRCp (ORCPT ); Sun, 16 May 2010 13:02:45 -0400 Received: from mail-ew0-f216.google.com ([209.85.219.216]:51606 "EHLO mail-ew0-f216.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753223Ab0EPRCo (ORCPT ); Sun, 16 May 2010 13:02:44 -0400 Received: by ewy8 with SMTP id 8so1499373ewy.28 for ; Sun, 16 May 2010 10:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=Opr+vs52/RSamdlzmEEhNegpzZhO/MedGPzxpFdwQdU=; b=YpcZs/o+4Iamtk+Kspvpjq4phjosCq2uZFbGwi5iJsNCNKFFrlgjLY/3tXPweWGIbh AGE4TjYegiCV7WK5Z4wzJ+qP0dv8iz4lkywtWZywpdNM4G/d4SkrPxUcS9yDlzOHUsmq 6ksiL+6intbinS5E5CO01rFhwO9wzANdCek34= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=fezkYiVTiONy2hz92afI1n+pqltznGnpTH7pCGcBpxZjIqyGSwtXjd0KnBLRPHVcpG 2W7tgjBbPBzJw6NZvzUPJE0eZzBskpoK9ztBb5otJ191jAadVMQpx4n/E90nEOW/iqR9 6SoN0HlbifXXKuGKgZR+UE+1TUVvpVf9Zv99o= Received: by 10.213.107.78 with SMTP id a14mr2082472ebp.10.1274029362013; Sun, 16 May 2010 10:02:42 -0700 (PDT) Received: from localhost (host-94-101-4-66.igua.fi [94.101.4.66]) by mx.google.com with ESMTPS id 14sm2399557ewy.14.2010.05.16.10.02.40 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 16 May 2010 10:02:41 -0700 (PDT) From: Jarkko Nikula To: linux-media@vger.kernel.org Cc: Jarkko Nikula , Eduardo Valentin Subject: [PATCH] si4713: Fix oops when si4713_platform_data is marked as __initdata Date: Sun, 16 May 2010 20:04:26 +0300 Message-Id: <1274029466-17456-1-git-send-email-jhnikula@gmail.com> X-Mailer: git-send-email 1.7.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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]); Sun, 16 May 2010 17:02:46 +0000 (UTC) diff --git a/drivers/media/radio/si4713-i2c.c b/drivers/media/radio/si4713-i2c.c index ab63dd5..cf9858d 100644 --- a/drivers/media/radio/si4713-i2c.c +++ b/drivers/media/radio/si4713-i2c.c @@ -369,7 +369,8 @@ static int si4713_powerup(struct si4713_device *sdev) if (sdev->power_state) return 0; - sdev->platform_data->set_power(1); + if (sdev->set_power) + sdev->set_power(1); err = si4713_send_command(sdev, SI4713_CMD_POWER_UP, args, ARRAY_SIZE(args), resp, ARRAY_SIZE(resp), @@ -383,8 +384,8 @@ static int si4713_powerup(struct si4713_device *sdev) err = si4713_write_property(sdev, SI4713_GPO_IEN, SI4713_STC_INT | SI4713_CTS); - } else { - sdev->platform_data->set_power(0); + } else if (sdev->set_power) { + sdev->set_power(0); } return err; @@ -411,7 +412,8 @@ static int si4713_powerdown(struct si4713_device *sdev) v4l2_dbg(1, debug, &sdev->sd, "Power down response: 0x%02x\n", resp[0]); v4l2_dbg(1, debug, &sdev->sd, "Device in reset mode\n"); - sdev->platform_data->set_power(0); + if (sdev->set_power) + sdev->set_power(0); sdev->power_state = POWER_OFF; } @@ -1959,6 +1961,7 @@ static int si4713_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct si4713_device *sdev; + struct si4713_platform_data *pdata = client->dev.platform_data; int rval; sdev = kzalloc(sizeof *sdev, GFP_KERNEL); @@ -1968,12 +1971,12 @@ static int si4713_probe(struct i2c_client *client, goto exit; } - sdev->platform_data = client->dev.platform_data; - if (!sdev->platform_data) { + if (!pdata) { v4l2_err(&sdev->sd, "No platform data registered.\n"); rval = -ENODEV; goto free_sdev; } + sdev->set_power = pdata->set_power; v4l2_i2c_subdev_init(&sdev->sd, client, &si4713_subdev_ops); diff --git a/drivers/media/radio/si4713-i2c.h b/drivers/media/radio/si4713-i2c.h index faf8cff..d1af889 100644 --- a/drivers/media/radio/si4713-i2c.h +++ b/drivers/media/radio/si4713-i2c.h @@ -220,7 +220,7 @@ struct si4713_device { /* private data structures */ struct mutex mutex; struct completion work; - struct si4713_platform_data *platform_data; + int (*set_power)(int power); struct rds_info rds_info; struct limiter_info limiter_info; struct pilot_info pilot_info;