Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp44924imm; Mon, 21 May 2018 01:53:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrZJCReVajniymx+pDdk7cMWEFUvHqZnJurQhu7OOoJBaB+2OmRuYj7L1KjPnEQwLSQxe80 X-Received: by 2002:a62:f713:: with SMTP id h19-v6mr18884991pfi.165.1526892828331; Mon, 21 May 2018 01:53:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526892828; cv=none; d=google.com; s=arc-20160816; b=e0uPvFre+ZyUu7C0k+xxBhBXrLPxJ+i8T582XRYws0r6TG0SZpjBnq+bey+6GB6GQ1 SkoCFD5I61q+0VoDsIcdH8j+KA4Va+TEvuGKI82c0IYqCcFxR/4niDCpd21VAzeQfi/i BaCahG7wvvwlhjKMdtHLUmp1U4eW9zAXr/+jv5wwDjB72Els3NKu3sEGE1s8tWrTskFe hG06L1/gfow7T73M5Dq6nzA/nJcEm+ZJAZPuPDrjV0CFuzeY2/jOmJwT+NfFQ7ciH5VY 6JYcElPIuywhZnwfBBHsB0jAeBq5/Vs/AsGNSbbBPOca0oXPtlg6CdVYxrrpWGInhr/2 5vHw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:openpgp:from:references:cc:to :subject:dkim-signature:arc-authentication-results; bh=fwEc9ZAla5Ub3OVm5Ff1yAzxnDUK4Tl9N24bp/ky2Dw=; b=D/166PjqqGVXE0A95WAbpJvsoqPxdl3wehHpOMP9N2AJwKCXhFvkwaBcYW6xNeOp3e DlTZUD1mGqqwnziOIkiwUyMf5ByFGtJB/YCKEcM6xxhfSVYx+dq9QfEKGs9Jdw/zWPel EZJ1tXjPmZzbRDH2qRfHwl2s6ObvGQ3JP93lrwvyCmng7s6pMeEpRZcB/x6hgkEX6nry +p/e8wS0nHP18zYWBosR/9UZwoCxPIxXcOozbPJCzM43OMiyaAbunmw8Vgb3SlWxifRq YnsPpzAOOP43s74mghjn40Aiy7/juG/TPrzLJCL3/ofRubo3g34BwNy3Hi8IodzvDCrA B+ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=uSEgkLjW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5-v6si13307364plz.356.2018.05.21.01.53.34; Mon, 21 May 2018 01:53:48 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=uSEgkLjW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751453AbeEUIxJ (ORCPT + 99 others); Mon, 21 May 2018 04:53:09 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:40838 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751161AbeEUIxD (ORCPT ); Mon, 21 May 2018 04:53:03 -0400 Received: by mail-wm0-f67.google.com with SMTP id j5-v6so25222507wme.5 for ; Mon, 21 May 2018 01:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:openpgp:autocrypt:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=fwEc9ZAla5Ub3OVm5Ff1yAzxnDUK4Tl9N24bp/ky2Dw=; b=uSEgkLjWa3/NwGi7WkVr4lNzJV9kE1YTziX5QcHtCX3QOTNwOSHm2PxmOZQDtyyYH1 3gAhlLnFMeCzEpIaDq508GMNioNZFbL+O42QAB+7NXPJmySxdLShSF5Pif2lZRXiBFp+ uSmgijNEiUrZgLNxg1pD0HwX5GZ07yvW0mM+Ea0uNP1mpOyOF4IrudD3qSPuGgGldjsi parpnIp+3GwLihPupfGtLg89fcAG5FsvTXHsDIfOw+4cfkhtnCY7hClLIfl1eZY/fb1X 289Slc46GgQbVmbafxg1mfHiQJYBfHzNmijREJOQ4nJjZnHcf9eZCGQziUTB6On3fxZ7 65UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :organization:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=fwEc9ZAla5Ub3OVm5Ff1yAzxnDUK4Tl9N24bp/ky2Dw=; b=EbBKHbQNx/UgadTFCvHncpLb2zxNnCFMpGQxVcPRTfVodzQzp1bOS256pPQCenLb9E cRUeVonU9Z5dkQCSgAccZuEsbMueirI7HQ8R0hWjxY/pFpAITK5+JSubO+Wpr/3YbI5p DVncskMx+PJ+rW1k0g5vNhALgZZj95VQ42soOV3ZWfbUJdQdZqKJWRV4XN0vIQuJHBHu ycaQ0KQkLsx6+I2U8vuMCUzmCU6J/0bhlfbIWKSrYcVGPxvCiEgh/WMWhHgHNKU3xq1u 3FocxeoLI6CHxWnpSfJXIwfTl2O4VIzFar0GcxZdoaqNaBTC96ichvfLkCpnLTpv32Q3 kh0w== X-Gm-Message-State: ALKqPwehymp9eZ2fXqcycjVDAQMGdSqPlTjOtJ/NJpGpY+sQ/RdArDmm NYWK5+UCcP8GWdNR8aFgzi+l60NeBZ0= X-Received: by 2002:a1c:f714:: with SMTP id v20-v6mr10791745wmh.73.1526892781722; Mon, 21 May 2018 01:53:01 -0700 (PDT) Received: from ?IPv6:2a01:cb1d:4ce:ea00:748b:2433:2688:e1f? ([2a01:cb1d:4ce:ea00:748b:2433:2688:e1f]) by smtp.gmail.com with ESMTPSA id h81-v6sm24392474wmd.0.2018.05.21.01.53.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 01:53:01 -0700 (PDT) Subject: Re: [PATCH v2 1/5] media: cec-notifier: Get notifier by device and connector name To: Sean Paul Cc: airlied@linux.ie, hans.verkuil@cisco.com, lee.jones@linaro.org, olof@lixom.net, seanpaul@google.com, sadolfsson@google.com, felixe@google.com, bleung@google.com, darekm@google.com, marcheu@chromium.org, fparent@baylibre.com, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <1526648704-16873-1-git-send-email-narmstrong@baylibre.com> <1526648704-16873-2-git-send-email-narmstrong@baylibre.com> <20180518154819.GL3373@art_vandelay> From: Neil Armstrong Openpgp: preference=signencrypt Autocrypt: addr=narmstrong@baylibre.com; prefer-encrypt=mutual; keydata= xsBNBE1ZBs8BCAD78xVLsXPwV/2qQx2FaO/7mhWL0Qodw8UcQJnkrWmgTFRobtTWxuRx8WWP GTjuhvbleoQ5Cxjr+v+1ARGCH46MxFP5DwauzPekwJUD5QKZlaw/bURTLmS2id5wWi3lqVH4 BVF2WzvGyyeV1o4RTCYDnZ9VLLylJ9bneEaIs/7cjCEbipGGFlfIML3sfqnIvMAxIMZrvcl9 qPV2k+KQ7q+aXavU5W+yLNn7QtXUB530Zlk/d2ETgzQ5FLYYnUDAaRl+8JUTjc0CNOTpCeik 80TZcE6f8M76Xa6yU8VcNko94Ck7iB4vj70q76P/J7kt98hklrr85/3NU3oti3nrIHmHABEB AAHNKE5laWwgQXJtc3Ryb25nIDxuYXJtc3Ryb25nQGJheWxpYnJlLmNvbT7CwHsEEwEKACUC GyMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheABQJX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lHnrCzq43WefRHI5XTTQbM0WUIBIcGmq38+OgUsMYu4NzLu7uZF Acmp6h8g Organization: Baylibre Message-ID: Date: Mon, 21 May 2018 10:53:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180518154819.GL3373@art_vandelay> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sean, On 18/05/2018 17:48, Sean Paul wrote: > On Fri, May 18, 2018 at 03:05:00PM +0200, Neil Armstrong wrote: >> In non device-tree world, we can need to get the notifier by the driver >> name directly and eventually defer probe if not yet created. >> >> This patch adds a variant of the get function by using the device name >> instead and will not create a notifier if not yet created. >> >> But the i915 driver exposes at least 2 HDMI connectors, this patch also >> adds the possibility to add a connector name tied to the notifier device >> to form a tuple and associate different CEC controllers for each HDMI >> connectors. >> >> Signed-off-by: Neil Armstrong > > Hi Neil, > Thanks for posting these! > >> --- >> drivers/media/cec/cec-notifier.c | 11 ++++++++--- >> include/media/cec-notifier.h | 27 ++++++++++++++++++++++++--- >> 2 files changed, 32 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/media/cec/cec-notifier.c b/drivers/media/cec/cec-notifier.c >> index 16dffa0..dd2078b 100644 >> --- a/drivers/media/cec/cec-notifier.c >> +++ b/drivers/media/cec/cec-notifier.c >> @@ -21,6 +21,7 @@ struct cec_notifier { >> struct list_head head; >> struct kref kref; >> struct device *dev; >> + const char *conn; >> struct cec_adapter *cec_adap; >> void (*callback)(struct cec_adapter *adap, u16 pa); >> >> @@ -30,13 +31,14 @@ struct cec_notifier { >> static LIST_HEAD(cec_notifiers); >> static DEFINE_MUTEX(cec_notifiers_lock); >> >> -struct cec_notifier *cec_notifier_get(struct device *dev) >> +struct cec_notifier *cec_notifier_get_conn(struct device *dev, const char *conn) >> { >> struct cec_notifier *n; >> >> mutex_lock(&cec_notifiers_lock); >> list_for_each_entry(n, &cec_notifiers, head) { >> - if (n->dev == dev) { >> + if (n->dev == dev && >> + (!conn || !strcmp(n->conn, conn))) { >> kref_get(&n->kref); >> mutex_unlock(&cec_notifiers_lock); >> return n; >> @@ -46,6 +48,8 @@ struct cec_notifier *cec_notifier_get(struct device *dev) >> if (!n) >> goto unlock; >> n->dev = dev; >> + if (conn) >> + n->conn = kstrdup(conn, GFP_KERNEL); >> n->phys_addr = CEC_PHYS_ADDR_INVALID; >> mutex_init(&n->lock); >> kref_init(&n->kref); >> @@ -54,7 +58,7 @@ struct cec_notifier *cec_notifier_get(struct device *dev) >> mutex_unlock(&cec_notifiers_lock); >> return n; >> } >> -EXPORT_SYMBOL_GPL(cec_notifier_get); >> +EXPORT_SYMBOL_GPL(cec_notifier_get_conn); >> >> static void cec_notifier_release(struct kref *kref) >> { >> @@ -62,6 +66,7 @@ static void cec_notifier_release(struct kref *kref) >> container_of(kref, struct cec_notifier, kref); >> >> list_del(&n->head); >> + kfree(n->conn); >> kfree(n); >> } >> >> diff --git a/include/media/cec-notifier.h b/include/media/cec-notifier.h >> index cf0add7..814eeef 100644 >> --- a/include/media/cec-notifier.h >> +++ b/include/media/cec-notifier.h >> @@ -20,8 +20,10 @@ struct cec_notifier; >> #if IS_REACHABLE(CONFIG_CEC_CORE) && IS_ENABLED(CONFIG_CEC_NOTIFIER) >> >> /** >> - * cec_notifier_get - find or create a new cec_notifier for the given device. >> + * cec_notifier_get_conn - find or create a new cec_notifier for the given >> + * device and connector tuple. >> * @dev: device that sends the events. >> + * @conn: the connector name from which the event occurs > > Probably best to use "name" instead of connector, since it doesn't necessarily > _have_ to be a connector name. So, cec_notifier_get_by_name(dev, name) I don't have a stong opinion, but since the CEC is tied to a connector, it should mention connector, maybe conn_name ? > >> * >> * If a notifier for device @dev already exists, then increase the refcount >> * and return that notifier. >> @@ -31,7 +33,8 @@ struct cec_notifier; >> * >> * Return NULL if the memory could not be allocated. >> */ >> -struct cec_notifier *cec_notifier_get(struct device *dev); >> +struct cec_notifier *cec_notifier_get_conn(struct device *dev, >> + const char *conn); >> >> /** >> * cec_notifier_put - decrease refcount and delete when the refcount reaches 0. >> @@ -85,7 +88,8 @@ void cec_register_cec_notifier(struct cec_adapter *adap, >> struct cec_notifier *notifier); >> >> #else >> -static inline struct cec_notifier *cec_notifier_get(struct device *dev) >> +static inline struct cec_notifier *cec_notifier_get_conn(struct device *dev, >> + const char *conn) >> { >> /* A non-NULL pointer is expected on success */ >> return (struct cec_notifier *)0xdeadfeed; >> @@ -121,6 +125,23 @@ static inline void cec_register_cec_notifier(struct cec_adapter *adap, >> #endif >> >> /** >> + * cec_notifier_get - find or create a new cec_notifier for the given device. >> + * @dev: device that sends the events. >> + * >> + * If a notifier for device @dev already exists, then increase the refcount >> + * and return that notifier. >> + * >> + * If it doesn't exist, then allocate a new notifier struct and return a >> + * pointer to that new struct. > > You might also want to cover the case where you have multiple named notifiers > for the same device. It looks like it just grabs the first one? Yes, the code grabs the first one if not precised, do you mean I'll need to add a line to document the behaviour ? > > Sean > >> + * >> + * Return NULL if the memory could not be allocated. >> + */ >> +static inline struct cec_notifier *cec_notifier_get(struct device *dev) >> +{ >> + return cec_notifier_get_conn(dev, NULL); >> +} >> + >> +/** >> * cec_notifier_phys_addr_invalidate() - set the physical address to INVALID >> * >> * @n: the CEC notifier >> -- >> 2.7.4 >> > Thanks, Neil