From: Russ Weight <russell.h.weight@intel.com>
To: "Xu Yilun" <yilun.xu@intel.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: <linux-fpga@vger.kernel.org>, Wu Hao <hao.wu@intel.com>,
Tom Rix <trix@redhat.com>, Moritz Fischer <mdf@kernel.org>,
Lee Jones <lee@kernel.org>,
Matthew Gerlach <matthew.gerlach@linux.intel.com>,
"Tianfei zhang" <tianfei.zhang@intel.com>,
Mark Brown <broonie@kernel.org>,
Greg KH <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 02/12] mfd: intel-m10-bmc: Create m10bmc_platform_info for type specific info
Date: Mon, 14 Nov 2022 17:17:06 -0800 [thread overview]
Message-ID: <30c62175-e96f-3911-8176-cac3d4928eb5@intel.com> (raw)
In-Reply-To: <Y3Gg29pGm4DwjOgI@yilunxu-OptiPlex-7050>
On 11/13/22 17:58, Xu Yilun wrote:
> On 2022-11-11 at 13:49:38 +0200, Ilpo Järvinen wrote:
>> On Fri, 11 Nov 2022, Xu Yilun wrote:
>>
>>> On 2022-11-08 at 16:42:55 +0200, Ilpo Järvinen wrote:
>>>> BMC type specific info is currently set by a switch/case block. The
>>>> size of this info is expected to grow as more dev types and features
>>>> are added which would have made the switch block bloaty.
>>>>
>>>> Store type specific info into struct and place them into .driver_data
>>>> instead because it makes things a bit cleaner.
>>>>
>>>> Reviewed-by: Russ Weight <russell.h.weight@intel.com>
>>>> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
>>>> ---
>>>> drivers/mfd/intel-m10-bmc.c | 50 +++++++++++++++++--------------
>>>> include/linux/mfd/intel-m10-bmc.h | 14 +++++++++
>>>> 2 files changed, 41 insertions(+), 23 deletions(-)
>>>>
>>>> diff --git a/drivers/mfd/intel-m10-bmc.c b/drivers/mfd/intel-m10-bmc.c
>>>> index ee167c5dcd29..762808906380 100644
>>>> --- a/drivers/mfd/intel-m10-bmc.c
>>>> +++ b/drivers/mfd/intel-m10-bmc.c
>>>> @@ -156,15 +156,17 @@ static int check_m10bmc_version(struct intel_m10bmc *ddata)
>>>> static int intel_m10_bmc_spi_probe(struct spi_device *spi)
>>>> {
>>>> const struct spi_device_id *id = spi_get_device_id(spi);
>>>> + const struct intel_m10bmc_platform_info *info;
>>>> struct device *dev = &spi->dev;
>>>> - struct mfd_cell *cells;
>>>> struct intel_m10bmc *ddata;
>>>> - int ret, n_cell;
>>>> + int ret;
>>>>
>>>> ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
>>>> if (!ddata)
>>>> return -ENOMEM;
>>>>
>>>> + info = (struct intel_m10bmc_platform_info *)id->driver_data;
>>>> + ddata->info = info;
>>> Where to use the ddata->info?
>> In patch 5/12 there are many these constructs:
>> const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map;
>>
>> Now that I look though, this particular line is altered by the split patch
>> 4/12 so it would be not strictly necessary to do it here. I'd prefer,
>> however, still to add it here even if it's technically not used until
>> after the split 5/12 patch because it very much logically belongs to this
>> change.
> It's good to me.
>
>>>> ddata->dev = dev;
>>>>
>>>> ddata->regmap =
>>>> @@ -183,24 +185,8 @@ static int intel_m10_bmc_spi_probe(struct spi_device *spi)
>>>> return ret;
>>>> }
>>>>
>>>> - switch (id->driver_data) {
>>>> - case M10_N3000:
>>>> - cells = m10bmc_pacn3000_subdevs;
>>>> - n_cell = ARRAY_SIZE(m10bmc_pacn3000_subdevs);
>>>> - break;
>>>> - case M10_D5005:
>>>> - cells = m10bmc_d5005_subdevs;
>>>> - n_cell = ARRAY_SIZE(m10bmc_d5005_subdevs);
>>>> - break;
>>>> - case M10_N5010:
>>>> - cells = m10bmc_n5010_subdevs;
>>>> - n_cell = ARRAY_SIZE(m10bmc_n5010_subdevs);
>>>> - break;
>>>> - default:
>>>> - return -ENODEV;
>>>> - }
>>>> -
>>>> - ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, cells, n_cell,
>>>> + ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO,
>>>> + info->cells, info->n_cells,
>>>> NULL, 0, NULL);
>>>> if (ret)
>>>> dev_err(dev, "Failed to register sub-devices: %d\n", ret);
>>>> @@ -208,10 +194,28 @@ static int intel_m10_bmc_spi_probe(struct spi_device *spi)
>>>> return ret;
>>>> }
>>>>
>>>> +static const struct intel_m10bmc_platform_info m10bmc_m10_n3000 = {
>>>> + .type = M10_N3000,
>>> Is the type enum still useful? Found no usage.
>> There's no use within context of this patch series. However, I think there
>> might have been something depending on it in the changes that are not part
>> of this series so I left it in place for now.
> I'm not sure how it would be used later. This patch is to eliminate the
> "switch (board type) case" block, but similar code is still to be added
> later?
Unfortunately, these will be needed later. Consider the following (future)
function that has to account for a field that was moved from one register
to another:
static int
m10bmc_sec_status(struct m10bmc_sec *sec, u32 *status)
{
u32 reg_offset, reg_value;
int ret;
reg_offset = (sec->type == N6000BMC_SEC) ?
auth_result_reg(sec->m10bmc) : doorbell_reg(sec->m10bmc);
ret = m10bmc_sys_read(sec->m10bmc, reg_offset, ®_value);
if (ret)
return ret;
*status = rsu_stat(reg_value);
return 0;
}
With this patch-set, most conditionals are removed, but there will still
be some cases where it is needed. If you prefer, we could wait and add
the type in when we are ready to use it.
- Russ
>
> Thanks,
> Yilun
next prev parent reply other threads:[~2022-11-15 1:19 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 14:42 [PATCH 00/12] intel-m10-bmc: Split BMC to core and SPI parts & add PMCI+N6000 support Ilpo Järvinen
2022-11-08 14:42 ` [PATCH 01/12] mfd: intel-m10-bmc: Move m10bmc_type to header Ilpo Järvinen
2022-11-08 14:42 ` [PATCH 02/12] mfd: intel-m10-bmc: Create m10bmc_platform_info for type specific info Ilpo Järvinen
2022-11-11 10:12 ` Xu Yilun
2022-11-11 11:49 ` Ilpo Järvinen
2022-11-14 1:58 ` Xu Yilun
2022-11-15 1:17 ` Russ Weight [this message]
2022-11-15 1:55 ` Xu Yilun
2022-11-15 8:56 ` Ilpo Järvinen
2022-11-08 14:42 ` [PATCH 03/12] mfd: intel-m10-bmc: Rename the local variables Ilpo Järvinen
2022-11-08 14:42 ` [PATCH 04/12] mfd: intel-m10-bmc: Split into core and spi specific parts Ilpo Järvinen
2022-11-08 17:05 ` Guenter Roeck
2022-11-08 14:42 ` [PATCH 05/12] mfd: intel-m10-bmc: Support multiple CSR register layouts Ilpo Järvinen
2022-11-08 14:42 ` [PATCH 06/12] fpga: intel-m10-bmc: Add flash ops for sec update Ilpo Järvinen
2022-11-11 8:41 ` Xu Yilun
2022-11-11 13:32 ` Ilpo Järvinen
2022-11-14 7:31 ` Xu Yilun
2022-11-15 1:43 ` Russ Weight
2022-11-15 2:55 ` Xu Yilun
2022-11-08 14:43 ` [PATCH 07/12] mfd: intel-m10-bmc: Downscope SPI related defines Ilpo Järvinen
2022-11-11 9:29 ` Xu Yilun
2022-11-11 11:20 ` Ilpo Järvinen
2022-11-14 7:33 ` Xu Yilun
2022-11-08 14:43 ` [PATCH 08/12] regmap: indirect: Add indirect regmap support Ilpo Järvinen
2022-11-14 20:38 ` Marco Pagani
2022-11-16 17:00 ` matthew.gerlach
2022-11-08 14:43 ` [PATCH 09/12] intel-m10-bmc: Add regmap_indirect_cfg for Intel FPGA IPs Ilpo Järvinen
2022-11-08 18:29 ` matthew.gerlach
2022-11-08 14:43 ` [PATCH 10/12] mfd: intel-m10-bmc: Add PMCI driver Ilpo Järvinen
2022-11-11 10:04 ` Xu Yilun
2022-11-11 13:16 ` Ilpo Järvinen
2022-11-14 2:18 ` Xu Yilun
2022-11-14 12:25 ` Zhang, Tianfei
2022-11-08 14:43 ` [PATCH 11/12] fpga: m10bmc-sec: Add support for N6000 Ilpo Järvinen
2022-11-08 14:43 ` [PATCH 12/12] mfd: intel-m10-bmc: Change MODULE_LICENSE() to GPL Ilpo Järvinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=30c62175-e96f-3911-8176-cac3d4928eb5@intel.com \
--to=russell.h.weight@intel.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hao.wu@intel.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=lee@kernel.org \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.gerlach@linux.intel.com \
--cc=mdf@kernel.org \
--cc=tianfei.zhang@intel.com \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.