{"id":1213084,"url":"http://patchwork.ozlabs.org/api/patches/1213084/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/patch/9b532747ab61f00c943ca842ad9887691784a1ca.1576745635.git.matti.vaittinen@fi.rohmeurope.com/","project":{"id":42,"url":"http://patchwork.ozlabs.org/api/projects/42/?format=json","name":"Linux GPIO development","link_name":"linux-gpio","list_id":"linux-gpio.vger.kernel.org","list_email":"linux-gpio@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<9b532747ab61f00c943ca842ad9887691784a1ca.1576745635.git.matti.vaittinen@fi.rohmeurope.com>","list_archive_url":null,"date":"2019-12-19T09:46:40","name":"[v7,03/12] mfd: rohm PMICs - use platform_device_id to match MFD sub-devices","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7b8545e82de732e98060305d045fbefa7d6d78e3","submitter":{"id":74146,"url":"http://patchwork.ozlabs.org/api/people/74146/?format=json","name":"Matti Vaittinen","email":"matti.vaittinen@fi.rohmeurope.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-gpio/patch/9b532747ab61f00c943ca842ad9887691784a1ca.1576745635.git.matti.vaittinen@fi.rohmeurope.com/mbox/","series":[{"id":149534,"url":"http://patchwork.ozlabs.org/api/series/149534/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/list/?series=149534","date":"2019-12-19T09:44:08","name":"Support ROHM BD71828 PMIC","version":7,"mbox":"http://patchwork.ozlabs.org/series/149534/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/1213084/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/1213084/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linux-gpio-owner@vger.kernel.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org; spf=none (no SPF record)\n\tsmtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67;\n\thelo=vger.kernel.org;\n\tenvelope-from=linux-gpio-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dmarc=none (p=none dis=none)\n\theader.from=fi.rohmeurope.com"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 47dn8W6tf3z9sPc\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 19 Dec 2019 20:46:51 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1726652AbfLSJqv (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tThu, 19 Dec 2019 04:46:51 -0500","from mail-lf1-f67.google.com ([209.85.167.67]:44390 \"EHLO\n\tmail-lf1-f67.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1726618AbfLSJqv (ORCPT\n\t<rfc822; linux-gpio@vger.kernel.org>); Thu, 19 Dec 2019 04:46:51 -0500","by mail-lf1-f67.google.com with SMTP id v201so3846021lfa.11;\n\tThu, 19 Dec 2019 01:46:48 -0800 (PST)","from localhost.localdomain\n\t(dyt4gctb359myxd0pkwmt-4.rev.dnainternet.fi.\n\t[2001:14bb:430:5140:37cf:5409:8fcc:4495])\n\tby smtp.gmail.com with ESMTPSA id\n\tl8sm2506963ljj.96.2019.12.19.01.46.46\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 19 Dec 2019 01:46:47 -0800 (PST)"],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to:user-agent;\n\tbh=KCIurZNyCLNzhWqRV+qgCh1YDlQz1es+bh2U9/FnzhM=;\n\tb=lTdlxEjbBxgejRPjNUl64XlU0893Akjf49dNp/iRI/XSbWydqwPH+pfYJKKhnSFf0p\n\tQeNDwOIF01/3zRvk5NaGXjJqcWRsTDdCYn1Pcf0npoL4FSTIzZZH/eAxQxm8krKoVfhC\n\tj2JW4up4XvSpRCk58V9SQMGtasW1fwuBGjG0EX1gxs7EHkiW7Q7tyEgWTT22GAH2XP7U\n\tUBcFAg/Lf/YECYdL9Kc7AabWqCHt1qZZcr1LSKIW1VdWaT2L12PhULuT03h0/WAqmq9s\n\t9gJyOmfn0t4hPB14C7hIL2JxSkErgMFTrMP9l2O9utT0mfb6wikaoi9b++/Okzyw9FDN\n\tS3CA==","X-Gm-Message-State":"APjAAAWhmmngRk/DMzIeiZb35+okeVZDBY7Rp9L4QUEOjLTzGMtiRKcb\n\tu/2ffZsKtm+ybOP1GiglO10=","X-Google-Smtp-Source":"APXvYqz1t9Hze1CAtwarkmcuijz3kDAPGXga7M5fxCx/UuJGqqzGRE2tbACnOxlMgNN+xqxWM0oALw==","X-Received":"by 2002:a19:ae04:: with SMTP id f4mr4810628lfc.64.1576748808072; \n\tThu, 19 Dec 2019 01:46:48 -0800 (PST)","Date":"Thu, 19 Dec 2019 11:46:40 +0200","From":"Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>","To":"matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com","Cc":"Jacek Anaszewski <jacek.anaszewski@gmail.com>,\n\tPavel Machek <pavel@ucw.cz>, Dan Murphy <dmurphy@ti.com>,\n\tRob Herring <robh+dt@kernel.org>, Mark Rutland <mark.rutland@arm.com>,\n\tLee Jones <lee.jones@linaro.org>,\n\tMichael Turquette <mturquette@baylibre.com>,\n\tStephen Boyd <sboyd@kernel.org>,\n\tLinus Walleij <linus.walleij@linaro.org>,\n\tBartosz Golaszewski <bgolaszewski@baylibre.com>,\n\tLiam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>,\n\tAlessandro Zummo <a.zummo@towertech.it>,\n\tAlexandre Belloni <alexandre.belloni@bootlin.com>,\n\tlinux-leds@vger.kernel.org, devicetree@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,\n\tlinux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org","Subject":"[PATCH v7 03/12] mfd: rohm PMICs - use platform_device_id to match\n\tMFD sub-devices","Message-ID":"<9b532747ab61f00c943ca842ad9887691784a1ca.1576745635.git.matti.vaittinen@fi.rohmeurope.com>","References":"<cover.1576745635.git.matti.vaittinen@fi.rohmeurope.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<cover.1576745635.git.matti.vaittinen@fi.rohmeurope.com>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Sender":"linux-gpio-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-gpio.vger.kernel.org>","X-Mailing-List":"linux-gpio@vger.kernel.org"},"content":"Thanks to Stephen Boyd I today learned we can use platform_device_id\nto do device and module matching for MFD sub-devices!\n\nDo device matching using the platform_device_id instead of using\nexplicit module_aliases to load modules and custom parent-data field\nto do module loading and sub-device matching.\n\nSigned-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>\nAcked-for-MFD-by: Lee Jones <lee.jones@linaro.org>\n---\n\nNo changes since v6\n\n drivers/clk/clk-bd718x7.c             | 12 ++++++++-\n drivers/mfd/rohm-bd70528.c            |  3 +--\n drivers/mfd/rohm-bd718x7.c            | 39 ++++++++++++++++++++++-----\n drivers/regulator/bd718x7-regulator.c | 17 +++++++++---\n include/linux/mfd/rohm-generic.h      |  3 +--\n 5 files changed, 58 insertions(+), 16 deletions(-)","diff":"diff --git a/drivers/clk/clk-bd718x7.c b/drivers/clk/clk-bd718x7.c\nindex 00926c587390..33699ee1bdf3 100644\n--- a/drivers/clk/clk-bd718x7.c\n+++ b/drivers/clk/clk-bd718x7.c\n@@ -74,6 +74,7 @@ static int bd71837_clk_probe(struct platform_device *pdev)\n \t\t.name = \"bd718xx-32k-out\",\n \t\t.ops = &bd71837_clk_ops,\n \t};\n+\tenum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data;\n \n \tc = devm_kzalloc(&pdev->dev, sizeof(*c), GFP_KERNEL);\n \tif (!c)\n@@ -87,7 +88,7 @@ static int bd71837_clk_probe(struct platform_device *pdev)\n \t\tdev_err(&pdev->dev, \"No parent clk found\\n\");\n \t\treturn -EINVAL;\n \t}\n-\tswitch (mfd->chip_type) {\n+\tswitch (chip) {\n \tcase ROHM_CHIP_TYPE_BD71837:\n \tcase ROHM_CHIP_TYPE_BD71847:\n \t\tc->reg = BD718XX_REG_OUT32K;\n@@ -121,11 +122,20 @@ static int bd71837_clk_probe(struct platform_device *pdev)\n \treturn rval;\n }\n \n+static const struct platform_device_id bd718x7_clk_id[] = {\n+\t{ \"bd71837-clk\", ROHM_CHIP_TYPE_BD71837 },\n+\t{ \"bd71847-clk\", ROHM_CHIP_TYPE_BD71847 },\n+\t{ \"bd70528-clk\", ROHM_CHIP_TYPE_BD70528 },\n+\t{ },\n+};\n+MODULE_DEVICE_TABLE(platform, bd718x7_clk_id);\n+\n static struct platform_driver bd71837_clk = {\n \t.driver = {\n \t\t.name = \"bd718xx-clk\",\n \t},\n \t.probe = bd71837_clk_probe,\n+\t.id_table = bd718x7_clk_id,\n };\n \n module_platform_driver(bd71837_clk);\ndiff --git a/drivers/mfd/rohm-bd70528.c b/drivers/mfd/rohm-bd70528.c\nindex ef6786fd3b00..5c44d3b77b3e 100644\n--- a/drivers/mfd/rohm-bd70528.c\n+++ b/drivers/mfd/rohm-bd70528.c\n@@ -48,7 +48,7 @@ static struct mfd_cell bd70528_mfd_cells[] = {\n \t * We use BD71837 driver to drive the clock block. Only differences to\n \t * BD70528 clock gate are the register address and mask.\n \t */\n-\t{ .name = \"bd718xx-clk\", },\n+\t{ .name = \"bd70528-clk\", },\n \t{ .name = \"bd70528-wdt\", },\n \t{\n \t\t.name = \"bd70528-power\",\n@@ -236,7 +236,6 @@ static int bd70528_i2c_probe(struct i2c_client *i2c,\n \n \tdev_set_drvdata(&i2c->dev, &bd70528->chip);\n \n-\tbd70528->chip.chip_type = ROHM_CHIP_TYPE_BD70528;\n \tbd70528->chip.regmap = devm_regmap_init_i2c(i2c, &bd70528_regmap);\n \tif (IS_ERR(bd70528->chip.regmap)) {\n \t\tdev_err(&i2c->dev, \"Failed to initialize Regmap\\n\");\ndiff --git a/drivers/mfd/rohm-bd718x7.c b/drivers/mfd/rohm-bd718x7.c\nindex 85e7f5133365..bb86ec829079 100644\n--- a/drivers/mfd/rohm-bd718x7.c\n+++ b/drivers/mfd/rohm-bd718x7.c\n@@ -30,14 +30,24 @@ static struct gpio_keys_platform_data bd718xx_powerkey_data = {\n \t.name = \"bd718xx-pwrkey\",\n };\n \n-static struct mfd_cell bd718xx_mfd_cells[] = {\n+static struct mfd_cell bd71837_mfd_cells[] = {\n \t{\n \t\t.name = \"gpio-keys\",\n \t\t.platform_data = &bd718xx_powerkey_data,\n \t\t.pdata_size = sizeof(bd718xx_powerkey_data),\n \t},\n-\t{ .name = \"bd718xx-clk\", },\n-\t{ .name = \"bd718xx-pmic\", },\n+\t{ .name = \"bd71837-clk\", },\n+\t{ .name = \"bd71837-pmic\", },\n+};\n+\n+static struct mfd_cell bd71847_mfd_cells[] = {\n+\t{\n+\t\t.name = \"gpio-keys\",\n+\t\t.platform_data = &bd718xx_powerkey_data,\n+\t\t.pdata_size = sizeof(bd718xx_powerkey_data),\n+\t},\n+\t{ .name = \"bd71847-clk\", },\n+\t{ .name = \"bd71847-pmic\", },\n };\n \n static const struct regmap_irq bd718xx_irqs[] = {\n@@ -124,6 +134,9 @@ static int bd718xx_i2c_probe(struct i2c_client *i2c,\n {\n \tstruct bd718xx *bd718xx;\n \tint ret;\n+\tunsigned int chip_type;\n+\tstruct mfd_cell *mfd;\n+\tint cells;\n \n \tif (!i2c->irq) {\n \t\tdev_err(&i2c->dev, \"No IRQ configured\\n\");\n@@ -136,8 +149,21 @@ static int bd718xx_i2c_probe(struct i2c_client *i2c,\n \t\treturn -ENOMEM;\n \n \tbd718xx->chip_irq = i2c->irq;\n-\tbd718xx->chip.chip_type = (unsigned int)(uintptr_t)\n-\t\t\t\tof_device_get_match_data(&i2c->dev);\n+\tchip_type = (unsigned int)(uintptr_t)\n+\t\t    of_device_get_match_data(&i2c->dev);\n+\tswitch (chip_type) {\n+\tcase ROHM_CHIP_TYPE_BD71837:\n+\t\tmfd = bd71837_mfd_cells;\n+\t\tcells = ARRAY_SIZE(bd71837_mfd_cells);\n+\t\tbreak;\n+\tcase ROHM_CHIP_TYPE_BD71847:\n+\t\tmfd = bd71847_mfd_cells;\n+\t\tcells = ARRAY_SIZE(bd71847_mfd_cells);\n+\t\tbreak;\n+\tdefault:\n+\t\tdev_err(&i2c->dev, \"Unknown device type\");\n+\t\treturn -EINVAL;\n+\t}\n \tbd718xx->chip.dev = &i2c->dev;\n \tdev_set_drvdata(&i2c->dev, bd718xx);\n \n@@ -170,8 +196,7 @@ static int bd718xx_i2c_probe(struct i2c_client *i2c,\n \tbutton.irq = ret;\n \n \tret = devm_mfd_add_devices(bd718xx->chip.dev, PLATFORM_DEVID_AUTO,\n-\t\t\t\t   bd718xx_mfd_cells,\n-\t\t\t\t   ARRAY_SIZE(bd718xx_mfd_cells), NULL, 0,\n+\t\t\t\t   mfd, cells, NULL, 0,\n \t\t\t\t   regmap_irq_get_domain(bd718xx->irq_data));\n \tif (ret)\n \t\tdev_err(&i2c->dev, \"Failed to create subdevices\\n\");\ndiff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c\nindex 13a43eee2e46..6beaf867d9cb 100644\n--- a/drivers/regulator/bd718x7-regulator.c\n+++ b/drivers/regulator/bd718x7-regulator.c\n@@ -1164,6 +1164,7 @@ static int bd718xx_probe(struct platform_device *pdev)\n \n \tint i, j, err;\n \tbool use_snvs;\n+\tenum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data;\n \n \tmfd = dev_get_drvdata(pdev->dev.parent);\n \tif (!mfd) {\n@@ -1172,8 +1173,8 @@ static int bd718xx_probe(struct platform_device *pdev)\n \t\tgoto err;\n \t}\n \n-\tif (mfd->chip.chip_type >= ROHM_CHIP_TYPE_AMOUNT ||\n-\t    !pmic_regulators[mfd->chip.chip_type].r_datas) {\n+\tif (chip >= ROHM_CHIP_TYPE_AMOUNT || chip < 0 ||\n+\t    !pmic_regulators[chip].r_datas) {\n \t\tdev_err(&pdev->dev, \"Unsupported chip type\\n\");\n \t\terr = -EINVAL;\n \t\tgoto err;\n@@ -1215,13 +1216,13 @@ static int bd718xx_probe(struct platform_device *pdev)\n \t\t}\n \t}\n \n-\tfor (i = 0; i < pmic_regulators[mfd->chip.chip_type].r_amount; i++) {\n+\tfor (i = 0; i < pmic_regulators[chip].r_amount; i++) {\n \n \t\tconst struct regulator_desc *desc;\n \t\tstruct regulator_dev *rdev;\n \t\tconst struct bd718xx_regulator_data *r;\n \n-\t\tr = &pmic_regulators[mfd->chip.chip_type].r_datas[i];\n+\t\tr = &pmic_regulators[chip].r_datas[i];\n \t\tdesc = &r->desc;\n \n \t\tconfig.dev = pdev->dev.parent;\n@@ -1281,11 +1282,19 @@ static int bd718xx_probe(struct platform_device *pdev)\n \treturn err;\n }\n \n+static const struct platform_device_id bd718x7_pmic_id[] = {\n+\t{ \"bd71837-pmic\", ROHM_CHIP_TYPE_BD71837 },\n+\t{ \"bd71847-pmic\", ROHM_CHIP_TYPE_BD71847 },\n+\t{ },\n+};\n+MODULE_DEVICE_TABLE(platform, bd718x7_pmic_id);\n+\n static struct platform_driver bd718xx_regulator = {\n \t.driver = {\n \t\t.name = \"bd718xx-pmic\",\n \t},\n \t.probe = bd718xx_probe,\n+\t.id_table = bd718x7_pmic_id,\n };\n \n module_platform_driver(bd718xx_regulator);\ndiff --git a/include/linux/mfd/rohm-generic.h b/include/linux/mfd/rohm-generic.h\nindex bff15ac26f2c..922f88008232 100644\n--- a/include/linux/mfd/rohm-generic.h\n+++ b/include/linux/mfd/rohm-generic.h\n@@ -4,7 +4,7 @@\n #ifndef __LINUX_MFD_ROHM_H__\n #define __LINUX_MFD_ROHM_H__\n \n-enum {\n+enum rohm_chip_type {\n \tROHM_CHIP_TYPE_BD71837 = 0,\n \tROHM_CHIP_TYPE_BD71847,\n \tROHM_CHIP_TYPE_BD70528,\n@@ -12,7 +12,6 @@ enum {\n };\n \n struct rohm_regmap_dev {\n-\tunsigned int chip_type;\n \tstruct device *dev;\n \tstruct regmap *regmap;\n };\n","prefixes":["v7","03/12"]}