From patchwork Mon Mar 7 10:54:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 549900 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67CF9C433EF for ; Mon, 7 Mar 2022 11:24:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241892AbiCGLY6 (ORCPT ); Mon, 7 Mar 2022 06:24:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242032AbiCGLYr (ORCPT ); Mon, 7 Mar 2022 06:24:47 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F1E511A3B; Mon, 7 Mar 2022 02:53:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646650439; x=1678186439; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=sC24XqI4cOq5tDpnDicRMvYX6LRyMmRMKHu+c0x7JLA=; b=MPH29m6Xf64l/grs+6PMbsD2lVExu9faC9VV0WTr3TBubB+NkPZTbGXP SUrHuhbLpU8XRBxV4hURWVKWGpJRJLyhq4SniJZI6HYsq9Oe6nEIry2nB CYgAbuWvvV7z8Wyrz9S0FHEjUPNSnqS2FfLG3vCbYG/pOcDlDVyy6S2hn k1saiKMnVLyWwxFwtdpDk4IGi5C1I93TIM29774GrR7IFxiu5oKxytiwp Q44JgKBCV0NBb70S1AE0+HXEG1WRbD0cbGPYh6g7lNGwylYQPDEZnkCwA Dm/B87YlraAH+BgbzgdEvA+I0h88HT1SqRwCCV4Gy/9z5FdDxYQIVS043 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10278"; a="234318873" X-IronPort-AV: E=Sophos;i="5.90,161,1643702400"; d="scan'208";a="234318873" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 02:53:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,161,1643702400"; d="scan'208";a="537068602" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 07 Mar 2022 02:53:57 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id CA50810E; Mon, 7 Mar 2022 12:54:15 +0200 (EET) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij Subject: [PATCH v1 1/1] gpiolib: Use list_first_entry()/list_last_entry() Date: Mon, 7 Mar 2022 12:54:14 +0200 Message-Id: <20220307105414.17706-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Use list_first_entry()/list_last_entry() instead of open coded variants. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 002bf4b1616b..f5e7443208d4 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -262,14 +262,14 @@ static int gpiodev_add_to_list(struct gpio_device *gdev) return 0; } - next = list_entry(gpio_devices.next, struct gpio_device, list); + next = list_first_entry(&gpio_devices, struct gpio_device, list); if (gdev->base + gdev->ngpio <= next->base) { /* add before first entry */ list_add(&gdev->list, &gpio_devices); return 0; } - prev = list_entry(gpio_devices.prev, struct gpio_device, list); + prev = list_last_entry(&gpio_devices, struct gpio_device, list); if (prev->base + prev->ngpio <= gdev->base) { /* add behind last entry */ list_add_tail(&gdev->list, &gpio_devices); @@ -4426,7 +4426,7 @@ static void *gpiolib_seq_next(struct seq_file *s, void *v, loff_t *pos) if (list_is_last(&gdev->list, &gpio_devices)) ret = NULL; else - ret = list_entry(gdev->list.next, struct gpio_device, list); + ret = list_first_entry(&gdev->list, struct gpio_device, list); spin_unlock_irqrestore(&gpio_lock, flags); s->private = "\n";