spi.c (b5e3cf410b486a2415ff09b12f3ef18aba9f53ff) spi.c (f9481b08220d7dc1ff21e296a330ee8b721b44e4)
1// SPDX-License-Identifier: GPL-2.0-or-later
2// SPI init/core code
3//
4// Copyright (C) 2005 David Brownell
5// Copyright (C) 2008 Secret Lab Technologies Ltd.
6
7#include <linux/kernel.h>
8#include <linux/device.h>

--- 2361 unchanged lines hidden (view full) ---

2370 /*
2371 * Make sure all necessary hooks are implemented before registering
2372 * the SPI controller.
2373 */
2374 status = spi_controller_check_ops(ctlr);
2375 if (status)
2376 return status;
2377
1// SPDX-License-Identifier: GPL-2.0-or-later
2// SPI init/core code
3//
4// Copyright (C) 2005 David Brownell
5// Copyright (C) 2008 Secret Lab Technologies Ltd.
6
7#include <linux/kernel.h>
8#include <linux/device.h>

--- 2361 unchanged lines hidden (view full) ---

2370 /*
2371 * Make sure all necessary hooks are implemented before registering
2372 * the SPI controller.
2373 */
2374 status = spi_controller_check_ops(ctlr);
2375 if (status)
2376 return status;
2377
2378 /* even if it's just one always-selected device, there must
2379 * be at least one chipselect
2380 */
2381 if (ctlr->num_chipselect == 0)
2382 return -EINVAL;
2383 if (ctlr->bus_num >= 0) {
2384 /* devices with a fixed bus num must check-in with the num */
2385 mutex_lock(&board_lock);
2386 id = idr_alloc(&spi_master_idr, ctlr, ctlr->bus_num,
2387 ctlr->bus_num + 1, GFP_KERNEL);
2388 mutex_unlock(&board_lock);
2389 if (WARN(id < 0, "couldn't get idr"))
2390 return id == -ENOSPC ? -EBUSY : id;

--- 54 unchanged lines hidden (view full) ---

2445 } else {
2446 /* Legacy code path for GPIOs from DT */
2447 status = of_spi_register_master(ctlr);
2448 if (status)
2449 return status;
2450 }
2451 }
2452
2378 if (ctlr->bus_num >= 0) {
2379 /* devices with a fixed bus num must check-in with the num */
2380 mutex_lock(&board_lock);
2381 id = idr_alloc(&spi_master_idr, ctlr, ctlr->bus_num,
2382 ctlr->bus_num + 1, GFP_KERNEL);
2383 mutex_unlock(&board_lock);
2384 if (WARN(id < 0, "couldn't get idr"))
2385 return id == -ENOSPC ? -EBUSY : id;

--- 54 unchanged lines hidden (view full) ---

2440 } else {
2441 /* Legacy code path for GPIOs from DT */
2442 status = of_spi_register_master(ctlr);
2443 if (status)
2444 return status;
2445 }
2446 }
2447
2448 /*
2449 * Even if it's just one always-selected device, there must
2450 * be at least one chipselect.
2451 */
2452 if (!ctlr->num_chipselect)
2453 return -EINVAL;
2454
2453 status = device_add(&ctlr->dev);
2454 if (status < 0) {
2455 /* free bus id */
2456 mutex_lock(&board_lock);
2457 idr_remove(&spi_master_idr, ctlr->bus_num);
2458 mutex_unlock(&board_lock);
2459 goto done;
2460 }

--- 1389 unchanged lines hidden ---
2455 status = device_add(&ctlr->dev);
2456 if (status < 0) {
2457 /* free bus id */
2458 mutex_lock(&board_lock);
2459 idr_remove(&spi_master_idr, ctlr->bus_num);
2460 mutex_unlock(&board_lock);
2461 goto done;
2462 }

--- 1389 unchanged lines hidden ---