@@ -339,32 +339,13 @@ static BIN_ATTR_RW(pio, 1);staticssize_tcrccheck_show(structdevice*dev,structdevice_attribute*attr,char*buf){-if(put_user(w1_enable_crccheck+0x30,buf))-return-EFAULT;--returnsizeof(w1_enable_crccheck);+returnsysfs_emit(buf,"%d\n",w1_enable_crccheck);}staticssize_tcrccheck_store(structdevice*dev,structdevice_attribute*attr,constchar*buf,size_tcount){-charval;--if(count!=1||!buf)-return-EINVAL;--if(get_user(val,buf))-return-EFAULT;--/* convert to decimal */-val=val-0x30;-if(val!=0&&val!=1)-return-EINVAL;--/* set the new value */-w1_enable_crccheck=val;--returnsizeof(w1_enable_crccheck);+returnkstrtobool(buf,&w1_enable_crccheck)?:count;}staticDEVICE_ATTR_RW(crccheck);
@@ -339,32 +339,13 @@ static BIN_ATTR_RW(pio, 1);staticssize_tcrccheck_show(structdevice*dev,structdevice_attribute*attr,char*buf){-if(put_user(w1_enable_crccheck+0x30,buf))-return-EFAULT;--returnsizeof(w1_enable_crccheck);+returnsysfs_emit(buf,"%d\n",w1_enable_crccheck);}staticssize_tcrccheck_store(structdevice*dev,structdevice_attribute*attr,constchar*buf,size_tcount){-charval;--if(count!=1||!buf)-return-EINVAL;--if(get_user(val,buf))-return-EFAULT;--/* convert to decimal */-val=val-0x30;-if(val!=0&&val!=1)-return-EINVAL;--/* set the new value */-w1_enable_crccheck=val;--returnsizeof(w1_enable_crccheck);+returnkstrtobool(buf,&w1_enable_crccheck)?:count;
Please spell this line out, using ? : is unreadable at times.
You prefer something like:
int err = kstrtobool(buf, &w1_enable_crccheck);
return err ? err : count;
Or
int err = kstrtobool(buf, &w1_enable_crccheck);
if (err)
return err;
return count;
?
@@ -339,32 +339,13 @@ static BIN_ATTR_RW(pio, 1);staticssize_tcrccheck_show(structdevice*dev,structdevice_attribute*attr,char*buf){-if(put_user(w1_enable_crccheck+0x30,buf))-return-EFAULT;--returnsizeof(w1_enable_crccheck);+returnsysfs_emit(buf,"%d\n",w1_enable_crccheck);}staticssize_tcrccheck_store(structdevice*dev,structdevice_attribute*attr,constchar*buf,size_tcount){-charval;--if(count!=1||!buf)-return-EINVAL;--if(get_user(val,buf))-return-EFAULT;--/* convert to decimal */-val=val-0x30;-if(val!=0&&val!=1)-return-EINVAL;--/* set the new value */-w1_enable_crccheck=val;--returnsizeof(w1_enable_crccheck);+returnkstrtobool(buf,&w1_enable_crccheck)?:count;
Please spell this line out, using ? : is unreadable at times.
You prefer something like:
int err = kstrtobool(buf, &w1_enable_crccheck);
return err ? err : count;
Or
int err = kstrtobool(buf, &w1_enable_crccheck);
if (err)
return err;
return count;
This one. Write code for people to read first, compiler second.
thanks,
greg k-h
@@ -339,32 +339,13 @@ static BIN_ATTR_RW(pio, 1);staticssize_tcrccheck_show(structdevice*dev,structdevice_attribute*attr,char*buf){-if(put_user(w1_enable_crccheck+0x30,buf))-return-EFAULT;--returnsizeof(w1_enable_crccheck);+returnsysfs_emit(buf,"%d\n",w1_enable_crccheck);}staticssize_tcrccheck_store(structdevice*dev,structdevice_attribute*attr,constchar*buf,size_tcount){-charval;--if(count!=1||!buf)-return-EINVAL;--if(get_user(val,buf))-return-EFAULT;--/* convert to decimal */-val=val-0x30;-if(val!=0&&val!=1)-return-EINVAL;--/* set the new value */-w1_enable_crccheck=val;--returnsizeof(w1_enable_crccheck);+returnkstrtobool(buf,&w1_enable_crccheck)?:count;
Please spell this line out, using ? : is unreadable at times.
thanks,
greg k-h