Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: mcp251x: get rid of legacy platform data

Instead of using legacy platform data, switch to use device properties.
For clock frequency we are using well established clock-frequency property.

Users, two for now, are also converted here.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Andy Shevchenko and committed by
Marc Kleine-Budde
50ec8812 371fd7ba

+14 -35
+5 -4
arch/arm/mach-pxa/icontrol.c
··· 12 12 13 13 #include <linux/irq.h> 14 14 #include <linux/platform_device.h> 15 + #include <linux/property.h> 15 16 #include <linux/gpio.h> 16 17 17 18 #include <asm/mach-types.h> ··· 23 22 24 23 #include <linux/spi/spi.h> 25 24 #include <linux/spi/pxa2xx_spi.h> 26 - #include <linux/can/platform/mcp251x.h> 27 25 #include <linux/regulator/machine.h> 28 26 29 27 #include "generic.h" ··· 69 69 .gpio_cs = ICONTROL_MCP251x_nCS4 70 70 }; 71 71 72 - static struct mcp251x_platform_data mcp251x_info = { 73 - .oscillator_frequency = 16E6, 72 + static const struct property_entry mcp251x_properties[] = { 73 + PROPERTY_ENTRY_U32("clock-frequency", 16000000), 74 + {} 74 75 }; 75 76 76 77 static struct spi_board_info mcp251x_board_info[] = { ··· 80 79 .max_speed_hz = 6500000, 81 80 .bus_num = 3, 82 81 .chip_select = 0, 83 - .platform_data = &mcp251x_info, 82 + .properties = mcp251x_properties, 84 83 .controller_data = &mcp251x_chip_info1, 85 84 .irq = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1) 86 85 },
+5 -4
arch/arm/mach-pxa/zeus.c
··· 13 13 #include <linux/leds.h> 14 14 #include <linux/irq.h> 15 15 #include <linux/pm.h> 16 + #include <linux/property.h> 16 17 #include <linux/gpio.h> 17 18 #include <linux/gpio/machine.h> 18 19 #include <linux/serial_8250.h> ··· 28 27 #include <linux/platform_data/i2c-pxa.h> 29 28 #include <linux/platform_data/pca953x.h> 30 29 #include <linux/apm-emulation.h> 31 - #include <linux/can/platform/mcp251x.h> 32 30 #include <linux/regulator/fixed.h> 33 31 #include <linux/regulator/machine.h> 34 32 ··· 428 428 }, 429 429 }; 430 430 431 - static struct mcp251x_platform_data zeus_mcp2515_pdata = { 432 - .oscillator_frequency = 16*1000*1000, 431 + static const struct property_entry mcp251x_properties[] = { 432 + PROPERTY_ENTRY_U32("clock-frequency", 16000000), 433 + {} 433 434 }; 434 435 435 436 static struct spi_board_info zeus_spi_board_info[] = { 436 437 [0] = { 437 438 .modalias = "mcp2515", 438 - .platform_data = &zeus_mcp2515_pdata, 439 + .properties = mcp251x_properties, 439 440 .irq = PXA_GPIO_TO_IRQ(ZEUS_CAN_GPIO), 440 441 .max_speed_hz = 1*1000*1000, 441 442 .bus_num = 3,
+4 -5
drivers/net/can/spi/mcp251x.c
··· 22 22 #include <linux/can/core.h> 23 23 #include <linux/can/dev.h> 24 24 #include <linux/can/led.h> 25 - #include <linux/can/platform/mcp251x.h> 26 25 #include <linux/clk.h> 27 26 #include <linux/completion.h> 28 27 #include <linux/delay.h> ··· 985 986 static int mcp251x_can_probe(struct spi_device *spi) 986 987 { 987 988 const void *match = device_get_match_data(&spi->dev); 988 - struct mcp251x_platform_data *pdata = dev_get_platdata(&spi->dev); 989 989 struct net_device *net; 990 990 struct mcp251x_priv *priv; 991 991 struct clk *clk; 992 - int freq, ret; 992 + u32 freq; 993 + int ret; 993 994 994 995 clk = devm_clk_get_optional(&spi->dev, NULL); 995 996 if (IS_ERR(clk)) 996 997 return PTR_ERR(clk); 997 998 998 999 freq = clk_get_rate(clk); 999 - if (freq == 0 && pdata) 1000 - freq = pdata->oscillator_frequency; 1000 + if (freq == 0) 1001 + device_property_read_u32(&spi->dev, "clock-frequency", &freq); 1001 1002 1002 1003 /* Sanity check */ 1003 1004 if (freq < 1000000 || freq > 25000000)
-22
include/linux/can/platform/mcp251x.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _CAN_PLATFORM_MCP251X_H 3 - #define _CAN_PLATFORM_MCP251X_H 4 - 5 - /* 6 - * 7 - * CAN bus driver for Microchip 251x CAN Controller with SPI Interface 8 - * 9 - */ 10 - 11 - #include <linux/spi/spi.h> 12 - 13 - /* 14 - * struct mcp251x_platform_data - MCP251X SPI CAN controller platform data 15 - * @oscillator_frequency: - oscillator frequency in Hz 16 - */ 17 - 18 - struct mcp251x_platform_data { 19 - unsigned long oscillator_frequency; 20 - }; 21 - 22 - #endif /* !_CAN_PLATFORM_MCP251X_H */