Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * drivers/mfd/ab3100_otp.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2007-2009 ST-Ericsson AB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Driver to read out OTP from the AB3100 Mixed-signal circuit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Author: Linus Walleij <linus.walleij@stericsson.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/mfd/abx500.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /* The OTP registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define AB3100_OTP0		0xb0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define AB3100_OTP1		0xb1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define AB3100_OTP2		0xb2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #define AB3100_OTP3		0xb3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define AB3100_OTP4		0xb4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define AB3100_OTP5		0xb5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define AB3100_OTP6		0xb6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define AB3100_OTP7		0xb7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define AB3100_OTPP		0xbf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * struct ab3100_otp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * @dev: containing device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * @locked: whether the OTP is locked, after locking, no more bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *       can be changed but before locking it is still possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  *       to change bits from 1->0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * @freq: clocking frequency for the OTP, this frequency is either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *       32768Hz or 1MHz/30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * @paf: product activation flag, indicates whether this is a real
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *       product (paf true) or a lab board etc (paf false)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * @imeich: if this is set it is possible to override the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *       IMEI number found in the tac, fac and svn fields with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  *       (secured) software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * @cid: customer ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * @tac: type allocation code of the IMEI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * @fac: final assembly code of the IMEI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * @svn: software version number of the IMEI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  * @debugfs: a debugfs file used when dumping to file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) struct ab3100_otp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	bool locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	u32 freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	bool paf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	bool imeich;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	u16 cid:14;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	u32 tac:20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	u8 fac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	u32 svn:20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct dentry *debugfs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static int __init ab3100_otp_read(struct ab3100_otp *otp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	u8 otpval[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	u8 otpp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	err = abx500_get_register_interruptible(otp->dev, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		AB3100_OTPP, &otpp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		dev_err(otp->dev, "unable to read OTPP register\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	err = abx500_get_register_page_interruptible(otp->dev, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		AB3100_OTP0, otpval, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		dev_err(otp->dev, "unable to read OTP register page\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	/* Cache OTP properties, they never change by nature */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	otp->locked = (otpp & 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	otp->freq = (otpp & 0x40) ? 32768 : 34100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	otp->paf = (otpval[1] & 0x80);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	otp->imeich = (otpval[1] & 0x40);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	otp->cid = ((otpval[1] << 8) | otpval[0]) & 0x3fff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	otp->tac = ((otpval[4] & 0x0f) << 16) | (otpval[3] << 8) | otpval[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	otp->fac = ((otpval[5] & 0x0f) << 4) | (otpval[4] >> 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	otp->svn = (otpval[7] << 12) | (otpval[6] << 4) | (otpval[5] >> 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  * This is a simple debugfs human-readable file that dumps out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  * the contents of the OTP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) #ifdef CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) static int ab3100_show_otp(struct seq_file *s, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	struct ab3100_otp *otp = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	seq_printf(s, "OTP is %s\n", otp->locked ? "LOCKED" : "UNLOCKED");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	seq_printf(s, "OTP clock switch startup is %uHz\n", otp->freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	seq_printf(s, "PAF is %s\n", otp->paf ? "SET" : "NOT SET");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	seq_printf(s, "IMEI is %s\n", otp->imeich ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		   "CHANGEABLE" : "NOT CHANGEABLE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	seq_printf(s, "CID: 0x%04x (decimal: %d)\n", otp->cid, otp->cid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	seq_printf(s, "IMEI: %u-%u-%u\n", otp->tac, otp->fac, otp->svn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static int ab3100_otp_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	return single_open(file, ab3100_show_otp, inode->i_private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static const struct file_operations ab3100_otp_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	.open		= ab3100_otp_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	.read		= seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	.llseek		= seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	.release	= single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static void __init ab3100_otp_init_debugfs(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 					   struct ab3100_otp *otp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	otp->debugfs = debugfs_create_file("ab3100_otp", S_IFREG | S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 					   NULL, otp, &ab3100_otp_operations);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) static void __exit ab3100_otp_exit_debugfs(struct ab3100_otp *otp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	debugfs_remove(otp->debugfs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /* Compile this out if debugfs not selected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static inline void __init ab3100_otp_init_debugfs(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 						  struct ab3100_otp *otp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static inline void __exit ab3100_otp_exit_debugfs(struct ab3100_otp *otp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define SHOW_AB3100_ATTR(name) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) static ssize_t ab3100_otp_##name##_show(struct device *dev, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			       struct device_attribute *attr, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 			       char *buf) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	struct ab3100_otp *otp = dev_get_drvdata(dev); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	return sprintf(buf, "%u\n", otp->name); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) SHOW_AB3100_ATTR(locked)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) SHOW_AB3100_ATTR(freq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) SHOW_AB3100_ATTR(paf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) SHOW_AB3100_ATTR(imeich)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) SHOW_AB3100_ATTR(cid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) SHOW_AB3100_ATTR(fac)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) SHOW_AB3100_ATTR(tac)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) SHOW_AB3100_ATTR(svn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static struct device_attribute ab3100_otp_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	__ATTR(locked, S_IRUGO, ab3100_otp_locked_show, NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	__ATTR(freq, S_IRUGO, ab3100_otp_freq_show, NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	__ATTR(paf, S_IRUGO, ab3100_otp_paf_show, NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	__ATTR(imeich, S_IRUGO, ab3100_otp_imeich_show, NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	__ATTR(cid, S_IRUGO, ab3100_otp_cid_show, NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	__ATTR(fac, S_IRUGO, ab3100_otp_fac_show, NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	__ATTR(tac, S_IRUGO, ab3100_otp_tac_show, NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	__ATTR(svn, S_IRUGO, ab3100_otp_svn_show, NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static int __init ab3100_otp_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	struct ab3100_otp *otp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	otp = devm_kzalloc(&pdev->dev, sizeof(struct ab3100_otp), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	if (!otp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	otp->dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	/* Replace platform data coming in with a local struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	platform_set_drvdata(pdev, otp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	err = ab3100_otp_read(otp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	dev_info(&pdev->dev, "AB3100 OTP readout registered\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	/* sysfs entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	for (i = 0; i < ARRAY_SIZE(ab3100_otp_attrs); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		err = device_create_file(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 					 &ab3100_otp_attrs[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 			goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	/* debugfs entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	ab3100_otp_init_debugfs(&pdev->dev, otp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	while (--i >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		device_remove_file(&pdev->dev, &ab3100_otp_attrs[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) static int __exit ab3100_otp_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	struct ab3100_otp *otp = platform_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	for (i = 0; i < ARRAY_SIZE(ab3100_otp_attrs); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		device_remove_file(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 				   &ab3100_otp_attrs[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	ab3100_otp_exit_debugfs(otp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static struct platform_driver ab3100_otp_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		.name = "ab3100-otp",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	.remove	 = __exit_p(ab3100_otp_remove),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) module_platform_driver_probe(ab3100_otp_driver, ab3100_otp_probe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) MODULE_DESCRIPTION("AB3100 OTP Readout Driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) MODULE_LICENSE("GPL");