From patchwork Mon Jan 24 18:00:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12722642 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 98EBAC433EF for ; Mon, 24 Jan 2022 18:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244854AbiAXSBF (ORCPT ); Mon, 24 Jan 2022 13:01:05 -0500 Received: from mga14.intel.com ([192.55.52.115]:63121 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244856AbiAXSAm (ORCPT ); Mon, 24 Jan 2022 13:00:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643047242; x=1674583242; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BQSospdD4gesHVIwJjnamUSWWSLW6vXQL72nOd9YKGI=; b=TA2JAN2DVMPmfmWo5QitF5YwhQSauZWIrXi5sPUPbm9OPI4t/CXt+jAr VqmvkwJrzQXSzXCQaWDfn5zmEh2N0Ven5UnjxaRkfAwJ2rF8wrwSHC/lT rKX8u/0TYsbCD8j/+dN32jBfErggjJXD9auoR13SqwtgVP3W+ww0rSLFD d+4evnZQ3Gmkf5zup9KQmfn6MoaimVBQgm6/3kk02z2myk1Hx2Wq3o54R OTZmG6efBz5U/kWdCijIUwgs1QiSFeCiXWJPqzF9HxlqexIoEqJewoFvs 4Wq4LZ4r/n81LiIHfo4xFzVZEfwzLf49FBvKVQuT+Jey3nQjyxkTor7gW w==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="246326299" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="246326299" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 10:00:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="624164228" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 24 Jan 2022 10:00:29 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 52C3D178; Mon, 24 Jan 2022 20:00:42 +0200 (EET) From: Andy Shevchenko To: Miquel Raynal , Greg Kroah-Hartman , Srinivas Kandagatla , 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 Subject: [PATCH v2 1/5] nvmem: core: Remove unused devm_nvmem_unregister() Date: Mon, 24 Jan 2022 20:00:36 +0200 Message-Id: <20220124180040.50660-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 and remove the unused devm_nvmem_match() along with it. Signed-off-by: Andy Shevchenko --- v2: removed unused devm_nvmem_match() (lkp) drivers/nvmem/core.c | 22 ---------------------- include/linux/nvmem-provider.h | 8 -------- 2 files changed, 30 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 23a38dcf0fc4..1a70b3bdb71d 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -945,28 +945,6 @@ struct nvmem_device *devm_nvmem_register(struct device *dev, } EXPORT_SYMBOL_GPL(devm_nvmem_register); -static int devm_nvmem_match(struct device *dev, void *res, void *data) -{ - struct nvmem_device **r = res; - - 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 Mon Jan 24 18:00:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12722643 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 341EAC433F5 for ; Mon, 24 Jan 2022 18:01:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244860AbiAXSBG (ORCPT ); Mon, 24 Jan 2022 13:01:06 -0500 Received: from mga14.intel.com ([192.55.52.115]:63147 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241651AbiAXSAz (ORCPT ); Mon, 24 Jan 2022 13:00:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643047255; x=1674583255; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y8ZjakMo/mJ3Wq1rrQTj9HsDSrE7UOgOlZKX2oN9x20=; b=Tu35DCZePLJX7x9n2/dtNXueh6Lto/2Pg2jpHz5rNexBx8GZu7DCimUw HNGj3yoOF0xB8jK/EA+BPVJNS0vvoCRvIX28LCqb/eEZJZlCybBmE41eP 5fAzvtHrhFlPo0kIoZDWWL0dm/rSFj7YDUKwH+iJR1T2FDmOQpA2/XYsE IqqTLK/SaMHVhwsIkAWBDvQ+nyp1vPrtWJZ9wCaEdsg5AN29V5yJiyXsK G2iWoiUcfI7O4IoKJ+UlxunQkHBWfeuq12heF/kO+LqB9eq8tzvwuavzA tWTBcZQ0mJ6IVfqYvxCe4LPGaWAI4JroddftcxJSpMIMEQSZZbDm6eTaU g==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="246326304" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="246326304" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 10:00:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="695511924" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 24 Jan 2022 10:00:29 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5D751B7; Mon, 24 Jan 2022 20:00:42 +0200 (EET) From: Andy Shevchenko To: Miquel Raynal , Greg Kroah-Hartman , Srinivas Kandagatla , 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 Subject: [PATCH v2 2/5] nvmem: core: Use devm_add_action_or_reset() Date: Mon, 24 Jan 2022 20:00:37 +0200 Message-Id: <20220124180040.50660-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124180040.50660-1-andriy.shevchenko@linux.intel.com> References: <20220124180040.50660-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 --- v2: no changes 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 1a70b3bdb71d..68db7d3303ac 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 Mon Jan 24 18:00:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12722644 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 1FD8AC433EF for ; Mon, 24 Jan 2022 18:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244876AbiAXSBJ (ORCPT ); Mon, 24 Jan 2022 13:01:09 -0500 Received: from mga05.intel.com ([192.55.52.43]:37768 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241614AbiAXSAl (ORCPT ); Mon, 24 Jan 2022 13:00:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643047241; x=1674583241; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8JozRceOoyg4LNdwXwVz+BMwrK4+CMCruE+xcyfxVZ8=; b=hYgZSqqT+OYILj1ns+wM7PvGVBnYpfRoSQ1C8Wr+LWOCTDSmTfpZYa7y qhEUuMXHvS7l3psBXaicU4VslFPxvy6UpOqmMaW3KCavt4hyigDvMKO4J uDJvTbrEdkv+MY77VM81UMnQUsB56yFnM2GsS+w2fC6/5Hpi2n0COHcx6 ZYaD9SgaOW8xLnyIy7x7gIqWp5EFOqNP6N2AWQvX3YqWAhsda2iWT2HtA +v/uUUVAAjihtp4dNlNGv2mnC/pwo/62JyVPW5bnpEIFXPie2w8/zUu44 dNvodGGreaDfBK5w5J0kwH6RujnI5qhjXi5P1gHZNOZhKXwvveiCfACQz A==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="332462062" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="332462062" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 10:00:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="617333121" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 24 Jan 2022 10:00:29 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 68D70616; Mon, 24 Jan 2022 20:00:42 +0200 (EET) From: Andy Shevchenko To: Miquel Raynal , Greg Kroah-Hartman , Srinivas Kandagatla , 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 Subject: [PATCH v2 3/5] nvmem: core: Check input parameter for NULL in nvmem_unregister() Date: Mon, 24 Jan 2022 20:00:38 +0200 Message-Id: <20220124180040.50660-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124180040.50660-1-andriy.shevchenko@linux.intel.com> References: <20220124180040.50660-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 --- v2: no changes 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 68db7d3303ac..53a43d843743 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 Mon Jan 24 18:00: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: 12722645 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 6949BC433EF for ; Mon, 24 Jan 2022 18:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244568AbiAXSBN (ORCPT ); Mon, 24 Jan 2022 13:01:13 -0500 Received: from mga05.intel.com ([192.55.52.43]:37762 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244853AbiAXSAj (ORCPT ); Mon, 24 Jan 2022 13:00:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643047239; x=1674583239; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CNrKOx69eGmZ3K24njISK38bi6jWQ4/aJUl4ds2Q64o=; b=lpplnq9ZraUq2IUgH394GMZmMuZ3Q1W+XuqpXvRsyzm9tUtphpqxYc2f mgLZUkY9jfvTO+2DVa0BjEf5fxX4YyR3DF0Csl0OKmUo1gO+O+fuEpBty HBFuSV2vV9AD7DQGvNhHq1pfQUd5okOhOv6K9aroiTIJoiKjwFFmH6PVq aKQe6A0buznioDFzlEoddl02IPd+4TP1hCgVn4nZ6+F+c5Vv5IWCVBptp od6YQybGF79kdBw7THo7YDwrMwBTaMXaH8t4S+XWBWWnv2NidpcxIxEpO LRJdpPB69yIBueFobesiJygsWJ2EaZOqeBs1qtYPU/QsmxHJjrUXXHgcR A==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="332462054" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="332462054" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 10:00:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="617333123" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 24 Jan 2022 10:00:29 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 751A49E7; Mon, 24 Jan 2022 20:00:42 +0200 (EET) From: Andy Shevchenko To: Miquel Raynal , Greg Kroah-Hartman , Srinivas Kandagatla , 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 Subject: [PATCH v2 4/5] mtd: core: Drop duplicate NULL checks around nvmem_unregister() Date: Mon, 24 Jan 2022 20:00:39 +0200 Message-Id: <20220124180040.50660-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124180040.50660-1-andriy.shevchenko@linux.intel.com> References: <20220124180040.50660-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 --- v2: added tag (Miquel) 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 Mon Jan 24 18:00: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: 12722641 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 D37A8C433EF for ; Mon, 24 Jan 2022 18:01:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244870AbiAXSBD (ORCPT ); Mon, 24 Jan 2022 13:01:03 -0500 Received: from mga04.intel.com ([192.55.52.120]:41944 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244841AbiAXSAd (ORCPT ); Mon, 24 Jan 2022 13:00:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643047232; x=1674583232; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GQ5E0i+zBiGPpozPgnHLAnkyvtSeafp3A0mHCHJieDY=; b=aQlCK2Kk4zwsmu+vElfLBMXsITM8rTkMejV/LhKEM+PsPJ24mgX9U7Qo YNXkpC33aY763VFEUrMM4V2ucUVFqygvEMMjgnBNePvKnzbIjr6Db8F8Y mbcrB1iiRX8yEn0bp/xwnuTjFzv0raumScWJA/j4qF/9ozBzaujYAc1vl hupqwk0sYHJhQrEjiwm3f0HR1Jylxp69RJaMTqdxwxVAIu6qJ5D5gAre0 WoJDUGhYwDTGmv4Q+6vvtRfrSiKztY4GHk3BEbs8FBCsG5ZYf4Mm5pgB5 W3sP6y23eCSK8Qp9wGN6Xj4Cs9HMDUlxbckbA+NeZJWcMhkQvEaSw6x1v w==; X-IronPort-AV: E=McAfee;i="6200,9189,10237"; a="244942117" X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="244942117" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jan 2022 10:00:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,311,1635231600"; d="scan'208";a="766479413" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 24 Jan 2022 10:00:29 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8101BA51; Mon, 24 Jan 2022 20:00:42 +0200 (EET) From: Andy Shevchenko To: Miquel Raynal , Greg Kroah-Hartman , Srinivas Kandagatla , 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 Subject: [PATCH v2 5/5] thunderbolt: Drop duplicate NULL checks around nvmem_unregister() Date: Mon, 24 Jan 2022 20:00:40 +0200 Message-Id: <20220124180040.50660-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124180040.50660-1-andriy.shevchenko@linux.intel.com> References: <20220124180040.50660-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 --- v2: added tag (Mika) 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); }