Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp528517imu; Fri, 4 Jan 2019 02:21:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/WHFB/7UVCjaRH/PJqTrhZZS5rpXi80QQIXAwOTJwc/l7q2mlUtKVeaAvWJmB3f0FBX2IYS X-Received: by 2002:a62:2044:: with SMTP id g65mr51441659pfg.127.1546597301833; Fri, 04 Jan 2019 02:21:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546597301; cv=none; d=google.com; s=arc-20160816; b=BVo6O+l9bIqeHC2VqBi1Gzi3wLESsF0jMRyM3R4gxP3P7x0l/5DjHMWaDLgsM1Bk4i EB6ONgPla+JGj7oBCsCnzCj7Zf3FcSUReTpwGPaATrlIBOaJFvq0XzLHA1PCtiEkZ5qR 4N2DX4AmCOtSyt96FaWtdEObKbFSg451SYN4CGktjasLA5PlCxocopPWFSqfM2AmdKYh RN0Z9TcVu9GrY1tqL32o+b9Vc92nIPash7bBG5Wk0nWCB2J69No3JsB4wVt3PQ68ZGoI 4NgvDtON9kMgvJDuWrs4CIi+oVpvOUDCPNgOHMwma9TithSF7U7n0VS1CfGO5A548Otu BhHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gJSf2BDBYdFOd32Ue7e14bLPbyqb0fpPbgqPe5u65K4=; b=CdWlH9cVQwhPZCTJAcap7sxLgPJ7FIyYXo4DcZsTgkyZ23v8VTUBESn4Dn1XXKvxfY GuySa6aU7p4DMNQTAUpq5UAXzB4jsiarl1ZTG/pBPMg/DPs2th+YwTEddMCuz8GKpPSq GIg6oeXGWtb1FU0l/SUAJQTAn0AB0A4Bw3BbJ4WnkePPfCoIcnI2zCVla5MLT+WTMDjb swtRpHTcRVcuVh9EJ5UDtjI20AsiVux+k1pZNQj0eLN/G2c2tYV1CfdJmiZGmohmZ3Kd B3keDDIArozkHMcHBXgMMMaIyMFs0xOmghuLH7oYzPY1wmshIbFTCpY3dhIQPYB2BZWF vjVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c16si5191820pgn.222.2019.01.04.02.21.09; Fri, 04 Jan 2019 02:21:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727780AbfADI4F convert rfc822-to-8bit (ORCPT + 99 others); Fri, 4 Jan 2019 03:56:05 -0500 Received: from mx01.hxt-semitech.com ([223.203.96.7]:46675 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727039AbfADI4E (ORCPT ); Fri, 4 Jan 2019 03:56:04 -0500 X-ASG-Debug-ID: 1546592159-093b7e2d8806ba0001-xx1T2L Received: from HXTBJIDCEMVIW02.hxtcorp.net ([10.128.0.15]) by barracuda.hxt-semitech.com with ESMTP id 898rFEhDEaL4TxcG (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Fri, 04 Jan 2019 16:55:59 +0800 (CST) X-Barracuda-Envelope-From: xiaoting.liu@hxt-semitech.com Received: from openbmc001.localdomain (10.5.21.169) by HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 4 Jan 2019 16:55:55 +0800 From: Xiaoting Liu To: , CC: , , , Xiaoting Liu , Shunyong Yang Subject: [PATCH 1/4] pmbus: associate PMBUS_SKIP_STATUS_CHECK with driver_data Date: Fri, 4 Jan 2019 16:55:51 +0800 X-ASG-Orig-Subj: [PATCH 1/4] pmbus: associate PMBUS_SKIP_STATUS_CHECK with driver_data Message-ID: <680b4d5659971cc4f6e1a6878837c2ce49962a7c.1546591275.git.xiaoting.liu@hxt-semitech.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.5.21.169] X-ClientProxiedBy: HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) To HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) Content-Transfer-Encoding: 8BIT X-Barracuda-Connect: UNKNOWN[10.128.0.15] X-Barracuda-Start-Time: 1546592159 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA384 X-Barracuda-URL: https://192.168.50.101:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at hxt-semitech.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: INNOCENT GLOBAL 0.4997 1.0000 0.0000 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.65068 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Current code compares device name with name in i2c_device_id to decide whether PMBUS_SKIP_STATUS_CHECK should be set in pmbus_platform_data, which makes adding new devices with PMBUS_SKIP_STATUS_CHECK should also modify code in pmbus_probe(). This patch adds pmbus_device_info to save pages and flags. Its pointer is put in driver_data of i2c_device_id, which makes adding new device more straightforward. Signed-off-by: Shunyong Yang Signed-off-by: Xiaoting Liu --- drivers/hwmon/pmbus/pmbus.c | 54 +++++++++++++++++++++++++++------------------ include/linux/pmbus.h | 5 +++++ 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c index 7688dab32f6e..aa4cf9636e99 100644 --- a/drivers/hwmon/pmbus/pmbus.c +++ b/drivers/hwmon/pmbus/pmbus.c @@ -172,13 +172,15 @@ static int pmbus_probe(struct i2c_client *client, struct pmbus_driver_info *info; struct pmbus_platform_data *pdata = NULL; struct device *dev = &client->dev; + struct pmbus_device_info *device_info; info = devm_kzalloc(dev, sizeof(struct pmbus_driver_info), GFP_KERNEL); if (!info) return -ENOMEM; - if (!strcmp(id->name, "dps460") || !strcmp(id->name, "dps800") || - !strcmp(id->name, "sgd009")) { + device_info = (struct pmbus_device_info *)id->driver_data; + + if (device_info->flags & PMBUS_SKIP_STATUS_CHECK) { pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data), GFP_KERNEL); if (!pdata) @@ -187,36 +189,44 @@ static int pmbus_probe(struct i2c_client *client, pdata->flags = PMBUS_SKIP_STATUS_CHECK; } - info->pages = id->driver_data; + info->pages = device_info->pages; info->identify = pmbus_identify; dev->platform_data = pdata; return pmbus_do_probe(client, id, info); } +static const struct pmbus_device_info default_pmbus_info = {1, 0}; +static const struct pmbus_device_info dps460_pmbus_info = { + 1, PMBUS_SKIP_STATUS_CHECK}; +static const struct pmbus_device_info dps800_pmbus_info = { + 1, PMBUS_SKIP_STATUS_CHECK}; +static const struct pmbus_device_info sgd009_pmbus_info = { + 1, PMBUS_SKIP_STATUS_CHECK}; +static const struct pmbus_device_info pmbus_info = {0, 0}; /* * Use driver_data to set the number of pages supported by the chip. */ static const struct i2c_device_id pmbus_id[] = { - {"adp4000", 1}, - {"bmr453", 1}, - {"bmr454", 1}, - {"dps460", 1}, - {"dps800", 1}, - {"mdt040", 1}, - {"ncp4200", 1}, - {"ncp4208", 1}, - {"pdt003", 1}, - {"pdt006", 1}, - {"pdt012", 1}, - {"pmbus", 0}, - {"sgd009", 1}, - {"tps40400", 1}, - {"tps544b20", 1}, - {"tps544b25", 1}, - {"tps544c20", 1}, - {"tps544c25", 1}, - {"udt020", 1}, + {"adp4000", (kernel_ulong_t)&default_pmbus_info}, + {"bmr453", (kernel_ulong_t)&default_pmbus_info}, + {"bmr454", (kernel_ulong_t)&default_pmbus_info}, + {"dps460", (kernel_ulong_t)&dps460_pmbus_info}, + {"dps800", (kernel_ulong_t)&dps800_pmbus_info}, + {"mdt040", (kernel_ulong_t)&default_pmbus_info}, + {"ncp4200", (kernel_ulong_t)&default_pmbus_info}, + {"ncp4208", (kernel_ulong_t)&default_pmbus_info}, + {"pdt003", (kernel_ulong_t)&default_pmbus_info}, + {"pdt006", (kernel_ulong_t)&default_pmbus_info}, + {"pdt012", (kernel_ulong_t)&default_pmbus_info}, + {"pmbus", (kernel_ulong_t)&pmbus_info}, + {"sgd009", (kernel_ulong_t)&sgd009_pmbus_info}, + {"tps40400", (kernel_ulong_t)&default_pmbus_info}, + {"tps544b20", (kernel_ulong_t)&default_pmbus_info}, + {"tps544b25", (kernel_ulong_t)&default_pmbus_info}, + {"tps544c20", (kernel_ulong_t)&default_pmbus_info}, + {"tps544c25", (kernel_ulong_t)&default_pmbus_info}, + {"udt020", (kernel_ulong_t)&default_pmbus_info}, {} }; diff --git a/include/linux/pmbus.h b/include/linux/pmbus.h index ee3c2aba2a8e..3c05edad7666 100644 --- a/include/linux/pmbus.h +++ b/include/linux/pmbus.h @@ -46,4 +46,9 @@ struct pmbus_platform_data { struct regulator_init_data *reg_init_data; }; +struct pmbus_device_info { + int pages; + u32 flags; +}; + #endif /* _PMBUS_H_ */ -- 1.8.3.1 This email is intended only for the named addressee. It may contain information that is confidential/private, legally privileged, or copyright-protected, and you should handle it accordingly. If you are not the intended recipient, you do not have legal rights to retain, copy, or distribute this email or its contents, and should promptly delete the email and all electronic copies in your system; do not retain copies in any media. If you have received this email in error, please notify the sender promptly. Thank you.