From patchwork Mon Oct 31 07:36:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 13132 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2165551wru; Mon, 31 Oct 2022 00:40:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5wdJ22cCmCc8JVN0eMs2GNuk1jKb4l7jRY8pInK3mRiEEQSKrW+fz1Gm4S+BBRuy32FxyT X-Received: by 2002:a05:6402:754:b0:463:67da:3dc with SMTP id p20-20020a056402075400b0046367da03dcmr2798865edy.386.1667202054807; Mon, 31 Oct 2022 00:40:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667202054; cv=none; d=google.com; s=arc-20160816; b=025fdswDupxec8gA9ahGZebQ0Z18XQ7Uo77asgwXnhMwRwhzqnRZpvQ4X0e4QW4iSU 2ztm3gBmQz1i2K6Pr9uBEQvp936QjCiKAHFUnkwYOUu4tuhnDfOw8rC/RLYNQ9s+mx9r nhCg0O/SbDXTBI4LFJ8yG/VlB5iLF4aFBpJTsfGhZWpdNhytBP6Pjp2+QG96CFKB96uR npZvVXzLl5fLqXoUKMPX3mm4fy8loj7eXqB0/7H3YVzUR5p+Gn3T3YZ715mcmyZ0rJBO PEKWJTp8ey6YXW/G5Xrfo5a8QjyQZNEpdTHCX6Fb4SmxikK5LzUcyuWZWJQ5pmd5ex/K Xisw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=G3b6Wsi73HIrqs/xRo+3SU2g9dS+7mEe/fZern056cs=; b=hw2MIqy8ZAkWTkrT7bG/sVqqbd2S2soWYJ/hMdwqUUlwox/mY1yZGFx/jZ+VHFY5Me pgiQsZbMDWOg1I1zbP/UH5SoN3ZOjkr05EQX6Xvu6/3wDllhSXkXrXi7D1HnkUyP9zVK EU7bwp2hkIj8cRbL/brU8mX1GMQ5HSGq3GFU6XvQmW32PyFZnhFgIpjM3vKMCMsPX7cU CCs3YUbMqx6XnfZrPfmHxjq9JhDZWIYY6WKXL7fN27kHu9VSssF4wanZcFe2THQVPXix kwvyTsZ6eoPTRkQMM6pqfYfxcR0ZVOKgPvlxCNoTzQANOibR+LyxvS4Cj/zGLESki+pG zivw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hAu6B3Di; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c97-20020a509fea000000b0046198ab2c0bsi6030821edf.283.2022.10.31.00.40.31; Mon, 31 Oct 2022 00:40:54 -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=@gmail.com header.s=20210112 header.b=hAu6B3Di; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229628AbiJaHgq (ORCPT + 99 others); Mon, 31 Oct 2022 03:36:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiJaHgo (ORCPT ); Mon, 31 Oct 2022 03:36:44 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FF4365E5; Mon, 31 Oct 2022 00:36:43 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id o12so17928873lfq.9; Mon, 31 Oct 2022 00:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=G3b6Wsi73HIrqs/xRo+3SU2g9dS+7mEe/fZern056cs=; b=hAu6B3Diq/lytG+wSasHluNwrLLIQ2xitlZcdHb9BEAQZkCwYW2FuMT0iPVFVEC9Ir mzouzayBEa2ihYynXbl5vJHZUzYJDRn5Q+7lWf7kYqxpzv4D6Izr7IuciIkMyYjk8qVM XMCJT+mHAE2okRpxRhwd681Bw/G94+YtySQa2Cmp4p+yaWtD+iToRzTpUB70g6lBSTuO Swag4stJ8B4btHAxAfcP2SsFcnCsvq26HcARWweV0ykyiVuCnffNNNLVzECIWd9Xb4M5 p/87oaA+Eton+yYcqfxEVMTp5ksR34A2ZzpkcUvdaHxd0KubQr3LDCOjOo62lxonBIQa gShg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=G3b6Wsi73HIrqs/xRo+3SU2g9dS+7mEe/fZern056cs=; b=0G1Vh9L7PqlaSEw9OnCmQcuh+Nh+0tEulbjoLr+SSbZH8tEEwAm5O+BTgrmO9nI/q1 QLN+M5J6qdSY/Qw69CMVLHKYqTsKdCkWjnUXE1UvZ2zY/iDtCd+cvlGvUUJL/t95q1a5 XWk99HjgyychjZf70bkXA6aJLo044PHa/pD0lPz6GdtoawVVf4stQSuquZfIsBYIFEOe G3gN6/oAOgfQpMOiGRQ0ODhKPQKuqSl0VKTfl9x+hwt03KBoWX0veBB+y/PNqUK+OEI5 7Dx7FbAGZXCnJqtsRKJuk6zvgAZoHrl8hJuMMizGITaycD44R3J9afaHxNWDYfUtxCkX Z4jg== X-Gm-Message-State: ACrzQf30eNtyxk7GdZZHk/rKqaN9VkVtbjF2j7FzkIO83WQasbVIdvbc 7JMy+XKKNAhwAjyWSa1CuGk= X-Received: by 2002:a05:6512:2c88:b0:4a9:4051:79a1 with SMTP id dw8-20020a0565122c8800b004a9405179a1mr4530353lfb.331.1667201801690; Mon, 31 Oct 2022 00:36:41 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::2]) by smtp.gmail.com with ESMTPSA id x18-20020a056512079200b004a65780e4cfsm1162304lfr.106.2022.10.31.00.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 00:36:40 -0700 (PDT) Date: Mon, 31 Oct 2022 09:36:21 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Matti Vaittinen , Sebastian Reichel , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] power: supply: bd99954: Use LINEAR_RANGE() Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748188062172534991?= X-GMAIL-MSGID: =?utf-8?q?1748188062172534991?= Do minor clean-up by using newly inroduced LINEAR_RANGE() initialization macro. Signed-off-by: Matti Vaittinen --- drivers/power/supply/bd99954-charger.c | 84 ++++---------------------- 1 file changed, 13 insertions(+), 71 deletions(-) diff --git a/drivers/power/supply/bd99954-charger.c b/drivers/power/supply/bd99954-charger.c index 96e93e1b8094..250362e15c98 100644 --- a/drivers/power/supply/bd99954-charger.c +++ b/drivers/power/supply/bd99954-charger.c @@ -768,27 +768,13 @@ static const struct power_supply_desc bd9995x_power_supply_desc = { * Describe the setting in linear_range table. */ static const struct linear_range input_current_limit_ranges[] = { - { - .min = 0, - .step = 32000, - .min_sel = 0x0, - .max_sel = 0x1ff, - }, + LINEAR_RANGE(0, 0x0, 0x1ff, 32000), }; /* Possible trickle, pre-charging and termination current values */ static const struct linear_range charging_current_ranges[] = { - { - .min = 0, - .step = 64000, - .min_sel = 0x0, - .max_sel = 0x10, - }, { - .min = 1024000, - .step = 0, - .min_sel = 0x11, - .max_sel = 0x1f, - }, + LINEAR_RANGE(0, 0x0, 0x10, 64000), + LINEAR_RANGE(1024000, 0x11, 0x1f, 0), }; /* @@ -796,72 +782,28 @@ static const struct linear_range charging_current_ranges[] = { * and battery over voltage protection have same possible values */ static const struct linear_range charge_voltage_regulation_ranges[] = { - { - .min = 2560000, - .step = 0, - .min_sel = 0, - .max_sel = 0xA0, - }, { - .min = 2560000, - .step = 16000, - .min_sel = 0xA0, - .max_sel = 0x4B0, - }, { - .min = 19200000, - .step = 0, - .min_sel = 0x4B0, - .max_sel = 0x7FF, - }, + LINEAR_RANGE(2560000, 0, 0xA0, 0), + LINEAR_RANGE(2560000, 0xA0, 0x4B0, 16000), + LINEAR_RANGE(19200000, 0x4B0, 0x7FF, 0), }; /* Possible VSYS voltage regulation values */ static const struct linear_range vsys_voltage_regulation_ranges[] = { - { - .min = 2560000, - .step = 0, - .min_sel = 0, - .max_sel = 0x28, - }, { - .min = 2560000, - .step = 64000, - .min_sel = 0x28, - .max_sel = 0x12C, - }, { - .min = 19200000, - .step = 0, - .min_sel = 0x12C, - .max_sel = 0x1FF, - }, + LINEAR_RANGE(2560000, 0, 0x28, 0), + LINEAR_RANGE(2560000, 0x28, 0x12C, 64000), + LINEAR_RANGE(19200000, 0x12C, 0x1FF, 0), }; /* Possible settings for switching from trickle to pre-charging limits */ static const struct linear_range trickle_to_pre_threshold_ranges[] = { - { - .min = 2048000, - .step = 0, - .min_sel = 0, - .max_sel = 0x20, - }, { - .min = 2048000, - .step = 64000, - .min_sel = 0x20, - .max_sel = 0x12C, - }, { - .min = 19200000, - .step = 0, - .min_sel = 0x12C, - .max_sel = 0x1FF - } + LINEAR_RANGE(2048000, 0, 0x20, 0), + LINEAR_RANGE(2048000, 0x20, 0x12C, 64000), + LINEAR_RANGE(19200000, 0x12C, 0x1FF, 0), }; /* Possible current values for fast-charging constant current phase */ static const struct linear_range fast_charge_current_ranges[] = { - { - .min = 0, - .step = 64000, - .min_sel = 0, - .max_sel = 0xFF, - } + LINEAR_RANGE(0, 0, 0xFF, 64000), }; struct battery_init {