cregit-Linux how code gets into the kernel

Release 4.15 drivers/char/tpm/tpm-dev.c

Directory: drivers/char/tpm
/*
 * Copyright (C) 2004 IBM Corporation
 * Authors:
 * Leendert van Doorn <leendert@watson.ibm.com>
 * Dave Safford <safford@watson.ibm.com>
 * Reiner Sailer <sailer@watson.ibm.com>
 * Kylene Hall <kjhall@us.ibm.com>
 *
 * Copyright (C) 2013 Obsidian Research Corp
 * Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
 *
 * Device file system interface to the TPM
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, version 2 of the
 * License.
 *
 */
#include <linux/slab.h>
#include "tpm-dev.h"


static int tpm_open(struct inode *inode, struct file *file) { struct tpm_chip *chip; struct file_priv *priv; chip = container_of(inode->i_cdev, struct tpm_chip, cdev); /* It's assured that the chip will be opened just once, * by the check of is_open variable, which is protected * by driver_lock. */ if (test_and_set_bit(0, &chip->is_open)) { dev_dbg(&chip->dev, "Another process owns this TPM\n"); return -EBUSY; } priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (priv == NULL) goto out; tpm_common_open(file, chip, priv); return 0; out: clear_bit(0, &chip->is_open); return -ENOMEM; }

Contributors

PersonTokensPropCommitsCommitProp
Jason Gunthorpe9478.99%360.00%
James Bottomley2117.65%120.00%
Jarkko Sakkinen43.36%120.00%
Total119100.00%5100.00%


static ssize_t tpm_write(struct file *file, const char __user *buf, size_t size, loff_t *off) { return tpm_common_write(file, buf, size, off, NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Jason Gunthorpe3386.84%150.00%
James Bottomley513.16%150.00%
Total38100.00%2100.00%

/* * Called on file close */
static int tpm_release(struct inode *inode, struct file *file) { struct file_priv *priv = file->private_data; tpm_common_release(file, priv); clear_bit(0, &priv->chip->is_open); kfree(priv); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Jason Gunthorpe5096.15%266.67%
James Bottomley23.85%133.33%
Total52100.00%3100.00%

const struct file_operations tpm_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .open = tpm_open, .read = tpm_common_read, .write = tpm_write, .release = tpm_release, };

Overall Contributors

PersonTokensPropCommitsCommitProp
Jason Gunthorpe22086.61%360.00%
James Bottomley3011.81%120.00%
Jarkko Sakkinen41.57%120.00%
Total254100.00%5100.00%
Directory: drivers/char/tpm
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.