Commit f588af84 authored by David S. Miller's avatar David S. Miller
Browse files

Merge tag 'linux-can-next-for-5.4-20190820' of...

Merge tag 'linux-can-next-for-5.4-20190820' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next



Marc Kleine-Budde says:

====================
pull-request: can-next 2019-08-20

this is a pull request for net-next/master consisting of 18 patches.

The first patch is by Geert Uytterhoeven, it removes the unused platform
data support from the rcar_can driver.

A patch by Nishka Dasgupta marks the structure peak_pciec_i2c_bit_ops in
the peak_pci driver as constant.

A patch by me removes the custom DMA support from the hi311x driver.

The next 4 patches target the tcan4x5x driver and are also by me, they
first clean up the driver a bit, and then add missing error handling and
fix a bug in the length calculation in the regmap callbacks.

The next 2 patches are by me for the m_can_platform driver, they also
remove unneeded casts and add missing error handling.

The remaining 9 patches all target the mcp251x driver. The first 5 are
clean up patches by me, the next relaxes the timing in the
mcp251x_hw_reset() function. Alexander Shiyan's patch improves the name
which is used while registering the interrupt handler. Phil Elwell's
patch improves the mcp251x_open() function to use the DT-supplied
interrupt flags instead of hard coding them. The final patch is again by
me, it removes the custom DMA support from the hi311x driver.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c08129bb df58525d
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -16,24 +16,21 @@ struct m_can_plat_priv {

static u32 iomap_read_reg(struct m_can_classdev *cdev, int reg)
{
	struct m_can_plat_priv *priv =
			(struct m_can_plat_priv *)cdev->device_data;
	struct m_can_plat_priv *priv = cdev->device_data;

	return readl(priv->base + reg);
}

static u32 iomap_read_fifo(struct m_can_classdev *cdev, int offset)
{
	struct m_can_plat_priv *priv =
			(struct m_can_plat_priv *)cdev->device_data;
	struct m_can_plat_priv *priv = cdev->device_data;

	return readl(priv->mram_base + offset);
}

static int iomap_write_reg(struct m_can_classdev *cdev, int reg, int val)
{
	struct m_can_plat_priv *priv =
			(struct m_can_plat_priv *)cdev->device_data;
	struct m_can_plat_priv *priv = cdev->device_data;

	writel(val, priv->base + reg);

@@ -42,8 +39,7 @@ static int iomap_write_reg(struct m_can_classdev *cdev, int reg, int val)

static int iomap_write_fifo(struct m_can_classdev *cdev, int offset, int val)
{
	struct m_can_plat_priv *priv =
			(struct m_can_plat_priv *)cdev->device_data;
	struct m_can_plat_priv *priv = cdev->device_data;

	writel(val, priv->mram_base + offset);

@@ -67,6 +63,9 @@ static int m_can_plat_probe(struct platform_device *pdev)
	int irq, ret = 0;

	mcan_class = m_can_class_allocate_dev(&pdev->dev);
	if (!mcan_class)
		return -ENOMEM;

	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;
+13 −18
Original line number Diff line number Diff line
@@ -113,7 +113,6 @@
struct tcan4x5x_priv {
	struct regmap *regmap;
	struct spi_device *spi;
	struct mutex tcan4x5x_lock; /* SPI device lock */

	struct m_can_classdev *mcan_dev;

@@ -179,7 +178,7 @@ static int regmap_spi_gather_write(void *context, const void *reg,
		{ .tx_buf = val, .len = val_len, },
	};

	addr = TCAN4X5X_WRITE_CMD | (*((u16 *)reg) << 8) | val_len >> 3;
	addr = TCAN4X5X_WRITE_CMD | (*((u16 *)reg) << 8) | val_len >> 2;

	spi_message_init(&m);
	spi_message_add_tail(&t[0], &m);
@@ -193,7 +192,7 @@ static int tcan4x5x_regmap_write(void *context, const void *data, size_t count)
	u16 *reg = (u16 *)(data);
	const u32 *val = data + 4;

	return regmap_spi_gather_write(context, reg, 4, val, count);
	return regmap_spi_gather_write(context, reg, 4, val, count - 4);
}

static int regmap_spi_async_write(void *context,
@@ -234,7 +233,7 @@ static struct regmap_bus tcan4x5x_bus = {

static u32 tcan4x5x_read_reg(struct m_can_classdev *cdev, int reg)
{
	struct tcan4x5x_priv *priv = (struct tcan4x5x_priv *)cdev->device_data;
	struct tcan4x5x_priv *priv = cdev->device_data;
	u32 val;

	tcan4x5x_check_wake(priv);
@@ -246,7 +245,7 @@ static u32 tcan4x5x_read_reg(struct m_can_classdev *cdev, int reg)

static u32 tcan4x5x_read_fifo(struct m_can_classdev *cdev, int addr_offset)
{
	struct tcan4x5x_priv *priv = (struct tcan4x5x_priv *)cdev->device_data;
	struct tcan4x5x_priv *priv = cdev->device_data;
	u32 val;

	tcan4x5x_check_wake(priv);
@@ -258,7 +257,7 @@ static u32 tcan4x5x_read_fifo(struct m_can_classdev *cdev, int addr_offset)

static int tcan4x5x_write_reg(struct m_can_classdev *cdev, int reg, int val)
{
	struct tcan4x5x_priv *priv = (struct tcan4x5x_priv *)cdev->device_data;
	struct tcan4x5x_priv *priv = cdev->device_data;

	tcan4x5x_check_wake(priv);

@@ -268,8 +267,7 @@ static int tcan4x5x_write_reg(struct m_can_classdev *cdev, int reg, int val)
static int tcan4x5x_write_fifo(struct m_can_classdev *cdev,
			       int addr_offset, int val)
{
	struct tcan4x5x_priv *priv =
			(struct tcan4x5x_priv *)cdev->device_data;
	struct tcan4x5x_priv *priv = cdev->device_data;

	tcan4x5x_check_wake(priv);

@@ -290,8 +288,7 @@ static int tcan4x5x_power_enable(struct regulator *reg, int enable)
static int tcan4x5x_write_tcan_reg(struct m_can_classdev *cdev,
				   int reg, int val)
{
	struct tcan4x5x_priv *priv =
			(struct tcan4x5x_priv *)cdev->device_data;
	struct tcan4x5x_priv *priv = cdev->device_data;

	tcan4x5x_check_wake(priv);

@@ -300,8 +297,7 @@ static int tcan4x5x_write_tcan_reg(struct m_can_classdev *cdev,

static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev)
{
	struct tcan4x5x_priv *tcan4x5x =
				(struct tcan4x5x_priv *)cdev->device_data;
	struct tcan4x5x_priv *tcan4x5x = cdev->device_data;
	int ret;

	tcan4x5x_check_wake(tcan4x5x);
@@ -331,8 +327,7 @@ static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev)

static int tcan4x5x_init(struct m_can_classdev *cdev)
{
	struct tcan4x5x_priv *tcan4x5x =
				(struct tcan4x5x_priv *)cdev->device_data;
	struct tcan4x5x_priv *tcan4x5x = cdev->device_data;
	int ret;

	tcan4x5x_check_wake(tcan4x5x);
@@ -359,8 +354,7 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)

static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
{
	struct tcan4x5x_priv *tcan4x5x =
				(struct tcan4x5x_priv *)cdev->device_data;
	struct tcan4x5x_priv *tcan4x5x = cdev->device_data;

	tcan4x5x->interrupt_gpio = devm_gpiod_get(cdev->dev, "data-ready",
						  GPIOD_IN);
@@ -420,6 +414,9 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
	int freq, ret;

	mcan_class = m_can_class_allocate_dev(&spi->dev);
	if (!mcan_class)
		return -ENOMEM;

	priv = devm_kzalloc(&spi->dev, sizeof(*priv), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;
@@ -466,8 +463,6 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
	priv->regmap = devm_regmap_init(&spi->dev, &tcan4x5x_bus,
					&spi->dev, &tcan4x5x_regmap);

	mutex_init(&priv->tcan4x5x_lock);

	tcan4x5x_power_enable(priv->power, 1);

	ret = m_can_class_register(mcan_class);
+9 −13
Original line number Diff line number Diff line
@@ -15,11 +15,17 @@
#include <linux/can/led.h>
#include <linux/can/dev.h>
#include <linux/clk.h>
#include <linux/can/platform/rcar_can.h>
#include <linux/of.h>

#define RCAR_CAN_DRV_NAME	"rcar_can"

/* Clock Select Register settings */
enum CLKR {
	CLKR_CLKP1 = 0, /* Peripheral clock (clkp1) */
	CLKR_CLKP2 = 1, /* Peripheral clock (clkp2) */
	CLKR_CLKEXT = 3, /* Externally input clock */
};

#define RCAR_SUPPORTED_CLOCKS	(BIT(CLKR_CLKP1) | BIT(CLKR_CLKP2) | \
				 BIT(CLKR_CLKEXT))

@@ -736,7 +742,6 @@ static const char * const clock_names[] = {

static int rcar_can_probe(struct platform_device *pdev)
{
	struct rcar_can_platform_data *pdata;
	struct rcar_can_priv *priv;
	struct net_device *ndev;
	struct resource *mem;
@@ -745,17 +750,8 @@ static int rcar_can_probe(struct platform_device *pdev)
	int err = -ENODEV;
	int irq;

	if (pdev->dev.of_node) {
		of_property_read_u32(pdev->dev.of_node,
				     "renesas,can-clock-select", &clock_select);
	} else {
		pdata = dev_get_platdata(&pdev->dev);
		if (!pdata) {
			dev_err(&pdev->dev, "No platform data provided!\n");
			goto fail;
		}
		clock_select = pdata->clock_select;
	}
	of_property_read_u32(pdev->dev.of_node, "renesas,can-clock-select",
			     &clock_select);

	irq = platform_get_irq(pdev, 0);
	if (irq < 0) {
+1 −1
Original line number Diff line number Diff line
@@ -417,7 +417,7 @@ static void peak_pciec_write_reg(const struct sja1000_priv *priv,
	peak_pci_write_reg(priv, port, val);
}

static struct i2c_algo_bit_data peak_pciec_i2c_bit_ops = {
static const struct i2c_algo_bit_data peak_pciec_i2c_bit_ops = {
	.setsda	= pita_setsda,
	.setscl	= pita_setscl,
	.getsda	= pita_getsda,
+10 −49
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#include <linux/completion.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/freezer.h>
#include <linux/interrupt.h>
#include <linux/io.h>
@@ -126,10 +125,6 @@

#define DEVICE_NAME "hi3110"

static int hi3110_enable_dma = 1; /* Enable SPI DMA. Default: 1 (On) */
module_param(hi3110_enable_dma, int, 0444);
MODULE_PARM_DESC(hi3110_enable_dma, "Enable SPI DMA. Default: 1 (On)");

static const struct can_bittiming_const hi3110_bittiming_const = {
	.name = DEVICE_NAME,
	.tseg1_min = 2,
@@ -156,8 +151,6 @@ struct hi3110_priv {

	u8 *spi_tx_buf;
	u8 *spi_rx_buf;
	dma_addr_t spi_tx_dma;
	dma_addr_t spi_rx_dma;

	struct sk_buff *tx_skb;
	int tx_len;
@@ -217,13 +210,6 @@ static int hi3110_spi_trans(struct spi_device *spi, int len)
	int ret;

	spi_message_init(&m);

	if (hi3110_enable_dma) {
		t.tx_dma = priv->spi_tx_dma;
		t.rx_dma = priv->spi_rx_dma;
		m.is_dma_mapped = 1;
	}

	spi_message_add_tail(&t, &m);

	ret = spi_sync(spi, &m);
@@ -915,30 +901,6 @@ static int hi3110_can_probe(struct spi_device *spi)
	priv->spi = spi;
	mutex_init(&priv->hi3110_lock);

	/* If requested, allocate DMA buffers */
	if (hi3110_enable_dma) {
		spi->dev.coherent_dma_mask = ~0;

		/* Minimum coherent DMA allocation is PAGE_SIZE, so allocate
		 * that much and share it between Tx and Rx DMA buffers.
		 */
		priv->spi_tx_buf = dmam_alloc_coherent(&spi->dev,
						       PAGE_SIZE,
						       &priv->spi_tx_dma,
						       GFP_DMA);

		if (priv->spi_tx_buf) {
			priv->spi_rx_buf = (priv->spi_tx_buf + (PAGE_SIZE / 2));
			priv->spi_rx_dma = (dma_addr_t)(priv->spi_tx_dma +
							(PAGE_SIZE / 2));
		} else {
			/* Fall back to non-DMA */
			hi3110_enable_dma = 0;
		}
	}

	/* Allocate non-DMA buffers */
	if (!hi3110_enable_dma) {
	priv->spi_tx_buf = devm_kzalloc(&spi->dev, HI3110_RX_BUF_LEN,
					GFP_KERNEL);
	if (!priv->spi_tx_buf) {
@@ -952,7 +914,6 @@ static int hi3110_can_probe(struct spi_device *spi)
		ret = -ENOMEM;
		goto error_probe;
	}
	}

	SET_NETDEV_DEV(net, &spi->dev);

Loading