Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4440764ybi; Mon, 15 Jul 2019 08:58:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzed0b/ka014dBcfZ1fRqlqQM1t1FJlob04RHmM5feq5d7swciTRx9adOD37GxtaZbgQNbB X-Received: by 2002:a63:31c1:: with SMTP id x184mr22219945pgx.128.1563206322663; Mon, 15 Jul 2019 08:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563206322; cv=none; d=google.com; s=arc-20160816; b=E0o/uFH6IMprECYltYbK/VqyyJoss5Y+wWLD7hmrKKGbgPLwQgPZpDYy4a2wwaJrug hPrNQxYex3391sCsPergDuCqF9dmfiGUgjpaIA+LW7TqxIDo3MT63SRXprjrgYChSObT V7UBs4lgEqMF5VJjmC5c2U9nBDNygn5/LiG5qW5pXPT4M0es983LHpXupy1aRCp6L9kd H/qKQeovAG6LTe4wYlFayKJo0PmgSCHkOAI06YKIgoFUx59nDZmSiVm6Y9NxnamD8H4m XhbT8rKS6YatTwagoTj+MRP2xOduSKKeXPeqXp6tMhxlrmAUdcVrR8fL21QhRWHF0j76 OD2w== 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=BxdnANqifDB1z1Ih8rPgPPFQ52+wPGcxB0Lct34ID5Q=; b=NYdAUJ9QVvvAg2cDfKPfaYsOw1HOSb3CCAd6dTfGsHmVU9OKb6yPfhrJl/SJsyViKS 2H1vJzfWMop+mNLrPCf5CNjQ5Pd2JczfXREq158ikpDQMsyw9xeZs1oA29hMN3rDiKXv eQ4Y1WayWE6KmA4avJIgT/0dhGvs4eGnwtWtKA2/y7L4N6wd+DPwOIDBJIVjbCdKKMqX wsvoLj4yE9yPF35pOHTbce2B1XCvvmRBB+re2lSu7q91nBQneKxL/QtLO0BXxPEMwQ3p adyyAEWewYdx3sHntajOfjIpb9STCACGyIqHzn3C2MNmhzIj0DuJNzH2vifVWqHW5gXx ftbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SA30rmEv; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j4si11672022pfi.34.2019.07.15.08.58.25; Mon, 15 Jul 2019 08:58: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=@google.com header.s=20161025 header.b=SA30rmEv; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730569AbfGOP4d (ORCPT + 99 others); Mon, 15 Jul 2019 11:56:33 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:44685 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730257AbfGOP4c (ORCPT ); Mon, 15 Jul 2019 11:56:32 -0400 Received: by mail-ot1-f67.google.com with SMTP id b7so17478965otl.11 for ; Mon, 15 Jul 2019 08:56:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BxdnANqifDB1z1Ih8rPgPPFQ52+wPGcxB0Lct34ID5Q=; b=SA30rmEvAAB/UeWM0cJpboyXWomGji7I7a5x3X8IC2z8RDCcu48fRpx3oXaTPieM78 hMUBvyfACXuvhVyl7122TsYzmlo3PSQz9JgHl3IzAfFzF4LUSFpBOVOTOS1B1L4yygl7 QOOGtMtHFpJt8B1LZKpTsfOdvejMLuCIDQCalifs34k7ukv+KzyMS3/rAXEkr2VMjwP1 SBtlOVlmpKFktDXSl32r68WJn6RZP964o2hS1wrBNhCu42BpzNeAZYsIqnpYlDH19pdT IooGaAqomRnAwqqNrb8iHZz4u/RbyBz6uQU3gz+bKjgxr0xq0hFlSy/JRzbwLlHSQ+Nf EO5w== 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=BxdnANqifDB1z1Ih8rPgPPFQ52+wPGcxB0Lct34ID5Q=; b=mqm2iCYzXvmdpc/cFMtak0E+dJaCrf0C52s/9q7S4DHikU/W1C5xE6O1SXK7T2kvr0 kOCKApMJU5wHzBaGGqUDkRGGcPtA3AZabcB/HR5CamqRa5/ZkEjsRgAAIyQI+0FQS8Vh Us9TL/XpsceLVHHtOd2NQs4axzB1hNNOcnLx35hvNn/uZ0vdw6g43H5QKVA+UokF40eN rbDf9ueSIsodscM+9w6jyKTKExc+TNAWuFu9N0Hkh4nCKqu7S4xcGIf82cPbJSWtNLOv GB4qrhqr8/8Y/9U0ao/7SnjKEKxSV9syPY5YXO0W8RERDQldIp1RXFeQ9Z9lnilD+9Nv oxSw== X-Gm-Message-State: APjAAAVNepUGPW56PejeW3mcJQs/w75cxBmn1YLRiAGLSTtemh7yFXTT 2tFFfHeE0zni1J/8Lqan7FD9GpKeyTj4lXt0wvLrzg== X-Received: by 2002:a05:6830:1cd:: with SMTP id r13mr8619272ota.99.1563206191242; Mon, 15 Jul 2019 08:56:31 -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: <20190712105745.xr7jxc626lwoaajx@shell.armlinux.org.uk> From: Tzung-Bi Shih Date: Mon, 15 Jul 2019 23:56:19 +0800 Message-ID: Subject: Re: [PATCH v3 1/5] ASoC: hdmi-codec: Add an op to set callback function for plug event To: Russell King - ARM Linux admin Cc: Cheng-Yi Chiang , 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 , dgreid@chromium.org, 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 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". > 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?