From patchwork Fri May 25 14:36:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 136926 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3675103lji; Fri, 25 May 2018 07:38:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqnhfLJftBNb/sBJs/qL3SUPNWTtJyesMVH4EQgPZeuPnK6XK5aFwLQ0EVpruti9uaR56iR X-Received: by 2002:a17:902:8305:: with SMTP id bd5-v6mr2880102plb.13.1527259109169; Fri, 25 May 2018 07:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527259109; cv=none; d=google.com; s=arc-20160816; b=kV1erwi9W+cywJWcg08SG16/+8O2nEHYXq2x/EpwlyS2JhWAUOjAmd7I+IjHxyOV7e ddNwFHrc2vu13juQZdoqMTrZWxA/WO314N+1v7xstgH1dEBegmQFNeEbI9mgA59HXXUx ztpPjNlTBmA8gG2aBLfgpPZXUViYg8Ed5jk8uBdJbcC4Y4kfC1re05jjOuXP+AgdNpW7 ONrdNnjyCtZMR0WzQZtVgjU5+oQaP0GX2le1VD0+p0ub3Q9CyjMB8gH3XxmhsDGBgw2a GMBHZqS4PfUhWEdEnTUQV5+uoLnW41rods97RYHRsAAWaWKW504vPGXvznXUJRcKwKVK FpoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=0NJFO6su7aIrVN5C6zfM1WIOBkuoLZrsN0oLxSCKfNI=; b=ap4tnZBcfA1x6gjHFYqMZKYNlNWBlSsLFh8KcN91Y2i/xQZHA1Bo6ei4YzVLExi5yM 6K+mE7iL3sVurVGKVMFh//HvOQXUfVu9Qsa0xHtC9OWIMaDgQygu9dy2Ke0fdbjmjc82 GD6W4WWXAZSTThxEBKbMSnui+hXvkvDE7aV5AG0KjBODg14nr4sa1yJCP1jcNOR+TL3F MCZEPhrOAXViL+LIk5Hg7CKAVDrEXSqhOXh/onkfEdVU++3S5xDTCbqnu5DnfHYb382k x5r+vIwNyHgT9pnOTjYugOAc3RLAp7UAQ6wh0T4YWoQ+iUiSG0M162j6cc0oy+xy1rQV BfFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PE0HWr0y; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j33-v6si23992444pld.151.2018.05.25.07.38.28; Fri, 25 May 2018 07:38:29 -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; dkim=pass header.i=@linaro.org header.s=google header.b=PE0HWr0y; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965052AbeEYOi1 (ORCPT + 30 others); Fri, 25 May 2018 10:38:27 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:40243 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936298AbeEYOiY (ORCPT ); Fri, 25 May 2018 10:38:24 -0400 Received: by mail-wm0-f65.google.com with SMTP id x2-v6so7864576wmh.5 for ; Fri, 25 May 2018 07:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0NJFO6su7aIrVN5C6zfM1WIOBkuoLZrsN0oLxSCKfNI=; b=PE0HWr0yQJFDoSKPFM7ASJDP83LZNO18XAIA1tY3NZyM0kr7I1F/I3bFNUo8afnJmk DqZl833F0wCaiaIz6sjSVfqq5MUN3bzXUTZyAOiLZWNtu11IZasA3QvPGFHw7fhhAY4C zpnyOnkVXOd6vv4qMR7PYSO0mT7N7qHDwtnqg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0NJFO6su7aIrVN5C6zfM1WIOBkuoLZrsN0oLxSCKfNI=; b=GyNqAICaa9lKECh3VAZOh8JBkYDjjcGqaXfm93kTlK6gy/h2aYNxCF82sncmRsN1oC YOuxTIv5tn+vybgLG093ZIQxJzM0U60NhABQ1O6jdOn+L6bMv60npia6pYIN0pdpZd3x x5suIX2uCmNpxFd6lcUrW3kz+6Co8NId82mFnaHcjFskrvAobaEW2D56A/o3Hcz9QC0H icmw417QJ2ubauxnB6vrV2HDOBhmlivWwhd40EPx+MYivlZ5TJZOyX5aPYrk7C3tAGey 1+dqXxafi7KKTFzjonDnkWTEEw2j9PSbv45Zf8H8HEu13JdhSH3ZZ7dZq3S5t4IRcPqj 4p8Q== X-Gm-Message-State: ALKqPweSeYcpL4o0hwWZ0ZbMCDrc9sLKP4/TaTvDZsnVmrAF1iZfKX7c ArJbsVQPAoWbKq3glOAW6BbjKw== X-Received: by 2002:a1c:97d3:: with SMTP id z202-v6mr2034768wmd.66.1527259103610; Fri, 25 May 2018 07:38:23 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id r6-v6sm26165729wrg.73.2018.05.25.07.38.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 May 2018 07:38:23 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v3 2/8] slimbus: core: add need_tid flag to slim_msg_txn Date: Fri, 25 May 2018 15:36:12 +0100 Message-Id: <20180525143618.820-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180525143618.820-1-srinivas.kandagatla@linaro.org> References: <20180525143618.820-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add need_tid flag to txn, this flag can be set before start of transcation. Having this flag would avoid calling slim_tid_txn() multiple times on the same txn. Also it is handy for controller drivers too. Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/slimbus.h | 2 ++ 1 file changed, 2 insertions(+) -- 2.16.2 diff --git a/drivers/slimbus/slimbus.h b/drivers/slimbus/slimbus.h index 79f8e05d92dd..3ec5a85fba8e 100644 --- a/drivers/slimbus/slimbus.h +++ b/drivers/slimbus/slimbus.h @@ -102,6 +102,7 @@ struct slim_framer { * @msg: Elemental access message to be read/written * @comp: completion if read/write is synchronous, used internally * for tid based transactions. + * @need_tid: flag indicating if a tid is required for this txn */ struct slim_msg_txn { u8 rl; @@ -113,6 +114,7 @@ struct slim_msg_txn { u8 la; struct slim_val_inf *msg; struct completion *comp; + bool need_tid; }; /* Frequently used message transaction structures */ From patchwork Fri May 25 14:36:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 136929 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3675331lji; Fri, 25 May 2018 07:38:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo+cL6OGW4O9s++o29PVcQJ6aUNkQqG/cXuMYj8MAP+LnzpDDRCb+1URUPfLLSgvV+9UA1Q X-Received: by 2002:a62:ec6:: with SMTP id 67-v6mr2880500pfo.36.1527259124253; Fri, 25 May 2018 07:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527259124; cv=none; d=google.com; s=arc-20160816; b=q4Kku4qQtSE5rC0pfaBrwPPP61ypwBnleEh4RMjEuhOaChqF7166gGDOSPvdyHxL7S Q+vtWoswHURNeojMwwDkEZnwOBiit6D5030EuJq87VhUQrvnYIKC8JSq5AnS1CCUt4UC nxVmB3zKVmhsPPjG9X/IOl2ltVkzp7wgzFrlFsGWWXzeLDIq/ddK4D736iHMp8P14RxV +qeSpvBNteQWRUEYuvats/izqJW/GK+0mRbZTLnCyhSirxfSDKv41dy8lXTXSwft/pNm RnVWYu22xVjkivhmVBuu2ts+Gpa7d8SSbVe2KFXjgLb5gIf27TCG3hI22Q5XontlogVj UYlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=W6uYmgHxTWzfDftIQnpPK6qurtIUOyuIABrSN4ITJSQ=; b=jGtGq6Dd/AalSY9VtdkUUAiqYfi9YBJVBvlDLJEOt1XZoTVC2Q3VNUCuopW+4D92qh +mlX1tagw5JajQ3JgRIauRr+dXEbBlHCOiRIZ4NcmyYNlKqDE45IjTuy+UCE3dp1GAyt RqebC0o8vprdPNNNTbblbIW5vJo2WVygSE91sqR3ginxFCSC5Yv+P1RK34OebCCN2Shk G1vhAGqbS/JIGxB+AvhCAdQfTPjU4mMJ697db3wKhHWCUvrNAinQVlQ2tZ+zI/nvyLhS FJMQwPqsTPY45QkyTxFGvp0GPjQhaluVMBgCfQK6XbmQxLUHjZPqDvT6nY20O1oRKNkc cLLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aAss6bEk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1-v6si6807986pgv.36.2018.05.25.07.38.43; Fri, 25 May 2018 07:38:44 -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; dkim=pass header.i=@linaro.org header.s=google header.b=aAss6bEk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936378AbeEYOil (ORCPT + 30 others); Fri, 25 May 2018 10:38:41 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35977 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964821AbeEYOi0 (ORCPT ); Fri, 25 May 2018 10:38:26 -0400 Received: by mail-wr0-f194.google.com with SMTP id k5-v6so9652416wrn.3 for ; Fri, 25 May 2018 07:38:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W6uYmgHxTWzfDftIQnpPK6qurtIUOyuIABrSN4ITJSQ=; b=aAss6bEkFW1zDKvlkQSqWPIUc1nXbwMH0/KKtoTd9FK7M4/YxrSztC70AZQGydpNlJ ezexsd7uR5E3VAmweEN0UxwLbkfieAIFDKKrEJru0XG8Y+bAC1XaqajRzqVe9kSd6ish 2712VGN3x8MftzXT6fTYD3nNzMxX6NMVVOFZY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W6uYmgHxTWzfDftIQnpPK6qurtIUOyuIABrSN4ITJSQ=; b=ktVmmjcPYVK9AyNLvosdIOxtXvUxsKlhkRblVfrb6jzcexjCV+LXsbcEBasNUe0L9J O4w2hphsV6abY7RIjygy8NAuoCKEwh4lumsm+FLMGSwF4Z4HNnld+t3IoW3hX+bLBjBm P8GkPzJoTnLiqdCUaLRxHAunz53LHBZE2l9IreUTSlxm8wMuk0er/5p/1Eq9MYDHTXf6 TV3j7vASmooiIZTwe+TakjNFnRnF+WmAZ/nCWgoSM9Rx2+zK7s8aLhhwBToyyHQUPNkJ QhNcQQZ3Yoy/g457mJcdSIkkf4pVV2D7JdTqhZSW4BxSKE5z+7HIZGjdzdaZaXJT9QSw SwJA== X-Gm-Message-State: ALKqPweVPmNselNv7nsJpMzmILshMugw72gORaNn3uxND0WPArMPzwll 1byoCnOQQCg1g5tYZXTSC51VYQ== X-Received: by 2002:adf:87d0:: with SMTP id c16-v6mr2257053wrc.246.1527259105840; Fri, 25 May 2018 07:38:25 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id r6-v6sm26165729wrg.73.2018.05.25.07.38.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 May 2018 07:38:25 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v3 4/8] slimbus: messaging: remove multiple calls to pm_runtime_mark_last_busy Date: Fri, 25 May 2018 15:36:14 +0100 Message-Id: <20180525143618.820-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180525143618.820-1-srinivas.kandagatla@linaro.org> References: <20180525143618.820-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There seems to be a multiple calls to pm_runtime_mark_last_busy(), which looks like a typo. Fix this by properly adding pm_runtime_put_autosuspend to put controller in auto suspend state. Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/messaging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.16.2 diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c index 5a2ff01b394c..1c57b631031a 100644 --- a/drivers/slimbus/messaging.c +++ b/drivers/slimbus/messaging.c @@ -139,7 +139,7 @@ int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn) * if there was error during this transaction */ pm_runtime_mark_last_busy(ctrl->dev); - pm_runtime_mark_last_busy(ctrl->dev); + pm_runtime_put_autosuspend(ctrl->dev); } return ret; } From patchwork Fri May 25 14:36:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 136931 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3675801lji; Fri, 25 May 2018 07:39:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoh83NKvXFjSiP/NGzRDD8f6An5Cv5KcCOzJYsbIox5drAPez2Q9pDI8vwM6gRSsAAOAz52 X-Received: by 2002:a17:902:a5c7:: with SMTP id t7-v6mr2933053plq.360.1527259149467; Fri, 25 May 2018 07:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527259149; cv=none; d=google.com; s=arc-20160816; b=C3hMb4D1rB+ldXOw+YbeXCXmKCGmd3nioVhWfk11w7P45E+lFWpH1Z4ArNw5eqNF0n h6ua04Jb+DawzYdB8QSKCTfvRQSkvpMdLjIHUaS4PlWCbTc6+8yFzjqkumf2VGZWfJO0 w8V0y0ue5JKHmgH75fd+J2KEk8z+LE7uNbhVB1+8xNoHckzkJ2QrhaSOe8pESYNHTxOi rpKiCJzg3jlh11+KTHPbMXPrFPcz+qiRMorGGKzTgW9WZJK0bUkGU66v1GPGaR6oWmbP 9F+ILU3Rkkz1lY3ipE6ywI3y+b9fi+MCc799NpK0DsCnSkY6OK1qaNJk3ZcUewOVDsuL dbeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=DATBD+bfVSJYi0EGGsuGsSQSPfajgrHRQrhVJaxnXeI=; b=Q6ANIN8y7WTxT31gf/AE7NmA8Qofs3AKkgJgXiBltPnwOvqWizGd1dodIoHoXZwJNz uijtHOlOhX3o1mFKEje3QhCubqT1bSJhQYHmN+SSDp7ZEOqumIWz5LAwnL8Q/nSPdwCl FWfxw6tY9dn26GJ0oOEGcN4rbI8S25SGgFAxbz+nONZCPXE4tM76Bk+2lt1HOdoIc1Os sjA0o1nLaHg5osmmHlSnlchGR0vaCLCYmaoqKPzTvCRHKCcVOe1TVk8f7I9lOMp86BxX hlyF4ROBcjelSofqANOOXuRUauW746k0C0jgPnkO/l5D28RmYVPaQ0aY4rINDZTGACIv T9ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HqyU58eM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n12-v6si19479486pgs.560.2018.05.25.07.39.09; Fri, 25 May 2018 07:39:09 -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; dkim=pass header.i=@linaro.org header.s=google header.b=HqyU58eM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966083AbeEYOii (ORCPT + 30 others); Fri, 25 May 2018 10:38:38 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:52036 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965074AbeEYOi2 (ORCPT ); Fri, 25 May 2018 10:38:28 -0400 Received: by mail-wm0-f67.google.com with SMTP id j4-v6so15074905wme.1 for ; Fri, 25 May 2018 07:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DATBD+bfVSJYi0EGGsuGsSQSPfajgrHRQrhVJaxnXeI=; b=HqyU58eMmtno/FDQyjBEX2p+cfBlorJ4Tslx/3XvP77SOwFrgZ9zGAocup68F5XoRv vkjLRVddX9sh4CVQg2JqxeMCGFBETk8jXeIsGvMgQWFTqV8A/OMEMZpepNbye1ZeFytP Q7qr8rouc/xmX21XglrgFZ8KNPGlTLJyNIG7M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DATBD+bfVSJYi0EGGsuGsSQSPfajgrHRQrhVJaxnXeI=; b=awEB/3FTKuprk0W8sdMS8eFFfR2FGSwm+MKOaHfokELDFaCwI7OIi3fPHmBhvzRmfm NiljC5NW4x6N8XyWuVHrSaD+bFun/nbhtNvQzQ3R4wOxD+V84bovDpFpHIbqdFhwU+xH S3NPuL1WZ/ek8AoBLWhPK3rCbRDNrvDUrefkKKUNmDDClkPmcmZyCtPnySOcyxX/yBWm 9gNpXa4OK3Cs4VCFYh4AJ2HU6NYXVWelriHmoCuPX3b75n3N65t7Y3nVxtqIq87wAmWQ Rrh6EAOsH5QXXh18nzqAGiQaI5PZ8WWBV9hK+MaH0DWW50RK2+Tg4KaKVIp312N4b+RR HwkQ== X-Gm-Message-State: ALKqPweUTA+o81vD7P14xpzvk2m7YPBbW2vsKGisx+nBkvDBSCLD0iTC alLuk9ybSqanGCimevA7ItcMhkfpPWQ= X-Received: by 2002:a1c:d1c2:: with SMTP id i185-v6mr2147266wmg.10.1527259107033; Fri, 25 May 2018 07:38:27 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id r6-v6sm26165729wrg.73.2018.05.25.07.38.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 May 2018 07:38:26 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v3 5/8] slimbus: messaging: initialize completion correctly Date: Fri, 25 May 2018 15:36:15 +0100 Message-Id: <20180525143618.820-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180525143618.820-1-srinivas.kandagatla@linaro.org> References: <20180525143618.820-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org slim_val_inf can contain random value from stack, make sure the completion is initialized to NULL while filling the msg. Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/messaging.c | 1 + 1 file changed, 1 insertion(+) -- 2.16.2 diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c index 1c57b631031a..e3605ed1c459 100644 --- a/drivers/slimbus/messaging.c +++ b/drivers/slimbus/messaging.c @@ -246,6 +246,7 @@ static void slim_fill_msg(struct slim_val_inf *msg, u32 addr, msg->num_bytes = count; msg->rbuf = rbuf; msg->wbuf = wbuf; + msg->comp = NULL; } /** From patchwork Fri May 25 14:36:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 136933 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3676014lji; Fri, 25 May 2018 07:39:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqLuj5irE562WUVzWhai9DZ1Oew2UF+8XGImEQ1Zs8wvAxZZ9Uqly1vv3prVVWfPO+EA2sF X-Received: by 2002:a63:735e:: with SMTP id d30-v6mr1850709pgn.257.1527259161009; Fri, 25 May 2018 07:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527259161; cv=none; d=google.com; s=arc-20160816; b=UbuM0mhsZBJunsfGPs6osa4HLd2rXcZsnl+MYEBy/hvaqOyKupfQpYmwi/LmZm3srx RaC/ztLNyrl7N+GsiSMomR7g+IBMEpIt1W+PZM9EOOhBeDOQWNvszlvV5Cp4oAiYFyST yXUN8GmbxeJO4Sr4CVzHg5jU1kIt7ttDuBFso5HIVEPJh24w3mgvQenKLbsB9esgvPYp Z5+39bQHp9MOmUOVum+0XlsET1iDD6Wvxk47Gf/dWx9DEolFwRr9gp/4W4Qza8SL5cqj 7uPnJiJVkM78/M8DK7IzK9g2IdOOX6L1k2p9eu9WIjya4CSwpyZmx0A/GITqGWgnfgPN HjZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7dM/CZexMEE5T1vDyvQzFcF6a9NhIWwy9vIqMTrnZ70=; b=O9b09WMzSeroEizQYmB0pF9COwt9dMoV5l5HUlNjFihFAJFeklaVoDBFxapESGzmzB maLhECaRs9fObjD15mYLZMfUIUXNSPaWJPNe4Jk3mC3WCq8hEehTGfJ3BVyahHpbbvM3 CkTwtzc3VyS2u8PPFb0avYNN75mRFrEnkQfSGE+uffSMgXNtvzAJdtOcOOsL3muzJOq0 rLh7NFty+t0IUlgNjZM1m79j5X5vJXfLCUFUKbc1HLNRa7MkMS4+gGfLcnq9z9+ZHvta xGXtUPHScQj/yT3QJXn7zpFSk8MN5jIegc8pCRZd12xnCgNK8H9X/1MntOgmaAKkcn+I 37+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TbyDhLnB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n12-v6si19479486pgs.560.2018.05.25.07.39.20; Fri, 25 May 2018 07:39:20 -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; dkim=pass header.i=@linaro.org header.s=google header.b=TbyDhLnB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965805AbeEYOig (ORCPT + 30 others); Fri, 25 May 2018 10:38:36 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:39654 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965109AbeEYOia (ORCPT ); Fri, 25 May 2018 10:38:30 -0400 Received: by mail-wm0-f65.google.com with SMTP id f8-v6so15257469wmc.4 for ; Fri, 25 May 2018 07:38:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7dM/CZexMEE5T1vDyvQzFcF6a9NhIWwy9vIqMTrnZ70=; b=TbyDhLnBW+rke/ZeVaga++roBfMBYgPqxMobrrSjEINnwhKvXTnFbFsAYUPkBBrfBK YRfAOZHJbZTpBWRA7/LiHw6c6YH4smQ0W51eBvOPx5SDzRgUqjTqIHzmI8uJAA6qYG3U VFdemBq7sjhbpAppPt3jYLv32pP68Cn7KxguE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7dM/CZexMEE5T1vDyvQzFcF6a9NhIWwy9vIqMTrnZ70=; b=lYmVbWXb55ggrHPkuIm5nnb2hS3Nj9/nT3fjFkdHXbrTT+4a4QSz1Hvbrdz3LKeVh9 nNEFj8J3kbjyYMn1dhivMafDCmjgv26A7MKVSrUTdvWVUEKp/R2exjxp01Z7TcMvE/og goHGcuK5g1O+rKqztk8feilOZwKY05DwNkOgKxi+Xk2M+y3dE8egbEXtJWuSwEkbPykc 7l5tKDWaaJAf7fbJV2cW9WwW6qRrAK++ZVGWMEnyBrCSGv54o9piM2c66GR+1HlGD9Rp aO74qwwRdDt5A3ZqYT9Yb2JR155Cn/P92ZQThoshhZ76K/oCOdggbbN+MsQquZlhGQGy 9xlg== X-Gm-Message-State: ALKqPwcRiryR/oVO5WlyCpf573CDGYsu49KM3uMLaXuck62QYoLnQww+ 953mEKA9N0tq0KYviJhFQ1xRRw== X-Received: by 2002:a1c:da50:: with SMTP id r77-v6mr1794303wmg.105.1527259109091; Fri, 25 May 2018 07:38:29 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id r6-v6sm26165729wrg.73.2018.05.25.07.38.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 May 2018 07:38:28 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v3 7/8] slimbus: messaging: add slim_prepare_txn() helper function Date: Fri, 25 May 2018 15:36:17 +0100 Message-Id: <20180525143618.820-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180525143618.820-1-srinivas.kandagatla@linaro.org> References: <20180525143618.820-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds slim_prepare_txn() to allow controllers to prepare controller specific transaction. If not each controllers will duplicate the same code from core. Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/messaging.c | 84 ++++++++++++++++++++++++++++++--------------- drivers/slimbus/slimbus.h | 2 ++ 2 files changed, 58 insertions(+), 28 deletions(-) -- 2.16.2 diff --git a/drivers/slimbus/messaging.c b/drivers/slimbus/messaging.c index e3605ed1c459..cfffa1dece61 100644 --- a/drivers/slimbus/messaging.c +++ b/drivers/slimbus/messaging.c @@ -55,6 +55,46 @@ void slim_msg_response(struct slim_controller *ctrl, u8 *reply, u8 tid, u8 len) } EXPORT_SYMBOL_GPL(slim_msg_response); +/** + * slim_prepare_txn() - Prepare a transaction + * + * @ctrl: Controller handle + * @txn: transaction to be prepared + * @done: completion for transaction if msg does not have completion + * @need_tid: flag to indicate if tid is required for this txn + * note, user defined commands would need tid. + * + * Called by controller to prepare a transaction + * + * Return: zero on success and error code on failures. + */ +int slim_prepare_txn(struct slim_controller *ctrl, struct slim_msg_txn *txn, + struct completion *done, bool need_tid) +{ + unsigned long flags; + int ret = 0; + + txn->need_tid = need_tid; + if (!need_tid) + return 0; + + spin_lock_irqsave(&ctrl->txn_lock, flags); + ret = idr_alloc(&ctrl->tid_idr, txn, 0, SLIM_MAX_TIDS, GFP_ATOMIC); + if (ret < 0) + goto err; + + txn->tid = ret; + if (!txn->msg->comp) + txn->comp = done; + else + txn->comp = txn->msg->comp; + +err: + spin_unlock_irqrestore(&ctrl->txn_lock, flags); + return ret; +} +EXPORT_SYMBOL_GPL(slim_prepare_txn); + /** * slim_do_transfer() - Process a SLIMbus-messaging transaction * @@ -70,10 +110,9 @@ EXPORT_SYMBOL_GPL(slim_msg_response); */ int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn) { - DECLARE_COMPLETION_ONSTACK(done); - bool need_tid = false, clk_pause_msg = false; + bool clk_pause_msg = false; unsigned long flags; - int ret, tid, timeout; + int ret, timeout; /* * do not vote for runtime-PM if the transactions are part of clock @@ -94,28 +133,8 @@ int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn) } } - need_tid = slim_tid_txn(txn->mt, txn->mc); - - if (need_tid) { - spin_lock_irqsave(&ctrl->txn_lock, flags); - tid = idr_alloc(&ctrl->tid_idr, txn, 0, - SLIM_MAX_TIDS, GFP_ATOMIC); - txn->tid = tid; - - if (!txn->msg->comp) - txn->comp = &done; - else - txn->comp = txn->comp; - - spin_unlock_irqrestore(&ctrl->txn_lock, flags); - - if (tid < 0) - return tid; - } - ret = ctrl->xfer_msg(ctrl, txn); - - if (ret && need_tid && !txn->msg->comp) { + if (!ret && txn->need_tid && !txn->msg->comp) { unsigned long ms = txn->rl + HZ; timeout = wait_for_completion_timeout(txn->comp, @@ -123,7 +142,7 @@ int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn) if (!timeout) { ret = -ETIMEDOUT; spin_lock_irqsave(&ctrl->txn_lock, flags); - idr_remove(&ctrl->tid_idr, tid); + idr_remove(&ctrl->tid_idr, txn->tid); spin_unlock_irqrestore(&ctrl->txn_lock, flags); } } @@ -133,13 +152,14 @@ int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn) txn->mt, txn->mc, txn->la, ret); slim_xfer_err: - if (!clk_pause_msg && (!need_tid || ret == -ETIMEDOUT)) { + if (!clk_pause_msg && (!txn->need_tid || ret == -ETIMEDOUT)) { /* * remove runtime-pm vote if this was TX only, or * if there was error during this transaction */ pm_runtime_mark_last_busy(ctrl->dev); pm_runtime_put_autosuspend(ctrl->dev); + } return ret; } @@ -205,6 +225,8 @@ int slim_xfer_msg(struct slim_device *sbdev, struct slim_val_inf *msg, DEFINE_SLIM_LDEST_TXN(txn_stack, mc, 6, sbdev->laddr, msg); struct slim_msg_txn *txn = &txn_stack; struct slim_controller *ctrl = sbdev->ctrl; + DECLARE_COMPLETION_ONSTACK(done); + bool need_tid = false; int ret; u16 sl; @@ -232,10 +254,16 @@ int slim_xfer_msg(struct slim_device *sbdev, struct slim_val_inf *msg, break; } - if (slim_tid_txn(txn->mt, txn->mc)) + if (slim_tid_txn(txn->mt, txn->mc)) { txn->rl++; + need_tid = true; + } - return slim_do_transfer(ctrl, txn); + ret = slim_prepare_txn(ctrl, txn, &done, need_tid); + if (!ret) + return slim_do_transfer(ctrl, txn); + + return ret; } EXPORT_SYMBOL_GPL(slim_xfer_msg); diff --git a/drivers/slimbus/slimbus.h b/drivers/slimbus/slimbus.h index 3ec5a85fba8e..8266e53535cb 100644 --- a/drivers/slimbus/slimbus.h +++ b/drivers/slimbus/slimbus.h @@ -242,6 +242,8 @@ int slim_unregister_controller(struct slim_controller *ctrl); void slim_msg_response(struct slim_controller *ctrl, u8 *reply, u8 tid, u8 l); int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn); int slim_ctrl_clk_pause(struct slim_controller *ctrl, bool wakeup, u8 restart); +int slim_prepare_txn(struct slim_controller *ctrl, struct slim_msg_txn *txn, + struct completion *done, bool need_tid); static inline bool slim_tid_txn(u8 mt, u8 mc) { From patchwork Fri May 25 14:36:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 136928 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3675311lji; Fri, 25 May 2018 07:38:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpScy98ZugePsDNJ0AiifBP2KWnv6g3iiU6yn1B7SUsk/yPFhgGvvyyUOUjSexCODfUW5Mu X-Received: by 2002:a62:3889:: with SMTP id f131-v6mr2844474pfa.173.1527259122769; Fri, 25 May 2018 07:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527259122; cv=none; d=google.com; s=arc-20160816; b=FZY2j2/22udVowFh5nh+m8PksPVJwfWBM7TsxpQDHG8zgo48s2lN8CzARJ84gXI1Uz ZXRle4/673UPg3n987fJ/9OXPw9zk62G4n2yFZEKGUwrdxAicouge0xypxy3cDmE0eBr kjXUj+4kACJWde5nsv4ewDNha5J9+GGIhJ3m6mnNAmOpZb3PvR2WRybIv3fOGccR69P/ YQKFbNuPctqPHMbt1yRVqTz10x3OvOw6mj/2Mf3Ck6mVogDnKu4QPUItbBtYSTROtShp +SQtnJxjlAQ9GY0lzE0+6APOm9LtI0VYKynuDL0q2xt4p23IFzywCrnBzGQ4MjKkSySQ As3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=oUkKrmU5AVMZemQXTuIe+E4X5Oz1OuqiCCPkqRKqp/s=; b=dVI5gPgPe5SroGA7CyKzzkUfof8f0nxARvQHo8BCkxg0ykijegtzFeO+WLN4koo5Pw WqTtqmePxAKJ3HXwJWPXQbZbFRVIRHKIVJ7qMAwsFcGCXcxqN7C0NkpdkV2tkBIvQFhE ePiACXNhMCL+bUcASFTiC8PMKBS8KXA9yimppu4DIARFzJgr9Ibzoso8RU9RTxyRaaAf 5do4T4N6MexEb59qfKWMvjK5n+yvkaaQ4hEmh0sBAty+vmJetLAukhaOzVzQJ5iW2xaf AagnAQU5+nPD8VRhOj5WoPbwf1C6J9PO3WnuLzryq67EP92Q49aiN7PUEdiP+b1StjLG dtfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CcxqzJwc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z16-v6si23106195plo.5.2018.05.25.07.38.42; Fri, 25 May 2018 07:38:42 -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; dkim=pass header.i=@linaro.org header.s=google header.b=CcxqzJwc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966345AbeEYOij (ORCPT + 30 others); Fri, 25 May 2018 10:38:39 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:40290 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965176AbeEYOib (ORCPT ); Fri, 25 May 2018 10:38:31 -0400 Received: by mail-wm0-f66.google.com with SMTP id x2-v6so7865518wmh.5 for ; Fri, 25 May 2018 07:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oUkKrmU5AVMZemQXTuIe+E4X5Oz1OuqiCCPkqRKqp/s=; b=CcxqzJwc//n40W23kF9Cw9s8D2+pdzleCSZXm3Xit1NyfofHmZoGOxN7yjC/WI9LTW rZjc+jM8t428aBjLD+XAahUEiXd9hodH+a9oDhQIdwOyHFfb8qlTu40MPV8ZknDlCRSA QkhwdqBRvfDkij6jH1eh5q8IQ6hmnpB5qomtA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oUkKrmU5AVMZemQXTuIe+E4X5Oz1OuqiCCPkqRKqp/s=; b=f0ebXTteb0JKUUM6KbpN9Hth9+Iq9ve/FgHUyqaPbKWAbAQh22HPa1mABFIemabgPq WhJdt0/Yg7ywpKUB/npZutLmRSsjErqd/QquMNz3I2KWnnqdzzJbnzzadiUn1pN05vYc nZW7WfS0gyT064vpSRphXsykPvAwG/YFOrxMTfQzwkB++bmmn7cN2hLBIXDLGucVB64y QOF8LqUXgXESc2GXRjhMbS3eYGbnAopybrq8LQviwwF+iGqNtemWOjBsdFjIaHukWgvs v3bXZ4xxDBifG7ctx+BWz0Mijpzsb3vuLl7dkY8pvI0hcIks10qAV1vuy2FDlI29Katm 4UYQ== X-Gm-Message-State: ALKqPwdYN0E0a9A5c9ji3ciMMZBn5G2kzE38W/m3a8jwnK+9TrY4CkY0 0XVI5yLS5lw9UrT5qYu7qq4Ssg== X-Received: by 2002:a1c:1103:: with SMTP id 3-v6mr1929360wmr.26.1527259110002; Fri, 25 May 2018 07:38:30 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id r6-v6sm26165729wrg.73.2018.05.25.07.38.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 May 2018 07:38:29 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v3 8/8] slimbus: core: add of_slim_device_get() helper Date: Fri, 25 May 2018 15:36:18 +0100 Message-Id: <20180525143618.820-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180525143618.820-1-srinivas.kandagatla@linaro.org> References: <20180525143618.820-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On SLIMBus controllers like Qcom NGD(non ported device), controller can request logical address once the remote side is powered, having a helper function like this to explicitly enumerate the bus is helpful. Also codec drivers which are taking to interface device would need such a helper too. Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/core.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/slimbus.h | 2 ++ 2 files changed, 41 insertions(+) -- 2.16.2 diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c index 7ddfc675b131..88248a4ecad9 100644 --- a/drivers/slimbus/core.c +++ b/drivers/slimbus/core.c @@ -356,6 +356,45 @@ struct slim_device *slim_get_device(struct slim_controller *ctrl, } EXPORT_SYMBOL_GPL(slim_get_device); +static int of_slim_match_dev(struct device *dev, void *data) +{ + struct device_node *np = data; + struct slim_device *sbdev = to_slim_device(dev); + + return (sbdev->dev.of_node == np); +} + +static struct slim_device *of_find_slim_device(struct slim_controller *ctrl, + struct device_node *np) +{ + struct slim_device *sbdev; + struct device *dev; + + dev = device_find_child(ctrl->dev, np, of_slim_match_dev); + if (dev) { + sbdev = to_slim_device(dev); + return sbdev; + } + + return NULL; +} + +/** + * of_slim_get_device() - get handle to a device using dt node. + * + * @ctrl: Controller on which this device will be added/queried + * @np: node pointer to device + * + * Return: pointer to a device if it has already reported. Creates a new + * device and returns pointer to it if the device has not yet enumerated. + */ +struct slim_device *of_slim_get_device(struct slim_controller *ctrl, + struct device_node *np) +{ + return of_find_slim_device(ctrl, np); +} +EXPORT_SYMBOL_GPL(of_slim_get_device); + static int slim_device_alloc_laddr(struct slim_device *sbdev, bool report_present) { diff --git a/include/linux/slimbus.h b/include/linux/slimbus.h index 90af9eb26615..63801bcc5e60 100644 --- a/include/linux/slimbus.h +++ b/include/linux/slimbus.h @@ -138,6 +138,8 @@ static inline void slim_set_devicedata(struct slim_device *dev, void *data) dev_set_drvdata(&dev->dev, data); } +struct slim_device *of_slim_get_device(struct slim_controller *ctrl, + struct device_node *np); struct slim_device *slim_get_device(struct slim_controller *ctrl, struct slim_eaddr *e_addr); int slim_get_logical_addr(struct slim_device *sbdev);