Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp517616ybi; Tue, 16 Jul 2019 01:01:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxB0m2RpBVThAqI+w7p1aUi6xD2xjWc/PXA60KvRazb9Pr641pu2Y0anQEAW5bjM5lxduSh X-Received: by 2002:a17:90a:f98a:: with SMTP id cq10mr34547175pjb.43.1563264087582; Tue, 16 Jul 2019 01:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563264087; cv=none; d=google.com; s=arc-20160816; b=N54NYtkqmJngrOu7apf+8rJMKuVqVGBcyW0ZPXfLVMvJlZd9rw22+hJUTiMdcN3TkM nVLb2E+rgFRP4T4cWJN4qFfxniyYYLatfJROgEepjk0SDnK6U4JUHvEtUHaWrU+Zai5u 2yqMalzsKpAGjVo+ZFEElbiQ5LQv5jexX6tphkNfSJA/hidFzdO5OTWiMR8w/sV9R6Qx 38wOb3IuxdeoozvGbJbeMeo7K4eXK/61riiULWp5YOeBRdAKsoq2aWKSI3SIU7g9DsLS VAiXAGDj5rdkWZ/ocaPWZ8ux+8uYWb+NHtiF0tGRtiAJ5jDdEK1xLivOkVbvVv6GzGPE VwBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0k1aHf58/gxem57t+/HJk9SNpX74KfXqdFRssCgasHQ=; b=lAOmXSXOJ1lm3RHOLk3mLyWVZG6MvDn0tsaYfTyVYV79P/E4ohuVnK2MG+55A2/e8i qusHMlw1K22cBgRkWN8tjcdU0AKQ2l1/fBaGpN01OFghXBSIpw05v3/umCfBsyPMnQff hzdtPH2HX6QnbblNVLU1VfIrH67I44R1D4t47U7KXLNulwKP1Y/KSLrfuPFtjmasELLp M9SPdCnpSw/m8/3kubg0kGjrL2RJWa5Nz1VEkjT/vQMNhGwcBX2Y/JW2kHG6pVebwg7d 06TyRjU6NXEk+wAf9H4Sj0YZGxkt64Ol1vatZcbmAHq+jtSAspNt7omazUahf8Y5WczJ tZvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WkIXGD93; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22si17168902plp.192.2019.07.16.01.01.11; Tue, 16 Jul 2019 01:01:27 -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=@chromium.org header.s=google header.b=WkIXGD93; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731247AbfGPIAG (ORCPT + 99 others); Tue, 16 Jul 2019 04:00:06 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:42806 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbfGPIAF (ORCPT ); Tue, 16 Jul 2019 04:00:05 -0400 Received: by mail-vs1-f68.google.com with SMTP id 190so13259591vsf.9 for ; Tue, 16 Jul 2019 01:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0k1aHf58/gxem57t+/HJk9SNpX74KfXqdFRssCgasHQ=; b=WkIXGD93vnc7/jgdUJCOyAhWfQWj4JwZxZhvfijDRISLuLx4yflZHTDWWSxx7WAFgi P/75eR1ocFjiim/HAtaQ/hHHMdj/AJhGCoGv3O1KDMwV3amytYQ+kgBq/LAKt+YymIQH cgPBdjhd4eTA/OcE54ml3PqvteVAcATrUZsBw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0k1aHf58/gxem57t+/HJk9SNpX74KfXqdFRssCgasHQ=; b=AmwHsDPEII/3viYQ/FC62d/ByjNuW0kTWDBtoY3U97S3RVAyxhq57t4ADQ9GsOJID9 kpOHHd24D00KSUAeAoBXuEK8WUGIBmaefTxKlvkUNdJEZ9SddrU66T7NWYRlDh9HeDXi e79xPftXzmj7psvbAaNXnZpew8LVdL0tZMYeWYyrXFoBLuadgZPLUyKP5iDpL7Dqbp9R qBQmouRN8BhuR9ROwfekDJNjFCEBgKAFSx9/aBmHJb90B8Vhe5apxM2I97cM4hz31GJC dBbGZT0M/igRQXXpONI1GOfT833s1tTDToZJSqjbiVIS3EejwHPhJKDeS3d+fVC1AtPp YTzg== X-Gm-Message-State: APjAAAVb21LfE+yg0x6lFnlWheoBe7EdrxUgoYZnMNQ7J2VJ2ixvYa1o RhlFUpppsOnjBDogrUG4QKbRCjHC9Y/bD+kdlZU1iQ== X-Received: by 2002:a67:ebcb:: with SMTP id y11mr9527514vso.138.1563264004214; Tue, 16 Jul 2019 01:00:04 -0700 (PDT) MIME-Version: 1.0 References: <20190712100443.221322-1-cychiang@chromium.org> <20190712100443.221322-2-cychiang@chromium.org> <20190712105745.xr7jxc626lwoaajx@shell.armlinux.org.uk> In-Reply-To: From: Cheng-yi Chiang Date: Tue, 16 Jul 2019 15:59:36 +0800 Message-ID: Subject: Re: [PATCH v3 1/5] ASoC: hdmi-codec: Add an op to set callback function for plug event To: Tzung-Bi Shih Cc: Russell King - ARM Linux admin , Linux Kernel Mailing List , ALSA development , Douglas Anderson , Heiko Stuebner , linux-rockchip@lists.infradead.org, David Airlie , dri-devel@lists.freedesktop.org, Takashi Iwai , Liam Girdwood , tzungbi@chromium.org, Jaroslav Kysela , Hans Verkuil , Andrzej Hajda , Mark Brown , Laurent Pinchart , Daniel Vetter , Dylan Reid , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 15, 2019 at 11:56 PM Tzung-Bi Shih wrote: > > On Fri, Jul 12, 2019 at 6:58 PM Russell King - ARM Linux admin > wrote: > > > > On Fri, Jul 12, 2019 at 06:04:39PM +0800, Cheng-Yi Chiang wrote: > > > Add an op in hdmi_codec_ops so codec driver can register callback > > > function to handle plug event. > > > > > > Driver in DRM can use this callback function to report connector status. > > > > > > Signed-off-by: Cheng-Yi Chiang > > > --- > > > include/sound/hdmi-codec.h | 16 +++++++++++++ > > > sound/soc/codecs/hdmi-codec.c | 45 +++++++++++++++++++++++++++++++++++ > > > 2 files changed, 61 insertions(+) > > > > > > diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h > > > index 7fea496f1f34..9a8661680256 100644 > > > --- a/include/sound/hdmi-codec.h > > > +++ b/include/sound/hdmi-codec.h > > > @@ -47,6 +47,9 @@ struct hdmi_codec_params { > > > int channels; > > > }; > > > > > > +typedef void (*hdmi_codec_plugged_cb)(struct device *dev, > > > + bool plugged); > > > + > > > > I'd like to pose a question for people to think about. > > > > Firstly, typedefs are generally shunned in the kernel. However, for > > these cases it seems to make sense. > > > > However, should the "pointer"-ness be part of the typedef or not? To > > see what I mean, consider: > > > > typedef void (*hdmi_foo)(void); > > > > int register_foo(hdmi_foo foo); > > > > vs > > > > typedef void hdmi_foo(void); > > > > int register_foo(hdmi_foo *foo); > > > > which is more in keeping with how we code non-typedef'd code - it's > > obvious that foo is a pointer while reading the code. > I have a different opinion. Its suffix "_cb" self-described it is a > callback function. Since function and function pointer are equivalent > in the language, I think we don't need to emphasize that it is a > function "pointer". > > Hi Russell and Tzungbi, thank you for the review. Regarding this typedef of callback function, I found a thread discussing this very long time ago: https://yarchive.net/comp/linux/typedefs.html From that thread, Linus gave an example of using typedef for function pointer that is following to this pattern. I also looked around how other driver use it: $ git grep typedef | grep _cb | less | wc -l 138 $ git grep typedef | grep _cb | grep "(\*" | wc -l 115 Most of the typedef of callback function use this pattern. So I think this should be fine. Thanks! > > It seems to me that the latter better matches what is in the kernel's > > coding style, which states: > > > > In general, a pointer, or a struct that has elements that can > > reasonably be directly accessed should **never** be a typedef. > > > > or maybe Documentation/process/coding-style.rst needs updating?