cregit-Linux how code gets into the kernel

Release 4.14 drivers/uwb/driver.c

Directory: drivers/uwb
/*
 * Ultra Wide Band
 * Driver initialization, etc
 *
 * Copyright (C) 2005-2006 Intel Corporation
 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version
 * 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *
 *
 * FIXME: docs
 *
 * Life cycle: FIXME: explain
 *
 *  UWB radio controller:
 *
 *    1. alloc a uwb_rc, zero it
 *    2. call uwb_rc_init() on it to set it up + ops (won't do any
 *       kind of allocation)
 *    3. register (now it is owned by the UWB stack--deregister before
 *       freeing/destroying).
 *    4. It lives on it's own now (UWB stack handles)--when it
 *       disconnects, call unregister()
 *    5. free it.
 *
 *    Make sure you have a reference to the uwb_rc before calling
 *    any of the UWB API functions.
 *
 * TODO:
 *
 * 1. Locking and life cycle management is crappy still. All entry
 *    points to the UWB HCD API assume you have a reference on the
 *    uwb_rc structure and that it won't go away. They mutex lock it
 *    before doing anything.
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/kdev_t.h>
#include <linux/random.h>

#include "uwb-internal.h"


/* UWB stack attributes (or 'global' constants) */


/**
 * If a beacon disappears for longer than this, then we consider the
 * device who was represented by that beacon to be gone.
 *
 * ECMA-368[17.2.3, last para] establishes that a device must not
 * consider a device to be its neighbour if he doesn't receive a beacon
 * for more than mMaxLostBeacons. mMaxLostBeacons is defined in
 * ECMA-368[17.16] as 3; because we can get only one beacon per
 * superframe, that'd be 3 * 65ms = 195 ~ 200 ms. Let's give it time
 * for jitter and stuff and make it 500 ms.
 */

unsigned long beacon_timeout_ms = 500;


static ssize_t beacon_timeout_ms_show(struct class *class, struct class_attribute *attr, char *buf) { return scnprintf(buf, PAGE_SIZE, "%lu\n", beacon_timeout_ms); }

Contributors

PersonTokensPropCommitsCommitProp
Iñaky Pérez-González2784.38%150.00%
Andi Kleen515.62%150.00%
Total32100.00%2100.00%


static ssize_t beacon_timeout_ms_store(struct class *class, struct class_attribute *attr, const char *buf, size_t size) { unsigned long bt; ssize_t result; result = sscanf(buf, "%lu", &bt); if (result != 1) return -EINVAL; beacon_timeout_ms = bt; return size; }

Contributors

PersonTokensPropCommitsCommitProp
Iñaky Pérez-González5591.67%150.00%
Andi Kleen58.33%150.00%
Total60100.00%2100.00%

static CLASS_ATTR_RW(beacon_timeout_ms); static struct attribute *uwb_class_attrs[] = { &class_attr_beacon_timeout_ms.attr, NULL, }; ATTRIBUTE_GROUPS(uwb_class); /** Device model classes */ struct class uwb_rc_class = { .name = "uwb_rc", .class_groups = uwb_class_groups, };
static int __init uwb_subsys_init(void) { int result = 0; result = uwb_est_create(); if (result < 0) { printk(KERN_ERR "uwb: Can't initialize EST subsystem\n"); goto error_est_init; } result = class_register(&uwb_rc_class); if (result < 0) goto error_uwb_rc_class_register; /* Register the UWB bus */ result = bus_register(&uwb_bus_type); if (result) { pr_err("%s - registering bus driver failed\n", __func__); goto exit_bus; } uwb_dbg_init(); return 0; exit_bus: class_unregister(&uwb_rc_class); error_uwb_rc_class_register: uwb_est_destroy(); error_est_init: return result; }

Contributors

PersonTokensPropCommitsCommitProp
Iñaky Pérez-González6664.71%133.33%
Thomas Pugliese3332.35%133.33%
David Vrabel32.94%133.33%
Total102100.00%3100.00%

module_init(uwb_subsys_init);
static void __exit uwb_subsys_exit(void) { uwb_dbg_exit(); bus_unregister(&uwb_bus_type); class_unregister(&uwb_rc_class); uwb_est_destroy(); return; }

Contributors

PersonTokensPropCommitsCommitProp
Iñaky Pérez-González1967.86%133.33%
Thomas Pugliese621.43%133.33%
David Vrabel310.71%133.33%
Total28100.00%3100.00%

module_exit(uwb_subsys_exit); MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>"); MODULE_DESCRIPTION("Ultra Wide Band core"); MODULE_LICENSE("GPL");

Overall Contributors

PersonTokensPropCommitsCommitProp
Iñaky Pérez-González24876.54%116.67%
Thomas Pugliese3912.04%116.67%
Greg Kroah-Hartman206.17%116.67%
Andi Kleen103.09%116.67%
David Vrabel61.85%116.67%
Lucas De Marchi10.31%116.67%
Total324100.00%6100.00%
Directory: drivers/uwb
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.