From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754141AbcIHBqD (ORCPT ); Wed, 7 Sep 2016 21:46:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:57964 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750991AbcIHBp4 (ORCPT ); Wed, 7 Sep 2016 21:45:56 -0400 Date: Thu, 8 Sep 2016 03:45:55 +0200 From: "Luis R. Rodriguez" To: Daniel Wagner Cc: linux-kernel@vger.kernel.org, Daniel Wagner , Ming Lei , "Luis R . Rodriguez" , Greg Kroah-Hartman Subject: Re: [PATCH v4 3/4] firmware: Drop bit ops in favor of simple state machine Message-ID: <20160908014555.GB3296@wotan.suse.de> References: <1473237908-20989-1-git-send-email-wagi@monom.org> <1473237908-20989-4-git-send-email-wagi@monom.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1473237908-20989-4-git-send-email-wagi@monom.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 07, 2016 at 10:45:07AM +0200, Daniel Wagner wrote: > From: Daniel Wagner > > We track the state of the loading with bit ops. Since the state machine > has only a couple of states and there are only a few simple state > transition And they are all mutually exclusive ? > we can model this simplify. > > UNKNOWN -> LOADING -> DONE | ABORTED So why unsigned long ? Why not a u8? > > Signed-off-by: Daniel Wagner > Cc: Ming Lei > Cc: Luis R. Rodriguez > Cc: Greg Kroah-Hartman > --- > drivers/base/firmware_class.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c > index b11fbb0..7757c03 100644 > --- a/drivers/base/firmware_class.c > +++ b/drivers/base/firmware_class.c > @@ -120,16 +120,18 @@ static void fw_status_init(struct fw_status *fw_st) > > static int __fw_status_check(struct fw_status *fw_st, unsigned long status) > { > - return test_bit(status, &fw_st->status); > + return fw_st->status == status; > } > > static int fw_status_wait_timeout(struct fw_status *fw_st, long timeout) > { > + unsigned long status; > int ret; > > ret = wait_for_completion_interruptible_timeout(&fw_st->completion, > timeout); > - if (ret == 0 && test_bit(FW_STATUS_ABORTED, &fw_st->status)) > + status = READ_ONCE(fw_st->status); > + if (ret == 0 && status == FW_STATUS_ABORTED) > return -ENOENT; > > return ret; > @@ -138,13 +140,11 @@ static int fw_status_wait_timeout(struct fw_status *fw_st, long timeout) > static void __fw_status_set(struct fw_status *fw_st, > unsigned long status) > { > - set_bit(status, &fw_st->status); > + WRITE_ONCE(fw_st->status, status); > > if (status == FW_STATUS_DONE || > - status == FW_STATUS_ABORTED) { > - clear_bit(FW_STATUS_LOADING, &fw_st->status); > + status == FW_STATUS_ABORTED) > complete_all(&fw_st->completion); > - } > } > > #define fw_status_start(fw_st) \ See if all the above were prefixed with fw_umh or something like it it would make this easier to read and tell this is all umh related. Luis