From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E5881C9B6D; Thu, 10 Oct 2024 13:18:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728566312; cv=none; b=fCFPtkVGtT0dqsdYv6ktW2rx0vW7ivnNclrJUSRPkIV1nPe6X9ooYmtFky1CEl9XMUB5lBz90IgAtGzIhZrMoqQ4yCKsQyZe1RJZ64oO1PBmFL8/VjsAyM8ha9ioh7KWQ4VchdRirHJabuvTC0KP60+UoiJOe5F53Dlu0aELKf4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728566312; c=relaxed/simple; bh=3P18k/5s2T2XN83f+l8l3JR3wPxdW5ngjbiPxFBvjaA=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cy2kChD83eNcWdqstmnaw5/jIi87qq6VZzhiozUFih+NkzyLZBOtKc2jYKxD5XOHOtYNJ1ghfPwnfzE8XSNWE5O/NT2D1cQQvOV3HLXpXGSTfhm4Y8NGDRDeJTAXnhZeIp9f7rknPJ/uBc69gQWq2J3SdQFrzIZ/m8szOVmKFuA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XPVZl2rx8z6LDJY; Thu, 10 Oct 2024 21:14:07 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 2174914011A; Thu, 10 Oct 2024 21:18:28 +0800 (CST) Received: from localhost (10.203.177.66) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 10 Oct 2024 15:18:27 +0200 Date: Thu, 10 Oct 2024 14:18:26 +0100 From: Jonathan Cameron To: Ira Weiny CC: Dave Jiang , Fan Ni , "Navneet Singh" , Jonathan Corbet , "Andrew Morton" , Dan Williams , Davidlohr Bueso , "Alison Schofield" , Vishal Verma , , , , , Subject: Re: [PATCH v4 15/28] cxl/region: Refactor common create region code Message-ID: <20241010141826.0000796e@Huawei.com> In-Reply-To: <20241007-dcd-type2-upstream-v4-15-c261ee6eeded@intel.com> References: <20241007-dcd-type2-upstream-v4-0-c261ee6eeded@intel.com> <20241007-dcd-type2-upstream-v4-15-c261ee6eeded@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100004.china.huawei.com (7.191.162.219) To frapeml500008.china.huawei.com (7.182.85.71) On Mon, 07 Oct 2024 18:16:21 -0500 Ira Weiny wrote: > create_pmem_region_store() and create_ram_region_store() are identical > with the exception of the region mode. With the addition of DC region > mode this would end up being 3 copies of the same code. > > Refactor create_pmem_region_store() and create_ram_region_store() to use > a single common function to be used in subsequent DC code. > > Suggested-by: Fan Ni > Signed-off-by: Ira Weiny Nice. Reviewed-by: Jonathan Cameron Is it worth dragging out cleanup like this to the start of the series so Dave can queue it up as 'good to have whatever' and reduce this set a bit? Jonathan > --- > drivers/cxl/core/region.c | 28 +++++++++++----------------- > 1 file changed, 11 insertions(+), 17 deletions(-) > > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c > index ab00203f285a..2ca6148d108c 100644 > --- a/drivers/cxl/core/region.c > +++ b/drivers/cxl/core/region.c > @@ -2552,9 +2552,8 @@ static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd, > return devm_cxl_add_region(cxlrd, id, mode, CXL_DECODER_HOSTONLYMEM); > } > > + > +static ssize_t create_pmem_region_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t len) > +{ > + return create_region_store(dev, buf, len, CXL_REGION_PMEM); > +} > DEVICE_ATTR_RW(create_pmem_region); > > static ssize_t create_ram_region_store(struct device *dev, > struct device_attribute *attr, > const char *buf, size_t len) > { > - struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(dev); > - struct cxl_region *cxlr; > - int rc, id; > - > - rc = sscanf(buf, "region%d\n", &id); > - if (rc != 1) > - return -EINVAL; > - > - cxlr = __create_region(cxlrd, CXL_REGION_RAM, id); > - if (IS_ERR(cxlr)) > - return PTR_ERR(cxlr); > - > - return len; > + return create_region_store(dev, buf, len, CXL_REGION_RAM); > } > DEVICE_ATTR_RW(create_ram_region); > >