From patchwork Tue Jan 4 13:38:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12703483 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 AD331C433F5 for ; Tue, 4 Jan 2022 13:38:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233679AbiADNik (ORCPT ); Tue, 4 Jan 2022 08:38:40 -0500 Received: from mga14.intel.com ([192.55.52.115]:55154 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233656AbiADNij (ORCPT ); Tue, 4 Jan 2022 08:38:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641303519; x=1672839519; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=1faGgl1n5RMDy4eY/oAFnPrRhLAJ+Ie+KfhM2G1o9gw=; b=DGssk2yTp8y3WVpLVgil4oiS0/T6QP6I7zO6DwkI6XCgweSZyX+QyBqJ t99UdgHvrgOFtRKDad8yRK94tfAlDxm+7V/DtpZnCUqJS/qC0AduyRS1W 2bBlzon9UYbrVuO2nC3hiJqOIm8Drf1Qozm4V/J2nqxISUN6XvxPMmYz+ nTlYmen3h12rXJ2O7qF/5c8m2X40AW4hWHEBQrdbZq4ERC/nhBiyG10wb EMIUzpzIrnkID60cRHmkxBpf2sWitcE2bwMW03OeQeu9hOYBUR8N7pyEa bN4Nv2fk0WRJfPGYNRonIis1y6EfyUeFB1npNX/0tmihnyEWJmOdcfGuj g==; X-IronPort-AV: E=McAfee;i="6200,9189,10216"; a="242430114" X-IronPort-AV: E=Sophos;i="5.88,261,1635231600"; d="scan'208";a="242430114" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 05:38:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,261,1635231600"; d="scan'208";a="556169291" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 04 Jan 2022 05:38:35 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id CFCB41F8; Tue, 4 Jan 2022 15:38:45 +0200 (EET) From: Andy Shevchenko To: Miquel Raynal , Srinivas Kandagatla , Greg Kroah-Hartman , Mika Westerberg , Andy Shevchenko , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Richard Weinberger , Vignesh Raghavendra , Andreas Noever , Michael Jamet , Yehezkel Bernat , Alexander Usyskin Subject: [PATCH v1 1/5] nvmem: core: Remove unused devm_nvmem_unregister() Date: Tue, 4 Jan 2022 15:38:39 +0200 Message-Id: <20220104133843.44272-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-usb@vger.kernel.org There are no users and seems no will come of the devm_nvmem_unregister(). Remove the function. Signed-off-by: Andy Shevchenko Reported-by: kernel test robot --- drivers/nvmem/core.c | 15 --------------- include/linux/nvmem-provider.h | 8 -------- 2 files changed, 23 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 23a38dcf0fc4..fbf7dec775fb 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -952,21 +952,6 @@ static int devm_nvmem_match(struct device *dev, void *res, void *data) return *r == data; } -/** - * devm_nvmem_unregister() - Unregister previously registered managed nvmem - * device. - * - * @dev: Device that uses the nvmem device. - * @nvmem: Pointer to previously registered nvmem device. - * - * Return: Will be negative on error or zero on success. - */ -int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem) -{ - return devres_release(dev, devm_nvmem_release, devm_nvmem_match, nvmem); -} -EXPORT_SYMBOL(devm_nvmem_unregister); - static struct nvmem_device *__nvmem_device_get(void *data, int (*match)(struct device *dev, const void *data)) { diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 98efb7b5660d..99c01c43d7a8 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -133,8 +133,6 @@ void nvmem_unregister(struct nvmem_device *nvmem); struct nvmem_device *devm_nvmem_register(struct device *dev, const struct nvmem_config *cfg); -int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem); - void nvmem_add_cell_table(struct nvmem_cell_table *table); void nvmem_del_cell_table(struct nvmem_cell_table *table); @@ -153,12 +151,6 @@ devm_nvmem_register(struct device *dev, const struct nvmem_config *c) return nvmem_register(c); } -static inline int -devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem) -{ - return -EOPNOTSUPP; -} - static inline void nvmem_add_cell_table(struct nvmem_cell_table *table) {} static inline void nvmem_del_cell_table(struct nvmem_cell_table *table) {} From patchwork Tue Jan 4 13:38:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12703482 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 6B8D1C433F5 for ; Tue, 4 Jan 2022 13:38:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233713AbiADNio (ORCPT ); Tue, 4 Jan 2022 08:38:44 -0500 Received: from mga07.intel.com ([134.134.136.100]:25811 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233663AbiADNij (ORCPT ); Tue, 4 Jan 2022 08:38:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641303519; x=1672839519; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iKpVHqbLjmy+GnZIzKt6LP0hTcWqlU2qKV4ybnoaZ5Y=; b=B3vBSms37MREx8C/cBFTA2e9CdmrVL10xiFtdNFbY3Rmd35Wqz8pO0A4 V8xnf0Aq+z8t18MhuQEfKPYmfz2OJGm6d5lp1s1HHoyTiOKsvMRxmFA3o ZFlbt5tfpp9KzQBEJAKv9NVw0uJYw6Qrra3UbTu9CD4sICnAjkU1OGyO1 r1c3xMBh9QL1VJdZHs+ZadkPHNVsP/5ERaYR5Ex0ksEFv2AXStV38dkNY 3eO7uL3SG8TU9xbSmat9tJEg1ux5076yiLXd3uPiOAFgLtM0pVnPKxrsL 3aKQDw/fGH89dJuvrZ7cNVcs1LgVgz2nbYHsXvrW0j/ZxbFoL/0P5w8Ou Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10216"; a="305576180" X-IronPort-AV: E=Sophos;i="5.88,261,1635231600"; d="scan'208";a="305576180" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 05:38:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,261,1635231600"; d="scan'208";a="590678804" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 04 Jan 2022 05:38:35 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id D87DC18E; Tue, 4 Jan 2022 15:38:45 +0200 (EET) From: Andy Shevchenko To: Miquel Raynal , Srinivas Kandagatla , Greg Kroah-Hartman , Mika Westerberg , Andy Shevchenko , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Richard Weinberger , Vignesh Raghavendra , Andreas Noever , Michael Jamet , Yehezkel Bernat , Alexander Usyskin Subject: [PATCH v1 2/5] nvmem: core: Use devm_add_action_or_reset() Date: Tue, 4 Jan 2022 15:38:40 +0200 Message-Id: <20220104133843.44272-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104133843.44272-1-andriy.shevchenko@linux.intel.com> References: <20220104133843.44272-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Slightly simplify the devm_nvmem_register() by using the devm_add_action_or_reset(). Signed-off-by: Andy Shevchenko --- drivers/nvmem/core.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index fbf7dec775fb..6946d14876dc 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -907,9 +907,9 @@ void nvmem_unregister(struct nvmem_device *nvmem) } EXPORT_SYMBOL_GPL(nvmem_unregister); -static void devm_nvmem_release(struct device *dev, void *res) +static void devm_nvmem_unregister(void *nvmem) { - nvmem_unregister(*(struct nvmem_device **)res); + nvmem_unregister(nvmem); } /** @@ -926,20 +926,16 @@ static void devm_nvmem_release(struct device *dev, void *res) struct nvmem_device *devm_nvmem_register(struct device *dev, const struct nvmem_config *config) { - struct nvmem_device **ptr, *nvmem; - - ptr = devres_alloc(devm_nvmem_release, sizeof(*ptr), GFP_KERNEL); - if (!ptr) - return ERR_PTR(-ENOMEM); + struct nvmem_device *nvmem; + int ret; nvmem = nvmem_register(config); + if (IS_ERR(nvmem)) + return nvmem; - if (!IS_ERR(nvmem)) { - *ptr = nvmem; - devres_add(dev, ptr); - } else { - devres_free(ptr); - } + ret = devm_add_action_or_reset(dev, devm_nvmem_unregister, nvmem); + if (ret) + return ERR_PTR(ret); return nvmem; } From patchwork Tue Jan 4 13:38:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12703481 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 26FF8C433F5 for ; Tue, 4 Jan 2022 13:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233692AbiADNil (ORCPT ); Tue, 4 Jan 2022 08:38:41 -0500 Received: from mga11.intel.com ([192.55.52.93]:44752 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233676AbiADNik (ORCPT ); Tue, 4 Jan 2022 08:38:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641303520; x=1672839520; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5n0NVLD2/m8t8Qqc0BSLS9vuywuO9nv/kXq7ES1D9E8=; b=cGmAmbHdF0fDaebjM24SS7QpiS79DwOYifovQLqDhanmIqphB8Udl1bg MFR4MVqjReU4izH3xzGPRxfLQ4uembKPiT/dAap5efwcJMq5MBERxetFS Y7q2sPHST7N+OhCxQPwC0K4nyIQCOUc7cHCwXXpZN/+Tb6mymkofB+dhZ w3AXyGpCWx+VLcSjHJwEJjwsVQmc0Pn1qJEUpH2VllsMeouPzOASFv8Z1 KHy+f8hWiKWxMNpGJ15Oeh44x2tqZlvhw2KoaJQ1DRQGU1MPJccjSajTL X8q8Ov7yHcQRbSt6e1YOaw2uDPRuRfUxIQqRtnJEIoqajmrCH6mE9rcUc g==; X-IronPort-AV: E=McAfee;i="6200,9189,10216"; a="239765014" X-IronPort-AV: E=Sophos;i="5.88,261,1635231600"; d="scan'208";a="239765014" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 05:38:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,261,1635231600"; d="scan'208";a="472066539" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 04 Jan 2022 05:38:35 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id DFB2A21A; Tue, 4 Jan 2022 15:38:45 +0200 (EET) From: Andy Shevchenko To: Miquel Raynal , Srinivas Kandagatla , Greg Kroah-Hartman , Mika Westerberg , Andy Shevchenko , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Richard Weinberger , Vignesh Raghavendra , Andreas Noever , Michael Jamet , Yehezkel Bernat , Alexander Usyskin Subject: [PATCH v1 3/5] nvmem: core: Check input parameter for NULL in nvmem_unregister() Date: Tue, 4 Jan 2022 15:38:41 +0200 Message-Id: <20220104133843.44272-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104133843.44272-1-andriy.shevchenko@linux.intel.com> References: <20220104133843.44272-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org nvmem_unregister() frees resources and standard pattern is to allow caller to not care if it's NULL or not. This will reduce burden on the callers to perform this check. Signed-off-by: Andy Shevchenko --- drivers/nvmem/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 6946d14876dc..3ca6615d9430 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -903,7 +903,8 @@ static void nvmem_device_release(struct kref *kref) */ void nvmem_unregister(struct nvmem_device *nvmem) { - kref_put(&nvmem->refcnt, nvmem_device_release); + if (nvmem) + kref_put(&nvmem->refcnt, nvmem_device_release); } EXPORT_SYMBOL_GPL(nvmem_unregister); From patchwork Tue Jan 4 13:38:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12703484 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 651EFC433EF for ; Tue, 4 Jan 2022 13:38:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233768AbiADNiu (ORCPT ); Tue, 4 Jan 2022 08:38:50 -0500 Received: from mga11.intel.com ([192.55.52.93]:44752 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233657AbiADNij (ORCPT ); Tue, 4 Jan 2022 08:38:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641303519; x=1672839519; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Dk8eR+nk6aw16X9+1NKLpwmWVQ9jkxr8X5sDpD7O+wM=; b=ecSmSn/OQ8Ql0SMXgw4At0IhSq3BF/MzRnGIpSF1Rf3BjVAx9ONaHuaV W0+cA6a/G8hS4eWvpSVvocgvqXfStqAs5uAWn650vq7JXtTBE51a2I9s+ 2gelofG9x/wwL3ayY4FRVCsJe94j5iVZFXn/F9eUuCkPm8mLsSK7lfv0O ohHJf1Z8A0S5trMZ0DvRAYLkAnQdbKSWRvL7x6EQQKUHtzvYTTbLSsUIX liNmazfJ/pivPaG0lbKegvgPa6+j/RDHlwPb5sFXFolX3V1zd/BydBdRE r965IV8YwAy4NngaXYdnE1wEkP/kiPAzi5fL04DJB7P9XL4e2JsrHeHpJ A==; X-IronPort-AV: E=McAfee;i="6200,9189,10216"; a="239765011" X-IronPort-AV: E=Sophos;i="5.88,261,1635231600"; d="scan'208";a="239765011" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 05:38:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,261,1635231600"; d="scan'208";a="472066537" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 04 Jan 2022 05:38:35 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id EC8F449B; Tue, 4 Jan 2022 15:38:45 +0200 (EET) From: Andy Shevchenko To: Miquel Raynal , Srinivas Kandagatla , Greg Kroah-Hartman , Mika Westerberg , Andy Shevchenko , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Richard Weinberger , Vignesh Raghavendra , Andreas Noever , Michael Jamet , Yehezkel Bernat , Alexander Usyskin Subject: [PATCH v1 4/5] mtd: core: Drop duplicate NULL checks around nvmem_unregister() Date: Tue, 4 Jan 2022 15:38:42 +0200 Message-Id: <20220104133843.44272-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104133843.44272-1-andriy.shevchenko@linux.intel.com> References: <20220104133843.44272-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Since nvmem_unregister() checks for NULL, no need to repeat in the caller. Drop duplicate NULL checks. Signed-off-by: Andy Shevchenko Acked-by: Miquel Raynal --- drivers/mtd/mtdcore.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 70f492dce158..010ffc34532a 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -742,8 +742,7 @@ int del_mtd_device(struct mtd_info *mtd) debugfs_remove_recursive(mtd->dbg.dfs_dir); /* Try to remove the NVMEM provider */ - if (mtd->nvmem) - nvmem_unregister(mtd->nvmem); + nvmem_unregister(mtd->nvmem); device_unregister(&mtd->dev); @@ -921,8 +920,7 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd) return 0; err: - if (mtd->otp_user_nvmem) - nvmem_unregister(mtd->otp_user_nvmem); + nvmem_unregister(mtd->otp_user_nvmem); return err; } @@ -1026,11 +1024,8 @@ int mtd_device_unregister(struct mtd_info *master) memset(&master->reboot_notifier, 0, sizeof(master->reboot_notifier)); } - if (master->otp_user_nvmem) - nvmem_unregister(master->otp_user_nvmem); - - if (master->otp_factory_nvmem) - nvmem_unregister(master->otp_factory_nvmem); + nvmem_unregister(master->otp_user_nvmem); + nvmem_unregister(master->otp_factory_nvmem); err = del_mtd_partitions(master); if (err) From patchwork Tue Jan 4 13:38:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12703480 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 29705C433F5 for ; Tue, 4 Jan 2022 13:38:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233665AbiADNij (ORCPT ); Tue, 4 Jan 2022 08:38:39 -0500 Received: from mga12.intel.com ([192.55.52.136]:45362 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229700AbiADNij (ORCPT ); Tue, 4 Jan 2022 08:38:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641303519; x=1672839519; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VgbAQpftXwrGIO11WeKJEI86gSonJP5etagd1SMrm8M=; b=Ahk9LesHPnUAFKHYPC486vFphD2fGNimG6qRD5+nXXTO6wPbTWzzJEZN 5S3FGaDKkaRzR+13vxUMP9Xb0t+TWTr+8w8dcjdbxinl6c4i5+0VhQ7TH JlQKenV1ZDQik2hcZXwCfU7XmY9L1XGwP2UHQqKEQZCYmoItt3baTPlOE IM1A96FW9XOX50eI+BBYXxyKOdepqCwp3Ci4aPc4RzrfzVQkYtn4L3n9E pubqsWZqj25BPUsddCSHaEBtakufkv2sOKbDnRAK+oIcLE4jM75dvfYeH yujtOV+zRl/nagfsh09jy7cUyxBhGEVzQwyB58lQsLPJdqfwKrBGYdhTa g==; X-IronPort-AV: E=McAfee;i="6200,9189,10216"; a="222216293" X-IronPort-AV: E=Sophos;i="5.88,261,1635231600"; d="scan'208";a="222216293" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2022 05:38:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,261,1635231600"; d="scan'208";a="760439210" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 04 Jan 2022 05:38:35 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0249B512; Tue, 4 Jan 2022 15:38:45 +0200 (EET) From: Andy Shevchenko To: Miquel Raynal , Srinivas Kandagatla , Greg Kroah-Hartman , Mika Westerberg , Andy Shevchenko , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Richard Weinberger , Vignesh Raghavendra , Andreas Noever , Michael Jamet , Yehezkel Bernat , Alexander Usyskin Subject: [PATCH v1 5/5] thunderbolt: Drop duplicate NULL checks around nvmem_unregister() Date: Tue, 4 Jan 2022 15:38:43 +0200 Message-Id: <20220104133843.44272-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104133843.44272-1-andriy.shevchenko@linux.intel.com> References: <20220104133843.44272-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Since nvmem_unregister() checks for NULL, no need to repeat in the caller. Drop duplicate NULL checks. Signed-off-by: Andy Shevchenko Acked-by: Mika Westerberg --- drivers/thunderbolt/nvm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/thunderbolt/nvm.c b/drivers/thunderbolt/nvm.c index 3a5336913cca..b3f310389378 100644 --- a/drivers/thunderbolt/nvm.c +++ b/drivers/thunderbolt/nvm.c @@ -154,10 +154,8 @@ int tb_nvm_add_non_active(struct tb_nvm *nvm, size_t size, void tb_nvm_free(struct tb_nvm *nvm) { if (nvm) { - if (nvm->non_active) - nvmem_unregister(nvm->non_active); - if (nvm->active) - nvmem_unregister(nvm->active); + nvmem_unregister(nvm->non_active); + nvmem_unregister(nvm->active); vfree(nvm->buf); ida_simple_remove(&nvm_ida, nvm->id); }