blob: 52500e7fd836cbc08808581404d5d0ea02ef14c1 [file] [log] [blame]
Thomas Gleixner2b27bdc2019-05-29 16:57:50 -07001// SPDX-License-Identifier: GPL-2.0-only
Carlos Chineaa056ab82010-04-16 19:01:02 +03002/*
3 * HSI clients registration interface
4 *
5 * Copyright (C) 2010 Nokia Corporation. All rights reserved.
6 *
7 * Contact: Carlos Chinea <carlos.chinea@nokia.com>
Carlos Chineaa056ab82010-04-16 19:01:02 +03008 */
9#include <linux/hsi/hsi.h>
10#include <linux/list.h>
11#include <linux/slab.h>
12#include "hsi_core.h"
13
14/*
15 * hsi_board_list is only used internally by the HSI framework.
16 * No one else is allowed to make use of it.
17 */
18LIST_HEAD(hsi_board_list);
19EXPORT_SYMBOL_GPL(hsi_board_list);
20
21/**
22 * hsi_register_board_info - Register HSI clients information
23 * @info: Array of HSI clients on the board
24 * @len: Length of the array
25 *
26 * HSI clients are statically declared and registered on board files.
27 *
28 * HSI clients will be automatically registered to the HSI bus once the
29 * controller and the port where the clients wishes to attach are registered
30 * to it.
31 *
32 * Return -errno on failure, 0 on success.
33 */
34int __init hsi_register_board_info(struct hsi_board_info const *info,
35 unsigned int len)
36{
37 struct hsi_cl_info *cl_info;
38
Markus Elfringde7c98e2017-04-25 13:56:08 +020039 cl_info = kcalloc(len, sizeof(*cl_info), GFP_KERNEL);
Carlos Chineaa056ab82010-04-16 19:01:02 +030040 if (!cl_info)
41 return -ENOMEM;
42
43 for (; len; len--, info++, cl_info++) {
44 cl_info->info = *info;
45 list_add_tail(&cl_info->list, &hsi_board_list);
46 }
47
48 return 0;
49}