Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2358661ybg; Thu, 24 Oct 2019 08:33:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvrBnlLF4j1lSXj/b3TGJcTQ55CKW+sJaPn8ML+7cG/lbrfflkVgQpmMKUCnh0tuKD9tlR X-Received: by 2002:a17:906:4813:: with SMTP id w19mr23643875ejq.258.1571931181585; Thu, 24 Oct 2019 08:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571931181; cv=none; d=google.com; s=arc-20160816; b=CZWqRHEJFOs/nKL4hpsIY44MCYyIHqN/+WGse9hTjOYkJeZEhUnPKDTbCzdvdlu/FJ Q33v+tblJhO2NA1YpU0/FdYTJT/8LXDqE2bfpJELGLbbRrm13TSc1MfoTUD/UHX8V1pa HMlc956ewXTYF/rd8EVN5pwl9hL8Y2dIsZmCpNn3PS5YQe9kQA9GLU9LnwhjerRInql0 4MldlfdndUHInNq49ApNv3v8F3j95W1KrIQNPOigtn2OJn5W5KzbPx0yah4M5k9s/0P/ A8px34O2g4zN430NcyNFL/xcaSIvkRpicmIFmppSJ9PRzGbzrt265PFUmKCeNFCVDL8o amhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HTNU/vrbku4iXavy5HJYn+qbhqD5iVky7EyLzuaTjbs=; b=zwEGI0QFClQnqhDamyETqnF3EmwV+uStQfWmRcgYEujHPhNf23cW/IhyNFFTeQzLNo Muy75K959ZWlQt/gY4t2hceV0IhkprMiXaXWZOiYlRjF8kScXfSJS0Uxk6/yB5jV8wyy wDrkh8E/by1o+KkMUAXRDXT0hAS+oAwNQVtXtOKn6cWGtpmY9vUHAcRbWVH8QsMxPEGW Ru2yW5p9Tgqp5hqusBxXYbbbIQqjKew/5DmkFV/NLjnUDctADEI6k7Q9ywyOlS8LZ21x 1l+r3jOaQoQsyb5NTP6eoc6UMItR5SJpKKU2tQjnpyP7l7m8n5Lsy0XXVGNceODEIR1U X9aA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si16664549ejj.402.2019.10.24.08.32.36; Thu, 24 Oct 2019 08:33:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407513AbfJWV2w (ORCPT + 99 others); Wed, 23 Oct 2019 17:28:52 -0400 Received: from mga09.intel.com ([134.134.136.24]:24158 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392591AbfJWV2s (ORCPT ); Wed, 23 Oct 2019 17:28:48 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Oct 2019 14:28:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,222,1569308400"; d="scan'208";a="399541190" Received: from ayamada-mobl1.gar.corp.intel.com (HELO pbossart-mobl3.intel.com) ([10.254.95.208]) by fmsmga006.fm.intel.com with ESMTP; 23 Oct 2019 14:28:45 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org, tiwai@suse.de, broonie@kernel.org, vkoul@kernel.org, gregkh@linuxfoundation.org, jank@cadence.com, srinivas.kandagatla@linaro.org, slawomir.blauciak@intel.com, Bard liao , Rander Wang , Ranjani Sridharan , Pierre-Louis Bossart , Sanyog Kale Subject: [PATCH 06/14] soundwire: add support for sdw_slave_type Date: Wed, 23 Oct 2019 16:28:15 -0500 Message-Id: <20191023212823.608-7-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191023212823.608-1-pierre-louis.bossart@linux.intel.com> References: <20191023212823.608-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the bus does not have any explicit support for master devices. Add explicit support for sdw_slave_type, so that in follow-up patches we can add support for the sdw_md_type (md==Master Device), following the Grey Bus example. Signed-off-by: Pierre-Louis Bossart --- drivers/soundwire/bus_type.c | 9 ++++++++- drivers/soundwire/slave.c | 7 ++++++- include/linux/soundwire/sdw_type.h | 6 ++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c index 9a0fd3ee1014..5df095f4e12f 100644 --- a/drivers/soundwire/bus_type.c +++ b/drivers/soundwire/bus_type.c @@ -49,9 +49,16 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size) static int sdw_uevent(struct device *dev, struct kobj_uevent_env *env) { - struct sdw_slave *slave = to_sdw_slave_device(dev); + struct sdw_slave *slave; char modalias[32]; + if (is_sdw_slave(dev)) { + slave = to_sdw_slave_device(dev); + } else { + dev_warn(dev, "uevent for unknown Soundwire type\n"); + return -EINVAL; + } + sdw_slave_modalias(slave, modalias, sizeof(modalias)); if (add_uevent_var(env, "MODALIAS=%s", modalias)) diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c index 48a513680db6..c87267f12a3b 100644 --- a/drivers/soundwire/slave.c +++ b/drivers/soundwire/slave.c @@ -14,6 +14,11 @@ static void sdw_slave_release(struct device *dev) kfree(slave); } +struct device_type sdw_slave_type = { + .name = "sdw_slave", + .release = sdw_slave_release, +}; + static int sdw_slave_add(struct sdw_bus *bus, struct sdw_slave_id *id, struct fwnode_handle *fwnode) { @@ -41,9 +46,9 @@ static int sdw_slave_add(struct sdw_bus *bus, id->class_id, id->unique_id); } - slave->dev.release = sdw_slave_release; slave->dev.bus = &sdw_bus_type; slave->dev.of_node = of_node_get(to_of_node(fwnode)); + slave->dev.type = &sdw_slave_type; slave->bus = bus; slave->status = SDW_SLAVE_UNATTACHED; slave->dev_num = 0; diff --git a/include/linux/soundwire/sdw_type.h b/include/linux/soundwire/sdw_type.h index 7d4bc6a979bf..c681b3426478 100644 --- a/include/linux/soundwire/sdw_type.h +++ b/include/linux/soundwire/sdw_type.h @@ -5,6 +5,12 @@ #define __SOUNDWIRE_TYPES_H extern struct bus_type sdw_bus_type; +extern struct device_type sdw_slave_type; + +static inline int is_sdw_slave(const struct device *dev) +{ + return dev->type == &sdw_slave_type; +} #define to_sdw_slave_driver(_drv) \ container_of(_drv, struct sdw_driver, driver) -- 2.20.1