Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4248916imm; Tue, 25 Sep 2018 14:05:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV623R++wv1yzs9dgMXHSu6ukLbEwP8Zzqq+LPdkhYEcwGjwsNQMftiqgp8yzdyn/1Fmp6uOT X-Received: by 2002:a17:902:b092:: with SMTP id p18-v6mr2926864plr.90.1537909519292; Tue, 25 Sep 2018 14:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537909519; cv=none; d=google.com; s=arc-20160816; b=Yet8xLf6ef67DvMp2YmPC351tKQaKnaza8YlXjKwwaoixWHf/lKeKrAKatfOalDYP2 4GWpGxV2/n/l1xZ0tcohgz+COQT9MQYAKtVbufT4th4YASJcLKk6ehn0HMEita1iOyCF F+Q6jes/3T9py/1i1Drlfzt7yiX/5zQygTp1OD0sChyQre8yJLpa4qf0Q1AcDZCLr3wo oQy3MDO8pxojQ7xWZOzLRPjpcdhli56YNd0Gp/IpA0KKLuXTWVhkshtezzrTiAiSGvQu DKKJDrUizomhppCDbdHqe//QXSLgz/SBmgpwBZAPvfQkIhYScEQwyAXX/2rYFwuOOlur tp0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=WK7r8wejhPe5ljpFcfGZlQxN9aABB1ZopTM6DbI/7ps=; b=khxMyZNUHmiHKAu6tktjzCrH4ftea2aHO3FO8muPPfCuqH5igBZ7L8XigUo6FEVXsy Ygtw6jaXTLpQYfOARxHsJcSZOpO/UY/SSNpK/e1ygXolh7bNPhKxIO9Bfd8maOv0GWrG NgVIHcQUt5gkrs6Ag7hLIFO9dpV6bmMCzkl62Vauaq3pHN5AhfqaIbPO0Hv44jiVwIsX yvtIdfoa3UkTIbNCYdaH6G89M/5vxCMOUkUFB9vSx1SV/u/yuMnTfcBSSd6PGkjTq+rt v1CZRXrGqrxr6yJOfhTMizwSUZbe3Y1mH7F9DG/lWe1E8qDvFfFpfQtaRjENzhdYrZZl VcYw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11-v6si3278624pgr.490.2018.09.25.14.05.03; Tue, 25 Sep 2018 14:05:19 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727174AbeIZDNz (ORCPT + 99 others); Tue, 25 Sep 2018 23:13:55 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:33063 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726242AbeIZDNy (ORCPT ); Tue, 25 Sep 2018 23:13:54 -0400 Received: from svr-orw-mbx-02.mgc.mentorg.com ([147.34.90.202]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1g4uVN-0006y6-49 from Steve_Longerbeam@mentor.com ; Tue, 25 Sep 2018 14:04:25 -0700 Received: from [172.30.1.115] (147.34.91.1) by svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Tue, 25 Sep 2018 14:04:22 -0700 Subject: Re: [PATCH v6 02/17] media: v4l2: async: Allow searching for asd of any type To: Mauro Carvalho Chehab , Steve Longerbeam CC: , Mauro Carvalho Chehab , Sakari Ailus , =?UTF-8?Q?Niklas_S=c3=b6derlund?= , Hans Verkuil , Sebastian Reichel , open list References: <1531175957-1973-1-git-send-email-steve_longerbeam@mentor.com> <1531175957-1973-3-git-send-email-steve_longerbeam@mentor.com> <20180924140604.23e2b56f@coco.lan> From: Steve Longerbeam Message-ID: Date: Tue, 25 Sep 2018 14:04:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180924140604.23e2b56f@coco.lan> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-ClientProxiedBy: svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) To svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mauro, On 09/24/2018 10:06 AM, Mauro Carvalho Chehab wrote: > Em Mon, 9 Jul 2018 15:39:02 -0700 > Steve Longerbeam escreveu: > >> Generalize v4l2_async_notifier_fwnode_has_async_subdev() to allow >> searching for any type of async subdev, not just fwnodes. Rename to >> v4l2_async_notifier_has_async_subdev() and pass it an asd pointer. >> >> Signed-off-by: Steve Longerbeam >> --- >> Changes since v5: >> - none >> Changes since v4: >> - none >> Changes since v3: >> - removed TODO to support asd compare with CUSTOM match type in >> asd_equal(). >> Changes since v2: >> - code optimization in asd_equal(), and remove unneeded braces, >> suggested by Sakari Ailus. >> Changes since v1: >> - none >> --- >> drivers/media/v4l2-core/v4l2-async.c | 73 +++++++++++++++++++++--------------- >> 1 file changed, 43 insertions(+), 30 deletions(-) >> >> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c >> index 2b08d03..0e7e529 100644 >> --- a/drivers/media/v4l2-core/v4l2-async.c >> +++ b/drivers/media/v4l2-core/v4l2-async.c >> @@ -124,6 +124,31 @@ static struct v4l2_async_subdev *v4l2_async_find_match( >> return NULL; >> } >> >> +/* Compare two asd's for equivalence */ > Please, on comments, instead of "asd" prefer to use what this 3 random > letters mean, e. g.: > asd -> asynchronous subdevice Ok, I will change the comment to read: /* Compare two async subdevice descriptors for equivalence */ > >> +static bool asd_equal(struct v4l2_async_subdev *asd_x, >> + struct v4l2_async_subdev *asd_y) >> +{ >> + if (asd_x->match_type != asd_y->match_type) >> + return false; >> + >> + switch (asd_x->match_type) { >> + case V4L2_ASYNC_MATCH_DEVNAME: >> + return strcmp(asd_x->match.device_name, >> + asd_y->match.device_name) == 0; >> + case V4L2_ASYNC_MATCH_I2C: >> + return asd_x->match.i2c.adapter_id == >> + asd_y->match.i2c.adapter_id && >> + asd_x->match.i2c.address == >> + asd_y->match.i2c.address; >> + case V4L2_ASYNC_MATCH_FWNODE: >> + return asd_x->match.fwnode == asd_y->match.fwnode; >> + default: >> + break; >> + } >> + >> + return false; >> +} >> + >> /* Find the sub-device notifier registered by a sub-device driver. */ >> static struct v4l2_async_notifier *v4l2_async_find_subdev_notifier( >> struct v4l2_subdev *sd) >> @@ -308,29 +333,22 @@ static void v4l2_async_notifier_unbind_all_subdevs( >> notifier->parent = NULL; >> } >> >> -/* See if an fwnode can be found in a notifier's lists. */ >> -static bool __v4l2_async_notifier_fwnode_has_async_subdev( >> - struct v4l2_async_notifier *notifier, struct fwnode_handle *fwnode) >> +/* See if an async sub-device can be found in a notifier's lists. */ >> +static bool __v4l2_async_notifier_has_async_subdev( >> + struct v4l2_async_notifier *notifier, struct v4l2_async_subdev *asd) > This is a minor issue, but checkpatch complains (with reason) > (with --strict) about the above: > > CHECK: Lines should not end with a '(' > #63: FILE: drivers/media/v4l2-core/v4l2-async.c:337: > +static bool __v4l2_async_notifier_has_async_subdev( > > Better to declare it, instead, as: > > static bool > __v4l2_async_notifier_has_async_subdev(struct v4l2_async_notifier *notifier, > struct v4l2_async_subdev *asd) > > Similar warnings appear on other places: > CHECK: Lines should not end with a '(' > #102: FILE: drivers/media/v4l2-core/v4l2-async.c:362: > +static bool v4l2_async_notifier_has_async_subdev( > > CHECK: Lines should not end with a '(' > #141: FILE: drivers/media/v4l2-core/v4l2-async.c:410: > + if (v4l2_async_notifier_has_async_subdev( Will fix. > > Btw, Checkpatch also complains that the author's email is different > than the SOB's one: > > WARNING: Missing Signed-off-by: line by nominal patch author 'Steve Longerbeam ' > > (the some comes with Signed-off-by: Steve Longerbeam ) > > I suspect that other patches on this series will suffer from the same issue. Will fix when submitting v7. > > >> @@ -392,12 +406,11 @@ static int __v4l2_async_notifier_register(struct v4l2_async_notifier *notifier) >> case V4L2_ASYNC_MATCH_CUSTOM: >> case V4L2_ASYNC_MATCH_DEVNAME: >> case V4L2_ASYNC_MATCH_I2C: >> - break; >> case V4L2_ASYNC_MATCH_FWNODE: >> - if (v4l2_async_notifier_fwnode_has_async_subdev( >> - notifier, asd->match.fwnode, i)) { >> + if (v4l2_async_notifier_has_async_subdev( >> + notifier, asd, i)) { >> dev_err(dev, >> - "fwnode has already been registered or in notifier's subdev list\n"); >> + "asd has already been registered or in notifier's subdev list\n"); > Please, never use "asd" on messages printed to the user. While someone > may understand it while reading the source code, for a poor use, > "asd" is just a random sequence of 3 characters. I will change the message to read: "subdev descriptor already listed in this or other notifiers". Steve