hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
kernel/drivers/misc/eeprom/at24.c
....@@ -6,7 +6,6 @@
66 * Copyright (C) 2008 Wolfram Sang, Pengutronix
77 */
88
9
-#define DEBUG
109 #include <linux/kernel.h>
1110 #include <linux/init.h>
1211 #include <linux/module.h>
....@@ -107,8 +106,6 @@
107106 module_param_named(write_timeout, at24_write_timeout, uint, 0);
108107 MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)");
109108
110
-//Ben
111
-struct at24_data *at24_private=NULL;
112109 struct at24_chip_data {
113110 /*
114111 * these fields mirror their equivalents in
....@@ -424,146 +421,6 @@
424421 return 0;
425422 }
426423
427
-//add ben
428
-static ssize_t at24_read_private(struct at24_data *at24,
429
- char *buf, loff_t off, size_t count)
430
-{
431
- ssize_t retval = 0;
432
-
433
- if (unlikely(!count))
434
- return count;
435
-
436
- if (off + count > at24->byte_len)
437
- return -EINVAL;
438
-
439
- /*
440
- * Read data from chip, protecting against concurrent updates
441
- * from this host, but not from other I2C masters.
442
- */
443
- mutex_lock(&at24->lock);
444
-
445
- while (count) {
446
- ssize_t status;
447
-
448
- //status = at24_eeprom_read_i2c(at24, buf, off, count);
449
- status = at24_regmap_read(at24, buf, off, count);
450
- if (status <= 0) {
451
- if (retval == 0)
452
- retval = status;
453
- break;
454
- }
455
- buf += status;
456
- off += status;
457
- count -= status;
458
- retval += status;
459
- }
460
-
461
- mutex_unlock(&at24->lock);
462
-
463
- return retval;
464
-}
465
-
466
-#if 0
467
-static unsigned char AscToHex(unsigned char aChar)
468
-{
469
- if((aChar>=0x30)&&(aChar<=0x39))
470
- aChar -= 0x30;
471
- else if((aChar>=0x41)&&(aChar<=0x46))
472
- aChar -= 0x37;
473
- else if((aChar>=0x61)&&(aChar<=0x66))
474
- aChar -= 0x57;
475
- else aChar = 0xff;
476
-
477
- return aChar;
478
-}
479
-#endif
480
-
481
-#if 0
482
-ssize_t at24_mac_read(unsigned char* addr)
483
-{
484
- char buf[20];
485
- char buf_tmp[12];
486
- int i;
487
- ssize_t ret;
488
- if (at24_private == NULL)
489
- {
490
- printk("ben %s: at24_private==null error\n", __func__);
491
- return 0;
492
- }
493
- memset(buf, 0x00, 20);
494
- memset(buf_tmp, 0x00, 12);
495
- ret = at24_read(at24_private, 0, buf, 12);
496
- if (ret > 0)
497
- {
498
- for(i=0; i<12; i++)
499
- {
500
- buf_tmp[i] = AscToHex(buf[i]);
501
- }
502
- addr[0] = (buf_tmp[0] << 4) | buf_tmp[1];
503
- addr[1] = (buf_tmp[2] << 4) | buf_tmp[3];
504
- addr[2] = (buf_tmp[4] << 4) | buf_tmp[5];
505
- addr[3] = (buf_tmp[6] << 4) | buf_tmp[7];
506
- addr[4] = (buf_tmp[8] << 4) | buf_tmp[9];
507
- addr[5] = (buf_tmp[10] << 4) | buf_tmp[11];
508
- }
509
- return ret;
510
-}
511
-#endif
512
-
513
-ssize_t at24_mac_read(unsigned char* addr)
514
-{
515
- char buf[20];
516
- char buf_tmp[12];
517
- ssize_t ret;
518
- if (at24_private == NULL)
519
- {
520
- printk("ben: at24_mac_read at24_private==null error");
521
- return 0;
522
- }
523
- memset(buf, 0x00, 20);
524
- memset(buf_tmp, 0x00, 12);
525
- ret = at24_read_private(at24_private, buf, 0, 6);
526
- if (ret > 0)
527
- {
528
- addr[0] = buf[0];
529
- addr[1] = buf[1];
530
- addr[2] = buf[2];
531
- addr[3] = buf[3];
532
- addr[4] = buf[4];
533
- addr[5] = buf[5];
534
- }
535
- printk("at24_mac_read ...............\n");
536
- return ret;
537
-}
538
-EXPORT_SYMBOL(at24_mac_read);
539
-
540
-ssize_t at24_mac1_read(unsigned char* mac)
541
-{
542
- char buf[20];
543
- char buf_tmp[12];
544
- ssize_t ret;
545
- if (at24_private == NULL)
546
- {
547
- printk("zcl: at24_mac_read at24_private==null error");
548
- return 0;
549
- }
550
- memset(buf, 0x00, 20);
551
- memset(buf_tmp, 0x00, 12);
552
- ret = at24_read_private(at24_private, buf, 0x10, 6);
553
- if (ret > 0)
554
- {
555
- *mac = buf[0];
556
- *(mac + 1) = buf[1];
557
- *(mac + 2) = buf[2];
558
- *(mac + 3) = buf[3];
559
- *(mac + 4) = buf[4];
560
- *(mac + 5) = buf[5];
561
- }
562
- printk("at24_mac1_read ...............\n");
563
- return ret;
564
-}
565
-EXPORT_SYMBOL(at24_mac1_read);
566
-
567424 static int at24_write(void *priv, unsigned int off, void *val, size_t count)
568425 {
569426 struct at24_data *at24;
....@@ -773,7 +630,6 @@
773630 u8 test_byte;
774631 int err;
775632
776
- printk("ben %s ...\n", __func__);
777633 i2c_fn_i2c = i2c_check_functionality(client->adapter, I2C_FUNC_I2C);
778634 i2c_fn_block = i2c_check_functionality(client->adapter,
779635 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);
....@@ -818,7 +674,6 @@
818674 if (!at24)
819675 return -ENOMEM;
820676
821
- at24_private = at24;
822677 mutex_init(&at24->lock);
823678 at24->byte_len = pdata.byte_len;
824679 at24->page_size = pdata.page_size;
....@@ -937,8 +792,7 @@
937792 at24_io_limit = rounddown_pow_of_two(at24_io_limit);
938793 return i2c_add_driver(&at24_driver);
939794 }
940
-//module_init(at24_init);
941
-postcore_initcall_sync(at24_init);
795
+module_init(at24_init);
942796
943797 static void __exit at24_exit(void)
944798 {