cregit-Linux how code gets into the kernel

Release 4.11 net/atm/atm_sysfs.c

Directory: net/atm
/* ATM driver model support. */

#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/kobject.h>
#include <linux/atmdev.h>
#include "common.h"
#include "resources.h"


#define to_atm_dev(cldev) container_of(cldev, struct atm_dev, class_dev)


static ssize_t show_type(struct device *cdev, struct device_attribute *attr, char *buf) { struct atm_dev *adev = to_atm_dev(cdev); return scnprintf(buf, PAGE_SIZE, "%s\n", adev->type); }

Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan3579.55%133.33%
Kay Sievers613.64%133.33%
Chas Williams36.82%133.33%
Total44100.00%3100.00%


static ssize_t show_address(struct device *cdev, struct device_attribute *attr, char *buf) { struct atm_dev *adev = to_atm_dev(cdev); return scnprintf(buf, PAGE_SIZE, "%pM\n", adev->esi); }

Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan3375.00%133.33%
Kay Sievers613.64%133.33%
Chas Williams511.36%133.33%
Total44100.00%3100.00%


static ssize_t show_atmaddress(struct device *cdev, struct device_attribute *attr, char *buf) { unsigned long flags; struct atm_dev *adev = to_atm_dev(cdev); struct atm_dev_addr *aaddr; int bin[] = { 1, 2, 10, 6, 1 }, *fmt = bin; int i, j, count = 0; spin_lock_irqsave(&adev->lock, flags); list_for_each_entry(aaddr, &adev->local, entry) { for (i = 0, j = 0; i < ATM_ESA_LEN; ++i, ++j) { if (j == *fmt) { count += scnprintf(buf + count, PAGE_SIZE - count, "."); ++fmt; j = 0; } count += scnprintf(buf + count, PAGE_SIZE - count, "%02x", aaddr->addr.sas_addr.prv[i]); } count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); } spin_unlock_irqrestore(&adev->lock, flags); return count; }

Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan15880.61%133.33%
Chas Williams3216.33%133.33%
Kay Sievers63.06%133.33%
Total196100.00%3100.00%


static ssize_t show_atmindex(struct device *cdev, struct device_attribute *attr, char *buf) { struct atm_dev *adev = to_atm_dev(cdev); return scnprintf(buf, PAGE_SIZE, "%d\n", adev->number); }

Contributors

PersonTokensPropCommitsCommitProp
Dan J Williams4193.18%150.00%
Chas Williams36.82%150.00%
Total44100.00%2100.00%


static ssize_t show_carrier(struct device *cdev, struct device_attribute *attr, char *buf) { struct atm_dev *adev = to_atm_dev(cdev); return scnprintf(buf, PAGE_SIZE, "%d\n", adev->signal == ATM_PHY_SIG_LOST ? 0 : 1); }

Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan3978.00%133.33%
Kay Sievers612.00%133.33%
Chas Williams510.00%133.33%
Total50100.00%3100.00%


static ssize_t show_link_rate(struct device *cdev, struct device_attribute *attr, char *buf) { struct atm_dev *adev = to_atm_dev(cdev); int link_rate; /* show the link rate, not the data rate */ switch (adev->link_rate) { case ATM_OC3_PCR: link_rate = 155520000; break; case ATM_OC12_PCR: link_rate = 622080000; break; case ATM_25_PCR: link_rate = 25600000; break; default: link_rate = adev->link_rate * 8 * 53; } return scnprintf(buf, PAGE_SIZE, "%d\n", link_rate); }

Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan7887.64%133.33%
Kay Sievers66.74%133.33%
Chas Williams55.62%133.33%
Total89100.00%3100.00%

static DEVICE_ATTR(address, S_IRUGO, show_address, NULL); static DEVICE_ATTR(atmaddress, S_IRUGO, show_atmaddress, NULL); static DEVICE_ATTR(atmindex, S_IRUGO, show_atmindex, NULL); static DEVICE_ATTR(carrier, S_IRUGO, show_carrier, NULL); static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); static DEVICE_ATTR(link_rate, S_IRUGO, show_link_rate, NULL); static struct device_attribute *atm_attrs[] = { &dev_attr_atmaddress, &dev_attr_address, &dev_attr_atmindex, &dev_attr_carrier, &dev_attr_type, &dev_attr_link_rate, NULL };
static int atm_uevent(struct device *cdev, struct kobj_uevent_env *env) { struct atm_dev *adev; if (!cdev) return -ENODEV; adev = to_atm_dev(cdev); if (!adev) return -ENODEV; if (add_uevent_var(env, "NAME=%s%d", adev->type, adev->number)) return -ENOMEM; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan6592.86%133.33%
Kay Sievers57.14%266.67%
Total70100.00%3100.00%


static void atm_release(struct device *cdev) { struct atm_dev *adev = to_atm_dev(cdev); kfree(adev); }

Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan2596.15%150.00%
Kay Sievers13.85%150.00%
Total26100.00%2100.00%

static struct class atm_class = { .name = "atm", .dev_release = atm_release, .dev_uevent = atm_uevent, };
int atm_register_sysfs(struct atm_dev *adev, struct device *parent) { struct device *cdev = &adev->class_dev; int i, j, err; cdev->class = &atm_class; cdev->parent = parent; dev_set_drvdata(cdev, adev); dev_set_name(cdev, "%s%d", adev->type, adev->number); err = device_register(cdev); if (err < 0) return err; for (i = 0; atm_attrs[i]; i++) { err = device_create_file(cdev, atm_attrs[i]); if (err) goto err_out; } return 0; err_out: for (j = 0; j < i; j++) device_remove_file(cdev, atm_attrs[j]); device_del(cdev); return err; }

Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan9259.74%120.00%
Jeff Garzik4428.57%120.00%
Dan J Williams117.14%120.00%
Kay Sievers74.55%240.00%
Total154100.00%5100.00%


void atm_unregister_sysfs(struct atm_dev *adev) { struct device *cdev = &adev->class_dev; device_del(cdev); }

Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan2392.00%150.00%
Kay Sievers28.00%150.00%
Total25100.00%2100.00%


int __init atm_sysfs_init(void) { return class_register(&atm_class); }

Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan15100.00%1100.00%
Total15100.00%1100.00%


void __exit atm_sysfs_exit(void) { class_unregister(&atm_class); }

Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan14100.00%1100.00%
Total14100.00%1100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Roman Kagan69875.62%111.11%
Dan J Williams677.26%222.22%
Kay Sievers586.28%333.33%
Chas Williams535.74%111.11%
Jeff Garzik444.77%111.11%
Tejun Heo30.33%111.11%
Total923100.00%9100.00%
Directory: net/atm
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.