From patchwork Mon Sep 12 18:23:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 9327519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0847E60231 for ; Mon, 12 Sep 2016 18:35:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1D8C288B7 for ; Mon, 12 Sep 2016 18:35:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E040D28E28; Mon, 12 Sep 2016 18:35:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 533C228E1D for ; Mon, 12 Sep 2016 18:35:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755704AbcILSfA (ORCPT ); Mon, 12 Sep 2016 14:35:00 -0400 Received: from condef009-v.nifty.com ([210.131.4.246]:35022 "EHLO condef009-v.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754957AbcILSdE (ORCPT ); Mon, 12 Sep 2016 14:33:04 -0400 X-Greylist: delayed 321 seconds by postgrey-1.27 at vger.kernel.org; Mon, 12 Sep 2016 14:33:04 EDT Received: from conuserg-11.nifty.com ([10.26.8.74])by condef009-v.nifty.com with ESMTP id u8CIOXNP024938 for ; Tue, 13 Sep 2016 03:24:36 +0900 Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-11.nifty.com with ESMTP id u8CINPmB024739; Tue, 13 Sep 2016 03:23:27 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com u8CINPmB024739 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1473704608; bh=AUF75LPZvfIwaVF3judUhqFl/7JHi1VRP4qxYMTvSWw=; h=From:To:Cc:Subject:Date:From; b=QFMfdUJK805FcSvYXN3g+KwQ1OP9OOwistj6ddWciHy2aeZlVxf4Fjs6g3hPOF1+E Wm9N3byi3Mzqb3eBK2+6TivJ1Cv85S40JCT/we7xdrPYDGF0kOPapYSs5Vg0lBkUSl l4I8C/5VkPukODRpujGNDq05SlGdWijehcWMpeUu7cpOD6T7/G3MVfAk1+am0scHOM xH3TOXy6b285/yMVTUHPpHkvfu4XuGOgiYd1dr1CS5YuLxHNxxAVM62lz4Q0tBP7b0 D7jMR5W22STDZh8bh82rklR1wkjsnF0qS9wdUoFTnA9P+wiA6BFbpuOR/keytENl5g gBKSdHG0lm8xQ== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: linux-pm@vger.kernel.org Cc: Masahiro Yamada , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse , linux-kernel@vger.kernel.org Subject: [PATCH] power: ab8500: cleanup with list_first_entry_or_null() Date: Tue, 13 Sep 2016 03:23:21 +0900 Message-Id: <1473704601-3217-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The combo of list_empty() check and return list_first_entry() can be replaced with list_first_entry_or_null(). Signed-off-by: Masahiro Yamada --- drivers/power/ab8500_fg.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c index 5a36cf8..84b7fa9 100644 --- a/drivers/power/ab8500_fg.c +++ b/drivers/power/ab8500_fg.c @@ -245,13 +245,8 @@ static LIST_HEAD(ab8500_fg_list); */ struct ab8500_fg *ab8500_fg_get(void) { - struct ab8500_fg *fg; - - if (list_empty(&ab8500_fg_list)) - return NULL; - - fg = list_first_entry(&ab8500_fg_list, struct ab8500_fg, node); - return fg; + return list_first_entry_or_null(&ab8500_fg_list, struct ab8500_fg, + node); } /* Main battery properties */