Re: [PATCH 10/10] i2c: i801: Improve handling platform data for tco device
From: Heiner Kallweit <hkallweit1@gmail.com>
Date: 2021-08-05 20:06:10
On 05.08.2021 20:32, Jean Delvare wrote:
On Sun, 01 Aug 2021 16:24:30 +0200, Heiner Kallweit wrote:quoted
The platform data structures are used in the respective i801_add_tco functions only. Therefore we can make the definitions local to these functions. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> --- drivers/i2c/busses/i2c-i801.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 1ca92a1e0..64217479a 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c@@ -1464,15 +1464,14 @@ static inline unsigned int i801_get_adapter_class(struct i801_priv *priv) } #endif -static const struct itco_wdt_platform_data spt_tco_platform_data = { - .name = "Intel PCH", - .version = 4, -}; - static struct platform_device * i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev, struct resource *tco_res) { + static const struct itco_wdt_platform_data pldata = { + .name = "Intel PCH", + .version = 4, + }; static DEFINE_MUTEX(p2sb_mutex); struct resource *res; unsigned int devfn;@@ -1516,22 +1515,20 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev, res->flags = IORESOURCE_MEM; return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, - tco_res, 2, &spt_tco_platform_data, - sizeof(spt_tco_platform_data)); + tco_res, 2, &pldata, sizeof(pldata)); } -static const struct itco_wdt_platform_data cnl_tco_platform_data = { - .name = "Intel PCH", - .version = 6, -}; - static struct platform_device * i801_add_tco_cnl(struct i801_priv *priv, struct pci_dev *pci_dev, struct resource *tco_res) { - return platform_device_register_resndata(&pci_dev->dev, - "iTCO_wdt", -1, tco_res, 1, &cnl_tco_platform_data, - sizeof(cnl_tco_platform_data)); + static const struct itco_wdt_platform_data pldata = { + .name = "Intel PCH", + .version = 6, + }; + + return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, + tco_res, 1, &pldata, sizeof(pldata)); } static void i801_add_tco(struct i801_priv *priv)I don't really care either way, to be honest. But fine with me.
To explain the motivation: I try to restrict visibility of a variable as much as possible. This reduces risk of misuse / mistakes / name collisions.
Reviewed-by: Jean Delvare <redacted>