Message ID | 20221117160015.344528-2-umang.jain@ideasonboard.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp481109wrr; Thu, 17 Nov 2022 08:04:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf6zx42Trw1wDugct+niVAmzkkXAuRIg/gtsWdcW+CToL9OQkiBjVtXcIOF3oN4U0LCIin8c X-Received: by 2002:a63:1514:0:b0:46e:a4ed:467e with SMTP id v20-20020a631514000000b0046ea4ed467emr2652169pgl.319.1668701049848; Thu, 17 Nov 2022 08:04:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668701049; cv=none; d=google.com; s=arc-20160816; b=yu3148qtX90I/i/BSHYGmIiupHK0BTwxJN7CJLBVCX0uFJKZtuwG+HMrGCwfB+XoTp x9ukpj6r3p7bYpGrzudJVNdl3Ml4cwtiMgpY+rMs/yw6vfDpSRuz6bJLKDlZ7o8N13Ym NkGp5fyGDFfi90EKKfBH+OFSJJZ5fISGAjvL0OTEKM1oaFJyIXCdxDv/53W7vNAWB2Se aS00ta8JWYOoyALNjjcqWomRwezWG4b9koS1f1qyP0EEYMQmo0FyF13ZTSlgv840E6GH 3zEIoGtL+e1ivrPwpuk7esDTQuIwxwfqYYSBy4zhv8nI3n+siwINpc68oK8yGnBrf6s0 8oFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=owP8SA5SXgpZA7D6UvtncSnuoCQ9uC98ziNMvLLdOes=; b=BKZnnXBvTQ3+iQOVna3Bn+0lgi7+Jrgki7dmUoEFdz4VRGOTzF+GtBiEyV+EQUtYUw b7U8gczOaJ/S4hUjHVKueyTTcBg947Nfu52llE8/Ga2JHvtgSz2Lg1Vha96isxcKRHny gbb99Sa5H3uOzzxQ0ECkYYr4NDyNekociZ4GDsHNdvCHDzbtKpQfK2soO+5E9gBUtmO4 nF7wopdDyWX0BVMAU83mBCmdPwPetoGCBNrhkXo/Ce5cai78MlED4EzsIdvDj2jeu+dc i8I359ohbpNfRcsogEzrgySBdABRdmik5XlpuedwQX2wiezJYDMMU4VHhSdV22GwSTmm v75g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=SSTy3Pdl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a38-20020a056a001d2600b0053e8d0c9909si1219805pfx.221.2022.11.17.08.03.29; Thu, 17 Nov 2022 08:04:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=SSTy3Pdl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239893AbiKQQAj (ORCPT <rfc822;a1648639935@gmail.com> + 99 others); Thu, 17 Nov 2022 11:00:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233179AbiKQQAe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 17 Nov 2022 11:00:34 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E47E92D7 for <linux-kernel@vger.kernel.org>; Thu, 17 Nov 2022 08:00:33 -0800 (PST) Received: from ideasonboard.com (unknown [103.251.226.79]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C16BA1056; Thu, 17 Nov 2022 17:00:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1668700832; bh=n9ynhpvE53d3DCniGxgFDJ475k0hql5R70rDpcyDJxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SSTy3PdldKbcq8IWLceXcm5WjdtdV/nOZ5QfeVQQorJiFWqjP8MVE7WyllL+DJNmP wE4UfHnKnB++iPrcSLCj3bDW1G3DtHVqj1iDB/lrM7CC12u14gI6bzk8cb/8O8C2t5 fI/YHGqVNM5uxbcnVxKRxwjjkqoK9t4t0ToCE8yE= From: Umang Jain <umang.jain@ideasonboard.com> To: Florian Fainelli <f.fainelli@gmail.com>, Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>, Ray Jui <rjui@broadcom.com>, Dan Carpenter <error27@gmail.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Hans Verkuil <hverkuil-cisco@xs4all.nl>, Dave Stevenson <dave.stevenson@raspberrypi.com>, Mauro Carvalho Chehab <mchehab+samsung@kernel.org>, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Cc: kieran.bingham@ideasonboard.com, Umang Jain <umang.jain@ideasonboard.com> Subject: [PATCH 1/3] Revert "staging: mmal-vchiq: Avoid use of bool in structures" Date: Thu, 17 Nov 2022 21:30:13 +0530 Message-Id: <20221117160015.344528-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117160015.344528-1-umang.jain@ideasonboard.com> References: <20221117160015.344528-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749759871929493436?= X-GMAIL-MSGID: =?utf-8?q?1749759871929493436?= |
Series |
vc04_services: Promote bool usage
|
|
Commit Message
Umang Jain
Nov. 17, 2022, 4 p.m. UTC
This reverts commit 640e77466e69d9c28de227bc76881f5501f532ca.
In commit 7967656ffbfa ("coding-style: Clarify the expectations around
bool") the check to dis-allow bool structure members was removed from
checkpatch.pl. It promotes bool structure members to store boolean
values. This enhances code readability.
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
.../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 12 ++++++------
.../staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
Comments
Quoting Umang Jain (2022-11-17 16:00:13) > This reverts commit 640e77466e69d9c28de227bc76881f5501f532ca. > > In commit 7967656ffbfa ("coding-style: Clarify the expectations around > bool") the check to dis-allow bool structure members was removed from > checkpatch.pl. It promotes bool structure members to store boolean > values. This enhances code readability. > > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> > --- > .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 12 ++++++------ > .../staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 4 ++-- > 2 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c > index cb921c94996a..4abb6178cb9f 100644 > --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c > +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c > @@ -863,9 +863,9 @@ static int port_info_get(struct vchiq_mmal_instance *instance, > goto release_msg; > > if (rmsg->u.port_info_get_reply.port.is_enabled == 0) > - port->enabled = 0; > + port->enabled = false; > else > - port->enabled = 1; > + port->enabled = true; > > /* copy the values out of the message */ > port->handle = rmsg->u.port_info_get_reply.port_handle; > @@ -1304,7 +1304,7 @@ static int port_disable(struct vchiq_mmal_instance *instance, > if (!port->enabled) > return 0; > > - port->enabled = 0; > + port->enabled = false; > > ret = port_action_port(instance, port, > MMAL_MSG_PORT_ACTION_TYPE_DISABLE); > @@ -1359,7 +1359,7 @@ static int port_enable(struct vchiq_mmal_instance *instance, > if (ret) > goto done; > > - port->enabled = 1; > + port->enabled = true; > > if (port->buffer_cb) { > /* send buffer headers to videocore */ > @@ -1531,7 +1531,7 @@ int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance, > pr_err("failed disconnecting src port\n"); > goto release_unlock; > } > - src->connected->enabled = 0; > + src->connected->enabled = false; > src->connected = NULL; > } > > @@ -1799,7 +1799,7 @@ int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance, > > ret = disable_component(instance, component); > if (ret == 0) > - component->enabled = 0; > + component->enabled = false; > > mutex_unlock(&instance->vchiq_mutex); > > diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h > index 6006e29232b3..70eda6cac1c6 100644 > --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h > +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h > @@ -48,7 +48,7 @@ typedef void (*vchiq_mmal_buffer_cb)( > int status, struct mmal_buffer *buffer); > > struct vchiq_mmal_port { > - u32 enabled:1; > + bool enabled:1; Is this a direct revert with 'git revert' ? I would expect this to be bool enabled; > u32 handle; > u32 type; /* port type, cached to use on port info set */ > u32 index; /* port index, cached to use on port info set */ > @@ -83,7 +83,7 @@ struct vchiq_mmal_port { > > struct vchiq_mmal_component { > u32 in_use:1; > - u32 enabled:1; > + bool enabled:1; Same here of course. > u32 handle; /* VideoCore handle for component */ > u32 inputs; /* Number of input ports */ > u32 outputs; /* Number of output ports */ > -- > 2.38.1 >
Hi Kieran, On 11/17/22 9:39 PM, Kieran Bingham wrote: > Quoting Umang Jain (2022-11-17 16:00:13) >> This reverts commit 640e77466e69d9c28de227bc76881f5501f532ca. >> >> In commit 7967656ffbfa ("coding-style: Clarify the expectations around >> bool") the check to dis-allow bool structure members was removed from >> checkpatch.pl. It promotes bool structure members to store boolean >> values. This enhances code readability. >> >> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> >> --- >> .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 12 ++++++------ >> .../staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 4 ++-- >> 2 files changed, 8 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c >> index cb921c94996a..4abb6178cb9f 100644 >> --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c >> +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c >> @@ -863,9 +863,9 @@ static int port_info_get(struct vchiq_mmal_instance *instance, >> goto release_msg; >> >> if (rmsg->u.port_info_get_reply.port.is_enabled == 0) >> - port->enabled = 0; >> + port->enabled = false; >> else >> - port->enabled = 1; >> + port->enabled = true; >> >> /* copy the values out of the message */ >> port->handle = rmsg->u.port_info_get_reply.port_handle; >> @@ -1304,7 +1304,7 @@ static int port_disable(struct vchiq_mmal_instance *instance, >> if (!port->enabled) >> return 0; >> >> - port->enabled = 0; >> + port->enabled = false; >> >> ret = port_action_port(instance, port, >> MMAL_MSG_PORT_ACTION_TYPE_DISABLE); >> @@ -1359,7 +1359,7 @@ static int port_enable(struct vchiq_mmal_instance *instance, >> if (ret) >> goto done; >> >> - port->enabled = 1; >> + port->enabled = true; >> >> if (port->buffer_cb) { >> /* send buffer headers to videocore */ >> @@ -1531,7 +1531,7 @@ int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance, >> pr_err("failed disconnecting src port\n"); >> goto release_unlock; >> } >> - src->connected->enabled = 0; >> + src->connected->enabled = false; >> src->connected = NULL; >> } >> >> @@ -1799,7 +1799,7 @@ int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance, >> >> ret = disable_component(instance, component); >> if (ret == 0) >> - component->enabled = 0; >> + component->enabled = false; >> >> mutex_unlock(&instance->vchiq_mutex); >> >> diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h >> index 6006e29232b3..70eda6cac1c6 100644 >> --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h >> +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h >> @@ -48,7 +48,7 @@ typedef void (*vchiq_mmal_buffer_cb)( >> int status, struct mmal_buffer *buffer); >> >> struct vchiq_mmal_port { >> - u32 enabled:1; >> + bool enabled:1; > Is this a direct revert with 'git revert' ? No. It had conflicts plus I added the ':1' initialization to keep the logic same (in case 'enabled' gets used directly). Similar pattern come up with: ($) git grep 'bool' -- '*.[h]' | grep '\:1' So it shouldn't be an issue. > > I would expect this to be > bool enabled; True but it won't functionally not be the same in matter of initialization. Should the initialization be split to separate patch? > > >> u32 handle; >> u32 type; /* port type, cached to use on port info set */ >> u32 index; /* port index, cached to use on port info set */ >> @@ -83,7 +83,7 @@ struct vchiq_mmal_port { >> >> struct vchiq_mmal_component { >> u32 in_use:1; >> - u32 enabled:1; >> + bool enabled:1; > Same here of course. > >> u32 handle; /* VideoCore handle for component */ >> u32 inputs; /* Number of input ports */ >> u32 outputs; /* Number of output ports */ >> -- >> 2.38.1 >>
On Thu, Nov 17, 2022 at 11:25:48PM +0530, Umang Jain wrote: > Hi Kieran, > > On 11/17/22 9:39 PM, Kieran Bingham wrote: > > Quoting Umang Jain (2022-11-17 16:00:13) > > > This reverts commit 640e77466e69d9c28de227bc76881f5501f532ca. > > > > > > In commit 7967656ffbfa ("coding-style: Clarify the expectations around > > > bool") the check to dis-allow bool structure members was removed from > > > checkpatch.pl. It promotes bool structure members to store boolean > > > values. This enhances code readability. > > > > > > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> > > > --- > > > .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 12 ++++++------ > > > .../staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 4 ++-- > > > 2 files changed, 8 insertions(+), 8 deletions(-) > > > > > > diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c > > > index cb921c94996a..4abb6178cb9f 100644 > > > --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c > > > +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c > > > @@ -863,9 +863,9 @@ static int port_info_get(struct vchiq_mmal_instance *instance, > > > goto release_msg; > > > if (rmsg->u.port_info_get_reply.port.is_enabled == 0) > > > - port->enabled = 0; > > > + port->enabled = false; > > > else > > > - port->enabled = 1; > > > + port->enabled = true; > > > /* copy the values out of the message */ > > > port->handle = rmsg->u.port_info_get_reply.port_handle; > > > @@ -1304,7 +1304,7 @@ static int port_disable(struct vchiq_mmal_instance *instance, > > > if (!port->enabled) > > > return 0; > > > - port->enabled = 0; > > > + port->enabled = false; > > > ret = port_action_port(instance, port, > > > MMAL_MSG_PORT_ACTION_TYPE_DISABLE); > > > @@ -1359,7 +1359,7 @@ static int port_enable(struct vchiq_mmal_instance *instance, > > > if (ret) > > > goto done; > > > - port->enabled = 1; > > > + port->enabled = true; > > > if (port->buffer_cb) { > > > /* send buffer headers to videocore */ > > > @@ -1531,7 +1531,7 @@ int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance, > > > pr_err("failed disconnecting src port\n"); > > > goto release_unlock; > > > } > > > - src->connected->enabled = 0; > > > + src->connected->enabled = false; > > > src->connected = NULL; > > > } > > > @@ -1799,7 +1799,7 @@ int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance, > > > ret = disable_component(instance, component); > > > if (ret == 0) > > > - component->enabled = 0; > > > + component->enabled = false; > > > mutex_unlock(&instance->vchiq_mutex); > > > diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h > > > index 6006e29232b3..70eda6cac1c6 100644 > > > --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h > > > +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h > > > @@ -48,7 +48,7 @@ typedef void (*vchiq_mmal_buffer_cb)( > > > int status, struct mmal_buffer *buffer); > > > struct vchiq_mmal_port { > > > - u32 enabled:1; > > > + bool enabled:1; > > Is this a direct revert with 'git revert' ? > > > No. It had conflicts plus I added the ':1' initialization to keep the logic > same (in case 'enabled' gets used directly). Similar pattern come up with: > ($) git grep 'bool' -- '*.[h]' | grep '\:1' > > So it shouldn't be an issue. Please don't do that "bool foo:1" makes no sense. Drop the ":1" please. thanks, greg k-h
Hi Greg, On 11/17/22 11:32 PM, Greg Kroah-Hartman wrote: > On Thu, Nov 17, 2022 at 11:25:48PM +0530, Umang Jain wrote: >> Hi Kieran, >> >> On 11/17/22 9:39 PM, Kieran Bingham wrote: >>> Quoting Umang Jain (2022-11-17 16:00:13) >>>> This reverts commit 640e77466e69d9c28de227bc76881f5501f532ca. >>>> >>>> In commit 7967656ffbfa ("coding-style: Clarify the expectations around >>>> bool") the check to dis-allow bool structure members was removed from >>>> checkpatch.pl. It promotes bool structure members to store boolean >>>> values. This enhances code readability. >>>> >>>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> >>>> --- >>>> .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 12 ++++++------ >>>> .../staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 4 ++-- >>>> 2 files changed, 8 insertions(+), 8 deletions(-) >>>> >>>> diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c >>>> index cb921c94996a..4abb6178cb9f 100644 >>>> --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c >>>> +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c >>>> @@ -863,9 +863,9 @@ static int port_info_get(struct vchiq_mmal_instance *instance, >>>> goto release_msg; >>>> if (rmsg->u.port_info_get_reply.port.is_enabled == 0) >>>> - port->enabled = 0; >>>> + port->enabled = false; >>>> else >>>> - port->enabled = 1; >>>> + port->enabled = true; >>>> /* copy the values out of the message */ >>>> port->handle = rmsg->u.port_info_get_reply.port_handle; >>>> @@ -1304,7 +1304,7 @@ static int port_disable(struct vchiq_mmal_instance *instance, >>>> if (!port->enabled) >>>> return 0; >>>> - port->enabled = 0; >>>> + port->enabled = false; >>>> ret = port_action_port(instance, port, >>>> MMAL_MSG_PORT_ACTION_TYPE_DISABLE); >>>> @@ -1359,7 +1359,7 @@ static int port_enable(struct vchiq_mmal_instance *instance, >>>> if (ret) >>>> goto done; >>>> - port->enabled = 1; >>>> + port->enabled = true; >>>> if (port->buffer_cb) { >>>> /* send buffer headers to videocore */ >>>> @@ -1531,7 +1531,7 @@ int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance, >>>> pr_err("failed disconnecting src port\n"); >>>> goto release_unlock; >>>> } >>>> - src->connected->enabled = 0; >>>> + src->connected->enabled = false; >>>> src->connected = NULL; >>>> } >>>> @@ -1799,7 +1799,7 @@ int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance, >>>> ret = disable_component(instance, component); >>>> if (ret == 0) >>>> - component->enabled = 0; >>>> + component->enabled = false; >>>> mutex_unlock(&instance->vchiq_mutex); >>>> diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h >>>> index 6006e29232b3..70eda6cac1c6 100644 >>>> --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h >>>> +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h >>>> @@ -48,7 +48,7 @@ typedef void (*vchiq_mmal_buffer_cb)( >>>> int status, struct mmal_buffer *buffer); >>>> struct vchiq_mmal_port { >>>> - u32 enabled:1; >>>> + bool enabled:1; >>> Is this a direct revert with 'git revert' ? >> >> No. It had conflicts plus I added the ':1' initialization to keep the logic >> same (in case 'enabled' gets used directly). Similar pattern come up with: >> ($) git grep 'bool' -- '*.[h]' | grep '\:1' >> >> So it shouldn't be an issue. > Please don't do that "bool foo:1" makes no sense. Drop the ":1" > please. It won't affect this patch but if you take a look at 2/3 - you'll see a bool flag 'in_use' that needs to be initialized (as it's getting used directly). I can move the initialization part in the function (_init() or something) and drop the ":1" as you mentioned. That's fine as well but I do find patterns of 'bool foo:1' in the codebase so I assumed it would be safe to use. > > > thanks, > > greg k-h
> > > > > struct vchiq_mmal_port { > > > > > - u32 enabled:1; > > > > > + bool enabled:1; > > > > Is this a direct revert with 'git revert' ? > > > > > > No. It had conflicts plus I added the ':1' initialization to keep the logic > > > same (in case 'enabled' gets used directly). Similar pattern come up with: > > > ($) git grep 'bool' -- '*.[h]' | grep '\:1' > > > > > > So it shouldn't be an issue. > > Please don't do that "bool foo:1" makes no sense. Drop the ":1" > > please. > > It won't affect this patch but if you take a look at 2/3 - you'll see a bool > flag 'in_use' that needs to be initialized (as it's getting used directly). > > I can move the initialization part in the function (_init() or something) > and drop the ":1" as you mentioned. That's fine as well but I do find > patterns of 'bool foo:1' in the codebase so I assumed it would be safe to > use. Does :1 really initialise the variable? In "u32 enabled:1" it means this is a 1 bit wide bit field. It seems odd that bool is somehow special and :1 means something else. Andrew
Hi, On 11/18/22 5:42 AM, Andrew Lunn wrote: >>>>>> struct vchiq_mmal_port { >>>>>> - u32 enabled:1; >>>>>> + bool enabled:1; >>>>> Is this a direct revert with 'git revert' ? >>>> No. It had conflicts plus I added the ':1' initialization to keep the logic >>>> same (in case 'enabled' gets used directly). Similar pattern come up with: >>>> ($) git grep 'bool' -- '*.[h]' | grep '\:1' >>>> >>>> So it shouldn't be an issue. >>> Please don't do that "bool foo:1" makes no sense. Drop the ":1" >>> please. >> It won't affect this patch but if you take a look at 2/3 - you'll see a bool >> flag 'in_use' that needs to be initialized (as it's getting used directly). >> >> I can move the initialization part in the function (_init() or something) >> and drop the ":1" as you mentioned. That's fine as well but I do find >> patterns of 'bool foo:1' in the codebase so I assumed it would be safe to >> use. > Does :1 really initialise the variable? In "u32 enabled:1" it means > this is a 1 bit wide bit field. It seems odd that bool is somehow > special and :1 means something else. Yup you are correct - seems I mis-read :1 as initialization > > Andrew
On Fri, Nov 18, 2022 at 01:12:32AM +0100, Andrew Lunn wrote: > > Does :1 really initialise the variable? Obviously not. > In "u32 enabled:1" it means > this is a 1 bit wide bit field. It seems odd that bool is somehow > special and :1 means something else. If you have a bunch of consecutive bool a:1; bool b:1; then GCC will squeeze them into the same byte. But if you have bool a; bool b; then they each take a byte with GCC. I have specified GCC because the size of bool types are a bit vague in the C standard. regards, dan carpenter
diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index cb921c94996a..4abb6178cb9f 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -863,9 +863,9 @@ static int port_info_get(struct vchiq_mmal_instance *instance, goto release_msg; if (rmsg->u.port_info_get_reply.port.is_enabled == 0) - port->enabled = 0; + port->enabled = false; else - port->enabled = 1; + port->enabled = true; /* copy the values out of the message */ port->handle = rmsg->u.port_info_get_reply.port_handle; @@ -1304,7 +1304,7 @@ static int port_disable(struct vchiq_mmal_instance *instance, if (!port->enabled) return 0; - port->enabled = 0; + port->enabled = false; ret = port_action_port(instance, port, MMAL_MSG_PORT_ACTION_TYPE_DISABLE); @@ -1359,7 +1359,7 @@ static int port_enable(struct vchiq_mmal_instance *instance, if (ret) goto done; - port->enabled = 1; + port->enabled = true; if (port->buffer_cb) { /* send buffer headers to videocore */ @@ -1531,7 +1531,7 @@ int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance, pr_err("failed disconnecting src port\n"); goto release_unlock; } - src->connected->enabled = 0; + src->connected->enabled = false; src->connected = NULL; } @@ -1799,7 +1799,7 @@ int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance, ret = disable_component(instance, component); if (ret == 0) - component->enabled = 0; + component->enabled = false; mutex_unlock(&instance->vchiq_mutex); diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h index 6006e29232b3..70eda6cac1c6 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h @@ -48,7 +48,7 @@ typedef void (*vchiq_mmal_buffer_cb)( int status, struct mmal_buffer *buffer); struct vchiq_mmal_port { - u32 enabled:1; + bool enabled:1; u32 handle; u32 type; /* port type, cached to use on port info set */ u32 index; /* port index, cached to use on port info set */ @@ -83,7 +83,7 @@ struct vchiq_mmal_port { struct vchiq_mmal_component { u32 in_use:1; - u32 enabled:1; + bool enabled:1; u32 handle; /* VideoCore handle for component */ u32 inputs; /* Number of input ports */ u32 outputs; /* Number of output ports */