From patchwork Sat May 23 16:15:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 475911 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9E3421402CC for ; Sun, 24 May 2015 02:15:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757962AbbEWQPa (ORCPT ); Sat, 23 May 2015 12:15:30 -0400 Received: from sauhun.de ([89.238.76.85]:55134 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757938AbbEWQP3 (ORCPT ); Sat, 23 May 2015 12:15:29 -0400 Received: from p4fe25ce7.dip0.t-ipconnect.de ([79.226.92.231]:50497 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1YwC56-0000F1-Q0; Sat, 23 May 2015 18:15:25 +0200 From: Wolfram Sang To: linuxppc-dev@lists.ozlabs.org Cc: linux-i2c@vger.kernel.org, alsa-devel@alsa-project.org, Benjamin Herrenschmidt , Dan DeVoto , Mark Elliott , Wolfram Sang Subject: [RFC] sound: ppc: keywest: check if DEQ was already instantiated Date: Sat, 23 May 2015 18:15:11 +0200 Message-Id: <1432397711-3186-1-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.1.4 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Due to changes in i2c-powermac, for some Macs the DEQ is instantiated now in i2c-powermac while some need the instantiation here in the keywest sound driver. The proper fix is to convert this driver to AOA. Until then support both ways of instantiation. Before this patch, some Macs lost sound because the sound driver failed when instantiating the DEQ for the second time. Signed-off-by: Wolfram Sang --- Dan, Mark: I hope I found a generic but not too intrusive solution to the doubled instantiation problem. Can you please test this patch on top of this one "sound: ppc: keywest: drop using attach adapter" from last time? Check if you have sound and send the dmesg output, please. I hope it compiles even, couldn't test that this time. sound/ppc/keywest.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c index d7627bae08362e..6120a067494a44 100644 --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c @@ -31,10 +31,15 @@ */ static struct pmac_keywest *keywest_ctx; +static bool keywest_probed; static int keywest_probe(struct i2c_client *client, const struct i2c_device_id *id) { + keywest_probed = true; + /* If instantiated via i2c-powermac, we still need to set the client */ + if (!keywest_ctx->client) + keywest_ctx->client = client; i2c_set_clientdata(client, keywest_ctx); return 0; } @@ -92,7 +97,8 @@ static int keywest_remove(struct i2c_client *client) static const struct i2c_device_id keywest_i2c_id[] = { - { "keywest", 0 }, + { "MAC,tas3004", 0 }, /* instantiated by i2c-powermac */ + { "keywest", 0 }, /* instantiated by us if needed */ { } }; @@ -149,8 +155,13 @@ int snd_pmac_keywest_init(struct pmac_keywest *i2c) return err; } + /* There was already a device from i2c-powermac. Great, let's return */ + if (keywest_probed) + return 0; + /* We assume Macs have consecutive I2C bus numbers starting at 0 */ while (adap) { + /* Scan for devices to be bound to */ err = keywest_attach_adapter(adap); if (!err) return 0;