From patchwork Sun Aug 6 21:36:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Jarzmik X-Patchwork-Id: 9884075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E2974602B6 for ; Sun, 6 Aug 2017 21:37:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2C5128396 for ; Sun, 6 Aug 2017 21:37:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7C8628563; Sun, 6 Aug 2017 21:37:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 26E5F28396 for ; Sun, 6 Aug 2017 21:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=z13cqtOYsgxEK5k/YAp/wouqYpV70xFfv1bwwmLfN60=; b=tHY H2+ASj7mmvx6TGKtv2iKMRx8dm51Dot5L0gvjmNb15/Ga8tfuyOT7Hk/Pr2eq+9SM/x9H6wZK0q+7 u2VI5c46R5kpABNLKTrAu6UTQC9RAgWb1Tk8h6+67pNpkWocGL1Z9K9FYe4B1kRyts2VRo+O0MwC3 u9Fw/eB8zIHSGd6RFRJIlR2peFWSDGOJATMSgXlxnZ4Z6QKCZLdUtx603AhozReKO3X77WsvEZ08t xiFYuelF16bwtt16vLLL79FNbjwxQ+6pZZiu1QjiES5Ss1YG5DQKVyR0w9ffhuCMI8sZ3fX3DehvH IxIIyEgbdj4W3+Hbfu6R5tw6lbCMj1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1deTEn-0003Jk-KE; Sun, 06 Aug 2017 21:37:29 +0000 Received: from smtp02.smtpout.orange.fr ([80.12.242.124] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1deTE7-0002hh-GQ for linux-arm-kernel@lists.infradead.org; Sun, 06 Aug 2017 21:36:52 +0000 Received: from belgarion.home ([90.55.206.157]) by mwinf5d78 with ME id txcE1v0093QH74y03xcFJn; Sun, 06 Aug 2017 23:36:22 +0200 X-ME-Helo: belgarion.home X-ME-Date: Sun, 06 Aug 2017 23:36:22 +0200 X-ME-IP: 90.55.206.157 From: Robert Jarzmik To: Dmitry Torokhov , Lee Jones , Jaroslav Kysela , Takashi Iwai , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Liam Girdwood , Mark Brown , Lars-Peter Clausen , Charles Keepax Subject: [PATCH v5 00/12] AC97 device/driver model revamp Date: Sun, 6 Aug 2017 23:36:01 +0200 Message-Id: <20170806213613.5600-1-robert.jarzmik@free.fr> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170806_143648_024906_78092F44 X-CRM114-Status: GOOD ( 17.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-input@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Lars, Mark, Charles, Lee, This is a minor revision after v4, mainly reviews from Takashi, Charles. I extracted the diff from the v3 of sound/ac97 which is in [1] for easier spotting of what has globally changed. I tentatively kept your Ack Charles for patch 11/12, please shout if you disagree (there is an #ifdef added). I would still need a review from you, Lee, for the mfd patch (patch 6/12). Happy review. --- Robert Robert Jarzmik (12): ALSA: ac97: split out the generic ac97 registers ALSA: ac97: add an ac97 bus ASoC: add new ac97 bus support ASoC: arm: make pxa2xx-ac97-lib ac97 codec agnostic Input: wm97xx: split out touchscreen registering mfd: wm97xx-core: core support for wm97xx Codec Input: wm97xx: add new AC97 bus support ASoC: wm9713: add ac97 new bus support ASoC: wm9712: add ac97 new bus support ASoC: wm9705: add private structure ASoC: wm9705: add ac97 new bus support ASoC: pxa: switch to new ac97 bus support drivers/input/touchscreen/Kconfig | 2 +- drivers/input/touchscreen/wm97xx-core.c | 252 ++++++++++----- drivers/mfd/Kconfig | 15 + drivers/mfd/Makefile | 1 + drivers/mfd/wm97xx-core.c | 405 ++++++++++++++++++++++++ include/linux/mfd/wm97xx.h | 31 ++ include/sound/ac97/codec.h | 118 +++++++ include/sound/ac97/compat.h | 20 ++ include/sound/ac97/controller.h | 85 +++++ include/sound/ac97/regs.h | 262 ++++++++++++++++ include/sound/ac97_codec.h | 239 +------------- include/sound/pxa2xx-lib.h | 15 +- sound/Kconfig | 2 + sound/Makefile | 1 + sound/ac97/Kconfig | 19 ++ sound/ac97/Makefile | 8 + sound/ac97/ac97_core.h | 16 + sound/ac97/bus.c | 539 ++++++++++++++++++++++++++++++++ sound/ac97/codec.c | 15 + sound/ac97/snd_ac97_compat.c | 108 +++++++ sound/arm/Kconfig | 1 - sound/arm/pxa2xx-ac97-lib.c | 37 ++- sound/arm/pxa2xx-ac97.c | 35 ++- sound/soc/codecs/Kconfig | 9 +- sound/soc/codecs/wm9705.c | 61 ++-- sound/soc/codecs/wm9712.c | 39 ++- sound/soc/codecs/wm9713.c | 39 ++- sound/soc/pxa/Kconfig | 5 +- sound/soc/pxa/pxa2xx-ac97.c | 46 ++- 29 files changed, 2011 insertions(+), 414 deletions(-) create mode 100644 drivers/mfd/wm97xx-core.c create mode 100644 include/linux/mfd/wm97xx.h create mode 100644 include/sound/ac97/codec.h create mode 100644 include/sound/ac97/compat.h create mode 100644 include/sound/ac97/controller.h create mode 100644 include/sound/ac97/regs.h create mode 100644 sound/ac97/Kconfig create mode 100644 sound/ac97/Makefile create mode 100644 sound/ac97/ac97_core.h create mode 100644 sound/ac97/bus.c create mode 100644 sound/ac97/codec.c create mode 100644 sound/ac97/snd_ac97_compat.c diff --git a/include/sound/ac97/compat.h b/include/sound/ac97/compat.h index d876464bf7e4..1351cba40048 100644 --- a/include/sound/ac97/compat.h +++ b/include/sound/ac97/compat.h @@ -13,7 +13,6 @@ #define AC97_COMPAT_H #include -#include struct snd_ac97 *snd_ac97_compat_alloc(struct ac97_codec_device *adev); void snd_ac97_compat_release(struct snd_ac97 *ac97); diff --git a/include/sound/ac97/controller.h b/include/sound/ac97/controller.h index 18c699925a85..b36ecdd64f14 100644 --- a/include/sound/ac97/controller.h +++ b/include/sound/ac97/controller.h @@ -8,12 +8,13 @@ #ifndef AC97_CONTROLLER_H #define AC97_CONTROLLER_H +#include #include #define AC97_BUS_MAX_CODECS 4 #define AC97_SLOTS_AVAILABLE_ALL 0xf -struct device; +struct ac97_controller_ops; /** * struct ac97_controller - The AC97 controller of the AC-Link @@ -21,8 +22,8 @@ struct device; * @controllers: linked list of all existing controllers. * @adap: the shell device ac97-%d, ie. ac97 adapter * @nr: the number of the shell device - * @parent: the device providing the AC97 controller. * @slots_available: the mask of accessible/scanable codecs. + * @parent: the device providing the AC97 controller. * @codecs: the 4 possible AC97 codecs (NULL if none found). * @codecs_pdata: platform_data for each codec (NULL if no pdata). * @@ -34,8 +35,8 @@ struct ac97_controller { struct list_head controllers; struct device adap; int nr; - struct device *parent; unsigned short slots_available; + struct device *parent; struct ac97_codec_device *codecs[AC97_BUS_MAX_CODECS]; void *codecs_pdata[AC97_BUS_MAX_CODECS]; }; diff --git a/sound/ac97/ac97_core.h b/sound/ac97/ac97_core.h index 219fec0d52e0..08441a4fda7c 100644 --- a/sound/ac97/ac97_core.h +++ b/sound/ac97/ac97_core.h @@ -8,3 +8,9 @@ unsigned int snd_ac97_bus_scan_one(struct ac97_controller *ac97, unsigned int codec_num); + +static inline bool ac97_ids_match(unsigned int id1, unsigned int id2, + unsigned int mask) +{ + return (id1 & mask) == (id2 & mask); +} diff --git a/sound/ac97/bus.c b/sound/ac97/bus.c index af618a0e89cb..31f858eceffc 100644 --- a/sound/ac97/bus.c +++ b/sound/ac97/bus.c @@ -105,6 +105,7 @@ static int ac97_codec_add(struct ac97_controller *ac97_ctrl, int idx, return 0; err_free_codec: + put_device(&codec->dev); kfree(codec); ac97_ctrl->codecs[idx] = NULL; @@ -171,14 +172,10 @@ static int ac97_bus_reset(struct ac97_controller *ac97_ctrl) */ int snd_ac97_codec_driver_register(struct ac97_codec_driver *drv) { - int ret; - drv->driver.bus = &ac97_bus_type; - ret = driver_register(&drv->driver); - - return ret; + return driver_register(&drv->driver); } -EXPORT_SYMBOL(snd_ac97_codec_driver_register); +EXPORT_SYMBOL_GPL(snd_ac97_codec_driver_register); /** * snd_ac97_codec_driver_unregister - unregister an AC97 codec driver @@ -190,7 +187,7 @@ void snd_ac97_codec_driver_unregister(struct ac97_codec_driver *drv) { driver_unregister(&drv->driver); } -EXPORT_SYMBOL(snd_ac97_codec_driver_unregister); +EXPORT_SYMBOL_GPL(snd_ac97_codec_driver_unregister); /** * snd_ac97_codec_get_platdata - get platform_data @@ -208,7 +205,7 @@ void *snd_ac97_codec_get_platdata(const struct ac97_codec_device *adev) return ac97_ctrl->codecs_pdata[adev->num]; } -EXPORT_SYMBOL(snd_ac97_codec_get_platdata); +EXPORT_SYMBOL_GPL(snd_ac97_codec_get_platdata); static void ac97_ctrl_codecs_unregister(struct ac97_controller *ac97_ctrl) { @@ -359,7 +356,7 @@ struct ac97_controller *snd_ac97_controller_register( kfree(ac97_ctrl); return ERR_PTR(ret); } -EXPORT_SYMBOL(snd_ac97_controller_register); +EXPORT_SYMBOL_GPL(snd_ac97_controller_register); /** * snd_ac97_controller_unregister - unregister an ac97 controller @@ -370,7 +367,7 @@ void snd_ac97_controller_unregister(struct ac97_controller *ac97_ctrl) { ac97_del_adapter(ac97_ctrl); } -EXPORT_SYMBOL(snd_ac97_controller_unregister); +EXPORT_SYMBOL_GPL(snd_ac97_controller_unregister); #ifdef CONFIG_PM static int ac97_pm_runtime_suspend(struct device *dev) @@ -466,7 +463,7 @@ static int ac97_bus_match(struct device *dev, struct device_driver *drv) return false; do { - if ((id[i].id & id->mask) == (adev->vendor_id & id[i].mask)) + if (ac97_ids_match(id[i].id, adev->vendor_id, id[i].mask)) return true; } while (id[i++].id); diff --git a/sound/ac97/snd_ac97_compat.c b/sound/ac97/snd_ac97_compat.c index ac8d835c1513..61544e0d8de4 100644 --- a/sound/ac97/snd_ac97_compat.c +++ b/sound/ac97/snd_ac97_compat.c @@ -88,16 +88,19 @@ int snd_ac97_reset(struct snd_ac97 *ac97, bool try_warm, unsigned int id, { struct ac97_codec_device *adev = to_ac97_device(ac97->private_data); struct ac97_controller *actrl = adev->ac97_ctrl; + unsigned int scanned; if (try_warm) { compat_ac97_warm_reset(ac97); - if (snd_ac97_bus_scan_one(actrl, adev->num) == adev->vendor_id) + scanned = snd_ac97_bus_scan_one(actrl, adev->num); + if (ac97_ids_match(scanned, adev->vendor_id, id_mask)) return 1; } compat_ac97_reset(ac97); compat_ac97_warm_reset(ac97); - if (snd_ac97_bus_scan_one(actrl, adev->num) == adev->vendor_id) + scanned = snd_ac97_bus_scan_one(actrl, adev->num); + if (ac97_ids_match(scanned, adev->vendor_id, id_mask)) return 0; return -ENODEV;