Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4398647imw; Thu, 7 Jul 2022 18:44:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sxWpEOnzaK3f/HJ61KiJmiJZhqIokKh9YcMx5/cuOACP4AFGvvnN7DmXDyYOfTOBSEBlXy X-Received: by 2002:a17:90b:33ca:b0:1ec:c617:9660 with SMTP id lk10-20020a17090b33ca00b001ecc6179660mr8779512pjb.95.1657244683396; Thu, 07 Jul 2022 18:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657244683; cv=none; d=google.com; s=arc-20160816; b=ikYK2KvoVu/gE+DnD6uVE9Y4yX2gFKUMQKKC+DJIPAKlpJqDkiFEJKgMwFsM7fxfnT u1lLxPtib2wmIXnANwLZ910a7IzcNd3d6EHKoVZahyAkb2QeWeWO4+xSvP8fwzQekju1 sLqRInMST42O1bSSgi9Lg2XSy7wkEPr6sZKS8KJWNPf1oMn5TzBZIaM4ZHFeP37O6wVM Ntnnfk40ISNws6G6nM0A6LYmX1lHsPmbHyGGSii2Dic3dm0+FOnbvhsEEgb7Z0zXMi6N K+c0+7FuEyNkj3CNTQJNNKF/vFfyX3lMC0nXXnfjmjwWY+TZLpP+82M53A4x4TGJUIhN +lQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=OPU/FEXF1OZ7e78AGxI45y2Hs2e8lTo+nO3wH3PsGX0=; b=od8Z5MJPqwuQ9hTd2CUTF+NZFot1ZUvCuADvY5r1Moj0n58CeuTeycyqi9PH1domJd JaiHLlSfjb/w7TkxMWTyC9lOtk9ghiioqOXgsO6Bvo5Wdv4ctKIx3t65YabyTjO1fVXE xXKUffCMJ9sLlyglhg2ErDR44EVEwTofqYpBOHPskqSb4rbSV0Ifk1jhSjWcvw15kiqq XHw8wbt75csZH2tyrYU57tQm/yXBw7tSsb+TBre0yAuYQ2ZqpgMlmQsv52/JXS47zVWw r0mcX9XBoXzY0WQzP3JWdijBP3tMba5uPhQP6iL243ROwKObG/itLWRzIzpAwC8ezsQU 6l9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NgNkGcIa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n5-20020a170902d2c500b0016a7114fee1si5933883plc.405.2022.07.07.18.44.29; Thu, 07 Jul 2022 18:44:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=NgNkGcIa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236975AbiGHBbl (ORCPT + 99 others); Thu, 7 Jul 2022 21:31:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236954AbiGHBbk (ORCPT ); Thu, 7 Jul 2022 21:31:40 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 763DB72EDB for ; Thu, 7 Jul 2022 18:31:38 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2681VU1E033076; Thu, 7 Jul 2022 20:31:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1657243890; bh=OPU/FEXF1OZ7e78AGxI45y2Hs2e8lTo+nO3wH3PsGX0=; h=From:To:CC:Subject:Date; b=NgNkGcIaYslilGN4cxX95HuLpUHX538oCWMvT+rft15HcX9UlnaEb4Eo8kKtKG/H9 s+3or0tlJEZixAwK/wI4WwRz9OMsmMeG03xFsmSf9rljp9aeB3O8j2Pz8NCuKIJFQl 5LN9xUuWMGJ6U9ydSDOe3BOdbknKcVfsmCQsRqkE= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2681VUo9040305 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 7 Jul 2022 20:31:30 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 7 Jul 2022 20:31:29 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Thu, 7 Jul 2022 20:31:29 -0500 Received: from ubuntu.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2681VQfb045825; Thu, 7 Jul 2022 20:31:27 -0500 From: Matt Ranostay To: CC: Matt Ranostay , Mark Brown , Nishanth Menon Subject: [PATCH] regmap: add WARN_ONCE when invalid mask is provided to regmap_field_init() Date: Thu, 7 Jul 2022 18:31:25 -0700 Message-ID: <20220708013125.313892-1-mranostay@ti.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In regmap_field_init() when a invalid mask is provided it still initializes with any warnings. An example of this is when the LSB is greater than MSB a mask of zero is produced. WARN_ONCE() is not ideal for this but requires less changes to core regmap code. Cc: Mark Brown Cc: Nishanth Menon Signed-off-by: Matt Ranostay --- drivers/base/regmap/regmap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 4cf59e10d01b..0caa5690c560 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1298,6 +1298,9 @@ static void regmap_field_init(struct regmap_field *rm_field, rm_field->reg = reg_field.reg; rm_field->shift = reg_field.lsb; rm_field->mask = GENMASK(reg_field.msb, reg_field.lsb); + + WARN_ONCE(rm_field->mask == 0, "invalid empty mask defined\n"); + rm_field->id_size = reg_field.id_size; rm_field->id_offset = reg_field.id_offset; } -- 2.36.1