Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp786048imu; Tue, 20 Nov 2018 07:00:20 -0800 (PST) X-Google-Smtp-Source: AJdET5e9T9yRh4VDLJor3HA6mbiuJYLyASMMwJ9N4IeoytlzLuiJp29ucbZRXzadCMD7hn7i3boO X-Received: by 2002:aa7:8248:: with SMTP id e8-v6mr1451387pfn.164.1542726020325; Tue, 20 Nov 2018 07:00:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542726020; cv=none; d=google.com; s=arc-20160816; b=Bb1NzMM2moCkrooqFzRm0hGCPSP8HY5s2DYcXlaPHbnCk3qcwUeQ/flQWcDdxiA4pE eZTaRbWn66wEVIGMTdzzBN5mS9XyYkGxYkUEVtbriNO3wCDtHDPcIqWfpKfEH6WIJxiK F1BKX7iBxLW30UDMgYTAZ4D6skkfBjwS0aTVAen0Lpt1cKFSmdxTzIKk69g8FEPFVvDa YuGvsy6AFKNWjovxG2kfyAqIvah1nCp/K6gJxq2h/XyYXzfIWdMpN4Y0M95QG1/9cYyA N2nv2I7FD24akLIQz+WUrNc9yD2qECYbT4PeTcKgD3JaHxHF90RL2KcfmYsDMWFEBHL1 mitA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=8bSEho/Ncj9/bjfG+FXyeTfwpHs3qPMVz/EYLK5gOds=; b=TeJKmAts0YzH5TYhpaNmQ1YLb8PoEznYCHsSavU2+n5eWic+uqSewTTYDwcO8tPgkD G/BpMzDxRvLec3d2Wjg0/w6PIZPBX+FTURE9eWwt5lWNqM/oSLJ9y579+HpY8VTNNR/q U+qsv7FLFxZyjA4g/eXoTxK+9Mq080LixgH/kqYiQnwWmZBWnVSgzo7FCHgS3ohSCLhM xjHwSPq8Mvpt3jtB5CgjwQ43Rmi+mr4lTyEDt2Ax6cXfmwIXf0y5SEG+nkCz2Bxlz9vX vIw8Np5L+TC3EyjHOnOgnTz9jJy0k6p+Omof989NxfffwNo+ZJTjx28fUBIPxOqKPTh+ E8RA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v23-v6si45183750pff.103.2018.11.20.07.00.05; Tue, 20 Nov 2018 07:00:20 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729064AbeKUAqF (ORCPT + 99 others); Tue, 20 Nov 2018 19:46:05 -0500 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:37858 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725995AbeKUAqE (ORCPT ); Tue, 20 Nov 2018 19:46:04 -0500 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id wAKEEHBi030453; Tue, 20 Nov 2018 08:16:35 -0600 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail1.cirrus.com (mail1.cirrus.com [141.131.3.20]) by mx0a-001ae601.pphosted.com with ESMTP id 2nth984dqk-1; Tue, 20 Nov 2018 08:16:34 -0600 Received: from EX17.ad.cirrus.com (unknown [172.20.9.81]) by mail1.cirrus.com (Postfix) with ESMTP id CEC07611E126; Tue, 20 Nov 2018 08:16:33 -0600 (CST) Received: from imbe.wolfsonmicro.main (198.61.95.81) by EX17.ad.cirrus.com (172.20.9.81) with Microsoft SMTP Server id 14.3.408.0; Tue, 20 Nov 2018 14:16:32 +0000 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by imbe.wolfsonmicro.main (8.14.4/8.14.4) with ESMTP id wAKEGVqu000703; Tue, 20 Nov 2018 14:16:32 GMT From: Charles Keepax To: , , , , , CC: , , , , , , Subject: [PATCH v5 1/8] regulator: lochnagar: Move driver to binding from DT Date: Tue, 20 Nov 2018 14:16:24 +0000 Message-ID: <20181120141631.18949-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=981 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811200128 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Based on review comments on the MFD driver, move the child drivers for the Lochnagar MFD over to binding through device tree. Signed-off-by: Charles Keepax --- Changes since v4: - Split out regulator binding for each regulator Thanks, Charles drivers/regulator/lochnagar-regulator.c | 48 +++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/lochnagar-regulator.c b/drivers/regulator/lochnagar-regulator.c index 182198246479..5a89e6d4b9a6 100644 --- a/drivers/regulator/lochnagar-regulator.c +++ b/drivers/regulator/lochnagar-regulator.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -214,28 +215,52 @@ static const struct regulator_desc lochnagar_regulators[] = { }, }; +static const struct of_device_id lochnagar_of_match[] = { + { + .compatible = "cirrus,lochnagar2-micvdd", + .data = &lochnagar_regulators[LOCHNAGAR_MICVDD], + }, + { + .compatible = "cirrus,lochnagar2-mic1vdd", + .data = &lochnagar_regulators[LOCHNAGAR_MIC1VDD], + }, + { + .compatible = "cirrus,lochnagar2-mic2vdd", + .data = &lochnagar_regulators[LOCHNAGAR_MIC1VDD], + }, + { + .compatible = "cirrus,lochnagar2-vddcore", + .data = &lochnagar_regulators[LOCHNAGAR_VDDCORE], + }, + {}, +}; + static int lochnagar_regulator_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct lochnagar *lochnagar = dev_get_drvdata(dev->parent); struct regulator_config config = { }; + const struct of_device_id *of_id; + const struct regulator_desc *desc; struct regulator_dev *rdev; - int ret, i; + int ret; - config.dev = lochnagar->dev; + config.dev = dev; config.regmap = lochnagar->regmap; config.driver_data = lochnagar; - for (i = 0; i < ARRAY_SIZE(lochnagar_regulators); i++) { - const struct regulator_desc *desc = &lochnagar_regulators[i]; + of_id = of_match_device(lochnagar_of_match, dev); + if (!of_id) + return -EINVAL; - rdev = devm_regulator_register(dev, desc, &config); - if (IS_ERR(rdev)) { - ret = PTR_ERR(rdev); - dev_err(dev, "Failed to register %s regulator: %d\n", - desc->name, ret); - return ret; - } + desc = of_id->data; + + rdev = devm_regulator_register(dev, desc, &config); + if (IS_ERR(rdev)) { + ret = PTR_ERR(rdev); + dev_err(dev, "Failed to register %s regulator: %d\n", + desc->name, ret); + return ret; } return 0; @@ -244,6 +269,7 @@ static int lochnagar_regulator_probe(struct platform_device *pdev) static struct platform_driver lochnagar_regulator_driver = { .driver = { .name = "lochnagar-regulator", + .of_match_table = of_match_ptr(lochnagar_of_match), }, .probe = lochnagar_regulator_probe, -- 2.11.0